Context context = new Context(state, IndicesOptions.lenientExpandOpen()); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
private static Map<String, AliasOrIndex> suffixWildcard(Context context, MetaData metaData, String expression) { assert expression.length() >= 2 : "expression [" + expression + "] should have at least a length of 2"; String fromPrefix = expression.substring(0, expression.length() - 1); char[] toPrefixCharArr = fromPrefix.toCharArray(); toPrefixCharArr[toPrefixCharArr.length - 1]++; String toPrefix = new String(toPrefixCharArr); SortedMap<String,AliasOrIndex> subMap = metaData.getAliasAndIndexLookup().subMap(fromPrefix, toPrefix); if (context.getOptions().ignoreAliases()) { return subMap.entrySet().stream() .filter(entry -> entry.getValue().isAlias() == false) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } return subMap; }
indexExpressions = new String[]{MetaData.ALL}; MetaData metaData = context.getState().metaData(); IndicesOptions options = context.getOptions(); final boolean failClosed = options.forbidClosedIndices() && options.ignoreUnavailable() == false; continue; } else if (aliasOrIndex.isAlias() && context.getOptions().ignoreAliases()) { if (failNoIndices) { throw aliasesNotSupportedException(expression); if (aliasOrIndex.isAlias() && context.isResolveToWriteIndex()) { AliasOrIndex.Alias alias = (AliasOrIndex.Alias) aliasOrIndex; IndexMetaData writeIndex = alias.getWriteIndex();
@Override public List<String> resolve(Context context, List<String> expressions) { IndicesOptions options = context.getOptions(); MetaData metaData = context.getState().metaData(); if (options.expandWildcardsClosed() == false && options.expandWildcardsOpen() == false) { return expressions; for (Map.Entry<String, AliasOrIndex> entry : matches.entrySet()) { AliasOrIndex aliasOrIndex = entry.getValue(); if (context.isPreserveAliases() && aliasOrIndex.isAlias()) { expand.add(entry.getKey()); } else {
Context context = new Context(state, IndicesOptions.lenientExpandOpen()); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
Context context = new Context(state, IndicesOptions.lenientExpandOpen()); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
Context context = new Context(state, IndicesOptions.lenientExpandOpen()); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
Context context = new Context(state, IndicesOptions.lenientExpandOpen()); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
indexExpressions = new String[]{MetaData.ALL}; MetaData metaData = context.getState().metaData(); IndicesOptions options = context.getOptions(); final boolean failClosed = options.forbidClosedIndices() && options.ignoreUnavailable() == false; continue; } else if (aliasOrIndex.isAlias() && context.getOptions().ignoreAliases()) { if (failNoIndices) { throw aliasesNotSupportedException(expression); if (aliasOrIndex.isAlias() && context.isResolveToWriteIndex()) { AliasOrIndex.Alias alias = (AliasOrIndex.Alias) aliasOrIndex; IndexMetaData writeIndex = alias.getWriteIndex();
indexExpressions = new String[]{MetaData.ALL}; MetaData metaData = context.getState().metaData(); IndicesOptions options = context.getOptions(); final boolean failClosed = options.forbidClosedIndices() && options.ignoreUnavailable() == false; continue; } else if (aliasOrIndex.isAlias() && context.getOptions().ignoreAliases()) { if (failNoIndices) { throw aliasesNotSupportedException(expression); if (aliasOrIndex.isAlias() && context.isResolveToWriteIndex()) { AliasOrIndex.Alias alias = (AliasOrIndex.Alias) aliasOrIndex; IndexMetaData writeIndex = alias.getWriteIndex();
indexExpressions = new String[]{MetaData.ALL}; MetaData metaData = context.getState().metaData(); IndicesOptions options = context.getOptions(); boolean failClosed = options.forbidClosedIndices() && options.ignoreUnavailable() == false; boolean failNoIndices = options.ignoreUnavailable() == false;
indexExpressions = new String[]{MetaData.ALL}; MetaData metaData = context.getState().metaData(); IndicesOptions options = context.getOptions(); boolean failClosed = options.forbidClosedIndices() && options.ignoreUnavailable() == false; boolean failNoIndices = options.ignoreUnavailable() == false;
Context context = new Context(state, IndicesOptions.lenientExpandOpen(), true); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
Context context = new Context(state, IndicesOptions.lenientExpandOpen(), true, false); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
Context context = new Context(state, IndicesOptions.lenientExpandOpen(), true); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
Context context = new Context(state, IndicesOptions.lenientExpandOpen(), true, false); for (ExpressionResolver expressionResolver : expressionResolvers) { resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
/** * Utility method that allows to resolve an index expression to its corresponding single write index. * * @param state the cluster state containing all the data to resolve to expression to a concrete index * @param 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. * @throws IllegalArgumentException if the index resolution does not lead to an index, or leads to more than one index * @return the write index obtained as a result of the index resolution */ public Index concreteWriteIndex(ClusterState state, IndicesRequest request) { if (request.indices() == null || (request.indices() != null && request.indices().length != 1)) { throw new IllegalArgumentException("indices request must specify a single index expression"); } Context context = new Context(state, request.indicesOptions(), false, true); Index[] indices = concreteIndices(context, request.indices()[0]); if (indices.length != 1) { throw new IllegalArgumentException("The index expression [" + request.indices()[0] + "] and options provided did not point to a single write-index"); } return indices[0]; }
@Override public List<String> resolve(Context context, List<String> expressions) { IndicesOptions options = context.getOptions(); MetaData metaData = context.getState().metaData(); if (options.expandWildcardsClosed() == false && options.expandWildcardsOpen() == false) { return expressions; } if (isEmptyOrTrivialWildcard(expressions)) { return resolveEmptyOrTrivialWildcard(options, metaData); } Set<String> result = innerResolve(context, expressions, options, metaData); if (result == null) { return expressions; } if (result.isEmpty() && !options.allowNoIndices()) { IndexNotFoundException infe = new IndexNotFoundException((String)null); infe.setResources("index_or_alias", expressions.toArray(new String[0])); throw infe; } return new ArrayList<>(result); }
@Override public List<String> resolve(Context context, List<String> expressions) { IndicesOptions options = context.getOptions(); MetaData metaData = context.getState().metaData(); if (options.expandWildcardsClosed() == false && options.expandWildcardsOpen() == false) { return expressions; } if (isEmptyOrTrivialWildcard(expressions)) { return resolveEmptyOrTrivialWildcard(options, metaData, true); } Set<String> result = innerResolve(context, expressions, options, metaData); if (result == null) { return expressions; } if (result.isEmpty() && !options.allowNoIndices()) { IndexNotFoundException infe = new IndexNotFoundException((String)null); infe.setResources("index_or_alias", expressions.toArray(new String[0])); throw infe; } return new ArrayList<>(result); }
/** * Utility method that allows to resolve an index expression to its corresponding single write index. * * @param state the cluster state containing all the data to resolve to expression to a concrete index * @param 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. * @throws IllegalArgumentException if the index resolution does not lead to an index, or leads to more than one index * @return the write index obtained as a result of the index resolution */ public Index concreteWriteIndex(ClusterState state, IndicesRequest request) { if (request.indices() == null || (request.indices() != null && request.indices().length != 1)) { throw new IllegalArgumentException("indices request must specify a single index expression"); } Context context = new Context(state, request.indicesOptions(), false, true); Index[] indices = concreteIndices(context, request.indices()[0]); if (indices.length != 1) { throw new IllegalArgumentException("The index expression [" + request.indices()[0] + "] and options provided did not point to a single write-index"); } return indices[0]; }