Fix exclusion handling for CPS _search#144145
Merged
elasticsearchmachine merged 6 commits intoelastic:mainfrom Mar 13, 2026
Merged
Fix exclusion handling for CPS _search#144145elasticsearchmachine merged 6 commits intoelastic:mainfrom
elasticsearchmachine merged 6 commits intoelastic:mainfrom
Conversation
ywangd
reviewed
Mar 12, 2026
server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java
Outdated
Show resolved
Hide resolved
Collaborator
|
Pinging @elastic/es-security (Team:Security) |
Collaborator
|
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
Contributor
Author
|
Compile error after merge 👀 |
ywangd
approved these changes
Mar 13, 2026
Member
ywangd
left a comment
There was a problem hiding this comment.
LGTM
Thanks for fixing it.
I don't quite get why search resolve indices per project separately. But that's not related to the change here.
...st/java/org/elasticsearch/search/crossproject/CrossProjectIndexResolutionValidatorTests.java
Show resolved
Hide resolved
Comment on lines
+1239
to
+1249
| HashMap<String, OriginalIndices> participatingLinkedProjects = new HashMap<>(); | ||
| for (var entry : resolvedExpressions.entrySet()) { | ||
| boolean hasAnyResolvedIndices = entry.getValue().expressions().stream().anyMatch(expression -> { | ||
| var localExpressions = expression.localExpressions(); | ||
| return localExpressions.localIndexResolutionResult() == ResolvedIndexExpression.LocalIndexResolutionResult.SUCCESS | ||
| && localExpressions.indices().isEmpty() == false; | ||
| }); | ||
| if (hasAnyResolvedIndices) { | ||
| participatingLinkedProjects.put(entry.getKey(), originalResolvedIndices.getRemoteClusterIndices().get(entry.getKey())); | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Nit: It's possible to build participatingLinkedProjects with a stream. But I am ok with this as well.
Contributor
Author
There was a problem hiding this comment.
It gets a little awkward because it's explicitly a HashMap, i.e. needs to be mutable so the toMap step gets convoluted. I'll keep the for-loop but with the intention of revisiting this code -- I think we can do some clean up here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cross-project search with minimize_roundtrips=true was dropping index exclusion patterns (e.g.
linked_project:-shared-index-1) when dispatching to linked projects. The MRT=true path used _resolve/index to determine which projects participate, then reconstructed OriginalIndices from the resolve response — but exclusion expressions don't resolve to concrete indices, so they were silently lost.Instead, we can use the resolve response only to determine project participation, then pass the original index expressions (including exclusions) to participating projects.
Test coverage in linked PR.