# ElasticsearchEmbeddings

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/embeddings/elasticsearch/ElasticsearchEmbeddings)

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

## Signature

```python
ElasticsearchEmbeddings(
    self,
    client: MlClient,
    model_id: str,
    *,
    input_field: str = 'text_field',
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `client` | `MlClient` | Yes | An Elasticsearch ML client object. |
| `model_id` | `str` | Yes | The model_id of the model deployed in the Elasticsearch cluster. |
| `input_field` | `str` | No | The name of the key for the input text field in the document. Defaults to 'text_field'. (default: `'text_field'`) |

## Extends

- `Embeddings`

## Constructors

```python
__init__(
    self,
    client: MlClient,
    model_id: str,
    *,
    input_field: str = 'text_field',
)
```

| Name | Type |
|------|------|
| `client` | `MlClient` |
| `model_id` | `str` |
| `input_field` | `str` |


## Properties

- `client`
- `model_id`
- `input_field`

## Methods

- [`from_credentials()`](https://reference.langchain.com/python/langchain-community/embeddings/elasticsearch/ElasticsearchEmbeddings/from_credentials)
- [`from_es_connection()`](https://reference.langchain.com/python/langchain-community/embeddings/elasticsearch/ElasticsearchEmbeddings/from_es_connection)
- [`embed_documents()`](https://reference.langchain.com/python/langchain-community/embeddings/elasticsearch/ElasticsearchEmbeddings/embed_documents)
- [`embed_query()`](https://reference.langchain.com/python/langchain-community/embeddings/elasticsearch/ElasticsearchEmbeddings/embed_query)

## ⚠️ Deprecated

Deprecated since version 0.1.11. Use Use class in langchain-elasticsearch package instead.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/embeddings/elasticsearch.py#L15)