﻿---
title: ES|QL TEXT_EMBEDDING function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/2948/reference/query-languages/esql/functions-operators/dense-vector-functions/text_embedding
products:
  - Elasticsearch
---

# ES|QL TEXT_EMBEDDING function
<applies-to>
  - Elastic Stack: Preview in 9.3
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/2948/reference/query-languages/esql/images/functions/text_embedding.svg)


## Parameters

<definitions>
  <definition term="text">
    Text string to generate embeddings from. Must be a non-null literal string value.
  </definition>
  <definition term="inference_id">
    Identifier of an existing inference endpoint the that will generate the embeddings. The inference endpoint must have the `text_embedding` task type and should use the same model that was used to embed your indexed data.
  </definition>
</definitions>


## Description

Generates dense vector embeddings from text input using a specified [inference endpoint](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/2948/explore-analyze/elastic-inference/inference-api). Use this function to generate query vectors for KNN searches against your vectorized data or others dense vector based operations.

## Supported types


| text    | inference_id | result       |
|---------|--------------|--------------|
| keyword | keyword      | dense_vector |


## Example

Generate text embeddings using the 'test_dense_inference' inference endpoint.
```esql
FROM dense_vector_text METADATA _score
| WHERE KNN(text_embedding_field, TEXT_EMBEDDING("be excellent to each other", "test_dense_inference"))
```