From a84ff8174378f9cd6cab5b0a5fbe9629b8af676d Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Tue, 30 Jun 2020 13:45:04 -0500 Subject: [PATCH] Data stream support for get field mappings API (#58488) (#58766) --- .../60_data_streams.yml | 38 +++++++++++++++++++ .../elasticsearch/indices/DataStreamIT.java | 4 +- .../get/TransportGetFieldMappingsAction.java | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/60_data_streams.yml diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/60_data_streams.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/60_data_streams.yml new file mode 100644 index 00000000000..0766936cf02 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/60_data_streams.yml @@ -0,0 +1,38 @@ +--- +"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: + indices.get_field_mapping: + index: simple-data-stream1 + fields: foo + + - is_true: \.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 f58033ee9d3..41043ed1c4f 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/DataStreamIT.java @@ -385,7 +385,7 @@ public class DataStreamIT extends ESIntegTestCase { verifyResolvability(dataStreamName, client().admin().indices().prepareRecoveries(dataStreamName), false); verifyResolvability(dataStreamName, client().admin().indices().prepareUpgradeStatus(dataStreamName), false); verifyResolvability(dataStreamName, getAliases(dataStreamName), true); - verifyResolvability(dataStreamName, getFieldMapping(dataStreamName), true); + verifyResolvability(dataStreamName, getFieldMapping(dataStreamName), false); verifyResolvability(dataStreamName, getMapping(dataStreamName), false); verifyResolvability(dataStreamName, getSettings(dataStreamName), false); verifyResolvability(dataStreamName, health(dataStreamName), false); @@ -414,7 +414,7 @@ public class DataStreamIT extends ESIntegTestCase { verifyResolvability(wildcardExpression, client().admin().indices().prepareRecoveries(wildcardExpression), false); verifyResolvability(wildcardExpression, client().admin().indices().prepareUpgradeStatus(wildcardExpression), false); verifyResolvability(wildcardExpression, getAliases(wildcardExpression), true); - verifyResolvability(wildcardExpression, getFieldMapping(wildcardExpression), true); + verifyResolvability(wildcardExpression, getFieldMapping(wildcardExpression), false); verifyResolvability(wildcardExpression, getMapping(wildcardExpression), false); verifyResolvability(wildcardExpression, getSettings(wildcardExpression), false); verifyResolvability(wildcardExpression, health(wildcardExpression), false); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java index 79df765480f..57579cf8d92 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsAction.java @@ -56,7 +56,7 @@ public class TransportGetFieldMappingsAction extends HandledTransportAction listener) { ClusterState clusterState = clusterService.state(); - String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request); + String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request, true); final AtomicInteger indexCounter = new AtomicInteger(); final AtomicInteger completionCounter = new AtomicInteger(concreteIndices.length); final AtomicReferenceArray indexResponses = new AtomicReferenceArray<>(concreteIndices.length);