Dense vector search in Elasticsearch
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is generally available and ready for production usage. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless
Generally available
Stack
Generally available
Dense vectors use neural embeddings to represent semantic meaning. They translate text, images, or other data into fixed-length vectors of floating-point numbers. Content with similar meaning is mapped to nearby points in vector space, making dense vector search a powerful technique for:
- Finding semantically similar content
- Matching natural language questions with relevant answers
- Performing image and multimedia similarity search
- Delivering content-based recommendations
If you're using Elastic Cloud Serverless, compare Elasticsearch and Vector Database projects before implementing dense vector search.
For most use cases, the semantic_text field type is the recommended starting point. It provides automatic model management and sensible defaults for vector search.
To implement dense vector search in Elasticsearch, you need both an index configuration and a way to generate embeddings:
Index documents with embeddings
- Generate embeddings directly in Elasticsearch
- Refer to the overview of NLP model options
- Or bring your own embeddings
- Store them using the
dense_vectorfield type
- Store them using the
- The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Generally available since 9.4 This functionality is generally available and ready for production usage. Preview in 9.3 This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes. Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability Unavailable This functionality is not available in Elastic Cloud Serverless. Optionally accelerate HNSW indexing with a GPU
- Generate embeddings directly in Elasticsearch
Query the index with k-NN search
- Use the
knnquery to retrieve results based on vector similarity
- Use the
Better Binary Quantization (BBQ) is an advanced vector quantization technique for dense_vector fields. It compresses embeddings into compact binary form, enabling faster similarity search and reducing memory usage. This improves both search relevance and cost efficiency, especially when used with HNSW (Hierarchical Navigable Small World).
New indices with float or bfloat16 vectors and 384 or more dimensions will default to BBQ HNSW automatically for optimal performance and memory efficiency. Other element types, such as byte and bit, default to plain hnsw with no quantization.
Learn more about how BBQ works, supported algorithms, and configuration examples in the Better Binary Quantization (BBQ) documentation.
When using the semantic_text field type, you can configure BBQ and other quantization options through the index_options parameter. Refer to Optimizing vector storage with index_options for examples of using bbq_hnsw, int8_hnsw, and other quantization strategies with semantic text fields.