Skip to content

Conversation

@Mikep86
Copy link
Contributor

@Mikep86 Mikep86 commented Oct 16, 2025

Updates the semantic query and the semantic query rewrite interceptors to use suppliers when building the inference results map.

This fixes #136621, which was caused by changes made in #134956. In particular, gating inference action registration on queryRewriteContext.hasAsyncActions() == false caused problems when a query contained many clauses with a semantic or intercepted query. The hasAsyncActions check would only allow one semantic/intercepted query to register inference action(s) per rewrite iteration. If the query contained more than 16 clauses with semantic or intercepted queries, the rewrite rounds would be exhausted.

This is fixed through the usage of suppliers, which removes the need for the queryRewriteContext.hasAsyncActions() == false check and allows all semantic/intercepted queries to register inference actions(s) in the same rewrite round.

This PR also refactors some of the util methods used in inference plugin integration tests into a common location.

@Mikep86 Mikep86 requested review from a team and benwtrent October 16, 2025 20:01
@Mikep86 Mikep86 added >bug auto-backport Automatically create backport pull requests when merged :SearchOrg/Relevance Label for the Search (solution/org) Relevance team v9.2.1 labels Oct 16, 2025
@elasticsearchmachine elasticsearchmachine added v9.3.0 Team:Search - Relevance The Search organization Search Relevance team labels Oct 16, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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

@Mikep86
Copy link
Contributor Author

Mikep86 commented Oct 17, 2025

@elasticmachine update branch

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

I still don't fully understand why all clusters need to know about all the inference ids. Why wouldn't the rewrites happen fully on the remote clusters, period?

That is a bigger question, shouldn't block this PR. But this logic is absurdly complicated, and suspect has more sneaky bugs that await us.

@Mikep86
Copy link
Contributor Author

Mikep86 commented Oct 20, 2025

@elasticmachine update branch

@Mikep86 Mikep86 requested a review from benwtrent October 20, 2025 17:55
Copy link
Member

@kderusso kderusso left a comment

Choose a reason for hiding this comment

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

Changes LGTM

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

I think this is OK I haven't reviewed deeply, I will defer to searchorg folks here.

@Mikep86 Mikep86 merged commit e531d64 into elastic:main Oct 21, 2025
34 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
9.2 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 136720

Mikep86 added a commit to Mikep86/elasticsearch that referenced this pull request Oct 21, 2025
…36720)

(cherry picked from commit e531d64)

# Conflicts:
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilderTests.java
@Mikep86
Copy link
Contributor Author

Mikep86 commented Oct 21, 2025

💚 All backports created successfully

Status Branch Result
9.2

Questions ?

Please refer to the Backport tool documentation

elasticsearchmachine pushed a commit that referenced this pull request Oct 21, 2025
…136868)

(cherry picked from commit e531d64)

# Conflicts:
#	x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilderTests.java
chrisparrinello pushed a commit to chrisparrinello/elasticsearch that referenced this pull request Oct 24, 2025
fzowl pushed a commit to voyage-ai/elasticsearch that referenced this pull request Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >bug :SearchOrg/Relevance Label for the Search (solution/org) Relevance team Team:Search - Relevance The Search organization Search Relevance team v9.2.1 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Semantic Query may throw "too many rewrite rounds"

7 participants