langchain.vectorstores.elasticsearch.ElasticsearchStore¶
class langchain.vectorstores.elasticsearch.ElasticsearchStore(index_name: str, *, embedding: ~typing.Optional[~langchain.schema.embeddings.Embeddings] = None, es_connection: ~typing.Optional[Elasticsearch] = None, es_url: ~typing.Optional[str] = None, es_cloud_id: ~typing.Optional[str] = None, es_user: ~typing.Optional[str] = None, es_api_key: ~typing.Optional[str] = None, es_password: ~typing.Optional[str] = None, vector_query_field: str = 'vector', query_field: str = 'text', distance_strategy: ~typing.Optional[~typing.Literal[<DistanceStrategy.COSINE: 'COSINE'>, <DistanceStrategy.DOT_PRODUCT: 'DOT_PRODUCT'>, <DistanceStrategy.EUCLIDEAN_DISTANCE: 'EUCLIDEAN_DISTANCE'>]] = None, strategy: ~langchain.vectorstores.elasticsearch.BaseRetrievalStrategy = <langchain.vectorstores.elasticsearch.ApproxRetrievalStrategy object>)[source]¶
Elasticsearch vector store.
Example
from langchain.vectorstores import ElasticsearchStore
from langchain.embeddings.openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
vectorstore = ElasticsearchStore(
    embedding=OpenAIEmbeddings(),
    index_name="langchain-demo",
    es_url="http://localhost:9200"
)
Parameters
index_name – Name of the Elasticsearch index to create.
es_url – URL of the Elasticsearch instance to connect to.
cloud_id – Cloud ID of the Elasticsearch instance to connect to.
es_user – Username to use when connecting to Elasticsearch.
es_password – Password to use when connecting to Elasticsearch.
es_api_key – API key to use when connecting to Elasticsearch.
es_connection – Optional pre-existing Elasticsearch connection.