Construct ElasticsearchStore wrapper from raw documents.
from_texts(
cls,
texts: List[str],
embedding: Optional[Embeddings] = None,
metadatas: Optional[List[Dict[str, Any]]] = None,
bulk_kwargs: Optional[Dict] = None,
**kwargs: Any = {}
) -> ElasticsearchStoreExample:
.. code-block:: python
from langchain_community.vectorstores import ElasticsearchStore from langchain_community.embeddings.openai import OpenAIEmbeddings
db = ElasticsearchStore.from_texts( texts, // embeddings optional if using // a strategy that doesn't require inference embeddings, index_name="langchain-demo", es_url="http://localhost:9200" )
| Name | Type | Description |
|---|---|---|
texts* | List[str] | List of texts to add to the Elasticsearch index. |
embedding | Optional[Embeddings] | Default: NoneEmbedding function to use to embed the texts. |
metadatas | Optional[List[Dict[str, Any]]] | Default: NoneOptional list of metadatas associated with the texts. |
index_name* | unknown | Name of the Elasticsearch index to create. |
es_url* | unknown | URL of the Elasticsearch instance to connect to. |
cloud_id* | unknown | Cloud ID of the Elasticsearch instance to connect to. |
es_user* | unknown | Username to use when connecting to Elasticsearch. |
es_password* | unknown | Password to use when connecting to Elasticsearch. |
es_api_key* | unknown | API key to use when connecting to Elasticsearch. |
es_connection* | unknown | Optional pre-existing Elasticsearch connection. |
vector_query_field* | unknown | Optional. Name of the field to store the embedding vectors in. |
query_field* | unknown | Optional. Name of the field to store the texts in. |
distance_strategy* | unknown | Optional. Name of the distance strategy to use. Defaults to "COSINE". can be one of "COSINE", "EUCLIDEAN_DISTANCE", "DOT_PRODUCT", "MAX_INNER_PRODUCT". |
bulk_kwargs | Optional[Dict] | Default: NoneOptional. Additional arguments to pass to Elasticsearch bulk. |