Skip to content

ES|QL: Add TEXT_EMBEDDING function #131022

@afoucret

Description

@afoucret

meta issue: #123043

Summary

Add a new TEXT_EMBEDDING function to ES|QL that generates dense vector embeddings for text using a specified inference model.

Motivation

Enable users to generate text embeddings directly in their ES|QL queries, which is essential for semantic search, similarity search, and other vector operations without requiring a separate ETL step.

Basic Example

FROM documents
| WHERE KNN(embedding_field, TEXT_EMBEDDING(content, "all-MiniLM-L6-v2"), 10)

Detailed Design

Function Signature

TEXT_EMBEDDING(text: string, inference_id: string) -> dense_vector

Parameters

  • text: The input text to embed (string literal or column reference)
  • inference_id: The ID of the inference model to use (string literal)

Behavior

  1. Validates that both parameters are provided and of the correct type
  2. Loads the specified inference model using the inference service
  3. Generates a dense vector embedding for the input text
  4. Returns the embedding as a dense_vector type

Error Cases

  • Returns an error if the inference model is not found
  • Returns an error if the model fails to generate an embedding
  • Returns an error if the input text is null or empty

Related Issues

TODO List

Done:

WIP

Not started

  • Final implementation
  • Doc
  • Pull out of snapshot build
  • Kibana integration / autocomplete

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions