AI Hints
Home›Elasticsearch Tutorial›Semantic Search and Vectors
Elasticsearch · Lesson 97 of 120

Keyword vs Semantic Search

Words versus meaning.

⏱ 2 min read▶ Video at 1:31:09🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

A shopper types, something to keep me dry in a storm. None of our rain jackets use those exact words. Keyword search matches words. Semantic search matches meaning.

  • Dry in a storm?
  • Different words
  • Match meaning

Keyword search struggles

Here's a normal match query on the description. Run it. A tent comes first, and a sleeping bag third. They share words like dry and storm, but most of our rain jackets are missing.

Dev Tools Consoletext
GET products/_search?filter_path=hits.hits._source.name
{
  "query": { "match": { "description": "something to keep me dry in a storm" } },
  "size": 3
}
Output
{
  "hits": {
    "hits": [
      {"_source": {"name": "Basecamp 2-Person Tent"}},
      {"_source": {"name": "Cloudburst Rain Jacket"}},
      {"_source": {"name": "Alpine Down Sleeping Bag"}}
    ]
  }
}
Also uses _load
catalog

Keyword search is exact, fast, and great for names, codes and filters. Semantic search understands meaning and synonyms, but can miss exact terms. The best search engines combine both.

Keyword (BM25)

  • Exact wordsCodes, namesExplainable

Semantic (vectors)

  • MeaningSynonymsNatural questions

Summary

Keyword search matches words, and semantic search matches meaning. Next, how meaning becomes numbers, with embeddings.

Key takeaways
  • Words
  • Meaning
  • Use both
Next up: Embeddings — meaning as numbers