Module org.elasticsearch.server
Class CrossProjectIndexResolutionValidator
java.lang.Object
org.elasticsearch.search.crossproject.CrossProjectIndexResolutionValidator
Utility class for validating index resolution results in cross-project operations.
This class provides consistent error handling for scenarios where index resolution
spans multiple projects, taking into account the provided IndicesOptions.
It handles:
- Validation of index existence in both origin and linked projects based on IndicesOptions (ignoreUnavailable, allowNoIndices)
- Authorization issues during cross-project index resolution, returning appropriate
ElasticsearchSecurityExceptionresponses - Both flat (unqualified) and qualified index expressions (including "_origin:" prefixed indices)
- Wildcard index patterns that may resolve differently across projects
The validator examines both local and remote resolution results to determine the appropriate
error response, returning IndexNotFoundException for missing indices or
ElasticsearchSecurityException for authorization failures.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IndicesOptionsindicesOptionsForCrossProjectFanout(IndicesOptions indicesOptions) static String[]splitQualifiedResource(String resource) static ElasticsearchExceptionvalidate(IndicesOptions indicesOptions, String projectRouting, ResolvedIndexExpressions localResolvedExpressions, Map<String, ResolvedIndexExpressions> remoteResolvedExpressions) Validates the results of cross-project index resolution and returns appropriate exceptions based on the providedIndicesOptions.
-
Constructor Details
-
CrossProjectIndexResolutionValidator
public CrossProjectIndexResolutionValidator()
-
-
Method Details
-
validate
public static ElasticsearchException validate(IndicesOptions indicesOptions, @Nullable String projectRouting, ResolvedIndexExpressions localResolvedExpressions, Map<String, ResolvedIndexExpressions> remoteResolvedExpressions) Validates the results of cross-project index resolution and returns appropriate exceptions based on the providedIndicesOptions.This method handles error scenarios when resolving indices across multiple projects:
- If both
ignoreUnavailableandallowNoIndicesare true, the method returns null without validation (lenient mode) - For wildcard patterns that resolve to no indices, validates against
allowNoIndices - For concrete indices that don't exist, validates against
ignoreUnavailable - For indices with authorization issues, returns security exceptions
The method considers both flat (unqualified) and qualified index expressions, as well as local and linked project resolution results when determining the appropriate error response.
- Parameters:
indicesOptions- Controls error behavior for missing indicesprojectRouting- The project routing string from the request, can be null if request does not specify itlocalResolvedExpressions- Resolution results from the origin projectremoteResolvedExpressions- Resolution results from linked projects- Returns:
- a
ElasticsearchExceptionif validation fails, null if validation passes
- If both
-
indicesOptionsForCrossProjectFanout
-
splitQualifiedResource
-