Skip to content

Commit dcb1394

Browse files
jbaieraelasticsearchmachinefelixbarnygmarouli
authored
[8.x] Add selector syntax to index expressions (#118614) (#119832)
* Add selector syntax to index expressions (#118614) This PR introduces a new syntactical feature to index expression resolution: The selector. Selectors, denoted with a :: followed by a recognized suffix will allow users to specify which component of an index abstraction they would like to operate on within an API call. In this case, an index abstraction is a concrete index, data stream, or alias; Any abstraction that can be resolved to a set of indices/shards. We define a component of an index abstraction to be some searchable unit of the index abstraction. (cherry picked from commit c3839e1) # Conflicts: # modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java # server/src/main/java/org/elasticsearch/TransportVersions.java # server/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java * [CI] Auto commit changes from spotless * Fixing compiler issues * Remove feature flag from influencing the serialisation * Only add failure indices when failure store flag is on * Fix OriginalIndicesTests * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]> Co-authored-by: Felix Barnsteiner <[email protected]> Co-authored-by: Mary Gouseti <[email protected]> Co-authored-by: Mary Gouseti <[email protected]>
1 parent 308e8f3 commit dcb1394

File tree

72 files changed

+2377
-1077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2377
-1077
lines changed

docs/reference/ml/anomaly-detection/apis/put-job.asciidoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,4 +557,3 @@ The API returns the following results:
557557
// TESTRESPONSE[s/"job_version" : "8.4.0"/"job_version" : $body.job_version/]
558558
// TESTRESPONSE[s/1656087283340/$body.$_path/]
559559
// TESTRESPONSE[s/"superuser"/"_es_test_root"/]
560-
// TESTRESPONSE[s/"ignore_throttled" : true/"ignore_throttled" : true,"failure_store":"exclude"/]

modules/data-streams/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ restResources {
2121

2222
dependencies {
2323
testImplementation project(path: ':test:test-clusters')
24+
testImplementation project(":modules:mapper-extras")
2425
internalClusterTestImplementation project(":modules:mapper-extras")
2526
}
2627

@@ -71,4 +72,16 @@ tasks.named("yamlRestTestV7CompatTransform").configure({ task ->
7172
task.skipTest("data_stream/200_rollover_failure_store/Lazily roll over a data stream's failure store after a shard failure", "Configuring the failure store via data stream templates is not supported anymore.")
7273
task.skipTest("data_stream/200_rollover_failure_store/Don't roll over a data stream's failure store when conditions aren't met", "Configuring the failure store via data stream templates is not supported anymore.")
7374
task.skipTest("data_stream/200_rollover_failure_store/Roll over a data stream's failure store with conditions", "Configuring the failure store via data stream templates is not supported anymore.")
75+
76+
task.skipTest("data_stream/200_rollover_failure_store/Rolling over a failure store on a data stream without the failure store enabled should work", "Rolling over a data stream using target_failure_store is no longer supported.")
77+
task.skipTest("data_stream/200_rollover_failure_store/Rolling over an uninitialized failure store should initialize it", "Rolling over a data stream using target_failure_store is no longer supported.")
78+
79+
task.skipTest("data_stream/210_rollover_failure_store/A failure store marked for lazy rollover should only be rolled over when there is a failure", "Rolling over a data stream using target_failure_store is no longer supported.")
80+
task.skipTest("data_stream/210_rollover_failure_store/Don't roll over a data stream's failure store when conditions aren't met", "Rolling over a data stream using target_failure_store is no longer supported.")
81+
task.skipTest("data_stream/210_rollover_failure_store/Rolling over a failure store on a data stream without the failure store enabled should work", "Rolling over a data stream using target_failure_store is no longer supported.")
82+
task.skipTest("data_stream/210_rollover_failure_store/Rolling over an uninitialized failure store should initialize it", "Rolling over a data stream using target_failure_store is no longer supported.")
83+
task.skipTest("data_stream/210_rollover_failure_store/Roll over a data stream's failure store with conditions", "Rolling over a data stream using target_failure_store is no longer supported.")
84+
task.skipTest("data_stream/210_rollover_failure_store/Lazily roll over a data stream's failure store after an ingest failure", "Rolling over a data stream using target_failure_store is no longer supported.")
85+
task.skipTest("data_stream/210_rollover_failure_store/Lazily roll over a data stream's failure store after a shard failure", "Rolling over a data stream using target_failure_store is no longer supported.")
86+
task.skipTest("data_stream/210_rollover_failure_store/Roll over a data stream's failure store without conditions", "Rolling over a data stream using target_failure_store is no longer supported.")
7487
})

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
import org.elasticsearch.action.datastreams.CreateDataStreamAction;
3131
import org.elasticsearch.action.datastreams.DeleteDataStreamAction;
3232
import org.elasticsearch.action.datastreams.GetDataStreamAction;
33+
import org.elasticsearch.action.support.IndexComponentSelector;
3334
import org.elasticsearch.action.support.IndicesOptions;
3435
import org.elasticsearch.action.support.master.AcknowledgedResponse;
3536
import org.elasticsearch.client.internal.Client;
3637
import org.elasticsearch.cluster.metadata.DataStream;
3738
import org.elasticsearch.cluster.metadata.DataStreamAlias;
39+
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
3840
import org.elasticsearch.common.settings.Settings;
3941
import org.elasticsearch.common.unit.ByteSizeUnit;
4042
import org.elasticsearch.index.Index;
@@ -132,10 +134,7 @@ public void setup() throws Exception {
132134
assertTrue(response.isAcknowledged());
133135

134136
// Initialize the failure store.
135-
RolloverRequest rolloverRequest = new RolloverRequest("with-fs", null);
136-
rolloverRequest.setIndicesOptions(
137-
IndicesOptions.builder(rolloverRequest.indicesOptions()).selectorOptions(IndicesOptions.SelectorOptions.FAILURES).build()
138-
);
137+
RolloverRequest rolloverRequest = new RolloverRequest("with-fs::failures", null);
139138
response = client.execute(RolloverAction.INSTANCE, rolloverRequest).get();
140139
assertTrue(response.isAcknowledged());
141140

@@ -341,7 +340,7 @@ public void testFailureStoreSnapshotAndRestore() throws Exception {
341340
.cluster()
342341
.prepareCreateSnapshot(TEST_REQUEST_TIMEOUT, REPO, SNAPSHOT)
343342
.setWaitForCompletion(true)
344-
.setIndices(dataStreamName)
343+
.setIndices(IndexNameExpressionResolver.combineSelector(dataStreamName, IndexComponentSelector.ALL_APPLICABLE))
345344
.setIncludeGlobalState(false)
346345
.get();
347346

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
import org.elasticsearch.action.datastreams.CreateDataStreamAction;
2222
import org.elasticsearch.action.index.IndexRequest;
2323
import org.elasticsearch.action.ingest.PutPipelineRequest;
24-
import org.elasticsearch.action.support.IndicesOptions;
24+
import org.elasticsearch.action.support.IndexComponentSelector;
2525
import org.elasticsearch.action.support.WriteRequest;
2626
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
2727
import org.elasticsearch.cluster.metadata.DataStreamTestHelper;
2828
import org.elasticsearch.cluster.metadata.IndexMetadata;
29+
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
2930
import org.elasticsearch.cluster.metadata.Template;
3031
import org.elasticsearch.common.bytes.BytesArray;
3132
import org.elasticsearch.common.bytes.BytesReference;
@@ -197,9 +198,9 @@ public void testRejectionFromFailureStore() throws IOException {
197198
createDataStream();
198199

199200
// Initialize failure store.
200-
var rolloverRequest = new RolloverRequest(dataStream, null);
201-
rolloverRequest.setIndicesOptions(
202-
IndicesOptions.builder(rolloverRequest.indicesOptions()).selectorOptions(IndicesOptions.SelectorOptions.FAILURES).build()
201+
var rolloverRequest = new RolloverRequest(
202+
IndexNameExpressionResolver.combineSelector(dataStream, IndexComponentSelector.FAILURES),
203+
null
203204
);
204205
var rolloverResponse = client().execute(RolloverAction.INSTANCE, rolloverRequest).actionGet();
205206
var failureStoreIndex = rolloverResponse.getNewIndex();

modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/DataStreamOptionsIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void setup() throws IOException {
6060

6161
assertOK(client().performRequest(new Request("PUT", "/_data_stream/" + DATA_STREAM_NAME)));
6262
// Initialize the failure store.
63-
assertOK(client().performRequest(new Request("POST", DATA_STREAM_NAME + "/_rollover?target_failure_store")));
63+
assertOK(client().performRequest(new Request("POST", DATA_STREAM_NAME + "::failures/_rollover")));
6464
ensureGreen(DATA_STREAM_NAME);
6565

6666
final Response dataStreamResponse = client().performRequest(new Request("GET", "/_data_stream/" + DATA_STREAM_NAME));

modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/FailureStoreQueryParamIT.java

Lines changed: 0 additions & 221 deletions
This file was deleted.

modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DataStreamsStatsTransportAction.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.action.datastreams.DataStreamsStatsAction;
1717
import org.elasticsearch.action.support.ActionFilters;
1818
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
19+
import org.elasticsearch.action.support.IndexComponentSelector;
1920
import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction;
2021
import org.elasticsearch.cluster.ClusterState;
2122
import org.elasticsearch.cluster.block.ClusterBlockException;
@@ -102,10 +103,11 @@ protected ClusterBlockException checkRequestBlock(
102103

103104
@Override
104105
protected String[] resolveConcreteIndexNames(ClusterState clusterState, DataStreamsStatsAction.Request request) {
105-
return DataStreamsActionUtil.resolveConcreteIndexNames(
106+
return DataStreamsActionUtil.resolveConcreteIndexNamesWithSelector(
106107
indexNameExpressionResolver,
107108
clusterState,
108109
request.indices(),
110+
IndexComponentSelector.ALL_APPLICABLE,
109111
request.indicesOptions()
110112
).toArray(String[]::new);
111113
}
@@ -163,13 +165,17 @@ protected DataStreamsStatsAction.DataStreamShardStats readShardResult(StreamInpu
163165
request.indicesOptions(),
164166
request.indices()
165167
);
166-
for (String abstractionName : abstractionNames) {
167-
IndexAbstraction indexAbstraction = indicesLookup.get(abstractionName);
168+
for (String abstraction : abstractionNames) {
169+
IndexAbstraction indexAbstraction = indicesLookup.get(abstraction);
168170
assert indexAbstraction != null;
169171
if (indexAbstraction.getType() == IndexAbstraction.Type.DATA_STREAM) {
170172
DataStream dataStream = (DataStream) indexAbstraction;
171173
AggregatedStats stats = aggregatedDataStreamsStats.computeIfAbsent(dataStream.getName(), s -> new AggregatedStats());
172-
dataStream.getIndices().stream().map(Index::getName).forEach(index -> {
174+
dataStream.getBackingIndices().getIndices().stream().map(Index::getName).forEach(index -> {
175+
stats.backingIndices.add(index);
176+
allBackingIndices.add(index);
177+
});
178+
dataStream.getFailureIndices().getIndices().stream().map(Index::getName).forEach(index -> {
173179
stats.backingIndices.add(index);
174180
allBackingIndices.add(index);
175181
});

0 commit comments

Comments
 (0)