@Override public String[] provide(String[] original, Object request, boolean supportsReplace) { if(supportsReplace) { if(retainMode && original != null && original.length > 0) { //TODO datemath? List<String> originalAsList = Arrays.asList(original); if(originalAsList.contains("*") || originalAsList.contains("_all")) { return replacements; } original = resolver.concreteIndexNames(clusterService.state(), IndicesOptions.lenientExpandOpen(), original); final String[] retained = WildcardMatcher.getMatchAny(original, replacements).toArray(new String[0]); return retained; } return replacements; } else { return NOOP; } } }, false);
private String[] getResolvedIndexPattern(User user, IndexNameExpressionResolver resolver, ClusterService cs) { String unresolved = getUnresolvedIndexPattern(user); String[] resolved = null; if(WildcardMatcher.containsWildcard(unresolved)) { final String[] aliasesForPermittedPattern = cs.state().getMetaData().getAliasAndIndexLookup() .entrySet().stream() .filter(e->e.getValue().isAlias()) .filter(e->WildcardMatcher.match(unresolved, e.getKey())) .map(e->e.getKey()).toArray(String[]::new); if(aliasesForPermittedPattern != null && aliasesForPermittedPattern.length > 0) { resolved = resolver.concreteIndexNames(cs.state(), IndicesOptions.lenientExpandOpen(), aliasesForPermittedPattern); } } if(resolved == null && !unresolved.isEmpty()) { resolved = resolver.concreteIndexNames(cs.state(), IndicesOptions.lenientExpandOpen(), unresolved); } if(resolved == null || resolved.length == 0) { return new String[]{unresolved}; } else { //append unresolved value for pattern matching String[] retval = Arrays.copyOf(resolved, resolved.length +1); retval[retval.length-1] = unresolved; return retval; } }
final String[] allIndices = resolver.concreteIndexNames(cs.state(), IndicesOptions.lenientExpandOpen(), "*"); final Set<String> wanted = new HashSet<>(Arrays.asList(allIndices)); WildcardMatcher.wildcardRetainInSet(wanted, permitted);
@Override public IndicesOptions indicesOptions() { return IndicesOptions.lenientExpandOpen(); }
@Override public IndicesOptions indicesOptions() { return IndicesOptions.lenientExpandOpen(); }
/** * Returns <code>true</code> iff the given expression resolves to the given index name otherwise <code>false</code> */ public final boolean matchesIndex(String indexName, String expression, ClusterState state) { final String[] concreteIndices = concreteIndexNames(state, IndicesOptions.lenientExpandOpen(), expression); for (String index : concreteIndices) { if (Regex.simpleMatch(index, indexName)) { return true; } } return indexName.equals(expression); }
/** * @return whether the specified alias or index exists. If the alias or index contains datemath then that is resolved too. */ public boolean hasIndexOrAlias(String aliasOrIndex, ClusterState state) { Context context = new Context(state, IndicesOptions.lenientExpandOpen()); String resolvedAliasOrIndex = dateMathExpressionResolver.resolveExpression(aliasOrIndex, context); return state.metaData().getAliasAndIndexLookup().containsKey(resolvedAliasOrIndex); }
Context context = new Context(state, IndicesOptions.lenientExpandOpen()); 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);
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, IndicesOptions.lenientExpandOpen()); SyncedFlushRequest syncedFlushRequest = new SyncedFlushRequest(Strings.splitStringByCommaToArray(request.param("index"))); syncedFlushRequest.indicesOptions(indicesOptions); return channel -> client.admin().indices().syncedFlush(syncedFlushRequest, new RestBuilderListener<SyncedFlushResponse>(channel) { @Override public RestResponse buildResponse(SyncedFlushResponse results, XContentBuilder builder) throws Exception { builder.startObject(); results.toXContent(builder, request); builder.endObject(); return new BytesRestResponse(results.restStatus(), builder); } }); } }
@Override public IndicesOptions indicesOptions() { return IndicesOptions.lenientExpandOpen(); }
searchRequest.indicesOptions(IndicesOptions.lenientExpandOpen());
/** * Returns <code>true</code> iff the given expression resolves to the given index name otherwise <code>false</code> */ public final boolean matchesIndex(String indexName, String expression, ClusterState state) { final String[] concreteIndices = concreteIndexNames(state, IndicesOptions.lenientExpandOpen(), expression); for (String index : concreteIndices) { if (Regex.simpleMatch(index, indexName)) { return true; } } return indexName.equals(expression); }
/** * @return whether the specified alias or index exists. If the alias or index contains datemath then that is resolved too. */ public boolean hasIndexOrAlias(String aliasOrIndex, ClusterState state) { Context context = new Context(state, IndicesOptions.lenientExpandOpen()); String resolvedAliasOrIndex = dateMathExpressionResolver.resolveExpression(aliasOrIndex, context); return state.metaData().getAliasAndIndexLookup().containsKey(resolvedAliasOrIndex); }
/** * @return whether the specified alias or index exists. If the alias or index contains datemath then that is resolved too. */ public boolean hasIndexOrAlias(String aliasOrIndex, ClusterState state) { Context context = new Context(state, IndicesOptions.lenientExpandOpen()); String resolvedAliasOrIndex = dateMathExpressionResolver.resolveExpression(aliasOrIndex, context); return state.metaData().getAliasAndIndexLookup().containsKey(resolvedAliasOrIndex); }
protected boolean matchesIndices(String currentIndex, String... indices) { final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterService.state(), IndicesOptions.lenientExpandOpen(), indices); for (String index : concreteIndices) { if (Regex.simpleMatch(index, currentIndex)) { return true; } } return false; } }
/** * @return whether the specified alias or index exists. If the alias or index contains datemath then that is resolved too. */ public boolean hasIndexOrAlias(String aliasOrIndex, ClusterState state) { Context context = new Context(state, IndicesOptions.lenientExpandOpen()); String resolvedAliasOrIndex = dateMathExpressionResolver.resolveExpression(aliasOrIndex, context); return state.metaData().getAliasAndIndexLookup().containsKey(resolvedAliasOrIndex); }
private static GetIndexRequest createGetIndexRequest(String index) { return new GetIndexRequest() .local(true) .indices(index) .features(GetIndexRequest.Feature.MAPPINGS) //lenient because we throw our own errors looking at the response e.g. if something was not resolved //also because this way security doesn't throw authorization exceptions but rather honours ignore_unavailable .indicesOptions(IndicesOptions.lenientExpandOpen()); } }
private static GetIndexRequest createGetIndexRequest(String index) { return new GetIndexRequest() .local(true) .indices(index) .features(GetIndexRequest.Feature.MAPPINGS) //lenient because we throw our own errors looking at the response e.g. if something was not resolved //also because this way security doesn't throw authorization exceptions but rather honours ignore_unavailable .indicesOptions(IndicesOptions.lenientExpandOpen()); } }
@Override public ListenableFuture<List<DependencyLink>> findDependencies(String[] indices) { SearchRequestBuilder elasticRequest = client.prepareSearch( indices) .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setTypes(DEPENDENCY_LINK) .setSize(MAX_RESULT_WINDOW) .setQuery(matchAllQuery()); return transform(toGuava(elasticRequest.execute()), ConvertDependenciesResponse.INSTANCE); }