Skip to content

ES|QL - Add vector similarity functions to tech preview, allow pushdown of blockloader functions#139365

Merged
carlosdelest merged 20 commits intoelastic:mainfrom
carlosdelest:enhancement/esql-vector-similarity-functions-tech-preview
Dec 15, 2025
Merged

ES|QL - Add vector similarity functions to tech preview, allow pushdown of blockloader functions#139365
carlosdelest merged 20 commits intoelastic:mainfrom
carlosdelest:enhancement/esql-vector-similarity-functions-tech-preview

Conversation

@carlosdelest
Copy link
Member

@carlosdelest carlosdelest commented Dec 11, 2025

Get the following vector similarity functions into release builds:

V_DOT_PRODUCT
V_COSINE
V_L1_NORM
V_L2_NORM
V_HAMMING

Vector similarity functions use function pushdown to blockloaders - see #137002

Other functions that use pushdown to blockloaders are being pushed down as well.

@carlosdelest carlosdelest added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch :Search Relevance/ES|QL Search functionality in ES|QL >enhancement labels Dec 11, 2025
@elasticsearchmachine
Copy link
Collaborator

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

);
}

public void testVCosine() throws IOException {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vector similarity functions tests have been moved to PushVectorSimilarityToLoadIT, as they don't need the check now. We should merge them together again when pushing down is not behind snapshot.


@Override
public PushedBlockLoaderExpression tryPushToFieldLoading(SearchStats stats) {
if (EsqlCapabilities.Cap.BLOCK_LOADER_EXPRESSIONS_PUSHDOWN.isEnabled() == false) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks pushdown capability on the pushdown for all the non-vector similarity functions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how I'd do it too, but I think we should enable all of these now.

def(Magnitude.class, Magnitude::new, "v_magnitude"),
def(Hamming.class, Hamming::new, "v_hamming") } };
// dense vector functions
def(Magnitude.class, Magnitude::new, "v_magnitude")} };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V_MAGNITUDE is still not pushed down - #137535 tracks that

new InferIsNotNull(),
new InferNonNullAggConstraint(),
new ReplaceDateTruncBucketWithRoundTo(),
new PushExpressionsToFieldLoad()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the PushExpressionsToFieldLoad rule by default - now the BlockLoaderExpression.tryPushToFieldLoading method needs to take into account pushdown capabilities

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

@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?

@carlosdelest carlosdelest marked this pull request as ready for review December 11, 2025 14:38
@elasticsearchmachine elasticsearchmachine removed the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 11, 2025
@carlosdelest carlosdelest requested a review from nik9000 December 11, 2025 14:38
@elasticsearchmachine
Copy link
Collaborator

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

Comment on lines 2716 to 2727
checkVectorFunctionsNullArgs("v_magnitude(null)");
if (EsqlCapabilities.Cap.MAGNITUDE_SCALAR_VECTOR_FUNCTION.isEnabled()) {
checkVectorFunctionsNullArgs("v_magnitude(null)");
}
if (EsqlCapabilities.Cap.HAMMING_VECTOR_SIMILARITY_FUNCTION.isEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something is not right here - shouldn't v_magnitude tests still be skipped for non snapshot builds and the v_hamming ones be executed without a cap check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I screwed up here, thanks for the catch!

I'm fixing in 21f8197, and adding the test-release label

@carlosdelest carlosdelest added the test-release Trigger CI checks against release build label Dec 12, 2025
@carlosdelest
Copy link
Member Author

Failures are due to packaging and to #139401

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking the vector similarity functions to preview looks right to me.

Enabling pushdown looks right. The per-function-opt-out looks right, though I'd prefer if we didn't do it. I'd save that for a follow-up PR, but I have naming objections to the new capability you used. And, I figure, fixing the name is only marginally less expensive than dropping it entirely.

I have no strong opinion on if you should keep PushVectorSimilarityToLoadIT or move everything back into the original file. You don't have to keep it if you remove the capability and globally enable the pushdowns. But you might like it for organizational purposes. After the split, PushExpressionToLoadIT does a lot of work around different shapes of queries and PushVectorSimilarityToLoadIT is much more readable.

/**
* Support for {@link org.elasticsearch.xpack.esql.expression.function.blockloader.BlockLoaderExpression} pushdown
*/
BLOCK_LOADER_EXPRESSIONS_PUSHDOWN(Build.current().isSnapshot()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this entirely and enable all of the pushdowns? I think we're ready now.


@Override
public PushedBlockLoaderExpression tryPushToFieldLoading(SearchStats stats) {
if (EsqlCapabilities.Cap.BLOCK_LOADER_EXPRESSIONS_PUSHDOWN.isEnabled() == false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how I'd do it too, but I think we should enable all of these now.

@carlosdelest carlosdelest requested a review from nik9000 December 12, 2025 15:57
@carlosdelest
Copy link
Member Author

@nik9000 , I did allow pushdown for all functions and moved back PushVectorSimilarityToLoadIT to the original file in 067f542

@carlosdelest carlosdelest changed the title ES|QL - Add vector similarity functions to tech preview Dec 12, 2025
@carlosdelest carlosdelest merged commit 99ced4f into elastic:main Dec 15, 2025
36 checks passed
parkertimmins pushed a commit to parkertimmins/elasticsearch that referenced this pull request Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement :Search Relevance/ES|QL Search functionality in ES|QL Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch test-release Trigger CI checks against release build v9.3.0

4 participants