Elasticsearch can be used as a vector engine in Spice to store embeddings and execute kNN similarity search, full-text search (BM25), and hybrid search (RRF) natively in the Elasticsearch cluster. This is useful when Elasticsearch is already the system of record for a workload, or when the operational characteristics of a managed Elasticsearch cluster (replication, sharding, snapshots) are preferred over a dedicated vector store.
Unlike the Elasticsearch Data Connector, which reads an existing Elasticsearch index as a Spice dataset, the Elasticsearch vector engine accepts data from any Spice data connector, generates embeddings using the configured embedding model, and writes vectors (and source fields) to an Elasticsearch index that Spice manages.
:::note[Enterprise edition] The Elasticsearch vector engine is available in the Spice Enterprise edition. :::
| Parameter | Description | Example Value |
|---|---|---|
elasticsearch_endpoint | Required. Cluster URL. | https://localhost:9200 |
elasticsearch_user | Optional. Username for HTTP basic authentication. | ${secrets:es_user} |
elasticsearch_pass | Optional. Password for HTTP basic authentication. | ${secrets:es_pass} |
elasticsearch_index | Optional. Index used to store vectors. Defaults to a sanitized {dataset}-{column}-{model} value. | products-embeddings |
elasticsearch_vector_field | Optional. Name of the dense_vector field in Elasticsearch. Defaults to {column}_embedding. | description_embedding |
elasticsearch_distance_metric | Optional. Vector similarity metric for kNN search. One of: , , , . |
:::warning[Not yet supported] The Elasticsearch vector engine does not currently support:
partition_by — Partitioned vector indexes. Setting this parameter (or the dataset-level vectors.partition_by) returns a configuration error at startup. Use the S3 Vectors engine for partitioned workloads.spill_writes — Spilling writes to disk for backpressure. Setting spill_writes: true returns a configuration error at startup.Remove these parameters from the vectors: block, or choose a different vector engine.
:::
When configured as a vector engine, Spice:
dense_vector of the correct dimension plus text fields for full-text search).vector_search, text_search, and rrf against the Elasticsearch index using native kNN and BM25 queries.Source fields on the dataset are indexed as text in Elasticsearch so they can be used as full-text search targets. Primary key columns are indexed as keyword and included in kNN results so that matches can be joined back to the Spice base table when additional columns are requested.
:::warning[Limitations]
datasets[].acceleration.enabled: true) for the vector engine to be provided the appropriate data to ingest. See acceleration.enabled.row_id.:::
Any embedding model supported by Spice can be used to produce the vectors written to Elasticsearch, including local models via Hugging Face, hosted models via OpenAI, Bedrock, and others. The vector dimension is inferred from the embedding model and used to provision the Elasticsearch dense_vector field.
Spice requires a primary key to round-trip matches between Elasticsearch and the base dataset. If the source dataset does not carry primary key metadata, specify it on the column embedding:
By default the index name is a sanitized {dataset}-{column}-{model} and the vector field is {column}_embedding. Override either with elasticsearch_index and elasticsearch_vector_field:
Vector, full-text, and hybrid search use the standard Spice UDTFs. When the dataset is backed by the Elasticsearch vector engine, these UDTFs compile to native Elasticsearch queries rather than local computation.
The query text is embedded with the configured embedding model and sent to Elasticsearch as a kNN query. By default the number of candidates considered by Elasticsearch is twice the requested k.
Any Utf8/LargeUtf8 column on the dataset is available as a full-text search target:
Combine vector and full-text results with Reciprocal Rank Fusion:
Advanced RRF options — per-query rank_weight, recency decay, and custom smoothing k — work identically regardless of the underlying vector engine. See RRF for the full reference.
When elasticsearch_user and elasticsearch_pass are provided, the vector engine uses HTTP basic authentication. Prefer storing credentials in a secret store and referencing them with ${secrets:...}. TLS is enabled automatically for https:// endpoints.
| Use case | Use |
|---|---|
Query an existing Elasticsearch index (with or without dense_vector). | Elasticsearch Data Connector. |
| Ingest data from another source and have Spice manage vectors in ES. | Elasticsearch Vector Engine (this page). |
Both paths surface vector_search, text_search, and rrf; pick the one that matches which system owns the data.
cosinel2_normdot_productmax_inner_productcosine |
elasticsearch_hnsw_m | Optional. HNSW graph parameter m (links per node). Higher values improve recall at the cost of more memory. Elasticsearch default: 16. | 16 |
elasticsearch_hnsw_ef_construction | Optional. HNSW build parameter ef_construction (candidate list size at build time). Elasticsearch default: 100. | 100 |
client_timeout | Optional. Total request timeout for the Elasticsearch HTTP client, in time unit format. Default: 30s. | 30s |
connect_timeout | Optional. Connect timeout for the Elasticsearch HTTP client, in time unit format. Default: 10s. | 10s |
elasticsearch_max_retries | Optional. Maximum retry attempts for transient Elasticsearch errors (HTTP 429 / 5xx). Default: 3. | 3 |
elasticsearch_retry_initial_backoff | Optional. Initial backoff duration between retries, in time unit format. Default: 200ms. | 200ms |
elasticsearch_batch_write_rows | Optional. Maximum rows per Elasticsearch _bulk request. Controls memory usage and payload size during writes. Default: 1000. | 1000 |
elasticsearch_index_settings | Optional. JSON object passed as Elasticsearch index settings when creating the index. Existing indexes are not recreated. | {"index":{"codec":"best_compression"}} |
elasticsearch_number_of_shards | Optional. ES number_of_shards index setting, applied at index creation only. | 1 |
elasticsearch_number_of_replicas | Optional. ES number_of_replicas index setting, applied at index creation only. | 0 |
elasticsearch_refresh_interval | Optional. ES refresh_interval index setting, applied at index creation only. | 1s |
elasticsearch_bulk_load_refresh_interval | Optional. Temporary refresh_interval during bulk writes, restored afterward. Set to -1 to disable refresh during loading. | -1 |
elasticsearch_force_merge_after_write | Optional. Run _forcemerge after full/append writes. Default: false. | true |
elasticsearch_force_merge_segments | Optional. Max segments for _forcemerge. Setting this also enables force merge. Default when force merge enabled: 1. | 1 |