Module org.elasticsearch.server
Class IndexExpressionsRewriter
java.lang.Object
org.elasticsearch.search.crossproject.IndexExpressionsRewriter
Utility class for rewriting cross-project index expressions.
Provides methods that can rewrite qualified and unqualified index expressions to canonical CCS.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA container for a local expression and a list of remote expressions. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrewriteIndexExpression(String indexExpression, String originProjectAlias, Set<String> allProjectAliases) Rewrites an index expression for cross-project search requests.rewriteIndexExpressions(ProjectRoutingInfo originProject, List<ProjectRoutingInfo> linkedProjects, String[] originalIndices) Rewrites index expressions for cross-project search requests.
-
Field Details
-
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 aliaslinkedProjects- the list of linked and available projects to consider for a requestoriginalIndices- 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 expressionsNoMatchingProjectException- 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 CCSoriginProjectAlias- 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 expressionsNoMatchingProjectException- if a qualified resource cannot be resolved because a project is missing
-