Skip to content

Conversation

dimitris-athanasiou
Copy link
Contributor

Prevent field_caps from failing when can-match fails

FieldCapabilitiesFetcher performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning true to proceed.

This change does that by following suit with other callers of can-match.

Fixes #116106

@dimitris-athanasiou dimitris-athanasiou added >bug auto-backport Automatically create backport pull requests when merged :Search Relevance/Search Catch all for Search Relevance v9.2.0 v9.1.4 v8.19.4 labels Sep 4, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Sep 4, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@dimitris-athanasiou
Copy link
Contributor Author

Note: The first commit is reverting #131111. Before merging I'll split that out of this PR and raise it separately. But it is necessary for the fix to be reviewed here.

Copy link
Contributor

@Mikep86 Mikep86 left a comment

Choose a reason for hiding this comment

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

Nice work! Approach and tests look good overall, just a few nit comments. The big thing is silently swallowing the exception (which I know we discussed in #116106), but that feels so wrong...

@dimitris-athanasiou dimitris-athanasiou force-pushed the prevent-field-caps-from-failing-due-to-can-match-failure branch from d9e9315 to 3e5e34d Compare September 4, 2025 13:48
@dimitris-athanasiou
Copy link
Contributor Author

run elasticsearch-ci/part-2

@dimitris-athanasiou
Copy link
Contributor Author

@Mikep86 I have addressed review comments. This is ready for another look.

Copy link
Contributor

@Mikep86 Mikep86 left a comment

Choose a reason for hiding this comment

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

Looks good except for two things:

  • A missing cluster feature check
  • No changelog entry for the bug fix. CI should catch this, but maybe that's broken because we are reverting another changelog entry in this PR. Can you manually add it?

Once those are fixed, there are some logistics about how to merge and backport this:

  • Merge #134209 first and merge those changes into this PR, which should cancel out the revert changes here.
  • Merge and backport this, which should go smoothly now that the revert changes above are cancelled out.

@dimitris-athanasiou
Copy link
Contributor Author

@Mikep86 I have added the missing cluster feature checks and the changelog. I'm also fully onboard with the merging plan you laid out.

Copy link
Contributor

@Mikep86 Mikep86 left a comment

Choose a reason for hiding this comment

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

LGTM!

dimitris-athanasiou and others added 9 commits September 10, 2025 16:00
`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes elastic#116106
@dimitris-athanasiou dimitris-athanasiou force-pushed the prevent-field-caps-from-failing-due-to-can-match-failure branch from fb31c64 to 933bf28 Compare September 10, 2025 13:01
@dimitris-athanasiou
Copy link
Contributor Author

@elasticsearchmachine run elasticsearch-ci/part-1

@Mikep86
Copy link
Contributor

Mikep86 commented Sep 10, 2025

@elasticmachine run elasticsearch-ci/part-3

@dimitris-athanasiou dimitris-athanasiou merged commit 7295189 into elastic:main Sep 10, 2025
34 checks passed
dimitris-athanasiou added a commit to dimitris-athanasiou/elasticsearch that referenced this pull request Sep 11, 2025
)

`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes elastic#116106

(cherry picked from commit 7295189)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceFeatures.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilder.java
dimitris-athanasiou added a commit to dimitris-athanasiou/elasticsearch that referenced this pull request Sep 11, 2025
)

`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes elastic#116106

(cherry picked from commit 7295189)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceFeatures.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilder.java
#	x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping.yml
#	x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping_bwc.yml
@dimitris-athanasiou
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.1
9.0
8.19
8.18

Questions ?

Please refer to the Backport tool documentation

dimitris-athanasiou added a commit to dimitris-athanasiou/elasticsearch that referenced this pull request Sep 11, 2025
)

`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes elastic#116106

(cherry picked from commit 7295189)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceFeatures.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/queries/SemanticQueryBuilder.java
#	x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping.yml
#	x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping_bwc.yml
dimitris-athanasiou added a commit that referenced this pull request Sep 11, 2025
…134551)

`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes #116106

(cherry picked from commit 7295189)
dimitris-athanasiou added a commit that referenced this pull request Sep 11, 2025
…) (#134552)

`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes #116106

(cherry picked from commit 7295189)
dimitris-athanasiou added a commit that referenced this pull request Sep 11, 2025
) (#134558)

`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes #116106

(cherry picked from commit 7295189)
dimitris-athanasiou added a commit that referenced this pull request Sep 11, 2025
) (#134557)

`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes #116106

(cherry picked from commit 7295189)
@dimitris-athanasiou dimitris-athanasiou deleted the prevent-field-caps-from-failing-due-to-can-match-failure branch September 11, 2025 22:14
sarog pushed a commit to portsbuild/elasticsearch that referenced this pull request Sep 19, 2025
…tic#134134) (elastic#134557)

`FieldCapabilitiesFetcher` performs a can-match in order to quickly
return an empty response if no shard can match. However, if can-match
fails for some reason, it can cause the field capabilities request to fail.

An example of that is when a semantic query is used as filter. can-match
will fail as it won't be able to expand the inference results of the query.

In cases like that, it makes no sense to fail the field capabilities request.
Instead, we should treat can-match as returning `true` to proceed.

This change does that by following suit with other callers of can-match.

Fixes elastic#116106

(cherry picked from commit 7295189)
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 :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v8.18.7 v8.19.4 v9.0.7 v9.1.5 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IllegalStateException thrown in SemanticQueryBuilder

4 participants