Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,16 @@ private static void mergeResolvedIndices(
}
}

/*
* Projects that do not host the indices participating in a search should not appear in
* the search response's metadata. For MRT=false, this is handled by reconcileProjects().
* For MRT=true, we handle it here.
*/
boolean includeOriginProjectInMetadata = rewritten.getResolvedIndexExpressions()
.expressions()
.stream()
.anyMatch(e -> e.localExpressions().localIndexResolutionResult() == ResolvedIndexExpression.LocalIndexResolutionResult.SUCCESS);

ElasticsearchException ex = CrossProjectIndexResolutionValidator.validate(
rewritten.indicesOptions(),
rewritten.getProjectRouting(),
Expand Down Expand Up @@ -1246,7 +1256,7 @@ private static void mergeResolvedIndices(
listener.onResponse(
new ResolvedIndices(
participatingLinkedProjects,
resolvedIndicesForCps.getLocalIndices(),
includeOriginProjectInMetadata ? originalResolvedIndices.getLocalIndices() : null,
resolvedIndicesForCps.getConcreteLocalIndicesMetadata()
)
);
Expand Down