Move includeDataStream flag from IndicesOptions to IndexNameExpressionResolver.Context (#56151)
Backport of #56034. Move includeDataStream flag from an IndicesOptions to IndexNameExpressionResolver.Context as a dedicated field that callers to IndexNameExpressionResolver can set. Also alter indices stats api to support data streams. The rollover api uses this api and otherwise rolling over data stream does no longer work. Relates to #53100
This commit is contained in:
parent
9892813842
commit
2ac32db607
|
@ -1350,8 +1350,7 @@ public class RequestConvertersTests extends ESTestCase {
|
|||
searchRequest.indicesOptions(IndicesOptions.fromOptions(randomlyGenerated.ignoreUnavailable(),
|
||||
randomlyGenerated.allowNoIndices(), randomlyGenerated.expandWildcardsOpen(), randomlyGenerated.expandWildcardsClosed(),
|
||||
msearchDefault.expandWildcardsHidden(), msearchDefault.allowAliasesToMultipleIndices(),
|
||||
msearchDefault.forbidClosedIndices(), msearchDefault.ignoreAliases(), msearchDefault.ignoreThrottled(),
|
||||
msearchDefault.includeDataStreams()));
|
||||
msearchDefault.forbidClosedIndices(), msearchDefault.ignoreAliases(), msearchDefault.ignoreThrottled()));
|
||||
multiSearchRequest.add(searchRequest);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MultiSearchTemplateRequest extends ActionRequest implements Composi
|
|||
private int maxConcurrentSearchRequests = 0;
|
||||
private List<SearchTemplateRequest> requests = new ArrayList<>();
|
||||
|
||||
private IndicesOptions indicesOptions = IndicesOptions.strictIncludeDataStreamsExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
|
||||
public MultiSearchTemplateRequest() {}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class ReindexValidator {
|
|||
* it. This is the same sort of dance that TransportIndexRequest
|
||||
* uses to decide to autocreate the index.
|
||||
*/
|
||||
target = indexNameExpressionResolver.concreteWriteIndex(clusterState, destination).getName();
|
||||
target = indexNameExpressionResolver.concreteWriteIndex(clusterState, destination, false).getName();
|
||||
}
|
||||
for (String sourceIndex : indexNameExpressionResolver.concreteIndexNames(clusterState, source)) {
|
||||
if (sourceIndex.equals(target)) {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.action.admin.indices.refresh;
|
||||
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
||||
|
@ -37,7 +36,7 @@ import java.io.IOException;
|
|||
public class RefreshRequest extends BroadcastRequest<RefreshRequest> {
|
||||
|
||||
public RefreshRequest(String... indices) {
|
||||
super(indices, IndicesOptions.strictIncludeDataStreamsExpandOpenAndForbidClosed());
|
||||
super(indices);
|
||||
}
|
||||
|
||||
public RefreshRequest(StreamInput in) throws IOException {
|
||||
|
|
|
@ -64,4 +64,9 @@ public class TransportRefreshAction
|
|||
List<DefaultShardOperationFailedException> shardFailures) {
|
||||
return new RefreshResponse(totalNumCopies, successfulShards, failedShards, shardFailures);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldIncludeDataStreams() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ public class RolloverRequest extends AcknowledgedRequest<RolloverRequest> implem
|
|||
|
||||
@Override
|
||||
public IndicesOptions indicesOptions() {
|
||||
return IndicesOptions.strictSingleIndexIncludeDataStreamNoExpandForbidClosed();
|
||||
return IndicesOptions.strictSingleIndexNoExpandForbidClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -89,13 +89,10 @@ public class TransportRolloverAction extends TransportMasterNodeAction<RolloverR
|
|||
@Override
|
||||
protected ClusterBlockException checkBlock(RolloverRequest request, ClusterState state) {
|
||||
IndicesOptions indicesOptions = IndicesOptions.fromOptions(true, true,
|
||||
request.indicesOptions().expandWildcardsOpen(), request.indicesOptions().expandWildcardsClosed(),
|
||||
request.indicesOptions().expandWildcardsHidden(), true,
|
||||
request.indicesOptions().forbidClosedIndices(), request.indicesOptions().ignoreAliases(),
|
||||
request.indicesOptions().ignoreThrottled(), request.indicesOptions().includeDataStreams());
|
||||
request.indicesOptions().expandWildcardsOpen(), request.indicesOptions().expandWildcardsClosed());
|
||||
|
||||
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE,
|
||||
indexNameExpressionResolver.concreteIndexNames(state, indicesOptions, request.indices()));
|
||||
indexNameExpressionResolver.concreteIndexNames(state, indicesOptions, true, request.indices()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,7 +113,7 @@ public class TransportRolloverAction extends TransportMasterNodeAction<RolloverR
|
|||
String rolloverIndexName = preResult.rolloverIndexName;
|
||||
IndicesStatsRequest statsRequest = new IndicesStatsRequest().indices(rolloverRequest.getRolloverTarget())
|
||||
.clear()
|
||||
.indicesOptions(IndicesOptions.fromOptions(true, false, true, true, false, true, false, false, false, true))
|
||||
.indicesOptions(IndicesOptions.fromOptions(true, false, true, true))
|
||||
.docs(true);
|
||||
statsRequest.setParentTask(clusterService.localNode().getId(), task.getId());
|
||||
client.execute(IndicesStatsAction.INSTANCE, statsRequest,
|
||||
|
|
|
@ -57,6 +57,11 @@ public class TransportIndicesStatsAction extends TransportBroadcastByNodeAction<
|
|||
this.indicesService = indicesService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldIncludeDataStreams() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Status goes across *all* shards.
|
||||
*/
|
||||
|
|
|
@ -661,7 +661,8 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
Index resolveIfAbsent(DocWriteRequest<?> request) {
|
||||
Index concreteIndex = indices.get(request.index());
|
||||
if (concreteIndex == null) {
|
||||
concreteIndex = indexNameExpressionResolver.concreteWriteIndex(state, request);
|
||||
boolean includeDataStreams = request.opType() == DocWriteRequest.OpType.CREATE;
|
||||
concreteIndex = indexNameExpressionResolver.concreteWriteIndex(state, request, includeDataStreams);
|
||||
indices.put(request.index(), concreteIndex);
|
||||
}
|
||||
return concreteIndex;
|
||||
|
|
|
@ -264,12 +264,8 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
|
||||
@Override
|
||||
public IndicesOptions indicesOptions() {
|
||||
if (opType == OpType.CREATE) {
|
||||
return IndicesOptions.strictSingleIndexIncludeDataStreamNoExpandForbidClosed();
|
||||
} else {
|
||||
return IndicesOptions.strictSingleIndexNoExpandForbidClosed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The content type. This will be used when generating a document from user provided objects like Maps and when parsing the
|
||||
|
|
|
@ -60,7 +60,7 @@ public class MultiSearchRequest extends ActionRequest implements CompositeIndice
|
|||
private int maxConcurrentSearchRequests = 0;
|
||||
private final List<SearchRequest> requests = new ArrayList<>();
|
||||
|
||||
private IndicesOptions indicesOptions = IndicesOptions.strictIncludeDataStreamsExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
|
||||
public MultiSearchRequest() {}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class SearchRequest extends ActionRequest implements IndicesRequest.Repla
|
|||
private boolean ccsMinimizeRoundtrips = true;
|
||||
|
||||
public static final IndicesOptions DEFAULT_INDICES_OPTIONS =
|
||||
IndicesOptions.strictIncludeDataStreamsExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
IndicesOptions.strictExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
|
||||
private IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS;
|
||||
|
||||
|
|
|
@ -457,7 +457,7 @@ public class TransportSearchAction extends HandledTransportAction<SearchRequest,
|
|||
if (localIndices == null) {
|
||||
return Index.EMPTY_ARRAY; //don't search on any local index (happens when only remote indices were specified)
|
||||
}
|
||||
return indexNameExpressionResolver.concreteIndices(clusterState, indicesOptions,
|
||||
return indexNameExpressionResolver.concreteIndices(clusterState, indicesOptions, true,
|
||||
timeProvider.getAbsoluteStartMillis(), localIndices.indices());
|
||||
}
|
||||
|
||||
|
|
|
@ -102,8 +102,7 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
ALLOW_NO_INDICES,
|
||||
FORBID_ALIASES_TO_MULTIPLE_INDICES,
|
||||
FORBID_CLOSED_INDICES,
|
||||
IGNORE_THROTTLED,
|
||||
INCLUDE_DATA_STREAMS;
|
||||
IGNORE_THROTTLED;
|
||||
|
||||
public static final EnumSet<Option> NONE = EnumSet.noneOf(Option.class);
|
||||
}
|
||||
|
@ -113,9 +112,6 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
public static final IndicesOptions LENIENT_EXPAND_OPEN =
|
||||
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.IGNORE_UNAVAILABLE),
|
||||
EnumSet.of(WildcardStates.OPEN));
|
||||
public static final IndicesOptions LENIENT_INCLUDE_DATA_STREAMS_EXPAND_OPEN =
|
||||
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.IGNORE_UNAVAILABLE, Option.INCLUDE_DATA_STREAMS),
|
||||
EnumSet.of(WildcardStates.OPEN));
|
||||
public static final IndicesOptions LENIENT_EXPAND_OPEN_HIDDEN =
|
||||
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.IGNORE_UNAVAILABLE),
|
||||
EnumSet.of(WildcardStates.OPEN, WildcardStates.HIDDEN));
|
||||
|
@ -135,20 +131,13 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
public static final IndicesOptions STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED =
|
||||
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.FORBID_CLOSED_INDICES),
|
||||
EnumSet.of(WildcardStates.OPEN, WildcardStates.HIDDEN));
|
||||
public static final IndicesOptions STRICT_INCLUDE_DATA_STREAMS_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED =
|
||||
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.FORBID_CLOSED_INDICES, Option.IGNORE_THROTTLED,
|
||||
Option.INCLUDE_DATA_STREAMS), EnumSet.of(WildcardStates.OPEN));
|
||||
public static final IndicesOptions STRICT_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED =
|
||||
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.FORBID_CLOSED_INDICES, Option.IGNORE_THROTTLED),
|
||||
EnumSet.of(WildcardStates.OPEN));
|
||||
public static final IndicesOptions STRICT_SINGLE_INDEX_NO_EXPAND_FORBID_CLOSED =
|
||||
new IndicesOptions(EnumSet.of(Option.FORBID_ALIASES_TO_MULTIPLE_INDICES, Option.FORBID_CLOSED_INDICES),
|
||||
EnumSet.noneOf(WildcardStates.class));
|
||||
|
||||
public static final IndicesOptions STRICT_INCLUDE_DATA_STREAMS_EXPAND_OPEN_FORBID_CLOSED =
|
||||
new IndicesOptions(EnumSet.of(Option.ALLOW_NO_INDICES, Option.INCLUDE_DATA_STREAMS, Option.FORBID_CLOSED_INDICES),
|
||||
EnumSet.of(WildcardStates.OPEN));
|
||||
public static final IndicesOptions STRICT_SINGLE_INDEX_INCLUDE_DATA_STREAMS_NO_EXPAND_FORBID_CLOSED =
|
||||
new IndicesOptions(EnumSet.of(Option.FORBID_ALIASES_TO_MULTIPLE_INDICES, Option.FORBID_CLOSED_INDICES,
|
||||
Option.INCLUDE_DATA_STREAMS), EnumSet.noneOf(WildcardStates.class));
|
||||
|
||||
private final EnumSet<Option> options;
|
||||
private final EnumSet<WildcardStates> expandWildcards;
|
||||
|
||||
|
@ -237,13 +226,6 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
return EnumSet.copyOf(expandWildcards);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether to include data streams when resolving index expressions to concrete indices.
|
||||
*/
|
||||
public boolean includeDataStreams() {
|
||||
return options.contains(Option.INCLUDE_DATA_STREAMS);
|
||||
}
|
||||
|
||||
public void writeIndicesOptions(StreamOutput out) throws IOException {
|
||||
EnumSet<Option> options = this.options;
|
||||
// never write this out to a pre 6.6 version
|
||||
|
@ -251,10 +233,6 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
options = EnumSet.copyOf(options);
|
||||
options.remove(Option.IGNORE_THROTTLED);
|
||||
}
|
||||
if (out.getVersion().before(Version.V_7_8_0) && options.contains(Option.INCLUDE_DATA_STREAMS)) {
|
||||
options = EnumSet.copyOf(options);
|
||||
options.remove(Option.INCLUDE_DATA_STREAMS);
|
||||
}
|
||||
out.writeEnumSet(options);
|
||||
if (out.getVersion().before(Version.V_7_7_0) && expandWildcards.contains(WildcardStates.HIDDEN)) {
|
||||
final EnumSet<WildcardStates> states = EnumSet.copyOf(expandWildcards);
|
||||
|
@ -282,15 +260,14 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
public static IndicesOptions fromOptions(boolean ignoreUnavailable, boolean allowNoIndices, boolean expandToOpenIndices,
|
||||
boolean expandToClosedIndices, boolean expandToHiddenIndices) {
|
||||
return fromOptions(ignoreUnavailable, allowNoIndices, expandToOpenIndices, expandToClosedIndices, expandToHiddenIndices, true,
|
||||
false, false, false, false);
|
||||
false, false, false);
|
||||
}
|
||||
|
||||
public static IndicesOptions fromOptions(boolean ignoreUnavailable, boolean allowNoIndices, boolean expandToOpenIndices,
|
||||
boolean expandToClosedIndices, IndicesOptions defaultOptions) {
|
||||
return fromOptions(ignoreUnavailable, allowNoIndices, expandToOpenIndices, expandToClosedIndices,
|
||||
defaultOptions.expandWildcardsHidden(), defaultOptions.allowAliasesToMultipleIndices(),
|
||||
defaultOptions.forbidClosedIndices(), defaultOptions.ignoreAliases(), defaultOptions.ignoreThrottled(),
|
||||
defaultOptions.includeDataStreams());
|
||||
defaultOptions.forbidClosedIndices(), defaultOptions.ignoreAliases(), defaultOptions.ignoreThrottled());
|
||||
}
|
||||
|
||||
public static IndicesOptions fromOptions(boolean ignoreUnavailable, boolean allowNoIndices, boolean expandToOpenIndices,
|
||||
|
@ -298,13 +275,13 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
boolean forbidClosedIndices, boolean ignoreAliases,
|
||||
boolean ignoreThrottled) {
|
||||
return fromOptions(ignoreUnavailable, allowNoIndices, expandToOpenIndices, expandToClosedIndices, false,
|
||||
allowAliasesToMultipleIndices, forbidClosedIndices, ignoreAliases, ignoreThrottled, false);
|
||||
allowAliasesToMultipleIndices, forbidClosedIndices, ignoreAliases, ignoreThrottled);
|
||||
}
|
||||
|
||||
public static IndicesOptions fromOptions(boolean ignoreUnavailable, boolean allowNoIndices, boolean expandToOpenIndices,
|
||||
boolean expandToClosedIndices, boolean expandToHiddenIndices,
|
||||
boolean allowAliasesToMultipleIndices, boolean forbidClosedIndices, boolean ignoreAliases,
|
||||
boolean ignoreThrottled, boolean includeDataStreams) {
|
||||
boolean ignoreThrottled) {
|
||||
final EnumSet<Option> opts = EnumSet.noneOf(Option.class);
|
||||
final EnumSet<WildcardStates> wildcards = EnumSet.noneOf(WildcardStates.class);
|
||||
|
||||
|
@ -335,10 +312,6 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
if (ignoreThrottled) {
|
||||
opts.add(Option.IGNORE_THROTTLED);
|
||||
}
|
||||
if (includeDataStreams) {
|
||||
opts.add(Option.INCLUDE_DATA_STREAMS);
|
||||
}
|
||||
|
||||
return new IndicesOptions(opts, wildcards);
|
||||
}
|
||||
|
||||
|
@ -389,8 +362,7 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
defaultSettings.allowAliasesToMultipleIndices(),
|
||||
defaultSettings.forbidClosedIndices(),
|
||||
defaultSettings.ignoreAliases(),
|
||||
nodeBooleanValue(ignoreThrottled, "ignore_throttled", defaultSettings.ignoreThrottled()),
|
||||
defaultSettings.includeDataStreams());
|
||||
nodeBooleanValue(ignoreThrottled, "ignore_throttled", defaultSettings.ignoreThrottled()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -426,20 +398,10 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
/**
|
||||
* @return indices options that requires every specified index to exist, expands wildcards only to open indices,
|
||||
* allows that no indices are resolved from wildcard expressions (not returning an error),
|
||||
* supports data streams and forbids the use of closed indices by throwing an error.
|
||||
* forbids the use of closed indices by throwing an error and ignores indices that are throttled.
|
||||
*/
|
||||
public static IndicesOptions strictIncludeDataStreamsExpandOpenAndForbidClosed() {
|
||||
return STRICT_INCLUDE_DATA_STREAMS_EXPAND_OPEN_FORBID_CLOSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return indices options that requires every specified index to exist, expands wildcards only to open indices,
|
||||
* allows that no indices are resolved from wildcard expressions (not returning an error),
|
||||
* supports data streams and forbids the use of closed indices by throwing an error and
|
||||
* ignores indices that are throttled.
|
||||
*/
|
||||
public static IndicesOptions strictIncludeDataStreamsExpandOpenAndForbidClosedIgnoreThrottled() {
|
||||
return STRICT_INCLUDE_DATA_STREAMS_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED;
|
||||
public static IndicesOptions strictExpandOpenAndForbidClosedIgnoreThrottled() {
|
||||
return STRICT_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -466,14 +428,6 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
return STRICT_SINGLE_INDEX_NO_EXPAND_FORBID_CLOSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return indices option that requires each specified index or alias to exist, doesn't expand wildcards,
|
||||
* supports data streams and throws error if any of the aliases resolves to multiple indices.
|
||||
*/
|
||||
public static IndicesOptions strictSingleIndexIncludeDataStreamNoExpandForbidClosed() {
|
||||
return STRICT_SINGLE_INDEX_INCLUDE_DATA_STREAMS_NO_EXPAND_FORBID_CLOSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return indices options that ignores unavailable indices, expands wildcards only to open indices and
|
||||
* allows that no indices are resolved from wildcard expressions (not returning an error).
|
||||
|
@ -482,15 +436,6 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
return LENIENT_EXPAND_OPEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return indices options that ignores unavailable indices, expands wildcards only to open indices,
|
||||
* supports data streams and allows that no indices are resolved from wildcard expressions
|
||||
* (not returning an error).
|
||||
*/
|
||||
public static IndicesOptions lenientIncludeDataStreamsExpandOpen() {
|
||||
return LENIENT_INCLUDE_DATA_STREAMS_EXPAND_OPEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return indices options that ignores unavailable indices, expands wildcards to open and hidden indices, and
|
||||
* allows that no indices are resolved from wildcard expressions (not returning an error).
|
||||
|
@ -547,7 +492,6 @@ public class IndicesOptions implements ToXContentFragment {
|
|||
", forbid_closed_indices=" + forbidClosedIndices() +
|
||||
", ignore_aliases=" + ignoreAliases() +
|
||||
", ignore_throttled=" + ignoreThrottled() +
|
||||
", include_data_streams=" + includeDataStreams() +
|
||||
']';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,6 +225,10 @@ public abstract class TransportBroadcastByNodeAction<Request extends BroadcastRe
|
|||
new AsyncAction(task, request, listener).start();
|
||||
}
|
||||
|
||||
protected boolean shouldIncludeDataStreams() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected class AsyncAction {
|
||||
private final Task task;
|
||||
private final Request request;
|
||||
|
@ -249,7 +253,7 @@ public abstract class TransportBroadcastByNodeAction<Request extends BroadcastRe
|
|||
throw globalBlockException;
|
||||
}
|
||||
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request);
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request, shouldIncludeDataStreams());
|
||||
ClusterBlockException requestBlockException = checkRequestBlock(clusterState, request, concreteIndices);
|
||||
if (requestBlockException != null) {
|
||||
throw requestBlockException;
|
||||
|
|
|
@ -123,7 +123,7 @@ public abstract class TransportBroadcastReplicationAction<Request extends Broadc
|
|||
*/
|
||||
protected List<ShardId> shards(Request request, ClusterState clusterState) {
|
||||
List<ShardId> shardIds = new ArrayList<>();
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request);
|
||||
String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request, shouldIncludeDataStreams());
|
||||
for (String index : concreteIndices) {
|
||||
IndexMetadata indexMetadata = clusterState.metadata().getIndices().get(index);
|
||||
if (indexMetadata != null) {
|
||||
|
@ -136,6 +136,10 @@ public abstract class TransportBroadcastReplicationAction<Request extends Broadc
|
|||
return shardIds;
|
||||
}
|
||||
|
||||
protected boolean shouldIncludeDataStreams() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract ShardResponse newShardResponse();
|
||||
|
||||
protected abstract ShardRequest newShardRequest(Request request, ShardId shardId);
|
||||
|
|
|
@ -143,7 +143,7 @@ public abstract class TransportInstanceSingleOperationAction<
|
|||
throw blockException;
|
||||
}
|
||||
}
|
||||
request.concreteIndex(indexNameExpressionResolver.concreteWriteIndex(clusterState, request).getName());
|
||||
request.concreteIndex(indexNameExpressionResolver.concreteWriteIndex(clusterState, request, false).getName());
|
||||
resolveRequest(clusterState, request);
|
||||
blockException = checkRequestBlock(clusterState, request);
|
||||
if (blockException != null) {
|
||||
|
|
|
@ -71,7 +71,11 @@ public class IndexNameExpressionResolver {
|
|||
* are encapsulated in the specified request.
|
||||
*/
|
||||
public String[] concreteIndexNames(ClusterState state, IndicesRequest request) {
|
||||
Context context = new Context(state, request.indicesOptions());
|
||||
return concreteIndexNames(state, request, false);
|
||||
}
|
||||
|
||||
public String[] concreteIndexNames(ClusterState state, IndicesRequest request, boolean includeDataStreams) {
|
||||
Context context = new Context(state, request.indicesOptions(), false, false, includeDataStreams);
|
||||
return concreteIndexNames(context, request.indices());
|
||||
}
|
||||
|
||||
|
@ -102,6 +106,12 @@ public class IndexNameExpressionResolver {
|
|||
return concreteIndexNames(context, indexExpressions);
|
||||
}
|
||||
|
||||
public String[] concreteIndexNames(ClusterState state, IndicesOptions options, boolean includeDataStreams,
|
||||
String... indexExpressions) {
|
||||
Context context = new Context(state, options, false, false, includeDataStreams);
|
||||
return concreteIndexNames(context, indexExpressions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the provided index expression into actual concrete indices, properly deduplicated.
|
||||
*
|
||||
|
@ -116,7 +126,11 @@ public class IndexNameExpressionResolver {
|
|||
* indices options in the context don't allow such a case.
|
||||
*/
|
||||
public Index[] concreteIndices(ClusterState state, IndicesOptions options, String... indexExpressions) {
|
||||
Context context = new Context(state, options, false, false);
|
||||
return concreteIndices(state, options, false, indexExpressions);
|
||||
}
|
||||
|
||||
public Index[] concreteIndices(ClusterState state, IndicesOptions options, boolean includeDataStreams, String... indexExpressions) {
|
||||
Context context = new Context(state, options, false, false, includeDataStreams);
|
||||
return concreteIndices(context, indexExpressions);
|
||||
}
|
||||
|
||||
|
@ -133,8 +147,9 @@ public class IndexNameExpressionResolver {
|
|||
* @throws IllegalArgumentException if one of the aliases resolve to multiple indices and the provided
|
||||
* indices options in the context don't allow such a case.
|
||||
*/
|
||||
public Index[] concreteIndices(ClusterState state, IndicesOptions options, long startTime, String... indexExpressions) {
|
||||
Context context = new Context(state, options, startTime);
|
||||
public Index[] concreteIndices(ClusterState state, IndicesOptions options, boolean includeDataStreams, long startTime,
|
||||
String... indexExpressions) {
|
||||
Context context = new Context(state, options, startTime, false, false, includeDataStreams);
|
||||
return concreteIndices(context, indexExpressions);
|
||||
}
|
||||
|
||||
|
@ -205,7 +220,7 @@ public class IndexNameExpressionResolver {
|
|||
continue;
|
||||
}
|
||||
} else if (indexAbstraction.getType() == IndexAbstraction.Type.DATA_STREAM &&
|
||||
context.getOptions().includeDataStreams() == false) {
|
||||
context.includeDataStreams() == false) {
|
||||
throw dataStreamsNotSupportedException(expression);
|
||||
}
|
||||
|
||||
|
@ -311,14 +326,15 @@ public class IndexNameExpressionResolver {
|
|||
* @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.
|
||||
* @param includeDataStreams Whether data streams should be included in the evaluation.
|
||||
* @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) {
|
||||
public Index concreteWriteIndex(ClusterState state, IndicesRequest request, boolean includeDataStreams) {
|
||||
if (request.indices() == null || (request.indices() != null && request.indices().length != 1)) {
|
||||
throw new IllegalArgumentException("indices request must specify a single index expression");
|
||||
}
|
||||
return concreteWriteIndex(state, request.indicesOptions(), request.indices()[0], false);
|
||||
return concreteWriteIndex(state, request.indicesOptions(), request.indices()[0], false, includeDataStreams);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,11 +344,13 @@ public class IndexNameExpressionResolver {
|
|||
* @param options defines how the aliases or indices need to be resolved to concrete indices
|
||||
* @param index index that can be resolved to alias or index name.
|
||||
* @param allowNoIndices whether to allow resolve to no index
|
||||
* @param includeDataStreams Whether data streams should be included in the evaluation.
|
||||
* @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 or null if no index
|
||||
*/
|
||||
public Index concreteWriteIndex(ClusterState state, IndicesOptions options, String index, boolean allowNoIndices) {
|
||||
Context context = new Context(state, options, false, true);
|
||||
public Index concreteWriteIndex(ClusterState state, IndicesOptions options, String index, boolean allowNoIndices,
|
||||
boolean includeDataStreams) {
|
||||
Context context = new Context(state, options, false, true, includeDataStreams);
|
||||
Index[] indices = concreteIndices(context, index);
|
||||
if (allowNoIndices && indices.length == 0) {
|
||||
return null;
|
||||
|
@ -366,7 +384,7 @@ public class IndexNameExpressionResolver {
|
|||
* Resolve an array of expressions to the set of indices and aliases that these expressions match.
|
||||
*/
|
||||
public Set<String> resolveExpressions(ClusterState state, String... expressions) {
|
||||
Context context = new Context(state, IndicesOptions.lenientIncludeDataStreamsExpandOpen(), true, false);
|
||||
Context context = new Context(state, IndicesOptions.lenientExpandOpen(), true, false, true);
|
||||
List<String> resolvedExpressions = Arrays.asList(expressions);
|
||||
for (ExpressionResolver expressionResolver : expressionResolvers) {
|
||||
resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
|
||||
|
@ -460,7 +478,7 @@ public class IndexNameExpressionResolver {
|
|||
*/
|
||||
public Map<String, Set<String>> resolveSearchRouting(ClusterState state, @Nullable String routing, String... expressions) {
|
||||
List<String> resolvedExpressions = expressions != null ? Arrays.asList(expressions) : Collections.emptyList();
|
||||
Context context = new Context(state, IndicesOptions.lenientIncludeDataStreamsExpandOpen());
|
||||
Context context = new Context(state, IndicesOptions.lenientExpandOpen(), false, false, true);
|
||||
for (ExpressionResolver expressionResolver : expressionResolvers) {
|
||||
resolvedExpressions = expressionResolver.resolve(context, resolvedExpressions);
|
||||
}
|
||||
|
@ -619,26 +637,29 @@ public class IndexNameExpressionResolver {
|
|||
private final long startTime;
|
||||
private final boolean preserveAliases;
|
||||
private final boolean resolveToWriteIndex;
|
||||
private final boolean includeDataStreams;
|
||||
|
||||
Context(ClusterState state, IndicesOptions options) {
|
||||
this(state, options, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
Context(ClusterState state, IndicesOptions options, boolean preserveAliases, boolean resolveToWriteIndex) {
|
||||
this(state, options, System.currentTimeMillis(), preserveAliases, resolveToWriteIndex);
|
||||
Context(ClusterState state, IndicesOptions options, boolean preserveAliases, boolean resolveToWriteIndex,
|
||||
boolean includeDataStreams) {
|
||||
this(state, options, System.currentTimeMillis(), preserveAliases, resolveToWriteIndex, includeDataStreams);
|
||||
}
|
||||
|
||||
Context(ClusterState state, IndicesOptions options, long startTime) {
|
||||
this(state, options, startTime, false, false);
|
||||
this(state, options, startTime, false, false, false);
|
||||
}
|
||||
|
||||
protected Context(ClusterState state, IndicesOptions options, long startTime,
|
||||
boolean preserveAliases, boolean resolveToWriteIndex) {
|
||||
boolean preserveAliases, boolean resolveToWriteIndex, boolean includeDataStreams) {
|
||||
this.state = state;
|
||||
this.options = options;
|
||||
this.startTime = startTime;
|
||||
this.preserveAliases = preserveAliases;
|
||||
this.resolveToWriteIndex = resolveToWriteIndex;
|
||||
this.includeDataStreams = includeDataStreams;
|
||||
}
|
||||
|
||||
public ClusterState getState() {
|
||||
|
@ -669,6 +690,10 @@ public class IndexNameExpressionResolver {
|
|||
boolean isResolveToWriteIndex() {
|
||||
return resolveToWriteIndex;
|
||||
}
|
||||
|
||||
public boolean includeDataStreams() {
|
||||
return includeDataStreams;
|
||||
}
|
||||
}
|
||||
|
||||
private interface ExpressionResolver {
|
||||
|
@ -699,7 +724,7 @@ public class IndexNameExpressionResolver {
|
|||
}
|
||||
|
||||
if (isEmptyOrTrivialWildcard(expressions)) {
|
||||
if (options.includeDataStreams() == false && metadata.dataStreams().isEmpty() == false) {
|
||||
if (context.includeDataStreams() == false && metadata.dataStreams().isEmpty() == false) {
|
||||
throw dataStreamsNotSupportedException(expressions.toString());
|
||||
}
|
||||
return resolveEmptyOrTrivialWildcard(options, metadata);
|
||||
|
@ -727,7 +752,7 @@ public class IndexNameExpressionResolver {
|
|||
throw indexNotFoundException(expression);
|
||||
}
|
||||
validateAliasOrIndex(expression);
|
||||
if (aliasOrIndexExists(options, metadata, expression)) {
|
||||
if (aliasOrIndexExists(context, options, metadata, expression)) {
|
||||
if (result != null) {
|
||||
result.add(expression);
|
||||
}
|
||||
|
@ -753,7 +778,7 @@ public class IndexNameExpressionResolver {
|
|||
} else if (indexAbstraction.getType() == IndexAbstraction.Type.ALIAS && options.ignoreAliases()) {
|
||||
throw aliasesNotSupportedException(expression);
|
||||
} else if (indexAbstraction.getType() == IndexAbstraction.Type.DATA_STREAM &&
|
||||
options.includeDataStreams() == false) {
|
||||
context.includeDataStreams() == false) {
|
||||
throw dataStreamsNotSupportedException(expression);
|
||||
}
|
||||
}
|
||||
|
@ -793,7 +818,7 @@ public class IndexNameExpressionResolver {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean aliasOrIndexExists(IndicesOptions options, Metadata metadata, String expression) {
|
||||
private static boolean aliasOrIndexExists(Context context, IndicesOptions options, Metadata metadata, String expression) {
|
||||
IndexAbstraction indexAbstraction = metadata.getIndicesLookup().get(expression);
|
||||
if (indexAbstraction == null) {
|
||||
return false;
|
||||
|
@ -804,7 +829,7 @@ public class IndexNameExpressionResolver {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (indexAbstraction.getType() == IndexAbstraction.Type.DATA_STREAM && options.includeDataStreams() == false) {
|
||||
if (indexAbstraction.getType() == IndexAbstraction.Type.DATA_STREAM && context.includeDataStreams() == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -834,7 +859,7 @@ public class IndexNameExpressionResolver {
|
|||
|
||||
public static Map<String, IndexAbstraction> matches(Context context, Metadata metadata, String expression) {
|
||||
if (Regex.isMatchAllPattern(expression)) {
|
||||
return filterIndicesLookup(metadata.getIndicesLookup(), null, expression, context.getOptions());
|
||||
return filterIndicesLookup(context, metadata.getIndicesLookup(), null, expression, context.getOptions());
|
||||
} else if (expression.indexOf("*") == expression.length() - 1) {
|
||||
return suffixWildcard(context, metadata, expression);
|
||||
} else {
|
||||
|
@ -849,16 +874,16 @@ public class IndexNameExpressionResolver {
|
|||
toPrefixCharArr[toPrefixCharArr.length - 1]++;
|
||||
String toPrefix = new String(toPrefixCharArr);
|
||||
SortedMap<String, IndexAbstraction> subMap = metadata.getIndicesLookup().subMap(fromPrefix, toPrefix);
|
||||
return filterIndicesLookup(subMap, null, expression, context.getOptions());
|
||||
return filterIndicesLookup(context, subMap, null, expression, context.getOptions());
|
||||
}
|
||||
|
||||
private static Map<String, IndexAbstraction> otherWildcard(Context context, Metadata metadata, String expression) {
|
||||
final String pattern = expression;
|
||||
return filterIndicesLookup(metadata.getIndicesLookup(), e -> Regex.simpleMatch(pattern, e.getKey()),
|
||||
return filterIndicesLookup(context, metadata.getIndicesLookup(), e -> Regex.simpleMatch(pattern, e.getKey()),
|
||||
expression, context.getOptions());
|
||||
}
|
||||
|
||||
private static Map<String, IndexAbstraction> filterIndicesLookup(SortedMap<String, IndexAbstraction> indicesLookup,
|
||||
private static Map<String, IndexAbstraction> filterIndicesLookup(Context context, SortedMap<String, IndexAbstraction> indicesLookup,
|
||||
Predicate<? super Map.Entry<String, IndexAbstraction>> filter,
|
||||
String expression,
|
||||
IndicesOptions options) {
|
||||
|
@ -872,7 +897,7 @@ public class IndexNameExpressionResolver {
|
|||
shouldConsumeStream = true;
|
||||
stream = stream.filter(filter);
|
||||
}
|
||||
if (options.includeDataStreams() == false) {
|
||||
if (context.includeDataStreams() == false) {
|
||||
shouldConsumeStream = true;
|
||||
stream = stream.peek(e -> {
|
||||
if (e.getValue().getType() == IndexAbstraction.Type.DATA_STREAM) {
|
||||
|
|
|
@ -329,21 +329,21 @@ public class MultiSearchRequestTests extends ESTestCase {
|
|||
|
||||
public void testWritingExpandWildcards() throws IOException {
|
||||
assertExpandWildcardsValue(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), true, true, true, randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), "all");
|
||||
randomBoolean(), randomBoolean(), randomBoolean()), "all");
|
||||
assertExpandWildcardsValue(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), true, true, false, randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), "open,closed");
|
||||
randomBoolean(), randomBoolean(), randomBoolean()), "open,closed");
|
||||
assertExpandWildcardsValue(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), true, false, true, randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), "open,hidden");
|
||||
randomBoolean(), randomBoolean(), randomBoolean()), "open,hidden");
|
||||
assertExpandWildcardsValue(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), true, false, false, randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), "open");
|
||||
randomBoolean(), randomBoolean(), randomBoolean()), "open");
|
||||
assertExpandWildcardsValue(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), false, true, true, randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), "closed,hidden");
|
||||
randomBoolean(), randomBoolean(), randomBoolean()), "closed,hidden");
|
||||
assertExpandWildcardsValue(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), false, true, false, randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), "closed");
|
||||
randomBoolean(), randomBoolean(), randomBoolean()), "closed");
|
||||
assertExpandWildcardsValue(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), false, false, true, randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), "hidden");
|
||||
randomBoolean(), randomBoolean(), randomBoolean()), "hidden");
|
||||
assertExpandWildcardsValue(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), false, false, false, randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()), "none");
|
||||
randomBoolean(), randomBoolean(), randomBoolean()), "none");
|
||||
}
|
||||
|
||||
private void assertExpandWildcardsValue(IndicesOptions options, String expectedValue) throws IOException {
|
||||
|
@ -405,7 +405,7 @@ public class MultiSearchRequestTests extends ESTestCase {
|
|||
randomlyGenerated.ignoreUnavailable(), randomlyGenerated.allowNoIndices(), randomlyGenerated.expandWildcardsOpen(),
|
||||
randomlyGenerated.expandWildcardsClosed(), msearchDefault.expandWildcardsHidden(),
|
||||
msearchDefault.allowAliasesToMultipleIndices(), msearchDefault.forbidClosedIndices(), msearchDefault.ignoreAliases(),
|
||||
msearchDefault.ignoreThrottled(), msearchDefault.includeDataStreams()
|
||||
msearchDefault.ignoreThrottled()
|
||||
));
|
||||
|
||||
request.add(searchRequest);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
Version version = randomVersionBetween(random(), Version.V_7_0_0, null);
|
||||
IndicesOptions indicesOptions = IndicesOptions.fromOptions(
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean());
|
||||
randomBoolean(), randomBoolean());
|
||||
|
||||
BytesStreamOutput output = new BytesStreamOutput();
|
||||
output.setVersion(version);
|
||||
|
@ -81,11 +81,6 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
assertThat(indicesOptions2.allowAliasesToMultipleIndices(), equalTo(indicesOptions.allowAliasesToMultipleIndices()));
|
||||
|
||||
assertEquals(indicesOptions2.ignoreAliases(), indicesOptions.ignoreAliases());
|
||||
if (version.before(Version.V_7_8_0)) {
|
||||
assertThat(indicesOptions2.includeDataStreams(), is(false));
|
||||
} else {
|
||||
assertThat(indicesOptions2.includeDataStreams(), equalTo(indicesOptions.includeDataStreams()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,11 +126,10 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
final boolean forbidClosedIndices = randomBoolean();
|
||||
final boolean ignoreAliases = randomBoolean();
|
||||
final boolean ignoreThrottled = randomBoolean();
|
||||
final boolean includeDataStreams = randomBoolean();
|
||||
|
||||
IndicesOptions indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, allowNoIndices, expandToOpenIndices,
|
||||
expandToClosedIndices, expandToHiddenIndices, allowAliasesToMultipleIndices, forbidClosedIndices, ignoreAliases,
|
||||
ignoreThrottled, includeDataStreams);
|
||||
ignoreThrottled);
|
||||
|
||||
assertThat(indicesOptions.ignoreUnavailable(), equalTo(ignoreUnavailable));
|
||||
assertThat(indicesOptions.allowNoIndices(), equalTo(allowNoIndices));
|
||||
|
@ -147,7 +141,6 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
assertThat(indicesOptions.forbidClosedIndices(), equalTo(forbidClosedIndices));
|
||||
assertEquals(ignoreAliases, indicesOptions.ignoreAliases());
|
||||
assertEquals(ignoreThrottled, indicesOptions.ignoreThrottled());
|
||||
assertThat(indicesOptions.includeDataStreams(), equalTo(includeDataStreams));
|
||||
}
|
||||
|
||||
public void testFromOptionsWithDefaultOptions() {
|
||||
|
@ -157,7 +150,7 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
boolean expandToClosedIndices = randomBoolean();
|
||||
|
||||
IndicesOptions defaultOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
|
||||
|
||||
IndicesOptions indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, allowNoIndices, expandToOpenIndices,
|
||||
expandToClosedIndices, defaultOptions);
|
||||
|
@ -170,7 +163,6 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
assertEquals(defaultOptions.allowAliasesToMultipleIndices(), indicesOptions.allowAliasesToMultipleIndices());
|
||||
assertEquals(defaultOptions.forbidClosedIndices(), indicesOptions.forbidClosedIndices());
|
||||
assertEquals(defaultOptions.ignoreAliases(), indicesOptions.ignoreAliases());
|
||||
assertEquals(defaultOptions.includeDataStreams(), indicesOptions.includeDataStreams());
|
||||
}
|
||||
|
||||
public void testFromParameters() {
|
||||
|
@ -207,7 +199,7 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
String allowNoIndicesString = Boolean.toString(allowNoIndices);
|
||||
|
||||
IndicesOptions defaultOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
|
||||
|
||||
IndicesOptions updatedOptions = IndicesOptions.fromParameters(expandWildcardsString, ignoreUnavailableString,
|
||||
allowNoIndicesString, ignoreThrottled, defaultOptions);
|
||||
|
@ -220,17 +212,16 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
assertEquals(defaultOptions.allowAliasesToMultipleIndices(), updatedOptions.allowAliasesToMultipleIndices());
|
||||
assertEquals(defaultOptions.forbidClosedIndices(), updatedOptions.forbidClosedIndices());
|
||||
assertEquals(defaultOptions.ignoreAliases(), updatedOptions.ignoreAliases());
|
||||
assertEquals(defaultOptions.includeDataStreams(), updatedOptions.includeDataStreams());
|
||||
}
|
||||
|
||||
public void testEqualityAndHashCode() {
|
||||
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
|
||||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
|
||||
|
||||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(indicesOptions, opts -> {
|
||||
return IndicesOptions.fromOptions(opts.ignoreUnavailable(), opts.allowNoIndices(), opts.expandWildcardsOpen(),
|
||||
opts.expandWildcardsClosed(), opts.expandWildcardsHidden(), opts.allowAliasesToMultipleIndices(),
|
||||
opts.forbidClosedIndices(), opts.ignoreAliases(), opts.ignoreThrottled(), opts.includeDataStreams());
|
||||
opts.forbidClosedIndices(), opts.ignoreAliases(), opts.ignoreThrottled());
|
||||
}, opts -> {
|
||||
boolean mutated = false;
|
||||
boolean ignoreUnavailable = opts.ignoreUnavailable();
|
||||
|
@ -242,7 +233,6 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
boolean forbidClosed = opts.forbidClosedIndices();
|
||||
boolean ignoreAliases = opts.ignoreAliases();
|
||||
boolean ignoreThrottled = opts.ignoreThrottled();
|
||||
boolean includeDataStreams = opts.includeDataStreams();
|
||||
while (mutated == false) {
|
||||
if (randomBoolean()) {
|
||||
ignoreUnavailable = !ignoreUnavailable;
|
||||
|
@ -280,13 +270,9 @@ public class IndicesOptionsTests extends ESTestCase {
|
|||
ignoreThrottled = !ignoreThrottled;
|
||||
mutated = true;
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
includeDataStreams = !includeDataStreams;
|
||||
mutated = true;
|
||||
}
|
||||
}
|
||||
return IndicesOptions.fromOptions(ignoreUnavailable, allowNoIndices, expandOpen, expandClosed, expandHidden,
|
||||
allowAliasesToMulti, forbidClosed, ignoreAliases, ignoreThrottled, includeDataStreams);
|
||||
allowAliasesToMulti, forbidClosed, ignoreAliases, ignoreThrottled);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1227,7 +1227,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
|
|||
// And querying using a wildcard with indices options set to expand hidden
|
||||
searchResponse = client().prepareSearch("alias*")
|
||||
.setQuery(QueryBuilders.matchAllQuery())
|
||||
.setIndicesOptions(IndicesOptions.fromOptions(false, false, true, false, true, true, true, false, false, true)).get();
|
||||
.setIndicesOptions(IndicesOptions.fromOptions(false, false, true, false, true, true, true, false, false)).get();
|
||||
assertHits(searchResponse.getHits(), "1", "2", "3");
|
||||
|
||||
// And that querying the alias with a wildcard and no expand options fails
|
||||
|
|
|
@ -895,8 +895,8 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
final String dottedHiddenAlias = ".hidden_alias";
|
||||
final String dottedHiddenIndex = ".hidden_index";
|
||||
|
||||
IndicesOptions excludeHiddenOptions = IndicesOptions.fromOptions(false, false, true, false, false, true, false, false, false, true);
|
||||
IndicesOptions includeHiddenOptions = IndicesOptions.fromOptions(false, false, true, false, true, true, false, false, false, true);
|
||||
IndicesOptions excludeHiddenOptions = IndicesOptions.fromOptions(false, false, true, false, false, true, false, false, false);
|
||||
IndicesOptions includeHiddenOptions = IndicesOptions.fromOptions(false, false, true, false, true, true, false, false, false);
|
||||
|
||||
{
|
||||
// A visible index with a visible alias and a hidden index with a hidden alias
|
||||
|
@ -1029,8 +1029,8 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
final String hiddenAlias = "my-hidden-alias";
|
||||
final String visibleAlias = "my-visible-alias";
|
||||
|
||||
IndicesOptions excludeHiddenOptions = IndicesOptions.fromOptions(false, true, true, false, false, true, false, false, false, true);
|
||||
IndicesOptions includeHiddenOptions = IndicesOptions.fromOptions(false, true, true, false, true, true, false, false, false, true);
|
||||
IndicesOptions excludeHiddenOptions = IndicesOptions.fromOptions(false, true, true, false, false, true, false, false, false);
|
||||
IndicesOptions includeHiddenOptions = IndicesOptions.fromOptions(false, true, true, false, true, true, false, false, false);
|
||||
|
||||
Metadata.Builder mdBuilder = Metadata.builder()
|
||||
.put(indexBuilder(hiddenIndex, Settings.builder().put(INDEX_HIDDEN_SETTING.getKey(), true).build())
|
||||
|
@ -1432,13 +1432,13 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
return IndicesOptions.strictSingleIndexNoExpandForbidClosed();
|
||||
}
|
||||
};
|
||||
Index writeIndex = indexNameExpressionResolver.concreteWriteIndex(state, request);
|
||||
Index writeIndex = indexNameExpressionResolver.concreteWriteIndex(state, request, false);
|
||||
assertThat(writeIndex.getName(), equalTo("test-0"));
|
||||
|
||||
state = ClusterState.builder(state).metadata(Metadata.builder(state.metadata())
|
||||
.put(indexBuilder("test-1").putAlias(AliasMetadata.builder("test-alias")
|
||||
.writeIndex(testZeroWriteIndex ? randomFrom(false, null) : true)))).build();
|
||||
writeIndex = indexNameExpressionResolver.concreteWriteIndex(state, request);
|
||||
writeIndex = indexNameExpressionResolver.concreteWriteIndex(state, request, false);
|
||||
assertThat(writeIndex.getName(), equalTo(testZeroWriteIndex ? "test-0" : "test-1"));
|
||||
}
|
||||
|
||||
|
@ -1460,10 +1460,10 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
}
|
||||
};
|
||||
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, requestGen.apply(null)));
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, requestGen.apply(null), false));
|
||||
assertThat(exception.getMessage(), equalTo("indices request must specify a single index expression"));
|
||||
exception = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, requestGen.apply(new String[] {"too", "many"})));
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, requestGen.apply(new String[] {"too", "many"}), false));
|
||||
assertThat(exception.getMessage(), equalTo("indices request must specify a single index expression"));
|
||||
|
||||
|
||||
|
@ -1495,7 +1495,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
};
|
||||
|
||||
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, request));
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, request, false));
|
||||
assertThat(exception.getMessage(),
|
||||
equalTo("The index expression [test-*] and options provided did not point to a single write-index"));
|
||||
}
|
||||
|
@ -1512,7 +1512,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
DocWriteRequest request = randomFrom(new IndexRequest("test-alias"),
|
||||
new UpdateRequest("test-alias", "_type", "_id"), new DeleteRequest("test-alias"));
|
||||
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, request));
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, request, false));
|
||||
assertThat(exception.getMessage(), equalTo("no write index is defined for alias [test-alias]." +
|
||||
" The write index may be explicitly disabled using is_write_index=false or the alias points to multiple" +
|
||||
" indices without one being designated as a write index"));
|
||||
|
@ -1532,7 +1532,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
DocWriteRequest request = randomFrom(new IndexRequest("test-alias"),
|
||||
new UpdateRequest("test-alias", "_type", "_id"), new DeleteRequest("test-alias"));
|
||||
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, request));
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, request, false));
|
||||
assertThat(exception.getMessage(), equalTo("no write index is defined for alias [test-alias]." +
|
||||
" The write index may be explicitly disabled using is_write_index=false or the alias points to multiple" +
|
||||
" indices without one being designated as a write index"));
|
||||
|
@ -1712,7 +1712,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
ClusterState state = ClusterState.builder(new ClusterName("_name")).metadata(mdBuilder).build();
|
||||
{
|
||||
Index[] indices = indexNameExpressionResolver.concreteIndices(state,
|
||||
IndicesOptions.STRICT_INCLUDE_DATA_STREAMS_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "*");
|
||||
IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "*");
|
||||
assertEquals(1, indices.length);
|
||||
assertEquals("index", indices[0].getName());
|
||||
}
|
||||
|
@ -1724,18 +1724,18 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
}
|
||||
{
|
||||
Index[] indices = indexNameExpressionResolver.concreteIndices(state,
|
||||
IndicesOptions.STRICT_INCLUDE_DATA_STREAMS_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "test-alias");
|
||||
IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "test-alias");
|
||||
assertEquals(0, indices.length);
|
||||
}
|
||||
{
|
||||
Index[] indices = indexNameExpressionResolver.concreteIndices(state,
|
||||
IndicesOptions.STRICT_INCLUDE_DATA_STREAMS_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "test-*");
|
||||
IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "test-*");
|
||||
assertEquals(1, indices.length);
|
||||
assertEquals("index", indices[0].getName());
|
||||
}
|
||||
{
|
||||
Index[] indices = indexNameExpressionResolver.concreteIndices(state,
|
||||
IndicesOptions.STRICT_INCLUDE_DATA_STREAMS_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "ind*", "test-index");
|
||||
IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "ind*", "test-index");
|
||||
assertEquals(1, indices.length);
|
||||
Arrays.sort(indices, Comparator.comparing(Index::getName));
|
||||
assertEquals("index", indices[0].getName());
|
||||
|
@ -1774,9 +1774,8 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
ClusterState state = ClusterState.builder(new ClusterName("_name")).metadata(mdBuilder).build();
|
||||
|
||||
{
|
||||
IndicesOptions indicesOptions = new IndicesOptions(EnumSet.of(IndicesOptions.Option.INCLUDE_DATA_STREAMS),
|
||||
EnumSet.of(IndicesOptions.WildcardStates.OPEN));
|
||||
Index[] result = indexNameExpressionResolver.concreteIndices(state, indicesOptions, "my-data-stream");
|
||||
IndicesOptions indicesOptions = IndicesOptions.STRICT_EXPAND_OPEN;
|
||||
Index[] result = indexNameExpressionResolver.concreteIndices(state, indicesOptions, true, "my-data-stream");
|
||||
assertThat(result.length, equalTo(2));
|
||||
assertThat(result[0].getName(), equalTo(dataStreamName + "-000001"));
|
||||
assertThat(result[1].getName(), equalTo(dataStreamName + "-000002"));
|
||||
|
@ -1785,7 +1784,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
// Ignore data streams
|
||||
IndicesOptions indicesOptions = IndicesOptions.STRICT_EXPAND_OPEN;
|
||||
Exception e = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteIndices(state, indicesOptions, "my-data-stream"));
|
||||
() -> indexNameExpressionResolver.concreteIndices(state, indicesOptions, false, "my-data-stream"));
|
||||
assertThat(e.getMessage(), equalTo("The provided expression [my-data-stream] matches a " +
|
||||
"data stream, specify the corresponding concrete indices instead."));
|
||||
}
|
||||
|
@ -1794,7 +1793,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
IndicesOptions indicesOptions = new IndicesOptions(EnumSet.of(IndicesOptions.Option.ALLOW_NO_INDICES),
|
||||
EnumSet.of(IndicesOptions.WildcardStates.OPEN));
|
||||
Exception e = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteIndices(state, indicesOptions, "my-data-stream"));
|
||||
() -> indexNameExpressionResolver.concreteIndices(state, indicesOptions, false, "my-data-stream"));
|
||||
assertThat(e.getMessage(), equalTo("The provided expression [my-data-stream] matches a " +
|
||||
"data stream, specify the corresponding concrete indices instead."));
|
||||
}
|
||||
|
@ -1803,14 +1802,13 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
IndicesOptions indicesOptions = new IndicesOptions(EnumSet.of(IndicesOptions.Option.ALLOW_NO_INDICES,
|
||||
IndicesOptions.Option.IGNORE_UNAVAILABLE), EnumSet.of(IndicesOptions.WildcardStates.OPEN));
|
||||
Exception e = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteIndices(state, indicesOptions, "my-data-stream"));
|
||||
() -> indexNameExpressionResolver.concreteIndices(state, indicesOptions, false, "my-data-stream"));
|
||||
assertThat(e.getMessage(), equalTo("The provided expression [my-data-stream] matches a " +
|
||||
"data stream, specify the corresponding concrete indices instead."));
|
||||
}
|
||||
{
|
||||
IndicesOptions indicesOptions = new IndicesOptions(EnumSet.of(IndicesOptions.Option.INCLUDE_DATA_STREAMS),
|
||||
EnumSet.of(IndicesOptions.WildcardStates.OPEN));
|
||||
Index result = indexNameExpressionResolver.concreteWriteIndex(state, indicesOptions, "my-data-stream", false);
|
||||
IndicesOptions indicesOptions = IndicesOptions.STRICT_EXPAND_OPEN;
|
||||
Index result = indexNameExpressionResolver.concreteWriteIndex(state, indicesOptions, "my-data-stream", false, true);
|
||||
assertThat(result.getName(), equalTo(dataStreamName + "-000002"));
|
||||
}
|
||||
{
|
||||
|
@ -1818,7 +1816,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
IndicesOptions indicesOptions = new IndicesOptions(EnumSet.noneOf(IndicesOptions.Option.class),
|
||||
EnumSet.of(IndicesOptions.WildcardStates.OPEN));
|
||||
Exception e = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, indicesOptions, "my-data-stream", true));
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, indicesOptions, "my-data-stream", true, false));
|
||||
assertThat(e.getMessage(), equalTo("The provided expression [my-data-stream] matches a " +
|
||||
"data stream, specify the corresponding concrete indices instead."));
|
||||
|
||||
|
@ -1827,7 +1825,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
// Ignore data streams and allow no indices
|
||||
IndicesOptions indicesOptions = IndicesOptions.STRICT_EXPAND_OPEN;
|
||||
Exception e = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, indicesOptions, "my-data-stream", false));
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, indicesOptions, "my-data-stream", false, false));
|
||||
assertThat(e.getMessage(), equalTo("The provided expression [my-data-stream] matches a data stream, " +
|
||||
"specify the corresponding concrete indices instead."));
|
||||
}
|
||||
|
@ -1836,7 +1834,7 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
IndicesOptions indicesOptions = new IndicesOptions(EnumSet.of(IndicesOptions.Option.ALLOW_NO_INDICES,
|
||||
IndicesOptions.Option.IGNORE_UNAVAILABLE), EnumSet.of(IndicesOptions.WildcardStates.OPEN));
|
||||
Exception e = expectThrows(IllegalArgumentException.class,
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, indicesOptions, "my-data-stream", false));
|
||||
() -> indexNameExpressionResolver.concreteWriteIndex(state, indicesOptions, "my-data-stream", false, false));
|
||||
assertThat(e.getMessage(), equalTo("The provided expression [my-data-stream] matches a data stream, " +
|
||||
"specify the corresponding concrete indices instead."));
|
||||
}
|
||||
|
@ -1859,9 +1857,8 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
|
||||
ClusterState state = ClusterState.builder(new ClusterName("_name")).metadata(mdBuilder).build();
|
||||
{
|
||||
IndicesOptions indicesOptions = new IndicesOptions(EnumSet.of(IndicesOptions.Option.ALLOW_NO_INDICES,
|
||||
IndicesOptions.Option.INCLUDE_DATA_STREAMS), EnumSet.of(IndicesOptions.WildcardStates.OPEN));
|
||||
Index[] result = indexNameExpressionResolver.concreteIndices(state, indicesOptions, "logs-*");
|
||||
IndicesOptions indicesOptions = IndicesOptions.STRICT_EXPAND_OPEN;
|
||||
Index[] result = indexNameExpressionResolver.concreteIndices(state, indicesOptions, true, "logs-*");
|
||||
Arrays.sort(result, Comparator.comparing(Index::getName));
|
||||
assertThat(result.length, equalTo(4));
|
||||
assertThat(result[0].getName(), equalTo(dataStream1 + "-000001"));
|
||||
|
@ -1870,9 +1867,8 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
assertThat(result[3].getName(), equalTo(dataStream2 + "-000002"));
|
||||
}
|
||||
{
|
||||
IndicesOptions indicesOptions = new IndicesOptions(EnumSet.of(IndicesOptions.Option.ALLOW_NO_INDICES,
|
||||
IndicesOptions.Option.INCLUDE_DATA_STREAMS), EnumSet.of(IndicesOptions.WildcardStates.OPEN));
|
||||
Index[] result = indexNameExpressionResolver.concreteIndices(state, indicesOptions, "logs-m*");
|
||||
IndicesOptions indicesOptions = IndicesOptions.STRICT_EXPAND_OPEN;
|
||||
Index[] result = indexNameExpressionResolver.concreteIndices(state, indicesOptions, true, "logs-m*");
|
||||
Arrays.sort(result, Comparator.comparing(Index::getName));
|
||||
assertThat(result.length, equalTo(2));
|
||||
assertThat(result[0].getName(), equalTo(dataStream1 + "-000001"));
|
||||
|
@ -1906,8 +1902,8 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
|
|||
.put(new DataStream(dataStream1, "ts",
|
||||
org.elasticsearch.common.collect.List.of(index1.getIndex(), index2.getIndex())))).build();
|
||||
|
||||
IndicesOptions indicesOptions = IndicesOptions.strictIncludeDataStreamsExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
Index[] result = indexNameExpressionResolver.concreteIndices(state, indicesOptions, "logs-*");
|
||||
IndicesOptions indicesOptions = IndicesOptions.strictExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
Index[] result = indexNameExpressionResolver.concreteIndices(state, indicesOptions, true, "logs-*");
|
||||
Arrays.sort(result, Comparator.comparing(Index::getName));
|
||||
assertThat(result.length, equalTo(3));
|
||||
assertThat(result[0].getName(), equalTo("logs-foobar-000001"));
|
||||
|
|
|
@ -664,7 +664,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
|
|||
verifyResolvability(dataStreamName, clearCache(dataStreamName), true);
|
||||
verifyResolvability(dataStreamName, _flush(dataStreamName),true);
|
||||
verifyResolvability(dataStreamName, segments(dataStreamName), true);
|
||||
verifyResolvability(dataStreamName, stats(dataStreamName), true);
|
||||
verifyResolvability(dataStreamName, stats(dataStreamName), false);
|
||||
verifyResolvability(dataStreamName, forceMerge(dataStreamName), true);
|
||||
verifyResolvability(dataStreamName, validateQuery(dataStreamName), true);
|
||||
verifyResolvability(dataStreamName, getAliases(dataStreamName), true);
|
||||
|
@ -687,7 +687,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
|
|||
verifyResolvability(wildcardExpression, clearCache(wildcardExpression), true);
|
||||
verifyResolvability(wildcardExpression, _flush(wildcardExpression),true);
|
||||
verifyResolvability(wildcardExpression, segments(wildcardExpression), true);
|
||||
verifyResolvability(wildcardExpression, stats(wildcardExpression), true);
|
||||
verifyResolvability(wildcardExpression, stats(wildcardExpression), false);
|
||||
verifyResolvability(wildcardExpression, forceMerge(wildcardExpression), true);
|
||||
verifyResolvability(wildcardExpression, validateQuery(wildcardExpression), true);
|
||||
verifyResolvability(wildcardExpression, getAliases(wildcardExpression), true);
|
||||
|
|
|
@ -142,7 +142,7 @@ public abstract class TestCluster implements Closeable {
|
|||
try {
|
||||
// include wiping hidden indices!
|
||||
assertAcked(client().admin().indices().prepareDelete(indices)
|
||||
.setIndicesOptions(IndicesOptions.fromOptions(false, true, true, true, true, false, false, true, false, false)));
|
||||
.setIndicesOptions(IndicesOptions.fromOptions(false, true, true, true, true, false, false, true, false)));
|
||||
} catch (IndexNotFoundException e) {
|
||||
// ignore
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
|
|
@ -169,8 +169,8 @@ public final class SourceDestValidator {
|
|||
state,
|
||||
IndicesOptions.lenientExpandOpen(),
|
||||
dest,
|
||||
true
|
||||
);
|
||||
true,
|
||||
false);
|
||||
|
||||
resolvedDest = singleWriteIndex != null ? singleWriteIndex.getName() : dest;
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -228,7 +228,7 @@ public final class SourceDestValidator {
|
|||
|
||||
// note: this is equivalent to the default for search requests
|
||||
private static final IndicesOptions DEFAULT_INDICES_OPTIONS_FOR_VALIDATION = IndicesOptions
|
||||
.strictIncludeDataStreamsExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
.strictExpandOpenAndForbidClosedIgnoreThrottled();
|
||||
|
||||
public static final SourceDestValidation SOURCE_MISSING_VALIDATION = new SourceMissingValidation();
|
||||
public static final SourceDestValidation REMOTE_SOURCE_VALIDATION = new RemoteSourceEnabledAndRemoteLicenseValidation();
|
||||
|
|
|
@ -132,7 +132,7 @@ public class GenerateSnapshotNameStep extends ClusterStateActionStep {
|
|||
}
|
||||
|
||||
public ResolverContext(long startTime) {
|
||||
super(null, null, startTime, false, false);
|
||||
super(null, null, startTime, false, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -268,7 +268,7 @@ public class DatafeedNodeSelectorTests extends ESTestCase {
|
|||
equalTo("cannot start datafeed [datafeed_id] because it failed resolving indices given [not_foo] and " +
|
||||
"indices_options [IndicesOptions[ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, " +
|
||||
"expand_wildcards_closed=false, expand_wildcards_hidden=false, allow_aliases_to_multiple_indices=true, " +
|
||||
"forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true, include_data_streams=true]] " +
|
||||
"forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true]] " +
|
||||
"with exception [no such index [not_foo]]"));
|
||||
|
||||
ElasticsearchException e = expectThrows(ElasticsearchException.class,
|
||||
|
@ -282,8 +282,8 @@ public class DatafeedNodeSelectorTests extends ESTestCase {
|
|||
+ "[cannot start datafeed [datafeed_id] because it failed resolving " +
|
||||
"indices given [not_foo] and indices_options [IndicesOptions[ignore_unavailable=false, allow_no_indices=true, " +
|
||||
"expand_wildcards_open=true, expand_wildcards_closed=false, expand_wildcards_hidden=false, " +
|
||||
"allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true, " +
|
||||
"include_data_streams=true]] with exception [no such index [not_foo]]]"));
|
||||
"allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true" +
|
||||
"]] with exception [no such index [not_foo]]]"));
|
||||
}
|
||||
|
||||
public void testRemoteIndex() {
|
||||
|
@ -381,7 +381,7 @@ public class DatafeedNodeSelectorTests extends ESTestCase {
|
|||
+ "[cannot start datafeed [datafeed_id] because it failed resolving indices given [not_foo] and " +
|
||||
"indices_options [IndicesOptions[ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, " +
|
||||
"expand_wildcards_closed=false, expand_wildcards_hidden=false, allow_aliases_to_multiple_indices=true, " +
|
||||
"forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true, include_data_streams=true]] " +
|
||||
"forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true]] " +
|
||||
"with exception [no such index [not_foo]]]"));
|
||||
}
|
||||
|
||||
|
|
|
@ -1480,7 +1480,7 @@ public class IndicesAndAliasesResolverTests extends ESTestCase {
|
|||
|
||||
// closed + hidden, ignore aliases
|
||||
searchRequest = new SearchRequest();
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, false, false, true, true, true, false, true, false, true));
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, false, false, true, true, true, false, true, false));
|
||||
authorizedIndices = buildAuthorizedIndices(user, SearchAction.NAME);
|
||||
resolvedIndices = defaultIndicesResolver.resolveIndicesAndAliases(searchRequest, metadata, authorizedIndices);
|
||||
assertThat(resolvedIndices.getLocal(), containsInAnyOrder("bar-closed", "foofoo-closed", "hidden-closed", ".hidden-closed"));
|
||||
|
@ -1496,7 +1496,7 @@ public class IndicesAndAliasesResolverTests extends ESTestCase {
|
|||
|
||||
// allow no indices, do not expand to open or closed, expand hidden, ignore aliases
|
||||
searchRequest = new SearchRequest();
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, true, false, false, false, true, false, true, false, true));
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, true, false, false, false, true, false, true, false));
|
||||
authorizedIndices = buildAuthorizedIndices(user, SearchAction.NAME);
|
||||
resolvedIndices = defaultIndicesResolver.resolveIndicesAndAliases(searchRequest, metadata, authorizedIndices);
|
||||
assertThat(resolvedIndices.getLocal(), contains("-*"));
|
||||
|
@ -1538,14 +1538,14 @@ public class IndicesAndAliasesResolverTests extends ESTestCase {
|
|||
|
||||
// Make sure ignoring aliases works (visible only)
|
||||
searchRequest = new SearchRequest();
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, true, true, false, false, true, false, true, false, true));
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, true, true, false, false, true, false, true, false));
|
||||
resolvedIndices = defaultIndicesResolver.resolveIndicesAndAliases(searchRequest, metadata, authorizedIndices);
|
||||
assertThat(resolvedIndices.getLocal(), contains("-*"));
|
||||
assertThat(resolvedIndices.getRemote(), emptyIterable());
|
||||
|
||||
// Make sure ignoring aliases works (including hidden)
|
||||
searchRequest = new SearchRequest();
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, false, true, false, true, true, false, true, false, true));
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, false, true, false, true, true, false, true, false));
|
||||
resolvedIndices = defaultIndicesResolver.resolveIndicesAndAliases(searchRequest, metadata, authorizedIndices);
|
||||
assertThat(resolvedIndices.getLocal(), containsInAnyOrder("hidden-open"));
|
||||
assertThat(resolvedIndices.getRemote(), emptyIterable());
|
||||
|
@ -1559,15 +1559,15 @@ public class IndicesAndAliasesResolverTests extends ESTestCase {
|
|||
// Resolve data streams:
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
searchRequest.indices("logs-*");
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, false, true, false, false, true, true, true, true, true));
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, false, true, false, false, true, true, true, true));
|
||||
ResolvedIndices resolvedIndices = defaultIndicesResolver.resolveIndicesAndAliases(searchRequest, metadata, authorizedIndices);
|
||||
assertThat(resolvedIndices.getLocal(), contains("logs-foobar"));
|
||||
assertThat(resolvedIndices.getRemote(), emptyIterable());
|
||||
|
||||
// Ignore data streams:
|
||||
// Data streams with allow no indices:
|
||||
searchRequest = new SearchRequest();
|
||||
searchRequest.indices("logs-*");
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, true, true, false, false, true, true, true, true, false));
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, true, true, false, false, true, true, true, true));
|
||||
resolvedIndices = defaultIndicesResolver.resolveIndicesAndAliases(searchRequest, metadata, authorizedIndices);
|
||||
// if data streams are to be ignored then this happens in IndexNameExpressionResolver:
|
||||
assertThat(resolvedIndices.getLocal(), contains("logs-foobar"));
|
||||
|
@ -1580,7 +1580,7 @@ public class IndicesAndAliasesResolverTests extends ESTestCase {
|
|||
// Resolve *all* data streams:
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
searchRequest.indices("logs-*");
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, false, true, false, false, true, true, true, true, true));
|
||||
searchRequest.indicesOptions(IndicesOptions.fromOptions(false, false, true, false, false, true, true, true, true));
|
||||
ResolvedIndices resolvedIndices = defaultIndicesResolver.resolveIndicesAndAliases(searchRequest, metadata, authorizedIndices);
|
||||
assertThat(resolvedIndices.getLocal(), containsInAnyOrder("logs-foo", "logs-foobar"));
|
||||
assertThat(resolvedIndices.getRemote(), emptyIterable());
|
||||
|
|
Loading…
Reference in New Issue