From b73c16287b508651e9a0b01c88f14f9a08e3d5ce Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Mon, 16 Apr 2018 10:52:13 -0700 Subject: [PATCH] [Rollup] Document type should be _doc (elastic/x-pack-elasticsearch#4363) Rollup was using a historical `rollup` doc type, when we should be using `_doc` so that it is forward-compatible with the removal in 8.0 Original commit: elastic/x-pack-elasticsearch@4b3188e6c87a5ff329104fe721e1002d8a4ac45d --- docs/build.gradle | 14 +++--- .../xpack/core/rollup/RollupField.java | 1 + .../resources/rollup-dynamic-template.json | 44 +++++++++---------- .../xpack/rollup/action/RollupIndexCaps.java | 8 ++-- .../action/TransportGetRollupCapsAction.java | 2 +- .../action/TransportPutRollupJobAction.java | 6 +-- .../xpack/rollup/job/IndexerUtils.java | 3 +- .../elasticsearch/xpack/rollup/RollupIT.java | 9 ++++ .../GetRollupCapsActionRequestTests.java | 24 +++++----- .../action/PutJobStateMachineTests.java | 16 +++---- .../rollup/action/SearchActionTests.java | 24 +++++----- .../job/RollupIndexerIndexingTests.java | 28 ++++++------ .../rest-api-spec/test/rollup/delete_job.yml | 2 +- .../rest-api-spec/test/rollup/get_jobs.yml | 2 +- .../test/rollup/get_rollup_caps.yml | 24 +++++----- .../rest-api-spec/test/rollup/put_job.yml | 2 +- .../test/rollup/rollup_search.yml | 42 +++++++++--------- .../rest-api-spec/test/rollup/start_job.yml | 2 +- .../rest-api-spec/test/rollup/stop_job.yml | 2 +- 19 files changed, 131 insertions(+), 124 deletions(-) diff --git a/docs/build.gradle b/docs/build.gradle index 3d0688794c0..1a0732b0969 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -435,7 +435,7 @@ setups['sensor_rollup_job'] = ''' number_of_shards: 1 number_of_replicas: 0 mappings: - metric: + _doc: properties: timestamp: type: date @@ -485,7 +485,7 @@ setups['sensor_started_rollup_job'] = ''' number_of_shards: 1 number_of_replicas: 0 mappings: - data: + _doc: properties: timestamp: type: date @@ -499,7 +499,7 @@ setups['sensor_started_rollup_job'] = ''' - do: bulk: index: sensor-1 - type: data + type: _doc refresh: true body: | {"index":{}} @@ -559,7 +559,7 @@ setups['sensor_index'] = ''' number_of_shards: 1 number_of_replicas: 0 mappings: - data: + _doc: properties: timestamp: type: date @@ -590,7 +590,7 @@ setups['sensor_prefab_data'] = ''' number_of_shards: 1 number_of_replicas: 0 mappings: - data: + _doc: properties: timestamp: type: date @@ -608,7 +608,7 @@ setups['sensor_prefab_data'] = ''' number_of_shards: 1 number_of_replicas: 0 mappings: - rollup: + _doc: properties: node.terms.value: type: keyword @@ -665,7 +665,7 @@ setups['sensor_prefab_data'] = ''' - do: bulk: index: sensor_rollup - type: rollup + type: _doc refresh: true body: | {"index":{}} diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupField.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupField.java index 533a8008ba3..1e2e011276d 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupField.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/RollupField.java @@ -28,6 +28,7 @@ public class RollupField { public static final String TIMESTAMP = "timestamp"; public static final String FILTER = "filter"; public static final String NAME = "rollup"; + public static final String TYPE_NAME = "_doc"; public static final String AGG = "agg"; public static final String ROLLUP_MISSING = "ROLLUP_MISSING_40710B25931745D4B0B8B310F6912A69"; public static final List SUPPORTED_METRICS = Arrays.asList(MaxAggregationBuilder.NAME, MinAggregationBuilder.NAME, diff --git a/plugin/core/src/main/resources/rollup-dynamic-template.json b/plugin/core/src/main/resources/rollup-dynamic-template.json index d5495e4cb82..94336c60c4d 100644 --- a/plugin/core/src/main/resources/rollup-dynamic-template.json +++ b/plugin/core/src/main/resources/rollup-dynamic-template.json @@ -1,28 +1,26 @@ { - "rollup": { - "_meta":{ - "_rollup": { - "ROLLUP_METADATA_PLACEHOLDER":"ROLLUP_METADATA_PLACEHOLDER" - }, - "rollup-version": "${rollup.dynamic_template.version}" + "_meta":{ + "_rollup": { + "ROLLUP_METADATA_PLACEHOLDER":"ROLLUP_METADATA_PLACEHOLDER" }, - "dynamic_templates": [ - { - "strings": { - "match_mapping_type": "string", - "mapping": { - "type": "keyword" - } - } - }, - { - "date_histograms": { - "path_match": "*.date_histogram.timestamp", - "mapping": { - "type": "date" - } + "rollup-version": "${rollup.dynamic_template.version}" + }, + "dynamic_templates": [ + { + "strings": { + "match_mapping_type": "string", + "mapping": { + "type": "keyword" } } - ] - } + }, + { + "date_histograms": { + "path_match": "*.date_histogram.timestamp", + "mapping": { + "type": "date" + } + } + } + ] } \ No newline at end of file diff --git a/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java b/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java index 78290dd0cc1..22bf9ff06c2 100644 --- a/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java +++ b/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/RollupIndexCaps.java @@ -33,7 +33,7 @@ import java.util.stream.Collectors; public class RollupIndexCaps implements Writeable, ToXContentFragment { static ParseField ROLLUP_JOBS = new ParseField("rollup_jobs"); - private static ParseField INDEX_NAME = new ParseField(RollupField.NAME); + private static ParseField INDEX_NAME = new ParseField(RollupField.TYPE_NAME); //TODO find a way to make this parsing less hacky :( // Note: we ignore unknown fields since there may be unrelated metadata @@ -43,7 +43,7 @@ public class RollupIndexCaps implements Writeable, ToXContentFragment { /* Rollup index metadata layout is: - "rollup": { + "_doc": { "_meta" : { "_rollup": { "job-1": { @@ -58,8 +58,8 @@ public class RollupIndexCaps implements Writeable, ToXContentFragment { } */ METADATA_PARSER.declareField((parser, rollupIndexCaps, aVoid) -> { - // "rollup" - if (parser.currentName().equals(RollupField.NAME) && parser.currentToken().equals(XContentParser.Token.START_OBJECT)) { + // "_doc" + if (parser.currentName().equals(RollupField.TYPE_NAME) && parser.currentToken().equals(XContentParser.Token.START_OBJECT)) { parser.nextToken();// START_OBJECT List jobs = new ArrayList<>(); diff --git a/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupCapsAction.java b/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupCapsAction.java index a3429987f73..8789fb75ad1 100644 --- a/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupCapsAction.java +++ b/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupCapsAction.java @@ -91,7 +91,7 @@ public class TransportGetRollupCapsAction extends HandledTransportAction startPersistentTask(job, listener, persistentTasksService), e -> { @@ -154,7 +154,7 @@ public class TransportPutRollupJobAction extends TransportMasterNodeAction getMappingResponseHandler = getMappingResponse -> { - MappingMetaData mappings = getMappingResponse.getMappings().get(indexName).get(RollupField.NAME); + MappingMetaData mappings = getMappingResponse.getMappings().get(indexName).get(RollupField.TYPE_NAME); Object m = mappings.getSourceAsMap().get("_meta"); if (m == null) { String msg = "Expected to find _meta key in mapping of rollup index [" + indexName + "] but not found."; @@ -186,7 +186,7 @@ public class TransportPutRollupJobAction extends TransportMasterNodeAction newMapping = mappings.getSourceAsMap(); newMapping.put("_meta", metadata); PutMappingRequest request = new PutMappingRequest(indexName); - request.type(RollupField.NAME); + request.type(RollupField.TYPE_NAME); request.source(newMapping); client.execute(PutMappingAction.INSTANCE, request, ActionListener.wrap(putMappingResponse -> startPersistentTask(job, listener, persistentTasksService), diff --git a/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java b/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java index 9bf943e445f..092c76c9731 100644 --- a/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java +++ b/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java @@ -68,8 +68,7 @@ class IndexerUtils { doc.put(RollupField.ROLLUP_META + "." + RollupField.VERSION_FIELD, Rollup.ROLLUP_VERSION); doc.put(RollupField.ROLLUP_META + "." + RollupField.ID.getPreferredName(), jobId); - IndexRequest request = new IndexRequest(rollupIndex, - RollupField.NAME, String.valueOf(docId.getValue())); + IndexRequest request = new IndexRequest(rollupIndex, RollupField.TYPE_NAME, String.valueOf(docId.getValue())); request.source(doc); return request; }).collect(Collectors.toList()); diff --git a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupIT.java b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupIT.java index 2d83970a09f..ce8bf936d97 100644 --- a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupIT.java +++ b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/RollupIT.java @@ -20,6 +20,7 @@ import org.elasticsearch.analysis.common.CommonAnalysisPlugin; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.index.query.MatchAllQueryBuilder; import org.elasticsearch.license.LicenseService; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.aggregations.Aggregation; @@ -460,6 +461,14 @@ public class RollupIT extends ESIntegTestCase { Assert.assertThat(rollupAgg.getType(), equalTo(agg.getType())); verifyAgg((InternalDateHistogram)agg, (InternalDateHistogram)rollupAgg); } + + // And a quick sanity check for doc type + SearchRequest rollupRawRequest = new SearchRequest("rolled") + .source(new SearchSourceBuilder().query(new MatchAllQueryBuilder()) + .size(1)); + SearchResponse searchRawResponse = client().execute(SearchAction.INSTANCE, rollupRawRequest).get(); + Assert.assertNotNull(searchRawResponse); + assertThat(searchRawResponse.getHits().getAt(0).getType(), equalTo("_doc")); } private void verifyAgg(InternalDateHistogram verify, InternalDateHistogram rollup) { diff --git a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java index 289c093ef88..e63650397ab 100644 --- a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java +++ b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java @@ -91,14 +91,14 @@ public class GetRollupCapsActionRequestTests extends AbstractStreamableTestCase< String jobName = randomAlphaOfLength(5); RollupJobConfig job = ConfigTestHelpers.getRollupJob(jobName).build(); - MappingMetaData mappingMeta = new MappingMetaData(RollupField.NAME, - Collections.singletonMap(RollupField.NAME, + MappingMetaData mappingMeta = new MappingMetaData(RollupField.TYPE_NAME, + Collections.singletonMap(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, Collections.singletonMap(jobName, job))))); ImmutableOpenMap.Builder mappings = ImmutableOpenMap.builder(1); - mappings.put(RollupField.NAME, mappingMeta); + mappings.put(RollupField.TYPE_NAME, mappingMeta); IndexMetaData meta = Mockito.mock(IndexMetaData.class); Mockito.when(meta.getMappings()).thenReturn(mappings.build()); Optional caps = TransportGetRollupCapsAction.findRollupIndexCaps(indexPattern, meta); @@ -116,13 +116,13 @@ public class GetRollupCapsActionRequestTests extends AbstractStreamableTestCase< jobs.put(jobName, ConfigTestHelpers.getRollupJob(jobName).build()); } - MappingMetaData mappingMeta = new MappingMetaData(RollupField.NAME, - Collections.singletonMap(RollupField.NAME, + MappingMetaData mappingMeta = new MappingMetaData(RollupField.TYPE_NAME, + Collections.singletonMap(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, jobs)))); ImmutableOpenMap.Builder mappings = ImmutableOpenMap.builder(1); - mappings.put(RollupField.NAME, mappingMeta); + mappings.put(RollupField.TYPE_NAME, mappingMeta); IndexMetaData meta = Mockito.mock(IndexMetaData.class); Mockito.when(meta.getMappings()).thenReturn(mappings.build()); Optional caps = TransportGetRollupCapsAction.findRollupIndexCaps(indexPattern, meta); @@ -150,13 +150,13 @@ public class GetRollupCapsActionRequestTests extends AbstractStreamableTestCase< jobs.put(jobName, ConfigTestHelpers.getRollupJob(jobName).setIndexPattern(indexName).build()); } - MappingMetaData mappingMeta = new MappingMetaData(RollupField.NAME, - Collections.singletonMap(RollupField.NAME, + MappingMetaData mappingMeta = new MappingMetaData(RollupField.TYPE_NAME, + Collections.singletonMap(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, jobs)))); ImmutableOpenMap.Builder mappings = ImmutableOpenMap.builder(1); - mappings.put(RollupField.NAME, mappingMeta); + mappings.put(RollupField.TYPE_NAME, mappingMeta); IndexMetaData meta = Mockito.mock(IndexMetaData.class); Mockito.when(meta.getMappings()).thenReturn(mappings.build()); indices.put(randomAlphaOfLength(10), meta); @@ -182,13 +182,13 @@ public class GetRollupCapsActionRequestTests extends AbstractStreamableTestCase< jobs.put(jobName, ConfigTestHelpers.getRollupJob(jobName).setIndexPattern(indexName).build()); } - MappingMetaData mappingMeta = new MappingMetaData(RollupField.NAME, - Collections.singletonMap(RollupField.NAME, + MappingMetaData mappingMeta = new MappingMetaData(RollupField.TYPE_NAME, + Collections.singletonMap(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, jobs)))); ImmutableOpenMap.Builder mappings = ImmutableOpenMap.builder(1); - mappings.put(RollupField.NAME, mappingMeta); + mappings.put(RollupField.TYPE_NAME, mappingMeta); IndexMetaData meta = Mockito.mock(IndexMetaData.class); Mockito.when(meta.getMappings()).thenReturn(mappings.build()); diff --git a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobStateMachineTests.java b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobStateMachineTests.java index 3ba3ce62546..5bc8ce5c2b7 100644 --- a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobStateMachineTests.java +++ b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/PutJobStateMachineTests.java @@ -120,8 +120,8 @@ public class PutJobStateMachineTests extends ESTestCase { ArgumentCaptor listenerCaptor = ArgumentCaptor.forClass(ActionListener.class); ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(CreateIndexRequest.class); doAnswer(invocation -> { - assertNotNull(requestCaptor.getValue().mappings().get("rollup")); - String mapping = requestCaptor.getValue().mappings().get("rollup"); + assertNotNull(requestCaptor.getValue().mappings().get("_doc")); + String mapping = requestCaptor.getValue().mappings().get("_doc"); // Make sure the version is present, and we have our date template (the most important aspects) assertThat(mapping, containsString("\"rollup-version\": \"" + Version.CURRENT.toString() + "\"")); @@ -187,9 +187,9 @@ public class PutJobStateMachineTests extends ESTestCase { ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(ActionListener.class); doAnswer(invocation -> { GetMappingsResponse response = mock(GetMappingsResponse.class); - MappingMetaData meta = new MappingMetaData(RollupField.NAME, Collections.emptyMap()); + MappingMetaData meta = new MappingMetaData(RollupField.TYPE_NAME, Collections.emptyMap()); ImmutableOpenMap.Builder builder = ImmutableOpenMap.builder(1); - builder.put(RollupField.NAME, meta); + builder.put(RollupField.TYPE_NAME, meta); ImmutableOpenMap.Builder> builder2 = ImmutableOpenMap.builder(1); builder2.put(job.getConfig().getRollupIndex(), builder.build()); @@ -219,12 +219,12 @@ public class PutJobStateMachineTests extends ESTestCase { ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(ActionListener.class); doAnswer(invocation -> { GetMappingsResponse response = mock(GetMappingsResponse.class); - MappingMetaData meta = new MappingMetaData(RollupField.NAME, + MappingMetaData meta = new MappingMetaData(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, Collections.singletonMap(job.getConfig().getId(), job.getConfig())))); ImmutableOpenMap.Builder builder = ImmutableOpenMap.builder(1); - builder.put(RollupField.NAME, meta); + builder.put(RollupField.TYPE_NAME, meta); ImmutableOpenMap.Builder> builder2 = ImmutableOpenMap.builder(1); builder2.put(job.getConfig().getRollupIndex(), builder.build()); @@ -258,11 +258,11 @@ public class PutJobStateMachineTests extends ESTestCase { ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(ActionListener.class); doAnswer(invocation -> { GetMappingsResponse response = mock(GetMappingsResponse.class); - MappingMetaData meta = new MappingMetaData(RollupField.NAME, + MappingMetaData meta = new MappingMetaData(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, Collections.singletonMap(unrelatedJob.getId(), unrelatedJob)))); ImmutableOpenMap.Builder builder = ImmutableOpenMap.builder(1); - builder.put(RollupField.NAME, meta); + builder.put(RollupField.TYPE_NAME, meta); ImmutableOpenMap.Builder> builder2 = ImmutableOpenMap.builder(1); builder2.put(unrelatedJob.getRollupIndex(), builder.build()); diff --git a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/SearchActionTests.java b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/SearchActionTests.java index 765a2148954..23d60ef01e4 100644 --- a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/SearchActionTests.java +++ b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/SearchActionTests.java @@ -563,14 +563,14 @@ public class SearchActionTests extends ESTestCase { String jobName = randomAlphaOfLength(5); RollupJobConfig job = ConfigTestHelpers.getRollupJob(jobName).build(); - MappingMetaData mappingMeta = new MappingMetaData(RollupField.NAME, - Collections.singletonMap(RollupField.NAME, + MappingMetaData mappingMeta = new MappingMetaData(RollupField.TYPE_NAME, + Collections.singletonMap(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, Collections.singletonMap(jobName, job))))); ImmutableOpenMap.Builder mappings = ImmutableOpenMap.builder(1); - mappings.put(RollupField.NAME, mappingMeta); + mappings.put(RollupField.TYPE_NAME, mappingMeta); IndexMetaData meta = Mockito.mock(IndexMetaData.class); when(meta.getMappings()).thenReturn(mappings.build()); @@ -607,14 +607,14 @@ public class SearchActionTests extends ESTestCase { String jobName = randomAlphaOfLength(5); RollupJobConfig job = ConfigTestHelpers.getRollupJob(jobName).build(); - MappingMetaData mappingMeta = new MappingMetaData(RollupField.NAME, - Collections.singletonMap(RollupField.NAME, + MappingMetaData mappingMeta = new MappingMetaData(RollupField.TYPE_NAME, + Collections.singletonMap(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, Collections.singletonMap(jobName, job))))); ImmutableOpenMap.Builder mappings = ImmutableOpenMap.builder(1); - mappings.put(RollupField.NAME, mappingMeta); + mappings.put(RollupField.TYPE_NAME, mappingMeta); IndexMetaData indexMeta = Mockito.mock(IndexMetaData.class); when(indexMeta.getMappings()).thenReturn(mappings.build()); @@ -671,14 +671,14 @@ public class SearchActionTests extends ESTestCase { String jobName = randomAlphaOfLength(5); RollupJobConfig job = ConfigTestHelpers.getRollupJob(jobName).build(); - MappingMetaData mappingMeta = new MappingMetaData(RollupField.NAME, - Collections.singletonMap(RollupField.NAME, + MappingMetaData mappingMeta = new MappingMetaData(RollupField.TYPE_NAME, + Collections.singletonMap(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, Collections.singletonMap(jobName, job))))); ImmutableOpenMap.Builder mappings = ImmutableOpenMap.builder(1); - mappings.put(RollupField.NAME, mappingMeta); + mappings.put(RollupField.TYPE_NAME, mappingMeta); IndexMetaData indexMeta = Mockito.mock(IndexMetaData.class); when(indexMeta.getMappings()).thenReturn(mappings.build()); @@ -706,14 +706,14 @@ public class SearchActionTests extends ESTestCase { String jobName = randomAlphaOfLength(5); RollupJobConfig job = ConfigTestHelpers.getRollupJob(jobName).build(); - MappingMetaData mappingMeta = new MappingMetaData(RollupField.NAME, - Collections.singletonMap(RollupField.NAME, + MappingMetaData mappingMeta = new MappingMetaData(RollupField.TYPE_NAME, + Collections.singletonMap(RollupField.TYPE_NAME, Collections.singletonMap("_meta", Collections.singletonMap(RollupField.ROLLUP_META, Collections.singletonMap(jobName, job))))); ImmutableOpenMap.Builder mappings = ImmutableOpenMap.builder(1); - mappings.put(RollupField.NAME, mappingMeta); + mappings.put(RollupField.TYPE_NAME, mappingMeta); IndexMetaData indexMeta = Mockito.mock(IndexMetaData.class); when(indexMeta.getMappings()).thenReturn(mappings.build()); diff --git a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java index 29dfd9675ae..bf4f4892ef6 100644 --- a/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java +++ b/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java @@ -108,7 +108,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { assertThat(resp.size(), equalTo(2)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -121,7 +121,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { )); request = resp.get(1); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -169,7 +169,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { assertThat(resp.size(), equalTo(5)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -187,7 +187,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { )); request = resp.get(1); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -205,7 +205,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { )); request = resp.get(2); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -223,7 +223,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { )); request = resp.get(3); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -241,7 +241,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { )); request = resp.get(4); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -290,7 +290,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { assertThat(resp.size(), equalTo(3)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -303,7 +303,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { )); request = resp.get(1); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -316,7 +316,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { )); request = resp.get(2); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -359,7 +359,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { assertThat(resp.size(), equalTo(1)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -378,7 +378,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { assertThat(resp.size(), equalTo(2)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -391,7 +391,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { )); request = resp.get(1); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 1, @@ -429,7 +429,7 @@ public class RollupIndexerIndexingTests extends AggregatorTestCase { assertThat(resp.size(), greaterThan(0)); for (DocWriteRequest request : resp) { assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("rollup")); + assertThat(request.type(), equalTo("_doc")); Map source = ((IndexRequest) request).sourceAsMap(); diff --git a/plugin/src/test/resources/rest-api-spec/test/rollup/delete_job.yml b/plugin/src/test/resources/rest-api-spec/test/rollup/delete_job.yml index c14018fd809..d172e27b2a3 100644 --- a/plugin/src/test/resources/rest-api-spec/test/rollup/delete_job.yml +++ b/plugin/src/test/resources/rest-api-spec/test/rollup/delete_job.yml @@ -4,7 +4,7 @@ setup: index: foo body: mappings: - doc: + _doc: properties: the_field: type: date diff --git a/plugin/src/test/resources/rest-api-spec/test/rollup/get_jobs.yml b/plugin/src/test/resources/rest-api-spec/test/rollup/get_jobs.yml index d6818fc3e1c..fb2d9f59e34 100644 --- a/plugin/src/test/resources/rest-api-spec/test/rollup/get_jobs.yml +++ b/plugin/src/test/resources/rest-api-spec/test/rollup/get_jobs.yml @@ -4,7 +4,7 @@ setup: index: foo body: mappings: - doc: + _doc: properties: the_field: type: date diff --git a/plugin/src/test/resources/rest-api-spec/test/rollup/get_rollup_caps.yml b/plugin/src/test/resources/rest-api-spec/test/rollup/get_rollup_caps.yml index 7e7eda289b1..050e49bc4b4 100644 --- a/plugin/src/test/resources/rest-api-spec/test/rollup/get_rollup_caps.yml +++ b/plugin/src/test/resources/rest-api-spec/test/rollup/get_rollup_caps.yml @@ -2,26 +2,26 @@ setup: - do: indices.create: index: foo + include_type_name: false body: mappings: - doc: - properties: - the_field: - type: date - value_field: - type: integer + properties: + the_field: + type: date + value_field: + type: integer - do: indices.create: index: foo2 + include_type_name: false body: mappings: - doc: - properties: - the_field: - type: date - value_field: - type: integer + properties: + the_field: + type: date + value_field: + type: integer - do: headers: Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser diff --git a/plugin/src/test/resources/rest-api-spec/test/rollup/put_job.yml b/plugin/src/test/resources/rest-api-spec/test/rollup/put_job.yml index 430f3a73029..080fed7a80e 100644 --- a/plugin/src/test/resources/rest-api-spec/test/rollup/put_job.yml +++ b/plugin/src/test/resources/rest-api-spec/test/rollup/put_job.yml @@ -4,7 +4,7 @@ setup: index: foo body: mappings: - doc: + _doc: properties: the_field: type: date diff --git a/plugin/src/test/resources/rest-api-spec/test/rollup/rollup_search.yml b/plugin/src/test/resources/rest-api-spec/test/rollup/rollup_search.yml index 80e55806acc..d401d5c69ba 100644 --- a/plugin/src/test/resources/rest-api-spec/test/rollup/rollup_search.yml +++ b/plugin/src/test/resources/rest-api-spec/test/rollup/rollup_search.yml @@ -4,7 +4,7 @@ setup: index: foo body: mappings: - doc: + _doc: properties: timestamp: type: date @@ -49,7 +49,7 @@ setup: body: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T05:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -65,7 +65,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T06:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -81,7 +81,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T07:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -97,7 +97,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T08:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -113,7 +113,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T08:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -260,7 +260,7 @@ setup: body: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T05:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -276,7 +276,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T06:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -292,7 +292,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T07:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -308,7 +308,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T08:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -324,7 +324,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T08:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -408,7 +408,7 @@ setup: body: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T05:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -424,7 +424,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T06:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -440,7 +440,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T07:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -456,7 +456,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T08:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -472,7 +472,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T08:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -558,7 +558,7 @@ setup: body: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T05:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -574,7 +574,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T06:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -590,7 +590,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T07:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -606,7 +606,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T08:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" @@ -622,7 +622,7 @@ setup: - index: _index: "foo_rollup" - _type: "rollup" + _type: "_doc" - timestamp.date_histogram.timestamp: "2017-01-01T08:00:00Z" timestamp.date_histogram.interval: "1h" timestamp.date_histogram.time_zone: "UTC" diff --git a/plugin/src/test/resources/rest-api-spec/test/rollup/start_job.yml b/plugin/src/test/resources/rest-api-spec/test/rollup/start_job.yml index ea5af57a842..7adba9035eb 100644 --- a/plugin/src/test/resources/rest-api-spec/test/rollup/start_job.yml +++ b/plugin/src/test/resources/rest-api-spec/test/rollup/start_job.yml @@ -4,7 +4,7 @@ setup: index: foo body: mappings: - doc: + _doc: properties: the_field: type: date diff --git a/plugin/src/test/resources/rest-api-spec/test/rollup/stop_job.yml b/plugin/src/test/resources/rest-api-spec/test/rollup/stop_job.yml index 279e8a4dcb2..42a1dea8163 100644 --- a/plugin/src/test/resources/rest-api-spec/test/rollup/stop_job.yml +++ b/plugin/src/test/resources/rest-api-spec/test/rollup/stop_job.yml @@ -4,7 +4,7 @@ setup: index: foo body: mappings: - doc: + _doc: properties: the_field: type: date