Class CrossProjectIndexResolutionValidator

java.lang.Object
org.elasticsearch.search.crossproject.CrossProjectIndexResolutionValidator

public class CrossProjectIndexResolutionValidator extends Object
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 ElasticsearchSecurityException responses
  • 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 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 provided IndicesOptions.

      This method handles error scenarios when resolving indices across multiple projects:

      • If both ignoreUnavailable and allowNoIndices are 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 indices
      projectRouting - The project routing string from the request, can be null if request does not specify it
      localResolvedExpressions - Resolution results from the origin project
      remoteResolvedExpressions - Resolution results from linked projects
      Returns:
      a ElasticsearchException if validation fails, null if validation passes
    • indicesOptionsForCrossProjectFanout

      public static IndicesOptions indicesOptionsForCrossProjectFanout(IndicesOptions indicesOptions)
    • splitQualifiedResource

      public static String[] splitQualifiedResource(String resource)