Elasticsearch & Lucene (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is the difference between Dense Vector search in Elasticsearch and traditional search?
senior LevelMost AskedCode ExampleelasticsearchAdvanced Internals
In Simple Words:
Elasticsearch 8.x supports a native dense_vector field type using HNSW indexing:
- Allows running exact lexical queries (BM25) and approximate semantic vector search within the exact same query:
json
{
"knn": {
"field": "image_vector",
"query_vector": [0.15, -0.42, 0.88],
"k": 10,
"num_candidates": 100
},
"query": {
"match": { "category": "electronics" }
}
}