Skip to content

Conversation

@afoucret
Copy link
Contributor

@afoucret afoucret commented Sep 11, 2025

This PR introduces a new TEXT_EMBEDDING function to ES|QL, enabling users to generate dense vector embeddings for text directly within their queries.

Key Changes

  1. Introduction of the TEXT_EMBEDDING Function:

    • Added a new scalar function, TEXT_EMBEDDING, to the ES|QL query language.
    • This function generates dense vector embeddings for text using a specified inference endpoint, enabling advanced semantic search capabilities.
    • Introduced a new InferenceFunction base class to support inference-based functions like TEXT_EMBEDDING.
  2. Enhancements to the Inference Framework:

    • Created TextEmbeddingInferenceOperator to execute text embedding inference function
    • Added InferenceFunctionEvaluator for constant folding and optimization of inference functions during query execution
    • BulkInferenceRunner now use the SEARCH thread pool to answer (required to use it in the pre optimizer)
  3. Logical plan analysis

    • Enhanced the Analyzer to resolve inference functions and validate compatibility with inference endpoints.
  4. Integration with Logical Plan Optimization:

    • Updated the LogicalPlanPreOptimizer to include rules for folding inference functions.

How to use it

The TEXT_EMBEDDING function can be used in the EVAL clause to generate embeddings or directly within the WHERE clause with the KNN function for semantic search.

Example 1: Generating embeddings

FROM my_index
| EVAL embedding = TEXT_EMBEDDING("my text to embed", "my_embedding_model")

Example 2: Semantic search with KNN

FROM my_index
| WHERE KNN(my_vector_field, TEXT_EMBEDDING("my search query", "my_embedding_model"))

This work is part of #131079

TODO:

  • More CSV tests

@afoucret afoucret added >feature v9.2.0 :Search Relevance/ES|QL Search functionality in ES|QL labels Sep 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @afoucret, I've created a changelog YAML for you.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 11, 2025

🔍 Preview links for changed docs

@github-actions
Copy link
Contributor

ℹ️ Important: Docs version tagging

👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version.

We use applies_to tags to mark version-specific features and changes.

Expand for a quick overview

When to use applies_to tags:

✅ At the page level to indicate which products/deployments the content applies to (mandatory)
✅ When features change state (e.g. preview, ga) in a specific version
✅ When availability differs across deployments and environments

What NOT to do:

❌ Don't remove or replace information that applies to an older version
❌ Don't add new information that applies to a specific version without an applies_to tag
❌ Don't forget that applies_to tags can be used at the page, section, and inline level

🤔 Need help?

@afoucret afoucret force-pushed the esql_text_embedding_function branch from cc6aff8 to 44ace1a Compare September 11, 2025 17:55
@afoucret afoucret force-pushed the esql_text_embedding_function branch from b61da48 to cee2935 Compare September 13, 2025 04:56
@afoucret afoucret force-pushed the esql_text_embedding_function branch from cb8d640 to 9d7a23f Compare September 13, 2025 05:58
@elasticsearchmachine
Copy link
Collaborator

Hi @afoucret, I've created a changelog YAML for you.

@afoucret afoucret marked this pull request as ready for review September 18, 2025 17:21
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Sep 18, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine
Copy link
Collaborator

Hi @afoucret, I've created a changelog YAML for you.

@afoucret
Copy link
Contributor Author

afoucret commented Oct 1, 2025

Changes have been merged through several PR.

@afoucret afoucret closed this Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>feature :Search Relevance/ES|QL Search functionality in ES|QL Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants