Class IndexExpressionsRewriter

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

public class IndexExpressionsRewriter extends Object
Utility class for rewriting cross-project index expressions. Provides methods that can rewrite qualified and unqualified index expressions to canonical CCS.
  • Field Details

    • NO_MATCHING_PROJECT_EXCEPTION_VERSION

      public static TransportVersion NO_MATCHING_PROJECT_EXCEPTION_VERSION
  • Constructor Details

    • IndexExpressionsRewriter

      public IndexExpressionsRewriter()
  • Method Details

    • rewriteIndexExpressions

      public static Map<String,IndexExpressionsRewriter.IndexRewriteResult> rewriteIndexExpressions(ProjectRoutingInfo originProject, List<ProjectRoutingInfo> linkedProjects, String[] originalIndices)
      Rewrites index expressions for cross-project search requests. Handles qualified and unqualified expressions and match-all cases will also hand exclusions in the future.
      Parameters:
      originProject - the _origin project with its alias
      linkedProjects - the list of linked and available projects to consider for a request
      originalIndices - the array of index expressions to be rewritten to canonical CCS
      Returns:
      a map from original index expressions to lists of canonical index expressions
      Throws:
      IllegalArgumentException - if exclusions, date math or selectors are present in the index expressions
      NoMatchingProjectException - if a qualified resource cannot be resolved because a project is missing
    • rewriteIndexExpression

      public static IndexExpressionsRewriter.IndexRewriteResult rewriteIndexExpression(String indexExpression, @Nullable String originProjectAlias, Set<String> allProjectAliases)
      Rewrites an index expression for cross-project search requests.
      Parameters:
      indexExpression - the index expression to be rewritten to canonical CCS
      originProjectAlias - the alias of the origin project (can be null if it was excluded by project routing). It's passed additionally to allProjectAliases because the origin project requires special handling: it can match on its actual alias and on the special alias "_origin". Any expression matched by the origin project also cannot be qualified with its actual alias in the final rewritten expression.
      allProjectAliases - the list of all project aliases (linked and origin) consider for a request
      Throws:
      IllegalArgumentException - if exclusions, date math or selectors are present in the index expressions
      NoMatchingProjectException - if a qualified resource cannot be resolved because a project is missing