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.
An Elasticsearch ML client object.
The model_id of the model deployed in the Elasticsearch cluster.
The name of the key for the input text field in the document. Defaults to 'text_field'.
Instantiate embeddings from Elasticsearch credentials.
Instantiate embeddings from an existing Elasticsearch connection.
This method provides a way to create an instance of the ElasticsearchEmbeddings class using an existing Elasticsearch connection. The connection object is used to create an MlClient, which is then used to initialize the ElasticsearchEmbeddings instance.
Args: model_id (str): The model_id of the model deployed in the Elasticsearch cluster. es_connection (elasticsearch.Elasticsearch): An existing Elasticsearch connection object. input_field (str, optional): The name of the key for the input text field in the document. Defaults to 'text_field'.
Returns: ElasticsearchEmbeddings: An instance of the ElasticsearchEmbeddings class.
Generate embeddings for a list of documents.
Generate an embedding for a single query text.