Class IndexNameExpressionResolver


  • public class IndexNameExpressionResolver
    extends java.lang.Object
    • Constructor Detail

      • IndexNameExpressionResolver

        public IndexNameExpressionResolver()
    • Method Detail

      • concreteIndexNames

        public java.lang.String[] concreteIndexNames​(ClusterState state,
                                                     IndicesOptions options,
                                                     java.lang.String... indexExpressions)
        Translates the provided index expression into actual concrete indices, properly deduplicated.
        Parameters:
        state - the cluster state containing all the data to resolve to expressions to concrete indices
        options - defines how the aliases or indices need to be resolved to concrete indices
        indexExpressions - expressions that can be resolved to alias or index names.
        Returns:
        the resolved concrete indices based on the cluster state, indices options and index expressions
        Throws:
        IndexNotFoundException - if one of the index expressions is pointing to a missing index or alias and the provided indices options in the context don't allow such a case, or if the final result of the indices resolution contains no indices and the indices options in the context don't allow such a case.
        java.lang.IllegalArgumentException - if one of the aliases resolve to multiple indices and the provided indices options in the context don't allow such a case.
      • concreteIndices

        public Index[] concreteIndices​(ClusterState state,
                                       IndicesOptions options,
                                       java.lang.String... indexExpressions)
        Translates the provided index expression into actual concrete indices, properly deduplicated.
        Parameters:
        state - the cluster state containing all the data to resolve to expressions to concrete indices
        options - defines how the aliases or indices need to be resolved to concrete indices
        indexExpressions - expressions that can be resolved to alias or index names.
        Returns:
        the resolved concrete indices based on the cluster state, indices options and index expressions
        Throws:
        IndexNotFoundException - if one of the index expressions is pointing to a missing index or alias and the provided indices options in the context don't allow such a case, or if the final result of the indices resolution contains no indices and the indices options in the context don't allow such a case.
        java.lang.IllegalArgumentException - if one of the aliases resolve to multiple indices and the provided indices options in the context don't allow such a case.
      • concreteIndices

        public Index[] concreteIndices​(ClusterState state,
                                       IndicesOptions options,
                                       long startTime,
                                       java.lang.String... indexExpressions)
        Translates the provided index expression into actual concrete indices, properly deduplicated.
        Parameters:
        state - the cluster state containing all the data to resolve to expressions to concrete indices
        options - defines how the aliases or indices need to be resolved to concrete indices
        startTime - The start of the request where concrete indices is being invoked for
        indexExpressions - expressions that can be resolved to alias or index names.
        Returns:
        the resolved concrete indices based on the cluster state, indices options and index expressions provided indices options in the context don't allow such a case, or if the final result of the indices resolution contains no indices and the indices options in the context don't allow such a case.
        Throws:
        java.lang.IllegalArgumentException - if one of the aliases resolve to multiple indices and the provided indices options in the context don't allow such a case.
      • concreteSingleIndex

        public Index concreteSingleIndex​(ClusterState state,
                                         IndicesRequest request)
        Utility method that allows to resolve an index expression to its corresponding single concrete index. Callers should make sure they provide proper IndicesOptions that require a single index as a result. The indices resolution must in fact return a single index when using this method, an IllegalArgumentException gets thrown otherwise.
        Parameters:
        state - the cluster state containing all the data to resolve to expression to a concrete index
        request - The request that defines how the an alias or an index need to be resolved to a concrete index and the expression that can be resolved to an alias or an index name.
        Returns:
        the concrete index obtained as a result of the index resolution
        Throws:
        java.lang.IllegalArgumentException - if the index resolution lead to more than one index
      • concreteWriteIndex

        public Index concreteWriteIndex​(ClusterState state,
                                        IndicesRequest request)
        Utility method that allows to resolve an index expression to its corresponding single write index.
        Parameters:
        state - the cluster state containing all the data to resolve to expression to a concrete index
        request - The request that defines how the an alias or an index need to be resolved to a concrete index and the expression that can be resolved to an alias or an index name.
        Returns:
        the write index obtained as a result of the index resolution
        Throws:
        java.lang.IllegalArgumentException - if the index resolution does not lead to an index, or leads to more than one index
      • hasIndexOrAlias

        public boolean hasIndexOrAlias​(java.lang.String aliasOrIndex,
                                       ClusterState state)
        Returns:
        whether the specified alias or index exists. If the alias or index contains datemath then that is resolved too.
      • resolveDateMathExpression

        public java.lang.String resolveDateMathExpression​(java.lang.String dateExpression)
        Returns:
        If the specified string is data math expression then this method returns the resolved expression.
      • resolveExpressions

        public java.util.Set<java.lang.String> resolveExpressions​(ClusterState state,
                                                                  java.lang.String... expressions)
        Resolve an array of expressions to the set of indices and aliases that these expressions match.
      • filteringAliases

        public java.lang.String[] filteringAliases​(ClusterState state,
                                                   java.lang.String index,
                                                   java.util.Set<java.lang.String> resolvedExpressions)
        Iterates through the list of indices and selects the effective list of filtering aliases for the given index.

        Only aliases with filters are returned. If the indices list contains a non-filtering reference to the index itself - null is returned. Returns null if no filtering is required. NOTE: The provided expressions must have been resolved already via resolveExpressions(org.elasticsearch.cluster.ClusterState, java.lang.String...).

      • indexAliases

        public java.lang.String[] indexAliases​(ClusterState state,
                                               java.lang.String index,
                                               java.util.function.Predicate<AliasMetaData> requiredAlias,
                                               boolean skipIdentity,
                                               java.util.Set<java.lang.String> resolvedExpressions)
        Iterates through the list of indices and selects the effective list of required aliases for the given index.

        Only aliases where the given predicate tests successfully are returned. If the indices list contains a non-required reference to the index itself - null is returned. Returns null if no filtering is required.

        NOTE: the provided expressions must have been resolved already via resolveExpressions(org.elasticsearch.cluster.ClusterState, java.lang.String...).

      • resolveSearchRouting

        public java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> resolveSearchRouting​(ClusterState state,
                                                                                                          @Nullable
                                                                                                          java.lang.String routing,
                                                                                                          java.lang.String... expressions)
        Resolves the search routing if in the expression aliases are used. If expressions point to concrete indices or aliases with no routing defined the specified routing is used.
        Returns:
        routing values grouped by concrete index
      • resolveSearchRoutingAllIndices

        public java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> resolveSearchRoutingAllIndices​(MetaData metaData,
                                                                                                                    java.lang.String routing)
        Sets the same routing for all indices
      • isAllIndices

        public static boolean isAllIndices​(java.util.Collection<java.lang.String> aliasesOrIndices)
        Identifies whether the array containing index names given as argument refers to all indices The empty or null array identifies all indices
        Parameters:
        aliasesOrIndices - the array containing index names
        Returns:
        true if the provided array maps to all indices, false otherwise