LlamaIndex Vector Stores Elasticsearch
raw JSON → 0.6.0 verified Mon Apr 27 auth: no python
Elasticsearch vector store integration for LlamaIndex. Provides ElasticsearchStore for indexing and querying vector embeddings with full Elasticsearch features. Current version: 0.6.0. Release cadence: follows llama-index releases.
pip install llama-index-vector-stores-elasticsearch Common errors
error elasticsearch.BadRequestError: BadRequestError(400, 'x_content_parse_exception', 'failed to parse field [mappings.properties.embedding]') ↓
cause Elasticsearch index already exists with incorrect mapping for the embedding field (e.g., wrong dimension or type).
fix
Delete the existing index and let the store recreate it with correct mapping, or update the index mapping to match the expected dense_vector type.
error AttributeError: module 'llama_index.vector_stores.elasticsearch' has no attribute 'ElasticsearchStore' ↓
cause Old import path: from llama_index.vector_stores import ElasticsearchStore (incorrect).
fix
Use the correct import: from llama_index.vector_stores.elasticsearch import ElasticsearchStore
Warnings
breaking In version 0.6.0, the parameter `es_url` replaced the deprecated `host` and `port` parameters. Code using old parameters will fail. ↓
fix Use `es_url` instead of `host` and `port`.
deprecated The `distance_strategy` parameter is deprecated in favor of using `similarity` parameter with values like "cosine" or "l2". ↓
fix Replace `distance_strategy="COSINE"` with `similarity="cosine"`.
gotcha ElasticsearchStore does not automatically create the index if it doesn't exist. You must either pre-create the index with appropriate mappings or use the `create_index` parameter. ↓
fix Set `create_index=True` when initializing the store, or manually create the index with proper dense_vector field mapping.
gotcha When using authentication, ensure you pass both `es_user` and `es_password`. Passing only one may lead to unexpected connection errors. ↓
fix Always provide both user and password or use API key authentication.
Imports
- ElasticsearchStore
from llama_index.vector_stores.elasticsearch import ElasticsearchStore
Quickstart
import os
from llama_index.vector_stores.elasticsearch import ElasticsearchStore
vector_store = ElasticsearchStore(
index_name="my_index",
es_url=os.environ.get("ES_URL", "http://localhost:9200"),
es_user=os.environ.get("ES_USER", "elastic"),
es_password=os.environ.get("ES_PASSWORD", "changeme"),
)
print("Elasticsearch store created successfully.")