Instantiate embeddings from Elasticsearch credentials.
from_credentials(
cls,
model_id: str,
*,
es_cloud_id: Optional[str] = None,
es_user: Optional[str] = None,
es_password: Optional[str] = None,
input_field: str = 'text_field'
) -> ElasticsearchEmbeddingsExample:
.. code-block:: python
from langchain_community.embeddings import ElasticsearchEmbeddings
model_id = "your_model_id"
input_field = "your_input_field"
embeddings = ElasticsearchEmbeddings.from_credentials( model_id, input_field=input_field, # es_cloud_id="foo", # es_user="bar", # es_password="baz", )
documents = [ "This is an example document.", "Another example document to generate embeddings for.", ] embeddings_generator.embed_documents(documents)
| Name | Type | Description |
|---|---|---|
model_id* | str | The model_id of the model deployed in the Elasticsearch cluster. |
input_field | str | Default: 'text_field'The name of the key for the input text field in the document. Defaults to 'text_field'. |
es_cloud_id | Optional[str] | Default: None(str, optional): The Elasticsearch cloud ID to connect to. |
es_user | Optional[str] | Default: None(str, optional): Elasticsearch username. |
es_password | Optional[str] | Default: None(str, optional): Elasticsearch password. |