langchain.embeddings.elasticsearch.ElasticsearchEmbeddings¶
class langchain.embeddings.elasticsearch.ElasticsearchEmbeddings(client: MlClient, model_id: str, *, input_field: str = 'text_field')[source]¶
Elasticsearch embedding models.
This class provides an interface to generate embeddings using a model deployed
in an Elasticsearch cluster. It requires an Elasticsearch connection object
and the model_id of the model deployed in the cluster.
In Elasticsearch you need to have an embedding model loaded and deployed.
- https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-trained-model.html
- https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-deploy-models.html
Initialize the ElasticsearchEmbeddings instance.
Parameters
client (MlClient) – An Elasticsearch ML client object.
model_id (str) – The model_id of the model deployed in the Elasticsearch
cluster.
input_field (str) – The name of the key for the input text field in the
document. Defaults to ‘text_field’.
Methods
__init__(client, model_id, *[, input_field])
Initialize the ElasticsearchEmbeddings instance.
aembed_documents(texts)
Asynchronous Embed search docs.
aembed_query(text)
Asynchronous Embed query text.
embed_documents(texts)
Generate embeddings for a list of documents.
embed_query(text)
Generate an embedding for a single query text.
from_credentials(model_id, *[, es_cloud_id, ...])
Instantiate embeddings from Elasticsearch credentials.
from_es_connection(model_id, es_connection)
Instantiate embeddings from an existing Elasticsearch connection.
__init__(client: MlClient, model_id: str, *, input_field: str = 'text_field')[source]¶
Initialize the ElasticsearchEmbeddings instance.
Parameters