diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search_shards/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search_shards/10_basic.yml index 653979073b7..22e6c3ee6f8 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search_shards/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search_shards/10_basic.yml @@ -99,3 +99,41 @@ - match: { shards.0.0.index: test_index } - match: { indices.test_index.aliases: [test_alias_no_filter]} - is_false: indices.test_index.filter + +--- +"Search shards on data streams": + - skip: + features: allowed_warnings + version: " - 7.99.99" + reason: "change to 7.8.99 after backport" + + - do: + allowed_warnings: + - "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation" + indices.put_index_template: + name: my-template1 + body: + index_patterns: [simple-data-stream1] + template: + mappings: + properties: + '@timestamp': + type: date + data_stream: + timestamp_field: '@timestamp' + + - do: + indices.create_data_stream: + name: simple-data-stream1 + - is_true: acknowledged + + - do: + search_shards: + index: "simple-data-stream1" + + - match: { shards.0.0.index: ".ds-simple-data-stream1-000001" } + + - do: + indices.delete_data_stream: + name: simple-data-stream1 + - is_true: acknowledged diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java index 5fd0f54b3ad..8f1d0a5c4e2 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java @@ -392,6 +392,7 @@ public class DataStreamIT extends ESIntegTestCase { verifyResolvability(dataStreamName, client().admin().cluster().prepareState().setIndices(dataStreamName), false); verifyResolvability(dataStreamName, client().prepareFieldCaps(dataStreamName).setFields("*"), false); verifyResolvability(dataStreamName, client().admin().indices().prepareGetIndex().addIndices(dataStreamName), false); + verifyResolvability(dataStreamName, client().admin().cluster().prepareSearchShards(dataStreamName), false); verifyResolvability(dataStreamName, client().admin().indices().prepareOpen(dataStreamName), false); request = new CreateDataStreamAction.Request("logs-barbaz"); @@ -422,6 +423,7 @@ public class DataStreamIT extends ESIntegTestCase { verifyResolvability(wildcardExpression, client().admin().cluster().prepareState().setIndices(wildcardExpression), false); verifyResolvability(wildcardExpression, client().prepareFieldCaps(wildcardExpression).setFields("*"), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareGetIndex().addIndices(wildcardExpression), false); + verifyResolvability(wildcardExpression, client().admin().cluster().prepareSearchShards(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareOpen(wildcardExpression), false); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java index 44cae03b289..8a42c16eb99 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java @@ -68,7 +68,7 @@ public class TransportClusterSearchShardsAction extends @Override protected ClusterBlockException checkBlock(ClusterSearchShardsRequest request, ClusterState state) { return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, - indexNameExpressionResolver.concreteIndexNames(state, request)); + indexNameExpressionResolver.concreteIndexNames(state, request, true)); } @Override @@ -80,7 +80,7 @@ public class TransportClusterSearchShardsAction extends protected void masterOperation(final ClusterSearchShardsRequest request, final ClusterState state, final ActionListener listener) { ClusterState clusterState = clusterService.state(); - String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request); + String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request, true); Map> routingMap = indexNameExpressionResolver.resolveSearchRouting(state, request.routing(), request.indices()); Map indicesAndFilters = new HashMap<>(); Set indicesAndAliases = indexNameExpressionResolver.resolveExpressions(clusterState, request.indices());