from_documents(
cls,
documents: List[Document],
embedding: Optional[Embeddings] | Name | Type | Description |
|---|---|---|
documents* | List[Document] | List of documents to add to the Elasticsearch index. |
embedding | Optional[Embeddings] | Default: NoneEmbedding function to use to embed the texts. Do not provide if using a strategy that doesn't require inference. |
bulk_kwargs | Optional[Dict] | Default: None |
client | Optional[Elasticsearch] | Default: None |
**kwargs | Any | Default: {} |
Construct ElasticsearchStore wrapper from documents.
Example:
from langchain_elasticsearch.vectorstores import ElasticsearchStore
from langchain_openai import OpenAIEmbeddings
db = ElasticsearchStore.from_documents(
texts,
embeddings,
index_name="langchain-demo",
es_url="http://localhost:9200"
)Optional. Additional arguments to pass to Elasticsearch bulk.
Optional pre-existing client connection.
Alternatively, provide credentials (es_url, es_cloud_id, etc.).
Additional keyword arguments passed to the constructor.
See AsyncElasticsearchStore for supported options including
index_name, es_url, cloud_id, es_user, es_password,
es_api_key, vector_query_field, and query_field.