From 94d7e14d7f7ad4d64116c01553d646e26b40f775 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 23 Sep 2019 19:39:05 +0100 Subject: [PATCH 01/35] Remove types from bulk request --- .../elasticsearch/client/BulkProcessorIT.java | 100 ++---------------- .../BulkRequestWithGlobalParametersIT.java | 51 ++------- .../java/org/elasticsearch/client/CrudIT.java | 15 --- .../elasticsearch/upgrades/IndexingIT.java | 4 +- .../org/elasticsearch/upgrades/XPackIT.java | 6 +- .../elasticsearch/action/DocWriteRequest.java | 10 +- .../action/bulk/BulkProcessor.java | 23 +--- .../action/bulk/BulkRequest.java | 73 ++----------- .../action/bulk/BulkRequestBuilder.java | 24 +---- .../action/bulk/BulkRequestParser.java | 39 ++----- .../action/delete/DeleteRequest.java | 22 +--- .../action/index/IndexRequest.java | 15 +-- .../action/update/UpdateRequest.java | 21 +--- .../java/org/elasticsearch/client/Client.java | 4 +- .../client/support/AbstractClient.java | 4 +- .../rest/action/document/RestBulkAction.java | 25 +---- .../action/bulk/BulkIntegrationIT.java | 2 +- .../action/bulk/BulkRequestParserTests.java | 30 ++---- .../action/bulk/BulkRequestTests.java | 40 ++----- .../bulk/TransportBulkActionTookTests.java | 5 +- .../elasticsearch/search/geo/GeoFilterIT.java | 2 +- .../action/bulk/simple-bulk.json | 6 +- .../action/bulk/simple-bulk10.json | 18 ++-- .../action/bulk/simple-bulk11.json | 6 +- .../action/bulk/simple-bulk4.json | 2 +- .../action/bulk/simple-bulk5.json | 6 +- .../action/bulk/simple-bulk6.json | 6 +- .../action/bulk/simple-bulk7.json | 6 +- .../action/bulk/simple-bulk8.json | 6 +- .../mapper/FlatObjectSearchTests.java | 4 +- .../exporter/http/HttpExporterIT.java | 2 +- .../elasticsearch/upgrades/IndexingIT.java | 4 +- 32 files changed, 98 insertions(+), 483 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java index d30dbfc19cfa9..74c7e2dd813ad 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java @@ -36,11 +36,8 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.search.SearchHit; import org.hamcrest.Matcher; -import org.hamcrest.Matchers; import java.io.IOException; import java.util.Arrays; @@ -56,9 +53,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.fieldFromSource; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasId; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasIndex; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasProperty; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasType; import static org.hamcrest.Matchers.both; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.either; @@ -77,12 +72,6 @@ private static BulkProcessor.Builder initBulkProcessorBuilder(BulkProcessor.List bulkListener), listener); } - private static BulkProcessor.Builder initBulkProcessorBuilderUsingTypes(BulkProcessor.Listener listener) { - return BulkProcessor.builder( - (request, bulkListener) -> highLevelClient().bulkAsync(request, expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE), - bulkListener), listener); - } - public void testThatBulkProcessorCountIsCorrect() throws Exception { final CountDownLatch latch = new CountDownLatch(1); BulkProcessorTestListener listener = new BulkProcessorTestListener(latch); @@ -301,7 +290,6 @@ public void testGlobalParametersAndSingleRequest() throws Exception { // tag::bulk-processor-mix-parameters try (BulkProcessor processor = initBulkProcessorBuilder(listener) .setGlobalIndex("tweets") - .setGlobalType("_doc") .setGlobalRouting("routing") .setGlobalPipeline("pipeline_id") .build()) { @@ -329,103 +317,37 @@ public void testGlobalParametersAndBulkProcessor() throws Exception { createIndexWithMultipleShards("test"); createFieldAddingPipleine("pipeline_id", "fieldNameXYZ", "valueXYZ"); - final String customType = "testType"; - final String ignoredType = "ignoredType"; int numDocs = randomIntBetween(10, 10); { final CountDownLatch latch = new CountDownLatch(1); BulkProcessorTestListener listener = new BulkProcessorTestListener(latch); //Check that untyped document additions inherit the global type - String globalType = customType; String localType = null; - try (BulkProcessor processor = initBulkProcessorBuilderUsingTypes(listener) + try (BulkProcessor processor = initBulkProcessorBuilder(listener) //let's make sure that the bulk action limit trips, one single execution will index all the documents .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)) .setGlobalIndex("test") - .setGlobalType(globalType) .setGlobalRouting("routing") .setGlobalPipeline("pipeline_id") .build()) { - indexDocs(processor, numDocs, null, localType, "test", globalType, "pipeline_id"); + indexDocs(processor, numDocs, null, localType, "test", "pipeline_id"); latch.await(); assertThat(listener.beforeCounts.get(), equalTo(1)); assertThat(listener.afterCounts.get(), equalTo(1)); assertThat(listener.bulkFailures.size(), equalTo(0)); - assertResponseItems(listener.bulkItems, numDocs, globalType); + assertResponseItems(listener.bulkItems, numDocs); Iterable hits = searchAll(new SearchRequest("test").routing("routing")); assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ")))); - assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType(globalType)))); assertThat(hits, containsInAnyOrder(expectedIds(numDocs))); } } - { - //Check that typed document additions don't inherit the global type - String globalType = ignoredType; - String localType = customType; - final CountDownLatch latch = new CountDownLatch(1); - BulkProcessorTestListener listener = new BulkProcessorTestListener(latch); - try (BulkProcessor processor = initBulkProcessorBuilderUsingTypes(listener) - //let's make sure that the bulk action limit trips, one single execution will index all the documents - .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) - .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)) - .setGlobalIndex("test") - .setGlobalType(globalType) - .setGlobalRouting("routing") - .setGlobalPipeline("pipeline_id") - .build()) { - indexDocs(processor, numDocs, null, localType, "test", globalType, "pipeline_id"); - latch.await(); - - assertThat(listener.beforeCounts.get(), equalTo(1)); - assertThat(listener.afterCounts.get(), equalTo(1)); - assertThat(listener.bulkFailures.size(), equalTo(0)); - assertResponseItems(listener.bulkItems, numDocs, localType); - - Iterable hits = searchAll(new SearchRequest("test").routing("routing")); - - assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ")))); - assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType(localType)))); - assertThat(hits, containsInAnyOrder(expectedIds(numDocs))); - } - } - { - //Check that untyped document additions and untyped global inherit the established custom type - // (the custom document type introduced to the mapping by the earlier code in this test) - String globalType = null; - String localType = null; - final CountDownLatch latch = new CountDownLatch(1); - BulkProcessorTestListener listener = new BulkProcessorTestListener(latch); - try (BulkProcessor processor = initBulkProcessorBuilder(listener) - //let's make sure that the bulk action limit trips, one single execution will index all the documents - .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) - .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)) - .setGlobalIndex("test") - .setGlobalType(globalType) - .setGlobalRouting("routing") - .setGlobalPipeline("pipeline_id") - .build()) { - indexDocs(processor, numDocs, null, localType, "test", globalType, "pipeline_id"); - latch.await(); - - assertThat(listener.beforeCounts.get(), equalTo(1)); - assertThat(listener.afterCounts.get(), equalTo(1)); - assertThat(listener.bulkFailures.size(), equalTo(0)); - assertResponseItems(listener.bulkItems, numDocs, MapperService.SINGLE_MAPPING_NAME); - - Iterable hits = searchAll(new SearchRequest("test").routing("routing")); - - assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ")))); - assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType(customType)))); - assertThat(hits, containsInAnyOrder(expectedIds(numDocs))); - } - } } @SuppressWarnings("unchecked") @@ -437,7 +359,7 @@ private Matcher[] expectedIds(int numDocs) { } private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String localType, - String globalIndex, String globalType, String globalPipeline) throws Exception { + String globalIndex, String globalPipeline) throws Exception { MultiGetRequest multiGetRequest = new MultiGetRequest(); for (int i = 1; i <= numDocs; i++) { if (randomBoolean()) { @@ -445,12 +367,7 @@ private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String l .source(XContentType.JSON, "field", randomRealisticUnicodeOfLengthBetween(1, 30))); } else { BytesArray data = bytesBulkRequest(localIndex, localType, i); - processor.add(data, globalIndex, globalType, globalPipeline, XContentType.JSON); - - if (localType != null) { - // If the payload contains types, parsing it into a bulk request results in a warning. - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); - } + processor.add(data, globalIndex, globalPipeline, XContentType.JSON); } multiGetRequest.add(localIndex, Integer.toString(i)); } @@ -481,19 +398,14 @@ private static BytesArray bytesBulkRequest(String localIndex, String localType, } private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) throws Exception { - return indexDocs(processor, numDocs, "test", null, null, null, null); + return indexDocs(processor, numDocs, "test", null, null, null); } private static void assertResponseItems(List bulkItemResponses, int numDocs) { - assertResponseItems(bulkItemResponses, numDocs, MapperService.SINGLE_MAPPING_NAME); - } - - private static void assertResponseItems(List bulkItemResponses, int numDocs, String expectedType) { assertThat(bulkItemResponses.size(), is(numDocs)); int i = 1; for (BulkItemResponse bulkItemResponse : bulkItemResponses) { assertThat(bulkItemResponse.getIndex(), equalTo("test")); - assertThat(bulkItemResponse.getType(), equalTo(expectedType)); assertThat(bulkItemResponse.getId(), equalTo(Integer.toString(i++))); assertThat("item " + i + " failed with cause: " + bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkRequestWithGlobalParametersIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkRequestWithGlobalParametersIT.java index 4c8e05aa28ea5..551b3e485db7d 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkRequestWithGlobalParametersIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkRequestWithGlobalParametersIT.java @@ -24,7 +24,6 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.search.SearchHit; import java.io.IOException; @@ -33,7 +32,6 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasId; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasIndex; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasProperty; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasType; import static org.hamcrest.Matchers.both; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.emptyIterable; @@ -108,7 +106,7 @@ public void testMixPipelineOnRequestAndGlobal() throws IOException { } public void testGlobalIndex() throws IOException { - BulkRequest request = new BulkRequest("global_index", null); + BulkRequest request = new BulkRequest("global_index"); request.add(new IndexRequest().id("1") .source(XContentType.JSON, "field", "bulk1")); request.add(new IndexRequest().id("2") @@ -122,7 +120,7 @@ public void testGlobalIndex() throws IOException { @SuppressWarnings("unchecked") public void testIndexGlobalAndPerRequest() throws IOException { - BulkRequest request = new BulkRequest("global_index", null); + BulkRequest request = new BulkRequest("global_index"); request.add(new IndexRequest("local_index").id("1") .source(XContentType.JSON, "field", "bulk1")); request.add(new IndexRequest().id("2") // will take global index @@ -138,36 +136,6 @@ public void testIndexGlobalAndPerRequest() throws IOException { .and(hasIndex("global_index")))); } - public void testGlobalType() throws IOException { - BulkRequest request = new BulkRequest(null, "global_type"); - request.add(new IndexRequest("index").id("1") - .source(XContentType.JSON, "field", "bulk1")); - request.add(new IndexRequest("index").id("2") - .source(XContentType.JSON, "field", "bulk2")); - - bulkWithTypes(request); - - Iterable hits = searchAll("index"); - assertThat(hits, everyItem(hasType("global_type"))); - } - - public void testTypeGlobalAndPerRequest() throws IOException { - BulkRequest request = new BulkRequest(null, "global_type"); - request.add(new IndexRequest("index1", "local_type", "1") - .source(XContentType.JSON, "field", "bulk1")); - request.add(new IndexRequest("index2").id("2") // will take global type - .source(XContentType.JSON, "field", "bulk2")); - - bulkWithTypes(request); - - Iterable hits = searchAll("index1", "index2"); - assertThat(hits, containsInAnyOrder( - both(hasId("1")) - .and(hasType("local_type")), - both(hasId("2")) - .and(hasType("global_type")))); - } - public void testGlobalRouting() throws IOException { createIndexWithMultipleShards("index"); BulkRequest request = new BulkRequest((String) null); @@ -177,7 +145,7 @@ public void testGlobalRouting() throws IOException { .source(XContentType.JSON, "field", "bulk1")); request.routing("1"); bulk(request); - + Iterable emptyHits = searchAll(new SearchRequest("index").routing("xxx")); assertThat(emptyHits, is(emptyIterable())); @@ -199,7 +167,7 @@ public void testMixLocalAndGlobalRouting() throws IOException { Iterable hits = searchAll(new SearchRequest("index").routing("globalRouting", "localRouting")); assertThat(hits, containsInAnyOrder(hasId("1"), hasId("2"))); } - + public void testGlobalIndexNoTypes() throws IOException { BulkRequest request = new BulkRequest("global_index"); request.add(new IndexRequest().id("1") @@ -211,20 +179,13 @@ public void testGlobalIndexNoTypes() throws IOException { Iterable hits = searchAll("global_index"); assertThat(hits, everyItem(hasIndex("global_index"))); - } - - private BulkResponse bulkWithTypes(BulkRequest request) throws IOException { - BulkResponse bulkResponse = execute(request, highLevelClient()::bulk, highLevelClient()::bulkAsync, - expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); - assertFalse(bulkResponse.hasFailures()); - return bulkResponse; } - + private BulkResponse bulk(BulkRequest request) throws IOException { BulkResponse bulkResponse = execute(request, highLevelClient()::bulk, highLevelClient()::bulkAsync, RequestOptions.DEFAULT); assertFalse(bulkResponse.hasFailures()); return bulkResponse; - } + } @SuppressWarnings("unchecked") private static Function fieldFromSource(String fieldName) { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java index 1f7928dc4e99e..cb3ffa70096c2 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java @@ -54,7 +54,6 @@ import org.elasticsearch.index.VersionType; import org.elasticsearch.index.get.GetResult; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.rest.action.document.RestDeleteAction; import org.elasticsearch.rest.action.document.RestIndexAction; import org.elasticsearch.rest.action.document.RestUpdateAction; @@ -401,20 +400,6 @@ public void testMultiGet() throws IOException { } } - public void testMultiGetWithTypes() throws IOException { - BulkRequest bulk = new BulkRequest(); - bulk.setRefreshPolicy(RefreshPolicy.IMMEDIATE); - bulk.add(new IndexRequest("index", "type", "id1") - .source("{\"field\":\"value1\"}", XContentType.JSON)); - bulk.add(new IndexRequest("index", "type", "id2") - .source("{\"field\":\"value2\"}", XContentType.JSON)); - - highLevelClient().bulk(bulk, expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); - MultiGetRequest multiGetRequest = new MultiGetRequest(); - multiGetRequest.add("index", "id1"); - multiGetRequest.add("index", "id2"); - } - public void testIndex() throws IOException { final XContentType xContentType = randomFrom(XContentType.values()); { diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java index 96ebaedadce93..34fa4b91ec3a4 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java @@ -22,7 +22,6 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; import org.elasticsearch.common.Booleans; -import org.elasticsearch.rest.action.document.RestBulkAction; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -123,12 +122,11 @@ public void testIndexing() throws IOException { private void bulk(String index, String valueSuffix, int count) throws IOException { StringBuilder b = new StringBuilder(); for (int i = 0; i < count; i++) { - b.append("{\"index\": {\"_index\": \"").append(index).append("\", \"_type\": \"_doc\"}}\n"); + b.append("{\"index\": {\"_index\": \"").append(index).append("\"}}\n"); b.append("{\"f1\": \"v").append(i).append(valueSuffix).append("\", \"f2\": ").append(i).append("}\n"); } Request bulk = new Request("POST", "/_bulk"); bulk.addParameter("refresh", "true"); - bulk.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); bulk.setJsonEntity(b.toString()); client().performRequest(bulk); } diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/XPackIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/XPackIT.java index ba1cd80fc88a3..0e6cd229084e1 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/XPackIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/XPackIT.java @@ -19,9 +19,8 @@ package org.elasticsearch.upgrades; import org.apache.http.util.EntityUtils; -import org.junit.Before; import org.elasticsearch.client.Request; -import org.elasticsearch.rest.action.document.RestBulkAction; +import org.junit.Before; import java.io.IOException; @@ -53,14 +52,13 @@ public void skipIfNotXPack() { * might have already installed a trial license. */ public void testBasicFeature() throws IOException { - Request bulk = new Request("POST", "/sql_test/doc/_bulk"); + Request bulk = new Request("POST", "/sql_test/_bulk"); bulk.setJsonEntity( "{\"index\":{}}\n" + "{\"f\": \"1\"}\n" + "{\"index\":{}}\n" + "{\"f\": \"2\"}\n"); bulk.addParameter("refresh", "true"); - bulk.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); client().performRequest(bulk); Request sql = new Request("POST", "/_sql"); diff --git a/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java b/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java index 5594a21a2cc45..e99f8ddae31e2 100644 --- a/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java +++ b/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java @@ -65,15 +65,7 @@ public interface DocWriteRequest extends IndicesRequest { */ String type(); - /** - * Set the default type supplied to a bulk - * request if this individual request's type is null - * or empty - * @return the Request - */ - T defaultTypeIfNull(String defaultType); - - + /** * Get the id of the document for this request * @return the id diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java index 08c42c5ea40de..a44d47859d9c5 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java @@ -92,7 +92,6 @@ public static class Builder { private TimeValue flushInterval = null; private BackoffPolicy backoffPolicy = BackoffPolicy.exponentialBackoff(); private String globalIndex; - private String globalType; private String globalRouting; private String globalPipeline; @@ -148,11 +147,6 @@ public Builder setGlobalIndex(String globalIndex) { return this; } - public Builder setGlobalType(String globalType) { - this.globalType = globalType; - return this; - } - public Builder setGlobalRouting(String globalRouting) { this.globalRouting = globalRouting; return this; @@ -188,7 +182,7 @@ public BulkProcessor build() { } private Supplier createBulkRequestWithGlobalDefaults() { - return () -> new BulkRequest(globalIndex, globalType) + return () -> new BulkRequest(globalIndex) .pipeline(globalPipeline) .routing(globalRouting); } @@ -344,22 +338,13 @@ private void internalAdd(DocWriteRequest request) { /** * Adds the data from the bytes to be processed by the bulk processor */ - public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, - XContentType xContentType) throws Exception { - return add(data, defaultIndex, defaultType, null, xContentType); - } - - /** - * Adds the data from the bytes to be processed by the bulk processor - */ - public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, - @Nullable String defaultPipeline, - XContentType xContentType) throws Exception { + public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, + @Nullable String defaultPipeline, XContentType xContentType) throws Exception { Tuple bulkRequestToExecute = null; lock.lock(); try { ensureOpen(); - bulkRequest.add(data, defaultIndex, defaultType, null, null, defaultPipeline, + bulkRequest.add(data, defaultIndex, null, null, defaultPipeline, true, xContentType); bulkRequestToExecute = newBulkRequestIfNeeded(); } finally { diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index c1a4014b94b93..eb7c6ee3bea1a 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -37,7 +37,6 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -74,7 +73,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques private String globalPipeline; private String globalRouting; private String globalIndex; - private String globalType; private long sizeInBytes = 0; @@ -93,15 +91,6 @@ public BulkRequest(StreamInput in) throws IOException { public BulkRequest(@Nullable String globalIndex) { this.globalIndex = globalIndex; - } - - /** - * @deprecated Types are in the process of being removed. Use {@link #BulkRequest(String)} instead - */ - @Deprecated - public BulkRequest(@Nullable String globalIndex, @Nullable String globalType) { - this.globalIndex = globalIndex; - this.globalType = globalType; } /** @@ -225,83 +214,40 @@ public long estimatedSizeInBytes() { * Adds a framed data in binary format */ public BulkRequest add(byte[] data, int from, int length, XContentType xContentType) throws IOException { - return add(data, from, length, null, null, xContentType); + return add(data, from, length, null, xContentType); } /** * Adds a framed data in binary format - * @deprecated use {@link #add(byte[], int, int, String, XContentType)} instead */ - @Deprecated - public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, @Nullable String defaultType, + public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType) throws IOException { - return add(new BytesArray(data, from, length), defaultIndex, defaultType, xContentType); + return add(new BytesArray(data, from, length), defaultIndex, xContentType); } - /** * Adds a framed data in binary format */ - public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, + public BulkRequest add(BytesReference data, @Nullable String defaultIndex, XContentType xContentType) throws IOException { - return add(new BytesArray(data, from, length), defaultIndex, MapperService.SINGLE_MAPPING_NAME, xContentType); + return add(data, defaultIndex, null, null, null, true, xContentType); } - - /** - * Adds a framed data in binary format - * @deprecated use {@link #add(BytesReference, String, XContentType)} instead - */ - @Deprecated - public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, - XContentType xContentType) throws IOException { - return add(data, defaultIndex, defaultType, null, null, null, true, xContentType); - } - - /** - * Adds a framed data in binary format - */ - public BulkRequest add(BytesReference data, @Nullable String defaultIndex, - XContentType xContentType) throws IOException { - return add(data, defaultIndex, MapperService.SINGLE_MAPPING_NAME, null, null, null, true, xContentType); - } - /** - * Adds a framed data in binary format - * @deprecated use {@link #add(BytesReference, String, boolean, XContentType)} instead - */ - @Deprecated - public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex, - XContentType xContentType) throws IOException { - return add(data, defaultIndex, defaultType, null, null, null, allowExplicitIndex, xContentType); - } - /** * Adds a framed data in binary format */ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, boolean allowExplicitIndex, XContentType xContentType) throws IOException { - return add(data, defaultIndex, MapperService.SINGLE_MAPPING_NAME, null, null, null, allowExplicitIndex, xContentType); - } - - public BulkRequest add(BytesReference data, @Nullable String defaultIndex, - @Nullable String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, - @Nullable String defaultPipeline, boolean allowExplicitIndex, - XContentType xContentType) throws IOException { - return add(data, defaultIndex, MapperService.SINGLE_MAPPING_NAME, defaultRouting, defaultFetchSourceContext, - defaultPipeline, allowExplicitIndex, xContentType); + return add(data, defaultIndex, null, null, null, allowExplicitIndex, xContentType); } - /** - * @deprecated use {@link #add(BytesReference, String, String, FetchSourceContext, String, boolean, XContentType)} instead - */ - @Deprecated - public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, + public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable String defaultPipeline, boolean allowExplicitIndex, XContentType xContentType) throws IOException { String routing = valueOrDefault(defaultRouting, globalRouting); String pipeline = valueOrDefault(defaultPipeline, globalPipeline); - new BulkRequestParser(true).parse(data, defaultIndex, defaultType, routing, defaultFetchSourceContext, pipeline, + new BulkRequestParser(true).parse(data, defaultIndex, routing, defaultFetchSourceContext, pipeline, allowExplicitIndex, xContentType, this::internalAdd, this::internalAdd, this::add); return this; } @@ -418,9 +364,6 @@ public String getDescription() { private void applyGlobalMandatoryParameters(DocWriteRequest request) { request.index(valueOrDefault(request.index(), globalIndex)); - if (Strings.isNullOrEmpty(globalType) == false && MapperService.SINGLE_MAPPING_NAME.equals(globalType) == false) { - request.defaultTypeIfNull(globalType); - } } private static String valueOrDefault(String value, String globalDefault) { diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestBuilder.java index 34837d0e696db..edb3c60feaa84 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestBuilder.java @@ -33,7 +33,6 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.mapper.MapperService; /** * A bulk request holds an ordered {@link IndexRequest}s and {@link DeleteRequest}s and allows to executes @@ -42,14 +41,6 @@ public class BulkRequestBuilder extends ActionRequestBuilder implements WriteRequestBuilder { - /** - * @deprecated use {@link #BulkRequestBuilder(ElasticsearchClient, BulkAction, String)} instead - */ - @Deprecated - public BulkRequestBuilder(ElasticsearchClient client, BulkAction action, @Nullable String globalIndex, @Nullable String globalType) { - super(client, action, new BulkRequest(globalIndex, globalType)); - } - public BulkRequestBuilder(ElasticsearchClient client, BulkAction action, @Nullable String globalIndex) { super(client, action, new BulkRequest(globalIndex)); } @@ -117,25 +108,14 @@ public BulkRequestBuilder add(byte[] data, int from, int length, XContentType xC return this; } - /** - * Adds a framed data in binary format - * @deprecated use {@link #add(byte[], int, int, String, XContentType)} instead - */ - @Deprecated - public BulkRequestBuilder add(byte[] data, int from, int length, @Nullable String defaultIndex, @Nullable String defaultType, - XContentType xContentType) throws Exception { - request.add(data, from, length, defaultIndex, defaultType, xContentType); - return this; - } - /** * Adds a framed data in binary format */ public BulkRequestBuilder add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType) throws Exception { - request.add(data, from, length, defaultIndex, MapperService.SINGLE_MAPPING_NAME, xContentType); + request.add(data, from, length, defaultIndex, xContentType); return this; - } + } /** * Sets the number of shard copies that must be active before proceeding with the write. diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java index d1116b67b9a53..cba2302e85ce4 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java @@ -35,7 +35,6 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.VersionType; import org.elasticsearch.index.seqno.SequenceNumbers; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -114,26 +113,6 @@ public void parse( Consumer indexRequestConsumer, Consumer updateRequestConsumer, Consumer deleteRequestConsumer) throws IOException { - parse(data, defaultIndex, null, defaultRouting, defaultFetchSourceContext, defaultPipeline, allowExplicitIndex, xContentType, - indexRequestConsumer, updateRequestConsumer, deleteRequestConsumer); - } - - /** - * Parse the provided {@code data} assuming the provided default values. Index requests - * will be passed to the {@code indexRequestConsumer}, update requests to the - * {@code updateRequestConsumer} and delete requests to the {@code deleteRequestConsumer}. - * @deprecated Use {@link #parse(BytesReference, String, String, FetchSourceContext, String, boolean, XContentType, - * Consumer, Consumer, Consumer)} instead. - */ - @Deprecated - public void parse( - BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, - @Nullable String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, - @Nullable String defaultPipeline, boolean allowExplicitIndex, - XContentType xContentType, - Consumer indexRequestConsumer, - Consumer updateRequestConsumer, - Consumer deleteRequestConsumer) throws IOException { XContent xContent = xContentType.xContent(); int line = 0; int from = 0; @@ -172,7 +151,6 @@ public void parse( String action = parser.currentName(); String index = defaultIndex; - String type = defaultType; String id = null; String routing = defaultRouting; FetchSourceContext fetchSourceContext = defaultFetchSourceContext; @@ -199,12 +177,6 @@ public void parse( throw new IllegalArgumentException("explicit index in bulk is not allowed"); } index = parser.text(); - } else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) { - if (warnOnTypeUsage && typesDeprecationLogged == false) { - deprecationLogger.deprecatedAndMaybeLog("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE); - typesDeprecationLogged = true; - } - type = parser.text(); } else if (ID.match(currentFieldName, parser.getDeprecationHandler())) { id = parser.text(); } else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) { @@ -246,7 +218,7 @@ public void parse( } if ("delete".equals(action)) { - deleteRequestConsumer.accept(new DeleteRequest(index, type, id).routing(routing) + deleteRequestConsumer.accept(new DeleteRequest(index).id(id).routing(routing) .version(version).versionType(versionType).setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm)); } else { nextMarker = findNextMarker(marker, from, data); @@ -259,19 +231,19 @@ public void parse( // of index request. if ("index".equals(action)) { if (opType == null) { - indexRequestConsumer.accept(new IndexRequest(index, type, id).routing(routing) + indexRequestConsumer.accept(new IndexRequest(index).id(id).routing(routing) .version(version).versionType(versionType) .setPipeline(pipeline).setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm) .source(sliceTrimmingCarriageReturn(data, from, nextMarker,xContentType), xContentType)); } else { - indexRequestConsumer.accept(new IndexRequest(index, type, id).routing(routing) + indexRequestConsumer.accept(new IndexRequest(index).id(id).routing(routing) .version(version).versionType(versionType) .create("create".equals(opType)).setPipeline(pipeline) .setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm) .source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)); } } else if ("create".equals(action)) { - indexRequestConsumer.accept(new IndexRequest(index, type, id).routing(routing) + indexRequestConsumer.accept(new IndexRequest(index).id(id).routing(routing) .version(version).versionType(versionType) .create(true).setPipeline(pipeline).setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm) .source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)); @@ -280,7 +252,8 @@ public void parse( throw new IllegalArgumentException("Update requests do not support versioning. " + "Please use `if_seq_no` and `if_primary_term` instead"); } - UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).retryOnConflict(retryOnConflict) + UpdateRequest updateRequest = new UpdateRequest().index(index).id(id).routing(routing) + .retryOnConflict(retryOnConflict) .setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm) .routing(routing); // EMPTY is safe here because we never call namedObject diff --git a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java index 8074f7cbd6d42..cc7e10469e024 100644 --- a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java +++ b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java @@ -141,7 +141,7 @@ public ActionRequestValidationException validate() { @Override public String type() { if (type == null) { - return MapperService.SINGLE_MAPPING_NAME; + return MapperService.SINGLE_MAPPING_NAME; } return type; } @@ -157,22 +157,6 @@ public DeleteRequest type(String type) { this.type = type; return this; } - - /** - * Set the default type supplied to a bulk - * request if this individual request's type is null - * or empty - * - * @deprecated Types are in the process of being removed. - */ - @Deprecated - @Override - public DeleteRequest defaultTypeIfNull(String defaultType) { - if (Strings.isNullOrEmpty(type)) { - type = defaultType; - } - return this; - } /** * The id of the document to delete. @@ -292,8 +276,8 @@ public OpType opType() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. - // So we use the type accessor method here to make the type non-null (will default it to "_doc"). + // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. + // So we use the type accessor method here to make the type non-null (will default it to "_doc"). out.writeString(type()); out.writeString(id); out.writeOptionalString(routing()); diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 78862b0afdea4..2d6c4f28c5d0d 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -270,20 +270,7 @@ public IndexRequest type(String type) { return this; } - /** - * Set the default type supplied to a bulk - * request if this individual request's type is null - * or empty - * @deprecated Types are in the process of being removed. - */ - @Deprecated - @Override - public IndexRequest defaultTypeIfNull(String defaultType) { - if (Strings.isNullOrEmpty(type)) { - type = defaultType; - } - return this; - } + /** * The id of the indexed document. If not set, will be automatically generated. */ diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java b/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java index 97057eedd60d2..00b850109e496 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java @@ -217,7 +217,7 @@ public ActionRequestValidationException validate() { @Override public String type() { if (type == null) { - return MapperService.SINGLE_MAPPING_NAME; + return MapperService.SINGLE_MAPPING_NAME; } return type; } @@ -233,21 +233,6 @@ public UpdateRequest type(String type) { return this; } - /** - * Set the default type supplied to a bulk - * request if this individual request's type is null - * or empty - * @deprecated Types are in the process of being removed. - */ - @Deprecated - @Override - public UpdateRequest defaultTypeIfNull(String defaultType) { - if (Strings.isNullOrEmpty(type)) { - type = defaultType; - } - return this; - } - /** * The id of the indexed document. */ @@ -855,8 +840,8 @@ public UpdateRequest scriptedUpsert(boolean scriptedUpsert) { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); waitForActiveShards.writeTo(out); - // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. - // So we use the type accessor method here to make the type non-null (will default it to "_doc"). + // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. + // So we use the type accessor method here to make the type non-null (will default it to "_doc"). out.writeString(type()); out.writeString(id); out.writeOptionalString(routing); diff --git a/server/src/main/java/org/elasticsearch/client/Client.java b/server/src/main/java/org/elasticsearch/client/Client.java index 7e7cbf1c18be6..336875a602e93 100644 --- a/server/src/main/java/org/elasticsearch/client/Client.java +++ b/server/src/main/java/org/elasticsearch/client/Client.java @@ -231,9 +231,9 @@ public interface Client extends ElasticsearchClient, Releasable { BulkRequestBuilder prepareBulk(); /** - * Executes a bulk of index / delete operations with default index and/or type + * Executes a bulk of index / delete operations with default index */ - BulkRequestBuilder prepareBulk(@Nullable String globalIndex, @Nullable String globalType); + BulkRequestBuilder prepareBulk(@Nullable String globalIndex); /** * Gets the document that was indexed from an index with a type and id. diff --git a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java index 1180298f386ed..dbfcfc309fa1c 100644 --- a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -465,8 +465,8 @@ public BulkRequestBuilder prepareBulk() { } @Override - public BulkRequestBuilder prepareBulk(@Nullable String globalIndex, @Nullable String globalType) { - return new BulkRequestBuilder(this, BulkAction.INSTANCE, globalIndex, globalType); + public BulkRequestBuilder prepareBulk(@Nullable String globalIndex) { + return new BulkRequestBuilder(this, BulkAction.INSTANCE, globalIndex); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java index 33fd1d46b3ecf..43cd684bd47a7 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java @@ -19,20 +19,16 @@ package org.elasticsearch.rest.action.document; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkShardRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.Requests; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestStatusToXContentListener; -import org.elasticsearch.rest.action.search.RestSearchAction; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -42,19 +38,16 @@ /** *
- * { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" }
+ * { "index" : { "_index" : "test", "_id" : "1" }
  * { "type1" : { "field1" : "value1" } }
- * { "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
- * { "create" : { "_index" : "test", "_type" : "type1", "_id" : "1" }
+ * { "delete" : { "_index" : "test", "_id" : "2" } }
+ * { "create" : { "_index" : "test", "_id" : "1" }
  * { "type1" : { "field1" : "value1" } }
  * 
*/ public class RestBulkAction extends BaseRestHandler { private final boolean allowExplicitIndex; - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestSearchAction.class)); - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal]" + - " Specifying types in bulk requests is deprecated."; public RestBulkAction(Settings settings, RestController controller) { controller.registerHandler(POST, "/_bulk", this); @@ -62,10 +55,6 @@ public RestBulkAction(Settings settings, RestController controller) { controller.registerHandler(POST, "/{index}/_bulk", this); controller.registerHandler(PUT, "/{index}/_bulk", this); - // Deprecated typed endpoints. - controller.registerHandler(POST, "/{index}/{type}/_bulk", this); - controller.registerHandler(PUT, "/{index}/{type}/_bulk", this); - this.allowExplicitIndex = MULTI_ALLOW_EXPLICIT_INDEX.get(settings); } @@ -78,12 +67,6 @@ public String getName() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { BulkRequest bulkRequest = Requests.bulkRequest(); String defaultIndex = request.param("index"); - String defaultType = request.param("type"); - if (defaultType == null) { - defaultType = MapperService.SINGLE_MAPPING_NAME; - } else { - deprecationLogger.deprecatedAndMaybeLog("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE); - } String defaultRouting = request.param("routing"); FetchSourceContext defaultFetchSourceContext = FetchSourceContext.parseFromRestRequest(request); String defaultPipeline = request.param("pipeline"); @@ -93,7 +76,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC } bulkRequest.timeout(request.paramAsTime("timeout", BulkShardRequest.DEFAULT_TIMEOUT)); bulkRequest.setRefreshPolicy(request.param("refresh")); - bulkRequest.add(request.requiredContent(), defaultIndex, defaultType, defaultRouting, + bulkRequest.add(request.requiredContent(), defaultIndex, defaultRouting, defaultFetchSourceContext, defaultPipeline, allowExplicitIndex, request.getXContentType()); return channel -> client.bulk(bulkRequest, new RestStatusToXContentListener<>(channel)); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java index 5109f89d0dfee..73a3e0eee6c8e 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java @@ -116,7 +116,7 @@ public void testBulkWithGlobalDefaults() throws Exception { { createSamplePipeline("pipeline"); - BulkRequestBuilder bulkBuilder = client().prepareBulk("test","type1") + BulkRequestBuilder bulkBuilder = client().prepareBulk("test") .routing("routing") .pipeline("pipeline"); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java index fbcd5c46e2f90..584c2f5da9e7c 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java @@ -21,7 +21,6 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.test.ESTestCase; import java.io.IOException; @@ -33,7 +32,7 @@ public void testIndexRequest() throws IOException { BytesArray request = new BytesArray("{ \"index\":{ \"_id\": \"bar\" } }\n{}\n"); BulkRequestParser parser = new BulkRequestParser(randomBoolean()); final AtomicBoolean parsed = new AtomicBoolean(); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, + parser.parse(request, "foo", null, null, null, false, XContentType.JSON, indexRequest -> { assertFalse(parsed.get()); assertEquals("foo", indexRequest.index()); @@ -48,7 +47,7 @@ public void testDeleteRequest() throws IOException { BytesArray request = new BytesArray("{ \"delete\":{ \"_id\": \"bar\" } }\n"); BulkRequestParser parser = new BulkRequestParser(randomBoolean()); final AtomicBoolean parsed = new AtomicBoolean(); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, + parser.parse(request, "foo", null, null, null, false, XContentType.JSON, req -> fail(), req -> fail(), deleteRequest -> { assertFalse(parsed.get()); @@ -63,7 +62,7 @@ public void testUpdateRequest() throws IOException { BytesArray request = new BytesArray("{ \"update\":{ \"_id\": \"bar\" } }\n{}\n"); BulkRequestParser parser = new BulkRequestParser(randomBoolean()); final AtomicBoolean parsed = new AtomicBoolean(); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, + parser.parse(request, "foo", null, null, null, false, XContentType.JSON, req -> fail(), updateRequest -> { assertFalse(parsed.get()); @@ -79,7 +78,7 @@ public void testBarfOnLackOfTrailingNewline() throws IOException { BytesArray request = new BytesArray("{ \"index\":{ \"_id\": \"bar\" } }\n{}"); BulkRequestParser parser = new BulkRequestParser(randomBoolean()); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, - () -> parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, + () -> parser.parse(request, "foo", null, null, null, false, XContentType.JSON, indexRequest -> fail(), req -> fail(), req -> fail())); assertEquals("The bulk request must be terminated by a newline [\\n]", e.getMessage()); } @@ -87,28 +86,11 @@ public void testBarfOnLackOfTrailingNewline() throws IOException { public void testFailOnExplicitIndex() throws IOException { BytesArray request = new BytesArray("{ \"index\":{ \"_index\": \"foo\", \"_id\": \"bar\" } }\n{}\n"); BulkRequestParser parser = new BulkRequestParser(randomBoolean()); - + IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, - () -> parser.parse(request, null, null, null, null, null, false, XContentType.JSON, + () -> parser.parse(request, null, null, null, null, false, XContentType.JSON, req -> fail(), req -> fail(), req -> fail())); assertEquals("explicit index in bulk is not allowed", ex.getMessage()); } - public void testTypeWarning() throws IOException { - BytesArray request = new BytesArray("{ \"index\":{ \"_type\": \"quux\", \"_id\": \"bar\" } }\n{}\n"); - BulkRequestParser parser = new BulkRequestParser(true); - final AtomicBoolean parsed = new AtomicBoolean(); - parser.parse(request, "foo", null, null, null, null, false, XContentType.JSON, - indexRequest -> { - assertFalse(parsed.get()); - assertEquals("foo", indexRequest.index()); - assertEquals("bar", indexRequest.id()); - parsed.set(true); - }, - req -> fail(), req -> fail()); - assertTrue(parsed.get()); - - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); - } - } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java index ebd6590a80cca..22a50231fdfca 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java @@ -34,7 +34,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.script.Script; import org.elasticsearch.test.ESTestCase; @@ -63,12 +62,10 @@ public void testSimpleBulk1() throws Exception { assertThat(((IndexRequest) bulkRequest.requests().get(0)).source(), equalTo(new BytesArray("{ \"field1\" : \"value1\" }"))); assertThat(bulkRequest.requests().get(1), instanceOf(DeleteRequest.class)); assertThat(((IndexRequest) bulkRequest.requests().get(2)).source(), equalTo(new BytesArray("{ \"field1\" : \"value3\" }"))); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testSimpleBulkWithCarriageReturn() throws Exception { - String bulkAction = "{ \"index\":{\"_index\":\"test\",\"_type\":\"type1\",\"_id\":\"1\"} }\r\n{ \"field1\" : \"value1\" }\r\n"; + String bulkAction = "{ \"index\":{\"_index\":\"test\",\"_id\":\"1\"} }\r\n{ \"field1\" : \"value1\" }\r\n"; BulkRequest bulkRequest = new BulkRequest(); bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(1)); @@ -76,8 +73,6 @@ public void testSimpleBulkWithCarriageReturn() throws Exception { Map sourceMap = XContentHelper.convertToMap(((IndexRequest) bulkRequest.requests().get(0)).source(), false, XContentType.JSON).v2(); assertEquals("value1", sourceMap.get("field1")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testSimpleBulk2() throws Exception { @@ -103,7 +98,6 @@ public void testSimpleBulk4() throws Exception { assertThat(((UpdateRequest) bulkRequest.requests().get(0)).retryOnConflict(), equalTo(2)); assertThat(((UpdateRequest) bulkRequest.requests().get(0)).doc().source().utf8ToString(), equalTo("{\"field\":\"value\"}")); assertThat(bulkRequest.requests().get(1).id(), equalTo("0")); - assertThat(bulkRequest.requests().get(1).type(), equalTo("type1")); assertThat(bulkRequest.requests().get(1).index(), equalTo("index1")); Script script = ((UpdateRequest) bulkRequest.requests().get(1)).script(); assertThat(script, notNullValue()); @@ -114,21 +108,17 @@ public void testSimpleBulk4() throws Exception { assertThat(scriptParams.size(), equalTo(1)); assertThat(scriptParams.get("param1"), equalTo(1)); assertThat(((UpdateRequest) bulkRequest.requests().get(1)).upsertRequest().source().utf8ToString(), equalTo("{\"counter\":1}")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testBulkAllowExplicitIndex() throws Exception { String bulkAction1 = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json"); Exception ex = expectThrows(Exception.class, () -> new BulkRequest().add( - new BytesArray(bulkAction1.getBytes(StandardCharsets.UTF_8)), null, null, false, XContentType.JSON)); + new BytesArray(bulkAction1.getBytes(StandardCharsets.UTF_8)), null, false, XContentType.JSON)); assertEquals("explicit index in bulk is not allowed", ex.getMessage()); String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk5.json"); - new BulkRequest().add(new BytesArray(bulkAction.getBytes(StandardCharsets.UTF_8)), "test", null, false, XContentType.JSON); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); + new BulkRequest().add(new BytesArray(bulkAction.getBytes(StandardCharsets.UTF_8)), "test", false, XContentType.JSON); } public void testBulkAddIterable() { @@ -150,8 +140,6 @@ public void testSimpleBulk6() throws Exception { ParsingException exc = expectThrows(ParsingException.class, () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON)); assertThat(exc.getMessage(), containsString("Unknown key for a VALUE_STRING in [hello]")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testSimpleBulk7() throws Exception { @@ -161,8 +149,6 @@ public void testSimpleBulk7() throws Exception { () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON)); assertThat(exc.getMessage(), containsString("Malformed action/metadata line [5], expected a simple value for field [_unknown] but found [START_ARRAY]")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testSimpleBulk8() throws Exception { @@ -171,8 +157,6 @@ public void testSimpleBulk8() throws Exception { IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON)); assertThat(exc.getMessage(), containsString("Action/metadata line [3] contains an unknown parameter [_foo]")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testSimpleBulk9() throws Exception { @@ -189,12 +173,10 @@ public void testSimpleBulk10() throws Exception { BulkRequest bulkRequest = new BulkRequest(); bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(9)); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testBulkActionShouldNotContainArray() throws Exception { - String bulkAction = "{ \"index\":{\"_index\":[\"index1\", \"index2\"],\"_type\":\"type1\",\"_id\":\"1\"} }\r\n" + String bulkAction = "{ \"index\":{\"_index\":[\"index1\", \"index2\"],\"_id\":\"1\"} }\r\n" + "{ \"field1\" : \"value1\" }\r\n"; BulkRequest bulkRequest = new BulkRequest(); IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, @@ -280,7 +262,6 @@ public void testSmileIsSupported() throws IOException { builder.startObject(); builder.startObject("index"); builder.field("_index", "index"); - builder.field("_type", "type"); builder.field("_id", "test"); builder.endObject(); builder.endObject(); @@ -296,19 +277,16 @@ public void testSmileIsSupported() throws IOException { } BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(data, null, null, xContentType); + bulkRequest.add(data, null, xContentType); assertEquals(1, bulkRequest.requests().size()); DocWriteRequest docWriteRequest = bulkRequest.requests().get(0); assertEquals(DocWriteRequest.OpType.INDEX, docWriteRequest.opType()); assertEquals("index", docWriteRequest.index()); - assertEquals("type", docWriteRequest.type()); assertEquals("test", docWriteRequest.id()); assertThat(docWriteRequest, instanceOf(IndexRequest.class)); IndexRequest request = (IndexRequest) docWriteRequest; assertEquals(1, request.sourceAsMap().size()); assertEquals("value", request.sourceAsMap().get("field")); - //This test's content contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testToValidateUpsertRequestAndCASInBulkRequest() throws IOException { @@ -319,7 +297,6 @@ public void testToValidateUpsertRequestAndCASInBulkRequest() throws IOException builder.startObject(); builder.startObject("update"); builder.field("_index", "index"); - builder.field("_type", "type"); builder.field("_id", "id"); builder.field("if_seq_no", 1L); builder.field("if_primary_term", 100L); @@ -334,7 +311,6 @@ public void testToValidateUpsertRequestAndCASInBulkRequest() throws IOException values.put("if_seq_no", 1L); values.put("if_primary_term", 100L); values.put("_index", "index"); - values.put("_type", "type"); builder.field("upsert", values); builder.endObject(); } @@ -342,10 +318,8 @@ public void testToValidateUpsertRequestAndCASInBulkRequest() throws IOException data = out.bytes(); } BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(data, null, null, xContentType); + bulkRequest.add(data, null, xContentType); assertThat(bulkRequest.validate().validationErrors(), contains("upsert requests don't support `if_seq_no` and `if_primary_term`")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testBulkTerminatedByNewline() throws Exception { @@ -359,7 +333,5 @@ public void testBulkTerminatedByNewline() throws Exception { bulkRequestWithNewLine.add(bulkActionWithNewLine.getBytes(StandardCharsets.UTF_8), 0, bulkActionWithNewLine.length(), null, XContentType.JSON); assertEquals(3, bulkRequestWithNewLine.numberOfActions()); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java index d8fe82bf88e77..2b2c22cd9be5c 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java @@ -21,10 +21,10 @@ package org.elasticsearch.action.bulk; import org.apache.lucene.util.Constants; -import org.elasticsearch.action.ActionType; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.support.ActionFilters; @@ -38,7 +38,6 @@ import org.elasticsearch.common.util.concurrent.AtomicArray; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.tasks.Task; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.transport.CapturingTransport; @@ -199,8 +198,6 @@ public void onFailure(Exception e) { } }); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } static class Resolver extends IndexNameExpressionResolver { diff --git a/server/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java b/server/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java index 37b44afe099a2..fc4cc261ea4b1 100644 --- a/server/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java +++ b/server/src/test/java/org/elasticsearch/search/geo/GeoFilterIT.java @@ -387,7 +387,7 @@ public void testBulk() throws Exception { client().admin().indices().prepareCreate("countries").setSettings(settings) .addMapping("country", xContentBuilder).get(); - BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, null, xContentBuilder.contentType()).get(); + BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, xContentBuilder.contentType()).get(); for (BulkItemResponse item : bulk.getItems()) { assertFalse("unable to index data", item.isFailed()); diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk.json b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk.json index cf76477187524..e36d1b7fc00b8 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk.json @@ -1,5 +1,5 @@ -{ "index":{"_index":"test","_type":"type1","_id":"1"} } +{ "index":{"_index":"test","_id":"1"} } { "field1" : "value1" } -{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } } -{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } } +{ "delete" : { "_index" : "test", "_id" : "2" } } +{ "create" : { "_index" : "test", "_id" : "3" } } { "field1" : "value3" } diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk10.json b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk10.json index 3556dc261b037..7721d6f073fbd 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk10.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk10.json @@ -1,15 +1,15 @@ -{ "index" : {"_index":null, "_type":"type1", "_id":"0"} } +{ "index" : {"_index":null, "_id":"0"} } { "field1" : "value1" } -{ "index" : {"_index":"test", "_type":null, "_id":"0"} } +{ "index" : {"_index":"test", "_id":"0"} } { "field1" : "value1" } -{ "index" : {"_index":"test", "_type":"type1", "_id":null} } +{ "index" : {"_index":"test", "_id":null} } { "field1" : "value1" } -{ "delete" : {"_index":null, "_type":"type1", "_id":"0"} } -{ "delete" : {"_index":"test", "_type":null, "_id":"0"} } -{ "delete" : {"_index":"test", "_type":"type1", "_id":null} } -{ "create" : {"_index":null, "_type":"type1", "_id":"0"} } +{ "delete" : {"_index":null, "_id":"0"} } +{ "delete" : {"_index":"test", "_id":"0"} } +{ "delete" : {"_index":"test", "_id":null} } +{ "create" : {"_index":null, "_id":"0"} } { "field1" : "value1" } -{ "create" : {"_index":"test", "_type":null, "_id":"0"} } +{ "create" : {"_index":"test", "_id":"0"} } { "field1" : "value1" } -{ "create" : {"_index":"test", "_type":"type1", "_id":null} } +{ "create" : {"_index":"test", "_id":null} } { "field1" : "value1" } diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk11.json b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk11.json index 9be3c13061234..2242dd01c8145 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk11.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk11.json @@ -1,5 +1,5 @@ -{ "index":{"_index":"test","_type":"type1","_id":"1"} } +{ "index":{"_index":"test","_id":"1"} } { "field1" : "value1" } -{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } } -{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } } +{ "delete" : { "_index" : "test", "_id" : "2" } } +{ "create" : { "_index" : "test", "_id" : "3" } } { "field1" : "value3" } \ No newline at end of file diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk4.json b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk4.json index 94d95614568ca..e1911094e7d88 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk4.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk4.json @@ -1,6 +1,6 @@ { "update" : {"_id" : "1", "retry_on_conflict" : 2} } { "doc" : {"field" : "value"} } -{ "update" : { "_id" : "0", "_type" : "type1", "_index" : "index1" } } +{ "update" : { "_id" : "0", "_index" : "index1" } } { "script" : { "source" : "counter += param1", "lang" : "javascript", "params" : {"param1" : 1}}, "upsert" : {"counter" : 1}} { "delete" : { "_id" : "2" } } { "create" : { "_id" : "3" } } diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk5.json b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk5.json index 6ad5ff3052f25..d5312d64163a1 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk5.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk5.json @@ -1,5 +1,5 @@ -{ "index": {"_type": "type1","_id": "1"} } +{ "index": {"_id": "1"} } { "field1" : "value1" } -{ "delete" : { "_type" : "type1", "_id" : "2" } } -{ "create" : { "_type" : "type1", "_id" : "3" } } +{ "delete" : { "_id" : "2" } } +{ "create" : { "_id" : "3" } } { "field1" : "value3" } diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk6.json b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk6.json index e9c97965595eb..86e8757af832d 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk6.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk6.json @@ -1,6 +1,6 @@ -{"index": {"_index": "test", "_type": "doc", "_source": {"hello": "world"}, "_id": 0}} +{"index": {"_index": "test", "_source": {"hello": "world"}, "_id": 0}} {"field1": "value0"} -{"index": {"_index": "test", "_type": "doc", "_id": 1}} +{"index": {"_index": "test", "_id": 1}} {"field1": "value1"} -{"index": {"_index": "test", "_type": "doc", "_id": 2}} +{"index": {"_index": "test", "_id": 2}} {"field1": "value2"} diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk7.json b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk7.json index 669bfd10798e9..cd742def27e9f 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk7.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk7.json @@ -1,6 +1,6 @@ -{"index": {"_index": "test", "_type": "doc", "_id": 0}} +{"index": {"_index": "test", "_id": 0}} {"field1": "value0"} -{"index": {"_index": "test", "_type": "doc", "_id": 1}} +{"index": {"_index": "test", "_id": 1}} {"field1": "value1"} -{"index": {"_index": "test", "_type": "doc", "_id": 2, "_unknown": ["foo", "bar"]}} +{"index": {"_index": "test", "_id": 2, "_unknown": ["foo", "bar"]}} {"field1": "value2"} diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk8.json b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk8.json index c1a94b1d159d0..27d855258ed72 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk8.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/simple-bulk8.json @@ -1,6 +1,6 @@ -{"index": {"_index": "test", "_type": "doc", "_id": 0}} +{"index": {"_index": "test", "_id": 0}} {"field1": "value0"} -{"index": {"_index": "test", "_type": "doc", "_id": 1, "_foo": "bar"}} +{"index": {"_index": "test", "_id": 1, "_foo": "bar"}} {"field1": "value1"} -{"index": {"_index": "test", "_type": "doc", "_id": 2}} +{"index": {"_index": "test", "_id": 2}} {"field1": "value2"} diff --git a/x-pack/plugin/mapper-flattened/src/test/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectSearchTests.java b/x-pack/plugin/mapper-flattened/src/test/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectSearchTests.java index 373d1d16d8407..817cdec66e6d1 100644 --- a/x-pack/plugin/mapper-flattened/src/test/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectSearchTests.java +++ b/x-pack/plugin/mapper-flattened/src/test/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectSearchTests.java @@ -233,7 +233,7 @@ public void testCardinalityAggregation() throws IOException { int numDocs = randomIntBetween(2, 100); int precisionThreshold = randomIntBetween(0, 1 << randomInt(20)); - BulkRequestBuilder bulkRequest = client().prepareBulk("test", "_doc") + BulkRequestBuilder bulkRequest = client().prepareBulk("test") .setRefreshPolicy(RefreshPolicy.IMMEDIATE); // Add a random number of documents containing a flat object field, plus @@ -300,7 +300,7 @@ private void assertCardinality(Cardinality count, long value, int precisionThres } public void testTermsAggregation() throws IOException { - BulkRequestBuilder bulkRequest = client().prepareBulk("test", "_doc") + BulkRequestBuilder bulkRequest = client().prepareBulk("test") .setRefreshPolicy(RefreshPolicy.IMMEDIATE); for (int i = 0; i < 5; i++) { bulkRequest.add(client().prepareIndex() diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java index ecb0d637f14fb..d2d95b4738df7 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java @@ -866,7 +866,7 @@ private void enqueueResponse(MockWebServer mockWebServer, int responseCode, Stri private void assertBulkRequest(String requestBody, int numberOfActions) throws Exception { BulkRequest bulkRequest = Requests.bulkRequest() - .add(new BytesArray(requestBody.getBytes(StandardCharsets.UTF_8)), null, null, XContentType.JSON); + .add(new BytesArray(requestBody.getBytes(StandardCharsets.UTF_8)), null, XContentType.JSON); assertThat(bulkRequest.numberOfActions(), equalTo(numberOfActions)); for (DocWriteRequest actionRequest : bulkRequest.requests()) { assertThat(actionRequest, instanceOf(IndexRequest.class)); diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java index a392fea9beb34..ad5a8b68a5ea8 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; import org.elasticsearch.common.Booleans; -import org.elasticsearch.rest.action.document.RestBulkAction; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -109,12 +108,11 @@ public void testIndexing() throws IOException { private void bulk(String index, String valueSuffix, int count) throws IOException { StringBuilder b = new StringBuilder(); for (int i = 0; i < count; i++) { - b.append("{\"index\": {\"_index\": \"").append(index).append("\", \"_type\": \"_doc\"}}\n"); + b.append("{\"index\": {\"_index\": \"").append(index).append("\"}}\n"); b.append("{\"f1\": \"v").append(i).append(valueSuffix).append("\", \"f2\": ").append(i).append("}\n"); } Request bulk = new Request("POST", "/_bulk"); bulk.addParameter("refresh", "true"); - bulk.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); bulk.setJsonEntity(b.toString()); client().performRequest(bulk); } From 1f538a3f2fa55b8c9cd0af56b283a6a24d2b9222 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 23 Sep 2019 20:20:10 +0100 Subject: [PATCH 02/35] tests --- docs/build.gradle | 3 --- .../aggregations/bucket/rare-terms-aggregation.asciidoc | 2 +- .../rest-api-spec/test/multi_cluster/60_tophits.yml | 2 +- .../test/ingest_mustache/10_ingest_disabled.yml | 2 -- .../monitoring/action/MonitoringBulkRequestTests.java | 7 ------- .../org/elasticsearch/integration/BulkUpdateTests.java | 2 +- 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/docs/build.gradle b/docs/build.gradle index b7e2f81e3d746..23308a2258069 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -574,7 +574,6 @@ buildRestTests.setups['library'] = ''' - do: bulk: index: library - type: book refresh: true body: | {"index":{"_id": "Leviathan Wakes"}} @@ -923,7 +922,6 @@ buildRestTests.setups['farequote_data'] = buildRestTests.setups['farequote_index - do: bulk: index: farequote - type: metric refresh: true body: | {"index": {"_id":"1"}} @@ -983,7 +981,6 @@ buildRestTests.setups['server_metrics_data'] = buildRestTests.setups['server_met - do: bulk: index: server-metrics - type: metric refresh: true body: | {"index": {"_id":"1177"}} diff --git a/docs/reference/aggregations/bucket/rare-terms-aggregation.asciidoc b/docs/reference/aggregations/bucket/rare-terms-aggregation.asciidoc index 88500a4c887e8..f3e906f7b53b6 100644 --- a/docs/reference/aggregations/bucket/rare-terms-aggregation.asciidoc +++ b/docs/reference/aggregations/bucket/rare-terms-aggregation.asciidoc @@ -25,7 +25,7 @@ PUT /products } } -POST /products/_doc/_bulk?refresh +POST /products/_bulk?refresh {"index":{"_id":0}} {"genre": "rock", "product": "Product A"} {"index":{"_id":1}} diff --git a/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/60_tophits.yml b/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/60_tophits.yml index 9d94e7d5abb3f..ae213bae21405 100644 --- a/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/60_tophits.yml +++ b/qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/60_tophits.yml @@ -24,7 +24,7 @@ teardown: bulk: refresh: true body: - - '{"index": {"_index": "single_doc_index", "_type": "test_type"}}' + - '{"index": {"_index": "single_doc_index" }}' - '{"f1": "local_cluster", "sort_field": 0}' - do: search: diff --git a/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml b/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml index 5a3f64151f4ed..28c5165ecf545 100644 --- a/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml +++ b/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml @@ -109,12 +109,10 @@ body: - index: _index: test_index - _type: test_type _id: test_id - f1: v1 - index: _index: test_index - _type: test_type _id: test_id2 pipeline: my_pipeline_1 - f1: v2 diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java index f1d03bf5ff767..877dcb3390565 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java @@ -78,7 +78,6 @@ public void testAddRequestContent() throws IOException { final XContentType xContentType = XContentType.JSON; final int nbDocs = randomIntBetween(1, 20); - final String[] types = new String[nbDocs]; final String[] ids = new String[nbDocs]; final BytesReference[] sources = new BytesReference[nbDocs]; @@ -93,9 +92,6 @@ public void testAddRequestContent() throws IOException { builder.field("_index", ""); } - types[i] = randomAlphaOfLength(5); - builder.field("_type", types[i]); - if (randomBoolean()) { ids[i] = randomAlphaOfLength(10); builder.field("_id", ids[i]); @@ -132,7 +128,6 @@ public void testAddRequestContent() throws IOException { int count = 0; for (final MonitoringBulkDoc bulkDoc : bulkDocs) { assertThat(bulkDoc.getSystem(), equalTo(system)); - assertThat(bulkDoc.getType(), equalTo(types[count])); assertThat(bulkDoc.getId(), equalTo(ids[count])); assertThat(bulkDoc.getTimestamp(), equalTo(timestamp)); assertThat(bulkDoc.getIntervalMillis(), equalTo(interval)); @@ -158,7 +153,6 @@ public void testAddRequestContentWithEmptySource() throws IOException { builder.startObject("index"); { builder.field("_index", ""); - builder.field("_type", "doc"); builder.field("_id", String.valueOf(i)); } builder.endObject(); @@ -202,7 +196,6 @@ public void testAddRequestContentWithUnrecognizedIndexName() throws IOException builder.startObject("index"); { builder.field("_index", indexName); - builder.field("_type", "doc"); } builder.endObject(); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index 88a72072c952f..644c1c4137e4a 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java @@ -107,7 +107,7 @@ public void testThatBulkUpdateDoesNotLoseFieldsHttp() throws IOException { Request bulkRequest = new Request("POST", "/_bulk"); bulkRequest.setOptions(options); bulkRequest.setJsonEntity( - "{\"update\": {\"_index\": \"index1\", \"_type\": \"_doc\", \"_id\": \"1\"}}\n" + + "{\"update\": {\"_index\": \"index1\", \"_id\": \"1\"}}\n" + "{\"doc\": {\"bulk updated\":\"bulk updated\"}}\n"); getRestClient().performRequest(bulkRequest); From 748d1f6c1fd78133c45adcfac114641042fab5f2 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 23 Sep 2019 21:03:50 +0100 Subject: [PATCH 03/35] tests --- docs/reference/sql/getting-started.asciidoc | 2 +- .../test/lang_mustache/60_typed_keys.yml | 10 +-- .../ingest_mustache/10_ingest_disabled.yml | 3 - .../test/bulk/11_basic_with_types.yml | 72 ------------------ .../bulk/21_list_of_strings_with_types.yml | 17 ----- .../test/bulk/31_big_string_with_types.yml | 17 ----- .../test/bulk/41_source_with_types.yml | 76 ------------------- .../test/bulk/51_refresh_with_types.yml | 48 ------------ .../test/bulk/70_mix_typeless_typeful.yml | 31 -------- .../test/bulk/81_cas_with_types.yml | 41 ---------- .../mget/14_alias_to_multiple_indices.yml | 6 +- .../action/MonitoringBulkRequestTests.java | 2 +- .../test/old_cluster/50_token_auth.yml | 10 +-- 13 files changed, 15 insertions(+), 320 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/bulk/11_basic_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/bulk/21_list_of_strings_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/bulk/31_big_string_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/bulk/41_source_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/bulk/51_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/bulk/70_mix_typeless_typeful.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/bulk/81_cas_with_types.yml diff --git a/docs/reference/sql/getting-started.asciidoc b/docs/reference/sql/getting-started.asciidoc index dbcdb68d5e6a3..00ba8be6ba56a 100644 --- a/docs/reference/sql/getting-started.asciidoc +++ b/docs/reference/sql/getting-started.asciidoc @@ -8,7 +8,7 @@ an index with some data to experiment with: [source,console] -------------------------------------------------- -PUT /library/book/_bulk?refresh +PUT /library/_bulk?refresh {"index":{"_id": "Leviathan Wakes"}} {"name": "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561} {"index":{"_id": "Hyperion"}} diff --git a/modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/60_typed_keys.yml b/modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/60_typed_keys.yml index 0f97afbe5ab66..84a55f8b6f992 100644 --- a/modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/60_typed_keys.yml +++ b/modules/lang-mustache/src/test/resources/rest-api-spec/test/lang_mustache/60_typed_keys.yml @@ -21,15 +21,15 @@ setup: bulk: refresh: true body: - - '{"index": {"_index": "test-0", "_type": "_doc"}}' + - '{"index": {"_index": "test-0"}}' - '{"ip": "10.0.0.1", "integer": 38, "float": 12.5713, "name": "Ruth", "bool": true}' - - '{"index": {"_index": "test-0", "_type": "_doc"}}' + - '{"index": {"_index": "test-0"}}' - '{"ip": "10.0.0.2", "integer": 42, "float": 15.3393, "name": "Jackie", "surname": "Bowling", "bool": false}' - - '{"index": {"_index": "test-1", "_type": "_doc"}}' + - '{"index": {"_index": "test-1"}}' - '{"ip": "10.0.0.3", "integer": 29, "float": 19.0517, "name": "Stephanie", "bool": true}' - - '{"index": {"_index": "test-1", "_type": "_doc"}}' + - '{"index": {"_index": "test-1"}}' - '{"ip": "10.0.0.4", "integer": 19, "float": 19.3717, "surname": "Hamilton", "bool": true}' - - '{"index": {"_index": "test-2", "_type": "_doc"}}' + - '{"index": {"_index": "test-2"}}' - '{"ip": "10.0.0.5", "integer": 0, "float": 17.3349, "name": "Natalie", "bool": false}' --- diff --git a/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml b/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml index 28c5165ecf545..fb29017c3605e 100644 --- a/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml +++ b/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml @@ -54,7 +54,6 @@ "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar" @@ -92,12 +91,10 @@ body: - index: _index: test_index - _type: test_type _id: test_id - f1: v1 - index: _index: test_index - _type: test_type _id: test_id2 - f1: v2 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/11_basic_with_types.yml deleted file mode 100644 index 7e763cded3185..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/11_basic_with_types.yml +++ /dev/null @@ -1,72 +0,0 @@ ---- -"Array of objects": - - do: - bulk: - refresh: true - body: - - index: - _index: test_index - _type: test_type - _id: test_id - - f1: v1 - f2: 42 - - index: - _index: test_index - _type: test_type - _id: test_id2 - - f1: v2 - f2: 47 - - - do: - count: - index: test_index - - - match: {count: 2} - ---- -"Empty _id": - - do: - bulk: - refresh: true - body: - - index: - _index: test - _type: type - _id: '' - - f: 1 - - index: - _index: test - _type: type - _id: id - - f: 2 - - index: - _index: test - _type: type - - f: 3 - - match: { errors: true } - - match: { items.0.index.status: 400 } - - match: { items.0.index.error.type: illegal_argument_exception } - - match: { items.0.index.error.reason: if _id is specified it must not be empty } - - match: { items.1.index.result: created } - - match: { items.2.index.result: created } - - - do: - count: - index: test - - - match: { count: 2 } - ---- -"empty action": - - skip: - features: headers - - - do: - catch: /Malformed action\/metadata line \[3\], expected FIELD_NAME but found \[END_OBJECT\]/ - headers: - Content-Type: application/json - bulk: - body: | - {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}} - {"f1": "v1", "f2": 42} - {} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/21_list_of_strings_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/21_list_of_strings_with_types.yml deleted file mode 100644 index def91f4280722..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/21_list_of_strings_with_types.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -"List of strings": - - do: - bulk: - refresh: true - body: - - '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}' - - '{"f1": "v1", "f2": 42}' - - '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}' - - '{"f1": "v2", "f2": 47}' - - - do: - count: - index: test_index - - - match: {count: 2} - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/31_big_string_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/31_big_string_with_types.yml deleted file mode 100644 index 1d117253c9b01..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/31_big_string_with_types.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -"One big string": - - do: - bulk: - refresh: true - body: | - {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}} - {"f1": "v1", "f2": 42} - {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}} - {"f1": "v2", "f2": 47} - - - do: - count: - index: test_index - - - match: {count: 2} - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/41_source_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/41_source_with_types.yml deleted file mode 100644 index 3c8a86c13bdac..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/41_source_with_types.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- -"Source filtering": - - do: - index: - refresh: true - index: test_index - type: test_type - id: test_id_1 - body: { "foo": "bar", "bar": "foo" } - - - do: - index: - refresh: true - index: test_index - type: test_type - id: test_id_2 - body: { "foo": "qux", "bar": "pux" } - - - do: - index: - refresh: true - index: test_index - type: test_type - id: test_id_3 - body: { "foo": "corge", "bar": "forge" } - - - - do: - bulk: - refresh: true - body: | - { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": true } } - { "doc": { "foo": "baz" } } - { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } } - { "_source": true, "doc": { "foo": "quux" } } - - - match: { items.0.update.get._source.foo: baz } - - match: { items.1.update.get._source.foo: quux } - - - do: - bulk: - index: test_index - type: test_type - _source: true - body: | - { "update": { "_id": "test_id_3" } } - { "doc": { "foo": "garply" } } - - - match: { items.0.update.get._source.foo: garply } - - - do: - bulk: - refresh: true - body: | - { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": {"includes": "bar"} } } - { "doc": { "foo": "baz" } } - { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } } - { "_source": {"includes": "foo"}, "doc": { "foo": "quux" } } - - - match: { items.0.update.get._source.bar: foo } - - is_false: items.0.update.get._source.foo - - match: { items.1.update.get._source.foo: quux } - - is_false: items.1.update.get._source.bar - - - do: - bulk: - index: test_index - type: test_type - _source_includes: foo - body: | - { "update": { "_id": "test_id_3" } } - { "doc": { "foo": "garply" } } - - - match: { items.0.update.get._source.foo: garply } - - is_false: items.0.update.get._source.bar - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/51_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/51_refresh_with_types.yml deleted file mode 100644 index 6326b9464caa0..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/51_refresh_with_types.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -"refresh=true immediately makes changes are visible in search": - - do: - bulk: - refresh: true - body: | - {"index": {"_index": "bulk_50_refresh_1", "_type": "test_type", "_id": "bulk_50_refresh_id1"}} - {"f1": "v1", "f2": 42} - {"index": {"_index": "bulk_50_refresh_1", "_type": "test_type", "_id": "bulk_50_refresh_id2"}} - {"f1": "v2", "f2": 47} - - - do: - count: - index: bulk_50_refresh_1 - - match: {count: 2} - ---- -"refresh=empty string immediately makes changes are visible in search": - - do: - bulk: - refresh: "" - body: | - {"index": {"_index": "bulk_50_refresh_2", "_type": "test_type", "_id": "bulk_50_refresh_id3"}} - {"f1": "v1", "f2": 42} - {"index": {"_index": "bulk_50_refresh_2", "_type": "test_type", "_id": "bulk_50_refresh_id4"}} - {"f1": "v2", "f2": 47} - - - do: - count: - index: bulk_50_refresh_2 - - match: {count: 2} - - ---- -"refresh=wait_for waits until changes are visible in search": - - do: - bulk: - refresh: wait_for - body: | - {"index": {"_index": "bulk_50_refresh_3", "_type": "test_type", "_id": "bulk_50_refresh_id5"}} - {"f1": "v1", "f2": 42} - {"index": {"_index": "bulk_50_refresh_3", "_type": "test_type", "_id": "bulk_50_refresh_id6"}} - {"f1": "v2", "f2": 47} - - - do: - count: - index: bulk_50_refresh_3 - - match: {count: 2} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/70_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/70_mix_typeless_typeful.yml deleted file mode 100644 index 50bf6ac5bcf3a..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/70_mix_typeless_typeful.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -"bulk without types on an index that has types": - - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - do: - bulk: - refresh: true - body: - - index: - _index: index - _id: 0 - - foo: bar - - index: - _index: index - _id: 1 - - foo: bar - - - do: - count: - index: index - - - match: {count: 2} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/81_cas_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/81_cas_with_types.yml deleted file mode 100644 index 7de82e4fb23e0..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/81_cas_with_types.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -"Compare And Swap Sequence Numbers": - - - do: - index: - index: test_1 - type: _doc - id: 1 - body: { foo: bar } - - match: { _version: 1} - - set: { _seq_no: seqno } - - set: { _primary_term: primary_term } - - - do: - bulk: - body: - - index: - _index: test_1 - _type: _doc - _id: 1 - if_seq_no: 10000 - if_primary_term: $primary_term - - foo: bar2 - - - match: { errors: true } - - match: { items.0.index.status: 409 } - - match: { items.0.index.error.type: version_conflict_engine_exception } - - - do: - bulk: - body: - - index: - _index: test_1 - _type: _doc - _id: 1 - if_seq_no: $seqno - if_primary_term: $primary_term - - foo: bar2 - - - match: { errors: false} - - match: { items.0.index.status: 200 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/14_alias_to_multiple_indices.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/14_alias_to_multiple_indices.yml index 8d18ff7685117..87a40732be88d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/14_alias_to_multiple_indices.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/14_alias_to_multiple_indices.yml @@ -6,11 +6,11 @@ bulk: refresh: true body: | - {"index": {"_index": "test_1", "_type": "_doc", "_id": 1}} + {"index": {"_index": "test_1", "_id": 1}} { "foo": "bar" } - {"index": {"_index": "test_2", "_type": "_doc", "_id": 2}} + {"index": {"_index": "test_2", "_id": 2}} { "foo": "bar" } - {"index": {"_index": "test_3", "_type": "_doc", "_id": 3}} + {"index": {"_index": "test_3", "_id": 3}} { "foo": "bar" } - do: diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java index 877dcb3390565..0a82faa9fe066 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java @@ -180,7 +180,7 @@ public void testAddRequestContentWithEmptySource() throws IOException { bulkRequest.add(randomFrom(MonitoredSystem.values()), content.bytes(), xContentType, 0L, 0L) ); - assertThat(e.getMessage(), containsString("source is missing for monitoring document [][doc][" + nbDocs + "]")); + assertThat(e.getMessage(), containsString("source is missing for monitoring document [][_doc][" + nbDocs + "]")); } public void testAddRequestContentWithUnrecognizedIndexName() throws IOException { diff --git a/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/50_token_auth.yml b/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/50_token_auth.yml index e4d0eb8757f85..2f44c37a37f98 100644 --- a/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/50_token_auth.yml +++ b/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/old_cluster/50_token_auth.yml @@ -56,15 +56,15 @@ bulk: refresh: true body: - - '{"index": {"_index": "token_index", "_type": "_doc", "_id" : "1"}}' + - '{"index": {"_index": "token_index", "_id" : "1"}}' - '{"f1": "v1_old", "f2": 0}' - - '{"index": {"_index": "token_index", "_type": "_doc", "_id" : "2"}}' + - '{"index": {"_index": "token_index", "_id" : "2"}}' - '{"f1": "v2_old", "f2": 1}' - - '{"index": {"_index": "token_index", "_type": "_doc", "_id" : "3"}}' + - '{"index": {"_index": "token_index", "_id" : "3"}}' - '{"f1": "v3_old", "f2": 2}' - - '{"index": {"_index": "token_index", "_type": "_doc", "_id" : "4"}}' + - '{"index": {"_index": "token_index", "_id" : "4"}}' - '{"f1": "v4_old", "f2": 3}' - - '{"index": {"_index": "token_index", "_type": "_doc", "_id" : "5"}}' + - '{"index": {"_index": "token_index", "_id" : "5"}}' - '{"f1": "v5_old", "f2": 4}' - do: From 9ba9c59ff6d7482158e9f596d8d74a9cbb28b475 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 23 Sep 2019 21:39:42 +0100 Subject: [PATCH 04/35] tests --- .../http/netty4/Netty4HttpRequestSizeLimitIT.java | 2 +- .../xpack/monitoring/integration/MonitoringIT.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpRequestSizeLimitIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpRequestSizeLimitIT.java index eaec286c7b237..76d7f58403cbc 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpRequestSizeLimitIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpRequestSizeLimitIT.java @@ -80,7 +80,7 @@ public void testLimitsInFlightRequests() throws Exception { @SuppressWarnings("unchecked") Tuple[] requests = new Tuple[150]; for (int i = 0; i < requests.length; i++) { - requests[i] = Tuple.tuple("/index/type/_bulk", bulkRequest); + requests[i] = Tuple.tuple("/index/_bulk", bulkRequest); } HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index 223f1e106e334..6bcc3c8c09bf0 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -105,11 +105,11 @@ protected Collection> getPlugins() { } private String createBulkEntity() { - return "{\"index\":{\"_type\":\"monitoring_data_type\"}}\n" + + return "{\"index\":{}}\n" + "{\"foo\":{\"bar\":0}}\n" + - "{\"index\":{\"_type\":\"monitoring_data_type\"}}\n" + + "{\"index\":{}}\n" + "{\"foo\":{\"bar\":1}}\n" + - "{\"index\":{\"_type\":\"monitoring_data_type\"}}\n" + + "{\"index\":{}}\n" + "{\"foo\":{\"bar\":2}}\n" + "\n"; } From e63d10926c59c7533eba23e7fdce5ec6c49ebd64 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 24 Sep 2019 15:47:06 +0100 Subject: [PATCH 05/35] tests --- .../test/repository_azure/10_repository.yml | 7 --- .../action/bulk/BulkItemRequest.java | 2 +- .../action/bulk/BulkItemResponse.java | 59 +++++++----------- .../bulk/BulkPrimaryExecutionContext.java | 4 +- .../action/bulk/BulkResponse.java | 4 +- .../action/bulk/TransportBulkAction.java | 10 +-- .../index/reindex/BulkByScrollResponse.java | 6 +- .../action/bulk/BulkIntegrationIT.java | 1 - .../action/bulk/BulkItemResponseTests.java | 9 +-- .../action/bulk/BulkProcessorIT.java | 56 +++++++---------- .../action/bulk/BulkRequestModifierTests.java | 1 - .../action/bulk/BulkResponseTests.java | 5 +- .../action/bulk/BulkWithUpdatesIT.java | 3 - .../elasticsearch/action/bulk/RetryTests.java | 2 +- .../bulk/TransportShardBulkActionTests.java | 9 +-- .../document/DocumentActionsIT.java | 5 -- .../reindex/BulkByScrollResponseTests.java | 4 +- .../template/SimpleIndexTemplateIT.java | 1 - .../elasticsearch/action/bulk/bulk-log.json | 24 +++---- .../elasticsearch/search/geo/gzippedmap.gz | Bin 7686 -> 7710 bytes 20 files changed, 73 insertions(+), 139 deletions(-) diff --git a/plugins/repository-azure/qa/microsoft-azure-storage/src/test/resources/rest-api-spec/test/repository_azure/10_repository.yml b/plugins/repository-azure/qa/microsoft-azure-storage/src/test/resources/rest-api-spec/test/repository_azure/10_repository.yml index fade1f9f1e67d..088c4d28ef718 100644 --- a/plugins/repository-azure/qa/microsoft-azure-storage/src/test/resources/rest-api-spec/test/repository_azure/10_repository.yml +++ b/plugins/repository-azure/qa/microsoft-azure-storage/src/test/resources/rest-api-spec/test/repository_azure/10_repository.yml @@ -35,17 +35,14 @@ setup: body: - index: _index: docs - _type: doc _id: 1 - snapshot: one - index: _index: docs - _type: doc _id: 2 - snapshot: one - index: _index: docs - _type: doc _id: 3 - snapshot: one @@ -83,22 +80,18 @@ setup: body: - index: _index: docs - _type: doc _id: 4 - snapshot: two - index: _index: docs - _type: doc _id: 5 - snapshot: two - index: _index: docs - _type: doc _id: 6 - snapshot: two - index: _index: docs - _type: doc _id: 7 - snapshot: two diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java index e1306a437ca98..eaacf67c587a2 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java @@ -78,7 +78,7 @@ void setPrimaryResponse(BulkItemResponse primaryResponse) { */ public void abort(String index, Exception cause) { if (primaryResponse == null) { - final BulkItemResponse.Failure failure = new BulkItemResponse.Failure(index, request.type(), request.id(), + final BulkItemResponse.Failure failure = new BulkItemResponse.Failure(index, request.id(), Objects.requireNonNull(cause), true); setPrimaryResponse(new BulkItemResponse(id, request.opType(), failure)); } else { diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index 396d59c71c3ae..f443102a8bf92 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -21,6 +21,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ExceptionsHelper; +import org.elasticsearch.Version; import org.elasticsearch.action.DocWriteRequest.OpType; import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.delete.DeleteResponse; @@ -37,6 +38,7 @@ import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.seqno.SequenceNumbers; import org.elasticsearch.rest.RestStatus; @@ -54,7 +56,6 @@ public class BulkItemResponse implements Writeable, StatusToXContentObject { private static final String _INDEX = "_index"; - private static final String _TYPE = "_type"; private static final String _ID = "_id"; private static final String STATUS = "status"; private static final String ERROR = "error"; @@ -73,7 +74,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(STATUS, response.status().getStatus()); } else { builder.field(_INDEX, failure.getIndex()); - builder.field(_TYPE, failure.getType()); builder.field(_ID, failure.getId()); builder.field(STATUS, failure.getStatus().getStatus()); builder.startObject(ERROR); @@ -151,7 +151,7 @@ public static BulkItemResponse fromXContent(XContentParser parser, int id) throw BulkItemResponse bulkItemResponse; if (exception != null) { - Failure failure = new Failure(builder.getShardId().getIndexName(), builder.getType(), builder.getId(), exception, status); + Failure failure = new Failure(builder.getShardId().getIndexName(), builder.getId(), exception, status); bulkItemResponse = new BulkItemResponse(id, opType, failure); } else { bulkItemResponse = new BulkItemResponse(id, opType, builder.build()); @@ -164,13 +164,11 @@ public static BulkItemResponse fromXContent(XContentParser parser, int id) throw */ public static class Failure implements Writeable, ToXContentFragment { public static final String INDEX_FIELD = "index"; - public static final String TYPE_FIELD = "type"; public static final String ID_FIELD = "id"; public static final String CAUSE_FIELD = "cause"; public static final String STATUS_FIELD = "status"; private final String index; - private final String type; private final String id; private final Exception cause; private final RestStatus status; @@ -183,12 +181,11 @@ public static class Failure implements Writeable, ToXContentFragment { true, a -> new Failure( - (String)a[0], (String)a[1], (String)a[2], (Exception)a[3], RestStatus.fromCode((int)a[4]) + (String)a[0], (String)a[1], (Exception)a[2], RestStatus.fromCode((int)a[3]) ) ); static { PARSER.declareString(constructorArg(), new ParseField(INDEX_FIELD)); - PARSER.declareString(constructorArg(), new ParseField(TYPE_FIELD)); PARSER.declareString(optionalConstructorArg(), new ParseField(ID_FIELD)); PARSER.declareObject(constructorArg(), (p, c) -> ElasticsearchException.fromXContent(p), new ParseField(CAUSE_FIELD)); PARSER.declareInt(constructorArg(), new ParseField(STATUS_FIELD)); @@ -197,29 +194,28 @@ public static class Failure implements Writeable, ToXContentFragment { /** * For write failures before operation was assigned a sequence number. * - * use @{link {@link #Failure(String, String, String, Exception, long)}} + * use @{link {@link #Failure(String, String, Exception, long)}} * to record operation sequence no with failure */ - public Failure(String index, String type, String id, Exception cause) { - this(index, type, id, cause, ExceptionsHelper.status(cause), SequenceNumbers.UNASSIGNED_SEQ_NO, false); + public Failure(String index, String id, Exception cause) { + this(index, id, cause, ExceptionsHelper.status(cause), SequenceNumbers.UNASSIGNED_SEQ_NO, false); } - public Failure(String index, String type, String id, Exception cause, boolean aborted) { - this(index, type, id, cause, ExceptionsHelper.status(cause), SequenceNumbers.UNASSIGNED_SEQ_NO, aborted); + public Failure(String index, String id, Exception cause, boolean aborted) { + this(index, id, cause, ExceptionsHelper.status(cause), SequenceNumbers.UNASSIGNED_SEQ_NO, aborted); } - public Failure(String index, String type, String id, Exception cause, RestStatus status) { - this(index, type, id, cause, status, SequenceNumbers.UNASSIGNED_SEQ_NO, false); + public Failure(String index, String id, Exception cause, RestStatus status) { + this(index, id, cause, status, SequenceNumbers.UNASSIGNED_SEQ_NO, false); } /** For write failures after operation was assigned a sequence number. */ - public Failure(String index, String type, String id, Exception cause, long seqNo) { - this(index, type, id, cause, ExceptionsHelper.status(cause), seqNo, false); + public Failure(String index, String id, Exception cause, long seqNo) { + this(index, id, cause, ExceptionsHelper.status(cause), seqNo, false); } - public Failure(String index, String type, String id, Exception cause, RestStatus status, long seqNo, boolean aborted) { + public Failure(String index, String id, Exception cause, RestStatus status, long seqNo, boolean aborted) { this.index = index; - this.type = type; this.id = id; this.cause = cause; this.status = status; @@ -232,7 +228,10 @@ public Failure(String index, String type, String id, Exception cause, RestStatus */ public Failure(StreamInput in) throws IOException { index = in.readString(); - type = in.readString(); + if (in.getVersion().before(Version.V_8_0_0)) { + String type = in.readString(); + assert MapperService.SINGLE_MAPPING_NAME.equals(type); + } id = in.readOptionalString(); cause = in.readException(); status = ExceptionsHelper.status(cause); @@ -243,7 +242,9 @@ public Failure(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(getIndex()); - out.writeString(getType()); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeString(MapperService.SINGLE_MAPPING_NAME); + } out.writeOptionalString(getId()); out.writeException(getCause()); out.writeZLong(getSeqNo()); @@ -257,13 +258,6 @@ public String getIndex() { return this.index; } - /** - * The type of the action. - */ - public String getType() { - return type; - } - /** * The id of the action. */ @@ -313,7 +307,6 @@ public boolean isAborted() { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field(INDEX_FIELD, index); - builder.field(TYPE_FIELD, type); if (id != null) { builder.field(ID_FIELD, id); } @@ -398,16 +391,6 @@ public String getIndex() { return response.getIndex(); } - /** - * The type of the action. - */ - public String getType() { - if (failure != null) { - return failure.getType(); - } - return response.getType(); - } - /** * The id of the action. */ diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContext.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContext.java index 65452f9a75dba..8967ba4f41b2c 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContext.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContext.java @@ -239,7 +239,7 @@ public void failOnMappingUpdate(Exception cause) { executionResult = new BulkItemResponse(getCurrentItem().id(), docWriteRequest.opType(), // Make sure to use getCurrentItem().index() here, if you use docWriteRequest.index() it will use the // concrete index instead of an alias if used! - new BulkItemResponse.Failure(getCurrentItem().index(), docWriteRequest.type(), docWriteRequest.id(), cause)); + new BulkItemResponse.Failure(getCurrentItem().index(), docWriteRequest.id(), cause)); markAsCompleted(executionResult); } @@ -273,7 +273,7 @@ public void markOperationAsExecuted(Engine.Result result) { // Make sure to use request.index() here, if you // use docWriteRequest.index() it will use the // concrete index instead of an alias if used! - new BulkItemResponse.Failure(request.index(), docWriteRequest.type(), docWriteRequest.id(), + new BulkItemResponse.Failure(request.index(), docWriteRequest.id(), result.getFailure(), result.getSeqNo())); break; default: diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java index c021825bc7a8a..7d59eec63ca77 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java @@ -118,8 +118,8 @@ public String buildFailureMessage() { BulkItemResponse response = responses[i]; if (response.isFailed()) { sb.append("\n[").append(i) - .append("]: index [").append(response.getIndex()).append("], type [") - .append(response.getType()).append("], id [").append(response.getId()) + .append("]: index [").append(response.getIndex()) + .append("], id [").append(response.getId()) .append("], message [").append(response.getFailureMessage()).append("]"); } } diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index 9b047a0d4f1ac..a4b8ae7891e9a 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -378,7 +378,7 @@ void createIndex(String index, TimeValue timeout, ActionListener responses, int idx, DocWriteRequest request, String index, Exception e) { if (index.equals(request.index())) { - responses.set(idx, new BulkItemResponse(idx, request.opType(), new BulkItemResponse.Failure(request.index(), request.type(), + responses.set(idx, new BulkItemResponse(idx, request.opType(), new BulkItemResponse.Failure(request.index(), request.id(), e))); return true; } @@ -455,7 +455,7 @@ protected void doRun() { default: throw new AssertionError("request type not supported: [" + docWriteRequest.opType() + "]"); } } catch (ElasticsearchParseException | IllegalArgumentException | RoutingMissingException e) { - BulkItemResponse.Failure failure = new BulkItemResponse.Failure(concreteIndex.getName(), docWriteRequest.type(), + BulkItemResponse.Failure failure = new BulkItemResponse.Failure(concreteIndex.getName(), docWriteRequest.id(), e); BulkItemResponse bulkItemResponse = new BulkItemResponse(i, docWriteRequest.opType(), failure); responses.set(i, bulkItemResponse); @@ -518,7 +518,7 @@ public void onFailure(Exception e) { final String indexName = concreteIndices.getConcreteIndex(request.index()).getName(); DocWriteRequest docWriteRequest = request.request(); responses.set(request.id(), new BulkItemResponse(request.id(), docWriteRequest.opType(), - new BulkItemResponse.Failure(indexName, docWriteRequest.type(), docWriteRequest.id(), e))); + new BulkItemResponse.Failure(indexName, docWriteRequest.id(), e))); } if (counter.decrementAndGet() == 0) { finishHim(); @@ -598,7 +598,7 @@ private boolean addFailureIfIndexIsUnavailable(DocWriteRequest request, int i } private void addFailure(DocWriteRequest request, int idx, Exception unavailableException) { - BulkItemResponse.Failure failure = new BulkItemResponse.Failure(request.index(), request.type(), request.id(), + BulkItemResponse.Failure failure = new BulkItemResponse.Failure(request.index(), request.id(), unavailableException); BulkItemResponse bulkItemResponse = new BulkItemResponse(idx, request.opType(), failure); responses.set(idx, bulkItemResponse); @@ -757,7 +757,7 @@ void markCurrentItemAsFailed(Exception e) { // 2) Add a bulk item failure for this request // 3) Continue with the next request in the bulk. failedSlots.set(currentSlot); - BulkItemResponse.Failure failure = new BulkItemResponse.Failure(indexRequest.index(), indexRequest.type(), + BulkItemResponse.Failure failure = new BulkItemResponse.Failure(indexRequest.index(), indexRequest.id(), e); itemResponses.add(new BulkItemResponse(currentSlot, indexRequest.opType(), failure)); } diff --git a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java index 59ac32c666104..44bcba686f607 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java @@ -225,7 +225,6 @@ private static Object parseFailure(XContentParser parser) throws IOException { ensureExpectedToken(Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation); Token token; String index = null; - String type = null; String id = null; Integer status = null; Integer shardId = null; @@ -255,9 +254,6 @@ private static Object parseFailure(XContentParser parser) throws IOException { case Failure.INDEX_FIELD: index = parser.text(); break; - case Failure.TYPE_FIELD: - type = parser.text(); - break; case Failure.ID_FIELD: id = parser.text(); break; @@ -283,7 +279,7 @@ private static Object parseFailure(XContentParser parser) throws IOException { } } if (bulkExc != null) { - return new Failure(index, type, id, bulkExc, RestStatus.fromCode(status)); + return new Failure(index, id, bulkExc, RestStatus.fromCode(status)); } else if (searchExc != null) { if (status == null) { return new SearchFailure(searchExc, index, shardId, nodeId); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java index 73a3e0eee6c8e..1e3cb0b364a1c 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java @@ -62,7 +62,6 @@ public void testBulkIndexCreatesMapping() throws Exception { assertBusy(() -> { GetMappingsResponse mappingsResponse = client().admin().indices().prepareGetMappings().get(); assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30")); - assertTrue(mappingsResponse.getMappings().get("logstash-2014.03.30").containsKey("logs")); }); } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkItemResponseTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkItemResponseTests.java index 20a42407720ff..f6a3662370409 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkItemResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkItemResponseTests.java @@ -44,7 +44,7 @@ public class BulkItemResponseTests extends ESTestCase { public void testFailureToString() { - Failure failure = new Failure("index", "type", "id", new RuntimeException("test")); + Failure failure = new Failure("index", "id", new RuntimeException("test")); String toString = failure.toString(); assertThat(toString, containsString("\"type\":\"runtime_exception\"")); assertThat(toString, containsString("\"reason\":\"test\"")); @@ -88,16 +88,15 @@ public void testFailureToAndFromXContent() throws IOException { int itemId = randomIntBetween(0, 100); String index = randomAlphaOfLength(5); - String type = randomAlphaOfLength(5); String id = randomAlphaOfLength(5); DocWriteRequest.OpType opType = randomFrom(DocWriteRequest.OpType.values()); final Tuple exceptions = randomExceptions(); Exception bulkItemCause = (Exception) exceptions.v1(); - Failure bulkItemFailure = new Failure(index, type, id, bulkItemCause); + Failure bulkItemFailure = new Failure(index, id, bulkItemCause); BulkItemResponse bulkItemResponse = new BulkItemResponse(itemId, opType, bulkItemFailure); - Failure expectedBulkItemFailure = new Failure(index, type, id, exceptions.v2(), ExceptionsHelper.status(bulkItemCause)); + Failure expectedBulkItemFailure = new Failure(index, id, exceptions.v2(), ExceptionsHelper.status(bulkItemCause)); BulkItemResponse expectedBulkItemResponse = new BulkItemResponse(itemId, opType, expectedBulkItemFailure); BytesReference originalBytes = toShuffledXContent(bulkItemResponse, xContentType, ToXContent.EMPTY_PARAMS, randomBoolean()); @@ -120,7 +119,6 @@ public void testFailureToAndFromXContent() throws IOException { public static void assertBulkItemResponse(BulkItemResponse expected, BulkItemResponse actual) { assertEquals(expected.getItemId(), actual.getItemId()); assertEquals(expected.getIndex(), actual.getIndex()); - assertEquals(expected.getType(), actual.getType()); assertEquals(expected.getId(), actual.getId()); assertEquals(expected.getOpType(), actual.getOpType()); assertEquals(expected.getVersion(), actual.getVersion()); @@ -131,7 +129,6 @@ public static void assertBulkItemResponse(BulkItemResponse expected, BulkItemRes BulkItemResponse.Failure actualFailure = actual.getFailure(); assertEquals(expectedFailure.getIndex(), actualFailure.getIndex()); - assertEquals(expectedFailure.getType(), actualFailure.getType()); assertEquals(expectedFailure.getId(), actualFailure.getId()); assertEquals(expectedFailure.getMessage(), actualFailure.getMessage()); assertEquals(expectedFailure.getStatus(), actualFailure.getStatus()); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java index 6e2f78f456148..0c080c193f4b6 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java @@ -27,14 +27,10 @@ import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.test.ESIntegTestCase; import java.util.Arrays; @@ -62,10 +58,10 @@ public void testThatBulkProcessorCountIsCorrect() throws Exception { int numDocs = randomIntBetween(10, 100); try (BulkProcessor processor = BulkProcessor.builder(client(), listener) - //let's make sure that the bulk action limit trips, one single execution will index all the documents - .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) - .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)) - .build()) { + //let's make sure that the bulk action limit trips, one single execution will index all the documents + .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) + .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)) + .build()) { MultiGetRequestBuilder multiGetRequestBuilder = indexDocs(client(), processor, numDocs); @@ -86,9 +82,9 @@ public void testBulkProcessorFlush() throws Exception { int numDocs = randomIntBetween(10, 100); try (BulkProcessor processor = BulkProcessor.builder(client(), listener) - //let's make sure that this bulk won't be automatically flushed - .setConcurrentRequests(randomIntBetween(0, 10)).setBulkActions(numDocs + randomIntBetween(1, 100)) - .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) { + //let's make sure that this bulk won't be automatically flushed + .setConcurrentRequests(randomIntBetween(0, 10)).setBulkActions(numDocs + randomIntBetween(1, 100)) + .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) { MultiGetRequestBuilder multiGetRequestBuilder = indexDocs(client(), processor, numDocs); @@ -121,9 +117,9 @@ public void testBulkProcessorConcurrentRequests() throws Exception { MultiGetRequestBuilder multiGetRequestBuilder; try (BulkProcessor processor = BulkProcessor.builder(client(), listener) - .setConcurrentRequests(concurrentRequests).setBulkActions(bulkActions) - //set interval and size to high values - .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) { + .setConcurrentRequests(concurrentRequests).setBulkActions(bulkActions) + //set interval and size to high values + .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) { multiGetRequestBuilder = indexDocs(client(), processor, numDocs); @@ -146,7 +142,6 @@ public void testBulkProcessorConcurrentRequests() throws Exception { for (BulkItemResponse bulkItemResponse : listener.bulkItems) { assertThat(bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false)); assertThat(bulkItemResponse.getIndex(), equalTo("test")); - assertThat(bulkItemResponse.getType(), equalTo("test")); //with concurrent requests > 1 we can't rely on the order of the bulk requests assertThat(Integer.valueOf(bulkItemResponse.getId()), both(greaterThan(0)).and(lessThanOrEqualTo(numDocs))); //we do want to check that we don't get duplicate ids back @@ -161,11 +156,11 @@ public void testBulkProcessorWaitOnClose() throws Exception { int numDocs = randomIntBetween(10, 100); BulkProcessor processor = BulkProcessor.builder(client(), listener) - //let's make sure that the bulk action limit trips, one single execution will index all the documents - .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) - .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(randomIntBetween(1, 10), - RandomPicks.randomFrom(random(), ByteSizeUnit.values()))) - .build(); + //let's make sure that the bulk action limit trips, one single execution will index all the documents + .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) + .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(randomIntBetween(1, 10), + RandomPicks.randomFrom(random(), ByteSizeUnit.values()))) + .build(); MultiGetRequestBuilder multiGetRequestBuilder = indexDocs(client(), processor, numDocs); assertThat(processor.isOpen(), is(true)); @@ -189,7 +184,7 @@ public void testBulkProcessorWaitOnClose() throws Exception { public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception { createIndex("test-ro"); assertAcked(client().admin().indices().prepareUpdateSettings("test-ro") - .setSettings(Settings.builder().put(IndexMetaData.SETTING_BLOCKS_WRITE, true))); + .setSettings(Settings.builder().put(IndexMetaData.SETTING_BLOCKS_WRITE, true))); ensureGreen(); int bulkActions = randomIntBetween(10, 100); @@ -208,9 +203,9 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception BulkProcessorTestListener listener = new BulkProcessorTestListener(latch, closeLatch); try (BulkProcessor processor = BulkProcessor.builder(client(), listener) - .setConcurrentRequests(concurrentRequests).setBulkActions(bulkActions) - //set interval and size to high values - .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) { + .setConcurrentRequests(concurrentRequests).setBulkActions(bulkActions) + //set interval and size to high values + .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) { for (int i = 1; i <= numDocs; i++) { if (randomBoolean()) { @@ -237,7 +232,6 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception Set readOnlyIds = new HashSet<>(); for (BulkItemResponse bulkItemResponse : listener.bulkItems) { assertThat(bulkItemResponse.getIndex(), either(equalTo("test")).or(equalTo("test-ro"))); - assertThat(bulkItemResponse.getType(), equalTo("test")); if (bulkItemResponse.getIndex().equals("test")) { assertThat(bulkItemResponse.isFailed(), equalTo(false)); //with concurrent requests > 1 we can't rely on the order of the bulk requests @@ -259,15 +253,8 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception private static MultiGetRequestBuilder indexDocs(Client client, BulkProcessor processor, int numDocs) throws Exception { MultiGetRequestBuilder multiGetRequestBuilder = client.prepareMultiGet(); for (int i = 1; i <= numDocs; i++) { - if (randomBoolean()) { - processor.add(new IndexRequest("test", "test", Integer.toString(i)) - .source(Requests.INDEX_CONTENT_TYPE, "field", randomRealisticUnicodeOfLengthBetween(1, 30))); - } else { - final String source = "{ \"index\":{\"_index\":\"test\",\"_type\":\"test\",\"_id\":\"" + Integer.toString(i) + "\"} }\n" - + Strings.toString(JsonXContent.contentBuilder() - .startObject().field("field", randomRealisticUnicodeOfLengthBetween(1, 30)).endObject()) + "\n"; - processor.add(new BytesArray(source), null, null, XContentType.JSON); - } + processor.add(new IndexRequest("test", "test", Integer.toString(i)) + .source(Requests.INDEX_CONTENT_TYPE, "field", randomRealisticUnicodeOfLengthBetween(1, 30))); multiGetRequestBuilder.add("test", Integer.toString(i)); } return multiGetRequestBuilder; @@ -278,7 +265,6 @@ private static void assertResponseItems(List bulkItemResponses int i = 1; for (BulkItemResponse bulkItemResponse : bulkItemResponses) { assertThat(bulkItemResponse.getIndex(), equalTo("test")); - assertThat(bulkItemResponse.getType(), equalTo("test")); assertThat(bulkItemResponse.getId(), equalTo(Integer.toString(i++))); assertThat("item " + i + " failed with cause: " + bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false)); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestModifierTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestModifierTests.java index 82ed518256169..615c8f68a063a 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestModifierTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestModifierTests.java @@ -74,7 +74,6 @@ public void testBulkRequestModifier() { BulkItemResponse item = bulkResponse.getItems()[j]; assertThat(item.isFailed(), is(true)); assertThat(item.getFailure().getIndex(), equalTo("_index")); - assertThat(item.getFailure().getType(), equalTo("_type")); assertThat(item.getFailure().getId(), equalTo(String.valueOf(j))); assertThat(item.getFailure().getMessage(), equalTo("java.lang.RuntimeException")); } else { diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkResponseTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkResponseTests.java index 5da1451a13849..49b3c6aca5b61 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkResponseTests.java @@ -73,16 +73,15 @@ public void testToAndFromXContent() throws IOException { expectedBulkItems[i] = new BulkItemResponse(i, opType, randomDocWriteResponses.v2()); } else { String index = randomAlphaOfLength(5); - String type = randomAlphaOfLength(5); String id = randomAlphaOfLength(5); Tuple failures = randomExceptions(); Exception bulkItemCause = (Exception) failures.v1(); bulkItems[i] = new BulkItemResponse(i, opType, - new BulkItemResponse.Failure(index, type, id, bulkItemCause)); + new BulkItemResponse.Failure(index, id, bulkItemCause)); expectedBulkItems[i] = new BulkItemResponse(i, opType, - new BulkItemResponse.Failure(index, type, id, failures.v2(), ExceptionsHelper.status(bulkItemCause))); + new BulkItemResponse.Failure(index, id, failures.v2(), ExceptionsHelper.status(bulkItemCause))); } } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java index f79eed492519e..e89bfc0f42922 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java @@ -321,7 +321,6 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getVersion(), equalTo(1L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); - assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE)); assertThat(response.getItems()[i].getResponse().getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getResponse().getVersion(), equalTo(1L)); @@ -359,7 +358,6 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getVersion(), equalTo(2L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); - assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE)); assertThat(response.getItems()[i].getResponse().getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getResponse().getVersion(), equalTo(2L)); @@ -383,7 +381,6 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(id))); assertThat(response.getItems()[i].getVersion(), equalTo(3L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); - assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE)); } } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/RetryTests.java b/server/src/test/java/org/elasticsearch/action/bulk/RetryTests.java index bfbccf0b14262..81da3d98b0840 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/RetryTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/RetryTests.java @@ -232,7 +232,7 @@ private BulkItemResponse successfulResponse() { } private BulkItemResponse failedResponse() { - return new BulkItemResponse(1, OpType.INDEX, new BulkItemResponse.Failure("test", "test", "1", + return new BulkItemResponse(1, OpType.INDEX, new BulkItemResponse.Failure("test", "1", new EsRejectedExecutionException("pool full"))); } } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportShardBulkActionTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportShardBulkActionTests.java index 8acb3e8cc93a5..fab305327027a 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportShardBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportShardBulkActionTests.java @@ -153,7 +153,6 @@ public void testExecuteBulkIndexRequest() throws Exception { BulkItemResponse.Failure failure = primaryResponse.getFailure(); assertThat(failure.getIndex(), equalTo("index")); - assertThat(failure.getType(), equalTo("_doc")); assertThat(failure.getId(), equalTo("id")); assertThat(failure.getCause().getClass(), equalTo(VersionConflictEngineException.class)); assertThat(failure.getCause().getMessage(), @@ -201,7 +200,6 @@ public void testSkipBulkIndexRequestIfAborted() throws Exception { BulkItemResponse response = result.finalResponseIfSuccessful.getResponses()[i]; assertThat(response.getItemId(), equalTo(i)); assertThat(response.getIndex(), equalTo("index")); - assertThat(response.getType(), equalTo("_doc")); assertThat(response.getId(), equalTo("id_" + i)); assertThat(response.getOpType(), equalTo(DocWriteRequest.OpType.INDEX)); if (response.getItemId() == rejectItem.id()) { @@ -336,7 +334,6 @@ public void onFailure(final Exception e) { assertThat(primaryResponse.getFailureMessage(), containsString("some kind of exception")); BulkItemResponse.Failure failure = primaryResponse.getFailure(); assertThat(failure.getIndex(), equalTo("index")); - assertThat(failure.getType(), equalTo("_doc")); assertThat(failure.getId(), equalTo("id")); assertThat(failure.getCause(), equalTo(err)); @@ -515,7 +512,6 @@ public void testUpdateRequestWithFailure() throws Exception { assertThat(primaryResponse.getFailureMessage(), containsString("I'm dead <(x.x)>")); BulkItemResponse.Failure failure = primaryResponse.getFailure(); assertThat(failure.getIndex(), equalTo("index")); - assertThat(failure.getType(), equalTo("_doc")); assertThat(failure.getId(), equalTo("id")); assertThat(failure.getCause(), equalTo(err)); assertThat(failure.getStatus(), equalTo(RestStatus.INTERNAL_SERVER_ERROR)); @@ -563,7 +559,6 @@ public void testUpdateRequestWithConflictFailure() throws Exception { assertThat(primaryResponse.getFailureMessage(), containsString("I'm conflicted <(;_;)>")); BulkItemResponse.Failure failure = primaryResponse.getFailure(); assertThat(failure.getIndex(), equalTo("index")); - assertThat(failure.getType(), equalTo("_doc")); assertThat(failure.getId(), equalTo("id")); assertThat(failure.getCause(), equalTo(err)); assertThat(failure.getStatus(), equalTo(RestStatus.CONFLICT)); @@ -692,7 +687,6 @@ public void testFailureDuringUpdateProcessing() throws Exception { assertThat(primaryResponse.getFailureMessage(), containsString("oops")); BulkItemResponse.Failure failure = primaryResponse.getFailure(); assertThat(failure.getIndex(), equalTo("index")); - assertThat(failure.getType(), equalTo("_doc")); assertThat(failure.getId(), equalTo("id")); assertThat(failure.getCause(), equalTo(err)); assertThat(failure.getStatus(), equalTo(RestStatus.INTERNAL_SERVER_ERROR)); @@ -744,8 +738,7 @@ public void testNoOpReplicationOnPrimaryDocumentFailure() throws Exception { DocWriteRequest.OpType.DELETE, DocWriteRequest.OpType.INDEX ), - new BulkItemResponse.Failure("index", "_doc", "1", - exception, 1L) + new BulkItemResponse.Failure("index", "1", exception, 1L) )); BulkItemRequest[] itemRequests = new BulkItemRequest[1]; itemRequests[0] = itemRequest; diff --git a/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java b/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java index 6b431ea42090a..363af3ea87f02 100644 --- a/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java +++ b/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java @@ -199,31 +199,26 @@ public void testBulk() throws Exception { assertThat(bulkResponse.getItems()[0].isFailed(), equalTo(false)); assertThat(bulkResponse.getItems()[0].getOpType(), equalTo(OpType.INDEX)); assertThat(bulkResponse.getItems()[0].getIndex(), equalTo(getConcreteIndexName())); - assertThat(bulkResponse.getItems()[0].getType(), equalTo("type1")); assertThat(bulkResponse.getItems()[0].getId(), equalTo("1")); assertThat(bulkResponse.getItems()[1].isFailed(), equalTo(false)); assertThat(bulkResponse.getItems()[1].getOpType(), equalTo(OpType.CREATE)); assertThat(bulkResponse.getItems()[1].getIndex(), equalTo(getConcreteIndexName())); - assertThat(bulkResponse.getItems()[1].getType(), equalTo("type1")); assertThat(bulkResponse.getItems()[1].getId(), equalTo("2")); assertThat(bulkResponse.getItems()[2].isFailed(), equalTo(false)); assertThat(bulkResponse.getItems()[2].getOpType(), equalTo(OpType.INDEX)); assertThat(bulkResponse.getItems()[2].getIndex(), equalTo(getConcreteIndexName())); - assertThat(bulkResponse.getItems()[2].getType(), equalTo("type1")); String generatedId3 = bulkResponse.getItems()[2].getId(); assertThat(bulkResponse.getItems()[3].isFailed(), equalTo(false)); assertThat(bulkResponse.getItems()[3].getOpType(), equalTo(OpType.DELETE)); assertThat(bulkResponse.getItems()[3].getIndex(), equalTo(getConcreteIndexName())); - assertThat(bulkResponse.getItems()[3].getType(), equalTo("type1")); assertThat(bulkResponse.getItems()[3].getId(), equalTo("1")); assertThat(bulkResponse.getItems()[4].isFailed(), equalTo(true)); assertThat(bulkResponse.getItems()[4].getOpType(), equalTo(OpType.INDEX)); assertThat(bulkResponse.getItems()[4].getIndex(), equalTo(getConcreteIndexName())); - assertThat(bulkResponse.getItems()[4].getType(), equalTo("type1")); waitForRelocation(ClusterHealthStatus.GREEN); RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().actionGet(); diff --git a/server/src/test/java/org/elasticsearch/index/reindex/BulkByScrollResponseTests.java b/server/src/test/java/org/elasticsearch/index/reindex/BulkByScrollResponseTests.java index 8791c11bf2745..726e15af4e8bc 100644 --- a/server/src/test/java/org/elasticsearch/index/reindex/BulkByScrollResponseTests.java +++ b/server/src/test/java/org/elasticsearch/index/reindex/BulkByScrollResponseTests.java @@ -62,7 +62,7 @@ public void testRountTrip() throws IOException { private List randomIndexingFailures() { return usually() ? emptyList() - : singletonList(new Failure(randomSimpleString(random()), randomSimpleString(random()), + : singletonList(new Failure(randomSimpleString(random()), randomSimpleString(random()), new IllegalArgumentException("test"))); } @@ -91,7 +91,6 @@ private void assertResponseEquals(BulkByScrollResponse expected, BulkByScrollRes Failure expectedFailure = expected.getBulkFailures().get(i); Failure actualFailure = actual.getBulkFailures().get(i); assertEquals(expectedFailure.getIndex(), actualFailure.getIndex()); - assertEquals(expectedFailure.getType(), actualFailure.getType()); assertEquals(expectedFailure.getId(), actualFailure.getId()); assertEquals(expectedFailure.getMessage(), actualFailure.getMessage()); assertEquals(expectedFailure.getStatus(), actualFailure.getStatus()); @@ -118,7 +117,6 @@ public static void assertEqualBulkResponse(BulkByScrollResponse expected, BulkBy Failure expectedFailure = expected.getBulkFailures().get(i); Failure actualFailure = actual.getBulkFailures().get(i); assertEquals(expectedFailure.getIndex(), actualFailure.getIndex()); - assertEquals(expectedFailure.getType(), actualFailure.getType()); assertEquals(expectedFailure.getId(), actualFailure.getId()); assertEquals(expectedFailure.getStatus(), actualFailure.getStatus()); } diff --git a/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java index ce708d47d1722..ec59f4c4c5a70 100644 --- a/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java @@ -637,7 +637,6 @@ public void testStrictAliasParsingInIndicesCreatedViaTemplates() throws Exceptio assertThat(response.hasFailures(), is(false)); assertThat(response.getItems()[0].isFailed(), equalTo(false)); assertThat(response.getItems()[0].getIndex(), equalTo("a2")); - assertThat(response.getItems()[0].getType(), equalTo("test")); assertThat(response.getItems()[0].getId(), equalTo("test")); assertThat(response.getItems()[0].getVersion(), equalTo(1L)); diff --git a/server/src/test/resources/org/elasticsearch/action/bulk/bulk-log.json b/server/src/test/resources/org/elasticsearch/action/bulk/bulk-log.json index 9c3663c3f63bc..05fccca8ca91d 100644 --- a/server/src/test/resources/org/elasticsearch/action/bulk/bulk-log.json +++ b/server/src/test/resources/org/elasticsearch/action/bulk/bulk-log.json @@ -1,24 +1,24 @@ -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} -{"index":{"_index":"logstash-2014.03.30","_type":"logs"}} +{"index":{"_index":"logstash-2014.03.30"}} {"message":"in24.inetnebr.com--[01/Aug2/1995:00:00:01-0400]\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"2001839","@version":"1","@timestamp":"2014-03-30T12:38:10.048Z","host":["romeo","in24.inetnebr.com"],"monthday":1,"month":8,"year":1995,"time":"00:00:01","tz":"-0400","request":"\"GET/shuttle/missions/sts-68/news/sts-68-mcc-05.txtHTTP/1.0\"","httpresponse":"200","size":1839,"rtime":"1995-08-01T00:00:01.000Z"} diff --git a/server/src/test/resources/org/elasticsearch/search/geo/gzippedmap.gz b/server/src/test/resources/org/elasticsearch/search/geo/gzippedmap.gz index f8894811a6c088ce2bc166d8252f09ac9390bff6..a2401171fab28754c2cfa872630214a4786456ea 100644 GIT binary patch literal 7710 zcmV+(9^v61iwFpxD2iPG17~_^aByX0ZDDW#on1+fq{nf+^H&V!Jl)8B(M_ARTZT5+ zCJ2KN34?$@3Nj5?5cuEyUSwosR%}_SKjF^Zo-r|3W_e;jiDn`|jO$pZw$fU%&eLJ-+h(FQ0$={s+mw z`V>FB|I0V{Ft}G&+IRe~KY#x1SKkb{Z~y++FY$lg|Mi={{QbZ2*#~U!&ELNG>g&(H z#TGw!_vxpfVigy>E7^^I{=+-pUsEi>$3FhG&pr^W_EL(QpA~^C&gDG6n&JR#sR2Si z9B{GJTD^YcGU38&@y*Tex{$|$DYqErf&(sNS0C5;c-QJv2)E~JE%;XSvnpV@^^$zQ zg^SU9SGRirF!fODJWG&!xYzC))|?*-9JcUwjWWPm&VbX;;#jY@m?j2XQb5;nU%iJP z>y_$zN)s*IHv$LU+nMzu4x5I#U~9Tw?A5n<5kX%o(dGH&76x4MHT5#_mjp1hR$SW= z<6dKSp@y|D>7cga=bP6s5cr&4KKtxDlIzD1`Hy~hpUBgzFI|b;*H@h93Xum;M|X81 zq2tgMwANdiuUX0PzFOygdB8=`Z74Tz z-ldc#r?}%Uu{yu_fPfJ+PqLlg7P#zPo7;j02VC}X z(bTwa0NF08)%5}-kR31z{^VBkz9COB!u!hK6TdR?uMdAfAXmuxXZOiEyw>8U?9M=x zzev^zXb%fXp}w}-eVG>tdb>oFY)ArJN-e6yhNuYMBn1B2@SLFKMYdxV$R3xL{F7y3 zPYc(6>I$4H8?6$sKnFmQ7$ACR{m4}Z?4o06tMFr}kQo@ElyfhS}@!WumkXF!d z^F89&)@|>mV3Y?YcT(1UD;L~V1#l2jb@R-6-O?ccOsJ_)0F|4?k*poJTA1#lw$ zraTxDv4iW(5EV5qa1aNR&Ff%&aI|mpvoPQe_Pv0uAO7LK9&c#am+gc2kq7>2$r{Sn3HgyzGF`ca8vy#h^9%>NK0 zwkP;y=JgCPn!Tngs@O)5ZL!@*T^Q#MmaeG}0Rtn@)6iYRfGc!_OykL}pyOr4r2&>< ziZ_$A!^EzBUvI$C!k8ZoKeEuG+$=ni(ghauk~_mhg>m3FFSHD}{qaAPsAjZBWLyk;2Jp@ySnxdaS zg}1oG01JlbSO;7N8|OVl&|vpL7nrpD7&UUPl@93i0(bq(FYa(q9US|zm=^!2T3bQlhqn@)!)AL!(2 zEaWvLQ4-L!32cDnO?B2bW6jStz2cueFrhuH3UklEFjw$ID+zu?uka6Qq0lykwB#Tu!vKSb{z z1be>g1zi370q?;R3uXh*w7lY$G3*$i$Ki2CePD`e2Vc_R+%@^20jT=Mhoxrn1Os<@ zX!BrT5qii+cnGDd0z@#f(lg=~{-qWgfU3bVc3#5cM#j=<_nNF-#;>_YMBPr3$ra(+?68fG{XUr@IrgBI^j1X zp@PeSAfw;m5_8KCF7wIL0IU&YZ&}I#*q8;e$Zb==78fg|0SKcC;@*t<0hpNl$O8bB zS1fT`b*0QR*m(&UaW;{p8=V0Vre2EU?^McldIj==_`C0MB}(+{E<$myc)$R3rTe_4 z1h^tuELn7daE#T~)V3_HT*337!leP1L`2_W7Y6|^&s!;AfGcG0r8w!56H&k%24I9P zjryLEZreOrB=wgF_aC;3h0X~mW{Bd7@xhg-k&OFG7|x@ey$ry%i9=zJ7s*p>hp*#E z@S7}BBRc}FI!0nQzU0wi8?;TRapPFF*OE8_0U=6u&yEYykg}wS*JohtH>Z7P52C@r zEf%iNKpDGbG-N?C!=#CzfDLlDO^nt7m|*z@OD7ctWPL;0j|e=#hKy$EC_(L_&5skd z2;t0e64Ml0(&cFs&%_uBcafA?M0S`hl zZjs9s=2v6zx`GI+ozfuGxP>kdX}s^%E=5cNXGJy&hco58NKpadE9EUGL%>wQD;7+f zM@|q3Z%8&VZ;{>{J>WtXdPoD1CSSN=7QitFS8m}_Ocux(*~!9~Os`h5P{t8~l6AzS zcS&ME?3BYSYhBVn7i1laMO&J(=`I7al31rHyG0~~6hZKBut?Pbz;Fu~V_l4|&sG_l zdb1$i(K?wRPiD!GLR-j0L|DTKEmotX$l{`AoIyYbu}XBmc|X%dtY=EJDJDjPVx?^< z{h)vWTbl8q4-8sc@!>cCJ=2-<5=q$r{^S-UqoAhy?U$aES`%)~D8-G6CLpV2=Ed@) zR?zhpS{KpJD6g@%^8Ah8uYitb_l;zyCB+E&JkEd%Bn7iC^@P}1v>>eLzNytR{+y-q zLI2L!{A9g2`7wnp&Nh`BOMh-~RwSS9Re@JV6mP}ok=b*_SbLDbf}WeM5-i(mk&4s& z#aTY&Jio#;vQ-ilfs1V`!K%}khAh4X18=-7LZC?Y4504YnpPp$a0x(qlu4QbTwmghhQG~R4FhRhg)C|n~YI#ZC{lq*T zf(0z*)oE3WNUphWmiVtEYbJXsm}}Y8{zxa`$Z^XTh&{>jCJzB(ZuYFz18-VoqgMM! zGHSkek^pt57dMkzRVyXSmgVr`Oc6hZzo3PeKCUu97JM?y?xC2bbmX(e4oe)bKDQXY z8F+njvd3znt$?VIaeZxhy_%1++!HS}OO_bwWT*uvnPDj}r{lJTCd#@5)T`JW^P5_Y zI?T75ZQ&>zqj-6Z*g#bq<#zS=7gu-%Yb3AvSsvkyyp@o7ipdDSJ0#POend-L39F7( zcq6_+e3vIHanaP^4Ia;P-=#*G;@K=otqWsO?OuvF)+-x%R}E;zzFb6+c}!8ZWuiA_ zHddj{<@`u_dbi1=s&FX)S9854f!EZmuGmK{Y^r1+i|~ASS0OC7oKMhVOz{lnu7O~s zgv}(<+Ro6@jS&J$sgxn}Y<_?>@tfyeWmmW3Sl)~ktWe!?6QG5OAybOO=%ScnfIe}R z8!gdQY=Q?(lv4i{Fi2bSc7(Oam>@kv&p6YbO0F~V(XA43U;%`|locEEVHQ9f7Z5zx=of5|Up>fgH%JOKLP~v&?oz^pWC}HDrXJA1 zj3}AP!i!4wk~0IzFcV6KGTIt%>}W3-f#@3ZT|-&Lj(OBGXTKHIr=Wllm))z`K+iR}YzkD7$6{2kg`zaaOb99_e5z&v zOPwnN@2j441b_kPGqvdaPzqG(E3M)g*)Ov&V|f}?&JXuGSgy+JdW=t-3)MzlwA=ql zn2}@@w)E@>pR<_3A`$}%tQ2jJmX(-rLQ`0}+GC=;Qgr_xj|xGvCHnFBsb1lrb6g(3 z4TyQ=2|m1wbnpu+taXb#;9Oc|xKsy`tvFkFIO7NnTP zaFE8XZF3;n0CP3gZVEmR^d(T8Stp-KaZ$*=tw_g!%NcIK)Xrl;&-|sgAfXoyfM;(7 zq&_PgPEssRq~a*{WkG8hl4rc2^xK;M;%IQ(&;f6Pb8nG$!clPUk>E_%FRWU&QQ!(E zz~VI{0hd__7lPZ|UMZ~Ij9aJW${k2fdkaQnL5#Cc2KliM3zBF^1U5ufb8NJ#J4z;a zB3`e)E72K|ZT) ztMp58X!2e z#%9Kx%$AgZ-AFT<7U`qNo1UP><`j;ex#hju=*AFbGu6LDsSkI);zT?s?qu|L3Wo%# zcB%P}7H{;HeaG!s>K?YV>afm0Tov-wh>LI`!}T&(R*lg;bW1@>Z(&uLKt^kcz0aF> zPh{~yy0_U3!^i}^jUqlf9s>?r_4}-_uek=Z`53B$@O8nhnXHy_rR16hwQim8L99SX2lUAn0>RJ$PG<*hmS_qM_0;76~uooH8A)$%A6}F^4o=h^6 z^FvAvT+6S@)6q&TlmfHFvTO7s@e%H`A}>k<&@gE)nFdKg9$IvyPlxF_g$YWOzwY;P3@zjN-~gxk=-@I%{Nm^#4v*2dH|`gOAL z6<^^&tvS?3oy{IBvAJRjpK7#I4T(dsRl`CXl0?g4^9!r0zLfhaMHMg(@>!XVb3J-? zhbwmLkMAQs!uU|UR}j&qzH6=l7kVbTGSh<~sL(AFIMc47W{X8i0+jU7J*Pu|IIX8x zN?KxwFf!Bk((i|}!%jz$osTw4X`2pJN9BiO7v}`4^LUT2cEwuw_xq+5IJ39)#Qoa* z3mUfF=IHo5{MWz=w&?(jYCk5ax6v&FnZ0k7DnY?Y+=4&4p4w(=)mvYJv)~s9`7LwTJy^T2GN^D{cjlt zO4KLzQbQYHoLGdbRR~laz{1K65??C0C+V>T82uK{u4jmYHlg4$hf-sg87czCYV}6k zwUQ+YM7SW$Qt+4ZS{%;RSl&P*22ftP_aUPI9Y8XFlK>vt__R|LWbigwe7zLd}oj$O2~8?{D!V_C}?B z7)Bm&ZFs-ijU{Zc#%pM{5X3U@2I&Jq6mH8$*vqgh<`K3levRpv$>LVJvrK{xTM2&4 z0_yOi9=3aq;9dwzQ+nyxkeO0@aflE=_p5+z)C&@hTyK;zNO^Q1y#XxDac(^XEJP;< z7&U4Vz3zkL!kFKf+?K-_4x0v2_{c;G!`z=o=p zn{_6ARPy;WnSGudKgzYArtTf*;`DW9?FDCj&|V@zdAoCC%{n*FttxA${u{jk%iV_2 zcFMXKAydB=wa559cYq3HLGI%eFn34K!+_ z)b>Xi3IrT_*c@QsH2Oj+KyrnZKyyI^Ism0vpi!!``C$Nd8V25v*==#ao$P!8VZXa? zwy}~mSuGS>0s1vuhx98S?!Rkr>*?1^05<`C9 zgcQqJp@Gus#+7{=2Qyey;$(>B^I@20Lp9Hbbe;|UJRKr>K9n>;W#`SPWLqNR{7dH! zII^sktHOh7U2E&B-we>POR8HlUnp~%?ZW}*)7HPJ#r2iqe+@en*1)&onmVU-@zQl+ zPcLxUZ&CQ5ZA@n~0ghPrN}TCI%A&HhX%%0B6s`%JGhTeg(+sz4+Ib8_u6vBCst92b zl$94I;X$?zP1|9_JUC&FOt=^R0g`N4TP^?uXb5=TqCb+rs|+Yaz;> z=_JyA^GSkkEO&)r+3~;7Yb@HP=Gc7YI4OcA+<>FpV*xgtpBi--u?sA2Z9Wv(rggw| zCb23o(fUlD9c+80LheEB61#V&Viza#O8({}dN7~O$~>OAc{UvTcozBRbCsnX$2`7J@>Ip%;l&3P>C`#Q z*CAK&WE)YHlWV4cKBK+(LOC+8%-s;Vgs4Atw&1N_Hm-@9@+X6`|OEH zEe5N@8MU^|=1${iHYh#c_R8$lpFfhP&3>q%vNG>lEok0)H>BvD^R~7j4s%vl_p7o~ zBG;Ln786s`*l4cwz0r~dx8-f&1rC3w&d2fUcNPo?g_DsH z7xULj)@Wq?^IlTfldiKh7S#cFvfq{3s2@FQigPxr?e$V28Ph`?#P2|%RV?8b8VZiC z2?Jby7Nu}78SIQkH`WVOlrkw8$BYHdE{PsF#sW+Ldr-8igpYW0*obg}k}daa*9&O+ z6;k0GHgJOa2* zF}b(X9d3NZ#<*WcmKdM6x)T2W(6#!Uo@>urMGcqYI4etDgyD-p(JYNPW|7P2Ju@e~ z#+>%a@^P$}w;yUzu!C){IJgh&S5ESqxMHopyIjwCRP1tAJ9GX6TxUP%b^Hrq=RY}i z_zPyIKZthr18bT2$8|aVoxHIBCe#3nEWy}msDVlu&DML(XzAgX#Alsyab9{-fp;ZI|o{?gWYZ_#P5(sQ1^Ac+3-K*@PHIB65w*G89fmFSsK z^pyp3LwqL4V~6K#?3HkT!f8s?xn+x;ZFmslze3j#-^b9todj0g!Z3?dEu{vH$=8 literal 7686 zcmV+h9{J%PiwFotUF}u^17~_^aByX0ZDDW#tzBKOY)5f@=T}_aXP=|~sP5|K&42^O z5D>;F2|^J96j?$xB90V<{NJ-yf7U)e;L)co460!!Q5bKKl3<@85mfxe)Il^;-9_5kKX_FYkU~ov&-dM{@!*{>`{qM1g3*P1A`al2CJ71qA=HO%P|H>aeBAM2lvzwpg zMwgvSY5u9iPFSRXVtm-?Vpdf@K5~h4;W_)_=HI%I`ht>540FLwm$0jk`}z2;>LrBh z^OX{O$>TF^WU16FzFz5K^xmm?4-iTXs`FVwdk^id-%RyR$oQtv2fprGpK$&^LP=5O~YKUl(Al{>dSnQc6=pAm*yXr z(CNgh)I85m8eu3UyJ8QrHC;9@1LYwSDXdg9{IE^Cb~Ca*{tbfx-K z%^N@_6@RL8ztrg>m^tJNop&M!oNP_mmWfsN1^8)I@Kk9rFbOlP1$53585x9*+H-Rz=t32r=Yl$(Fjr{1 z@y9+kI;`s#7gil+Ac-!kqNx!!&dL`S@y~$*>^5ui63Y5uNTP>Az$wg4sI}!eWJvF_ zj$^qf!G~pPAQA!kCBnwdBOK4C87D1UyN8IA77g=IeLv_Ju!l8{_$a5an6?|UK+BbL zFvo|Rh6!DQ*y$ov7%X8h*N<(Txwk<^C9#x|q_MAZL2FcS20_&M>+9wMrI@TU08Ifd zU#3<2zGAM|=drOs5tqw*6vg|llPW`@6kPAxL)v|KTK%a7$9g%?H8JZY7&8Z*vJCK0 z?V>T(#>X)7vUH@TzK)9O(%!KN20fXj=ggSP~f?`h*x=nAx%&lHGs(y>?GNXbh-JCNeVQh zHadl5LHJ?T!PmJCx@JQ&TnU&n-`9hq7h_CCv*hLvobCIlBmCsX5yB#?Y{RBC-gAVo zKkdpdngh{C2^SX#bWM3qb~cGkazo{e#P{$wtpLi16p@%kXLbj_Au*}PkLpuTLI6q|Dk zYl;=8nU8(F4C|A{IDHv6f~auCT%C;m^|C+OoG|FiST33zQGkO>y-ZRggUB$>8M}r~ zml=k6^A;JdpWEJ|bg~4WzliZ*K&RfW*XiiBAD(MvT6PdSADCk?hC`=@FoV% zolYE#nY7bQBAdm6@82Wr*t#>c%Yy5ilU!WjjQ0dHW)t<%;_vtLQRWNqG{=X&(Rug) zs+S-L&yTlHOIT7<&#^Xox;(WCV6U*ygzKu z7ZE}%FT4f1SgVz2Rh@c!${gfZHoc67#FZ{oy#BaBe@x*)&?Q{vUoos@lz?X!9SSt8KY|FW+I^fesiQK<@ z`l`rfm;<-`C2)h@<#OVr>E{Xf6|W?vM^F@{KfnB$P6MHe_lXasuJzv7^;iVe|}_1vf%8Dz6V({mRHM6l)ts5EvKCeV`%!s+2Qghdu%@O(sklIt)r5xzliF!G7ka1g$^?ZXc6i(7G`o5>0$ z^y57lAKU`s%bKH!jA?w~1O%IsOwX)+trT64*D}11?UJMs=x7en@F}krI&TF@`XO=C zaUgac*&POoXL09Y7z;AGuq*%GJtmmeoYEyDsf-M=%hwV|f}v3Rc<@}ZiG@bhG2<=5 zC7LPE;(hhz)?lE0^83wZ{8rPh{J3uKONFS2&FA8fqgyu1^|Y^x<^X228>*?ga5aQ1gei2w2vZ!#eMUx-^T{GbBFAT}?w9-r5;oUnoE4LsyGYe=2~VNNv+LP& zCoD!sHko;9H5&8q+8+s_+{!4m9YLp#xn(1)d~~=L#b`Qi9J9HtmhT`T^otEPxgedh zRWS178ko&aVt4jn8a#NuUYAhunrcp4kisx|A`HR;Wn5%yI}!@K$q;SUh=fFehVCoBcH;q) zgb>mT*%&U3*?3(2Ji|CNMS&qrmurT{=hD_FX%NDBfe+nR3IXbL@$guPfQIpX!QrHN zGik_ui9OZX7Vu!CB`xjcGHc5*__0D$R+iJC)VRf1ATl7Zn4sMJ1h=3_gAUJ>QnC00 z5+W!|YWV^BKp`v9)-(CY0)_B`WrdX(dGY80FSN2D(h2DthKsO(j`hcUrIRQtx6&)K znQ5Y`3&WB7BjQN*Bg%LeXM(LO5yREC&Z9he4-RXV*UNzzym4FBR3 zX*xg{u7ok_7W{E-%52$-1sV716oNE`B|!_xRR~bIEFixcyI71kO0b6F9p(D$L4dLl8!NfD3cfN!SF+hxJ@^)0zjPw1rlMQ^s zt(haam}n9bK6EjtSKJ*8p0I4IOS1-N&QXZMl96j%yPpL_+h}6NzU|wc@Ny4hk0^2%8f1-160%Lc0)m5$sjNLyyeUf_nj(bx%s|VROl{kA5}Y{KqTgq_+C*7 zW#is@x)XF4s7~$oU{m!2&BDsiiaWL6Lv!=yXB~4%o@G5?6%+c#Vv0xuRuaU-I-!xp zhL@P{JMcEiMwF>v1Q9(e{u?l#rp}5ffJm=2B^&G^6f0@@0=*W7M~Jgk)( zg%c~>bKH70Y*1(>O*r0H3uUKc8yo9$N&D7(oJd*R(8O>t(aKB>o@A!Fe0w@>o9VY) z5(CWSY335svG5evA=aBdx$fh`q&kQK7m{4DiENHUl@Pu&?2p$Az; z)AziJ%V9%+n{31v2VdKj<+ypO%LX6Mb6=Csp>wm{%K?-l9@zpm`+C{1w~l;RtUGRO zI*;|$vi>Lwf@b!UfY#8BrynU7 zA@|N#xOOvV|8o|br7=AG=Z8C!M*S6g!Ced9;73Z)KniM1q!ibl(NIo#R2A8T8#YE00SiNIx>9{R* zIZnchE?>Dpgqh6WP~4tW2BA;1w-;SwYWpQZO?IH7?fDU%hgB)_V?E})R|Hl% zq}$Qg>JNhdZKH!_+x%JZY(6p(|E+>raqE-Ler$Gwdg^L|U1z%Dq5+7Htq#3i z4$wi+O|h{I;5YWNGhMijVLzOb1z4V0g05$KDN|`;OQYOm}4bPK?7BP}bItk?khvJ$% zLl0xMnFlr9EOWhs2Yl37fBxAm?^7+>0IuJC(9pv|_;F$V5D|C=FeJ8_PhbNAw#%Ag z_5dt;b|)3tSO4=`Ea#PjTVY(tRMmbBOx)1KmL;NiBXII(hr8Jvutt>`}+|%g=5N5-{+zT<=O{ zAGXUMx8I-k^PhG=9yU~-_Gf-T+yC3=^051T-TK7@gSWecpb755A7YVUaNwyYjT3WY z!6x`(uaPdxR6A&%ap=k+4mu_aR?)8XmX~J0rk~NW>4!T%EQGlMfo1A?>K1{fysK-H z{&w^WPk>iuKS3~s;_e%Q4HY^&ZLSe0Q$&Ns0wX|X^UhSxj8!&n26}(=G5BN>4m?5L zQuS*lM|W|-nH|8m9*;Q?(_%2&7&K{E9w+mR@H=${^uG0yw>FFD*S)bjA;V9{Wy-}d zWeQJsgwV2|KEh{Nj&K-F2fp~Q$6K`Z7$7YZQ$`yIyk#esQz_W%QmtkOi>-liHR&jY z={~v9is2b7oBAzNRnQReGLECAzM|SrXEqHJJa5zFsTCs(tS~jYY@j+)N9#$oN&QQ&PJyelN`s7I@e$r3KsU*Q6%7KOVJUkbO62h6#4kpvhVl4;`QbOPs8y)_DHO9*69l2w- z*y0a|sX+GNma&HcbV_7EilBm@*WqkO`#!8Q^e4A!(@B=jXBP23#55h@os*#AWjrS#&cBrmVpnZ}0pt;Qs6GWTYCJ+2ALJyZ88$ zTm>p>IrfA{FdT)7TK15VM>-$8nkKhKw}CQlk}-j?vx1~bN%v5MN%iKY4+BX2@^zER z=?{|$pM=?%`z8&z^b(*bSGZ6a0|dlYDr+Z5eW1oUk&p_X>CYWmOW$mgAG{IHnj zi<_O6I(u)3PP)fCKQ*1FrWg;!&Y6|LX{E*#Oi-)C#!9Li#oNd@DM~N4?#y7Hy~D#? z=^wv-8xgM0xC{lm-PLc;H8f4JrU#&Gy9_njf(XfiCQ)0lCe&m%-pCw1QcQHx$O@Ts ze5a<9?)o|#UkqoGbmO>st4UM2pPRE6Iw z-+?n6ji3BhMgZc@#rp#ojNF>YAB)-Oa&SVyP+2?HIM;+q7zCH}H6)|Skm6*zU zUw8@+fnbFKtqLAyETL>zNJUGisf-~hBj_L&hj3TcCT7r~no{eBizet$c+&_#=`)X@ zLnBL@r8je)?fbA3yb*LTNS^A45Tg60(Fmsln87++iEYlIFt4w@CdMRf%Xr0_HIz=q ziCTDHg_0g)e+Z-@n@UbqS{F9R7>Ri{%R`%#NtH9_SjE~V_cStg6ciq4$*E<)NEcd{ z8)87FD{qs%`3jG^ieKMkX4VsT3E@5j%Xu#UX!yYCFoO>mj&M3`;dpw(={ShP=@Q4& zD$d4Vcn;1>=`weNoiheECnNpUm`@BgQCM)hcIsA&v)bQ=lpM)b(A!`l%B&5d?T@ztYR=XuTa zxCnb%)jhB*4>OWC+D{xO5$zF#P~Z1tr#Kn(MOKsbb2eeZ!JwlYTT@1Cqo{DO9^MJ0 zT6&j{f+Q*Y2|5-{%Y(3Wc@(O8cCB>6N*BWWK3gz$x|5wBb&9|F)vehQMHV!T4IcM6 z&L7aAe$?-N+CG2Wjjx3I8+*?;^?M|PAJBo2)YB>xp%eEct@ZGQm1;4|6sQ5?>crV~ zBPCk^8R&wSJ#!%rAbQ{!hiJ0FfwNL1u0HiTpuxd~Y@{tPV?@pHqB{q+N_N9_+qZB^ zhkVG4*0*Q9p3RIspFw*z)An>m?)l7JfpJgeQaKmaIHJ2w`=%TZNHL?(jEgb{%(O!7#zmGs1w*b)j*OHp&4i@m z^o0wc=Txg5UBbhx+84KS8BiJ%2$ea^;l5OAO$VFp6CIoG z9LI*xE$npEkc87Cpwc*|a=SoOa`7R<-_=f6S=Cbi468W#s|Zi8mZ zUA3zZXvlqQ>g)0J*t4NZLi^G?9GlaA)v<6>=pER&G$E>z4Gjr%))VcI>ANRgHQi2S zdIX5ue7($B^vcSwO%Sj_n9rq`L_%g~T)vn>tcO7Sg87V`@4Bp!pS?$KH4>jSB%d}o zpEpb&_Fo@x&%?%ae|{^>K*%}6jL4tAxI++VKa}03a4&oySg3pZmE}gdHF&FLQ$YCL z=z(^IbdreDXxg0%MviyL^stK7KC{5H*i|YgGsM>PaJccqw8D8S}t3OOj~Q64N_8KDBCQz_$zG)@a$H5d)tT28~)iXbzIi3 zpeP}g_aS?eY2;}g5S;R6ri7F=DthB|TiQLb?Z&I=A^f+2kbIhy5K?CXd374y+B8 zS#8IB93$(6*1`sonLjnKv&1qW=LzPxm`H}76w~dw2Oz#71&XtZ1x&rqY z6%Jx3dkTzqy=Bzd*&wau9fT}x6m6k8e;;Vi2p?Zt*lU%sj%hv9G5FzNzlWjHesrss z(yg(9&-uQ>Smi8@;=s$={O~7wB#zM%vvYoed^jTy4ozXW?Hg5W05!Pg%vsHrnHo7f z1>yq7vsvtx=IRqe0-`cm%e}Shqt5P&k8gpg+-i-F1ZtN1yn1M-Xp-$&HuN~XdY-O5%>Ld;9-ro(&vMzvKS+1@19zvtmv`QMcG}JM zwoE@tJN@qCTit+l{mw+wq5i&~6|OFN)?K|4syIg0L32CYabXMp95LpIUFR5C2IXV6 z9UDja35&jY(lHqb9>6JvVF;v6D}nI9f6%%J-`x0NCi3U6o}m)bFpsdX`R$G)R7Y3U zrV zSeQDuoxZb8ALioz^p=|j%RQakaBuqx)pU>*l4={S`pm4-8VBr?P9VXH-*S55F9*4u zi|ot=OXoO&%QVt)$u?qd2J?RY6w$%nk2=Voe{$;}p|SQs!t&gAkbw{t0QX0+A^ z5Xd@wd^iSW&qnU&(?GM=gf`*bapO6BrxT;EV;+!i_@% From f03a7400b6f38a216d9571ceaca0fcc05e10b527 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 24 Sep 2019 16:06:00 +0100 Subject: [PATCH 06/35] compilation; remove type from BulkResponse.Failure --- .../test/java/org/elasticsearch/client/BulkProcessorIT.java | 2 -- .../src/test/java/org/elasticsearch/client/CrudIT.java | 1 - .../index/reindex/AsyncBulkByScrollActionTests.java | 6 +++--- .../index/reindex/BulkIndexByScrollResponseTests.java | 2 +- .../xpack/security/authc/ExpiredApiKeysRemover.java | 4 ++-- .../xpack/security/authc/ExpiredTokenRemover.java | 4 ++-- .../xpack/watcher/actions/index/ExecutableIndexAction.java | 1 - .../xpack/watcher/actions/index/IndexActionTests.java | 2 +- 8 files changed, 9 insertions(+), 13 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java index 74c7e2dd813ad..bfa2e20e2b7f7 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java @@ -162,7 +162,6 @@ public void testBulkProcessorConcurrentRequests() throws Exception { for (BulkItemResponse bulkItemResponse : listener.bulkItems) { assertThat(bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false)); assertThat(bulkItemResponse.getIndex(), equalTo("test")); - assertThat(bulkItemResponse.getType(), equalTo("_doc")); //with concurrent requests > 1 we can't rely on the order of the bulk requests assertThat(Integer.valueOf(bulkItemResponse.getId()), both(greaterThan(0)).and(lessThanOrEqualTo(numDocs))); //we do want to check that we don't get duplicate ids back @@ -261,7 +260,6 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception Set readOnlyIds = new HashSet<>(); for (BulkItemResponse bulkItemResponse : listener.bulkItems) { assertThat(bulkItemResponse.getIndex(), either(equalTo("test")).or(equalTo("test-ro"))); - assertThat(bulkItemResponse.getType(), equalTo("_doc")); if (bulkItemResponse.getIndex().equals("test")) { assertThat(bulkItemResponse.isFailed(), equalTo(false)); //with concurrent requests > 1 we can't rely on the order of the bulk requests diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java index cb3ffa70096c2..e2010aaece66b 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java @@ -882,7 +882,6 @@ private void validateBulkResponses(int nbItems, boolean[] errors, BulkResponse b assertEquals(i, bulkItemResponse.getItemId()); assertEquals("index", bulkItemResponse.getIndex()); - assertEquals("_doc", bulkItemResponse.getType()); assertEquals(String.valueOf(i), bulkItemResponse.getId()); DocWriteRequest.OpType requestOpType = bulkRequest.requests().get(i).opType(); diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java index d4b154fb97d39..3a91aac0c6a3b 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java @@ -290,7 +290,7 @@ public void testBulkResponseSetsLotsOfStatus() throws Exception { if (rarely()) { versionConflicts++; responses[i] = new BulkItemResponse(i, randomFrom(DocWriteRequest.OpType.values()), - new Failure(shardId.getIndexName(), "type", "id" + i, + new Failure(shardId.getIndexName(), "id" + i, new VersionConflictEngineException(shardId, "id", "test"))); continue; } @@ -399,7 +399,7 @@ public void testSearchTimeoutsAbortRequest() throws Exception { * Mimicks bulk indexing failures. */ public void testBulkFailuresAbortRequest() throws Exception { - Failure failure = new Failure("index", "type", "id", new RuntimeException("test")); + Failure failure = new Failure("index", "id", new RuntimeException("test")); DummyAsyncBulkByScrollAction action = new DummyAsyncBulkByScrollAction(); BulkResponse bulkResponse = new BulkResponse(new BulkItemResponse[] {new BulkItemResponse(0, DocWriteRequest.OpType.CREATE, failure)}, randomLong()); @@ -902,7 +902,7 @@ void doExecute(ActionType action, Request request, ActionListener bulkFailures = frequently() ? emptyList() - : IntStream.range(0, between(1, 3)).mapToObj(j -> new BulkItemResponse.Failure("idx", "type", "id", new Exception())) + : IntStream.range(0, between(1, 3)).mapToObj(j -> new BulkItemResponse.Failure("idx", "id", new Exception())) .collect(Collectors.toList()); allBulkFailures.addAll(bulkFailures); List searchFailures = frequently() ? emptyList() diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredApiKeysRemover.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredApiKeysRemover.java index 755224671e1e4..fc92430f56df6 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredApiKeysRemover.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredApiKeysRemover.java @@ -83,8 +83,8 @@ private void debugDbqResponse(BulkByScrollResponse response) { logger.debug("delete by query of api keys finished with [{}] deletions, [{}] bulk failures, [{}] search failures", response.getDeleted(), response.getBulkFailures().size(), response.getSearchFailures().size()); for (BulkItemResponse.Failure failure : response.getBulkFailures()) { - logger.debug(new ParameterizedMessage("deletion failed for index [{}], type [{}], id [{}]", - failure.getIndex(), failure.getType(), failure.getId()), failure.getCause()); + logger.debug(new ParameterizedMessage("deletion failed for index [{}], id [{}]", + failure.getIndex(), failure.getId()), failure.getCause()); } for (ScrollableHitSource.SearchFailure failure : response.getSearchFailures()) { logger.debug(new ParameterizedMessage("search failed for index [{}], shard [{}] on node [{}]", diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java index 23e7bb2fe0fe5..78ac4e3745308 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ExpiredTokenRemover.java @@ -109,8 +109,8 @@ private void debugDbqResponse(BulkByScrollResponse response) { logger.debug("delete by query of tokens finished with [{}] deletions, [{}] bulk failures, [{}] search failures", response.getDeleted(), response.getBulkFailures().size(), response.getSearchFailures().size()); for (BulkItemResponse.Failure failure : response.getBulkFailures()) { - logger.debug(new ParameterizedMessage("deletion failed for index [{}], type [{}], id [{}]", - failure.getIndex(), failure.getType(), failure.getId()), failure.getCause()); + logger.debug(new ParameterizedMessage("deletion failed for index [{}], id [{}]", + failure.getIndex(), failure.getId()), failure.getCause()); } for (ScrollableHitSource.SearchFailure failure : response.getSearchFailures()) { logger.debug(new ParameterizedMessage("search failed for index [{}], shard [{}] on node [{}]", diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java index 82ac6f8d6d7f5..ee299d05b09b0 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java @@ -201,7 +201,6 @@ private static void itemResponseToXContent(XContentBuilder builder, BulkItemResp .field("failed", item.isFailed()) .field("message", item.getFailureMessage()) .field("id", item.getId()) - .field("type", item.getType()) .field("index", item.getIndex()) .endObject(); } else { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java index 4e7fb4347433b..6edfdf221499c 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java @@ -352,7 +352,7 @@ public void testFailureResult() throws Exception { ArgumentCaptor captor = ArgumentCaptor.forClass(BulkRequest.class); PlainActionFuture listener = PlainActionFuture.newFuture(); - BulkItemResponse.Failure failure = new BulkItemResponse.Failure("test-index", "test-type", "anything", + BulkItemResponse.Failure failure = new BulkItemResponse.Failure("test-index", "anything", new ElasticsearchException("anything")); BulkItemResponse firstResponse = new BulkItemResponse(0, DocWriteRequest.OpType.INDEX, failure); BulkItemResponse secondResponse; From e8d9158f65332d2aa39862f7ea0f18fb8a77968a Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 25 Sep 2019 11:25:38 +0100 Subject: [PATCH 07/35] tests --- .../test/repository_gcs/10_repository.yml | 7 ----- .../action/bulk/BulkRequestParser.java | 1 - .../test/monitoring/bulk/10_basic.yml | 28 +++++++++---------- .../test/monitoring/bulk/20_privileges.yml | 10 +++---- .../test/rollup/rollup_search.yml | 6 ---- .../resources/rest-api-spec/test/sql/sql.yml | 3 -- .../rest-api-spec/test/sql/translate.yml | 1 - 7 files changed, 19 insertions(+), 37 deletions(-) diff --git a/plugins/repository-gcs/qa/google-cloud-storage/src/test/resources/rest-api-spec/test/repository_gcs/10_repository.yml b/plugins/repository-gcs/qa/google-cloud-storage/src/test/resources/rest-api-spec/test/repository_gcs/10_repository.yml index 553b6a3e14e50..154a6b52c156e 100644 --- a/plugins/repository-gcs/qa/google-cloud-storage/src/test/resources/rest-api-spec/test/repository_gcs/10_repository.yml +++ b/plugins/repository-gcs/qa/google-cloud-storage/src/test/resources/rest-api-spec/test/repository_gcs/10_repository.yml @@ -48,17 +48,14 @@ setup: body: - index: _index: docs - _type: doc _id: 1 - snapshot: one - index: _index: docs - _type: doc _id: 2 - snapshot: one - index: _index: docs - _type: doc _id: 3 - snapshot: one @@ -96,22 +93,18 @@ setup: body: - index: _index: docs - _type: doc _id: 4 - snapshot: two - index: _index: docs - _type: doc _id: 5 - snapshot: two - index: _index: docs - _type: doc _id: 6 - snapshot: two - index: _index: docs - _type: doc _id: 7 - snapshot: two diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java index cba2302e85ce4..d01b6e3a1509e 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java @@ -117,7 +117,6 @@ public void parse( int line = 0; int from = 0; byte marker = xContent.streamSeparator(); - boolean typesDeprecationLogged = false; while (true) { int nextMarker = findNextMarker(marker, from, data); if (nextMarker == -1) { diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml index ce4751d690d80..ed0e8234dfc40 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml @@ -11,22 +11,22 @@ system_api_version: "6" interval: "10s" body: - - index: - _type: test_type + - index: {} - avg-cpu: user: 13.26 nice: 0.17 system: 1.51 iowait: 0.85 idle: 84.20 - - index: - _type: test_type + type: test_type + - index: {} - avg-cpu: user: 13.23 nice: 0.17 system: 1.51 iowait: 0.85 idle: 84.24 + type: test_type - is_false: errors @@ -50,11 +50,11 @@ body: - '{"index": {}}' - '{"field_1": "value_1"}' - - '{"index": {"_type": "custom_type"}}' + - '{"index": {}}' - '{"field_1": "value_2"}' - '{"index": {}}' - '{"field_1": "value_3"}' - - '{"index": {"_index": "_data", "_type": "kibana"}}' + - '{"index": {"_index": "_data"}}' - '{"field_1": "value_4"}' - is_false: errors @@ -99,11 +99,11 @@ body: - '{"index": {}}' - '{"field_1": "value_1"}' - - '{"index": {"_type": "custom_type"}}' + - '{"index": {}}' - '{"field_1": "value_2"}' - '{"index": {}}' - '{"field_1": "value_3"}' - - '{"index": {"_index": "_data", "_type": "kibana"}}' + - '{"index": {"_index": "_data"}}' - '{"field_1": "value_4"}' - is_false: errors @@ -177,16 +177,16 @@ system_api_version: "6" interval: "5s" body: - - index: - _type: metric_beat + - index: {} - modules: nginx: true mysql: false - - index: - _type: file_beat + type: metric_beat + - index: {} - file: path: /var/log/dmesg size: 31kb + type: file_beat - is_false: errors @@ -210,8 +210,8 @@ system_api_version: "6" interval: "5s" body: - - index: - _type: file_beat + - index: {} - file: path: /var/log/auth.log size: 5kb + type: file_beat diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml index 437ce21d0c823..3f57cd97f22fd 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml @@ -87,15 +87,15 @@ teardown: system_api_version: "6" interval: "10s" body: - - index: - _type: logstash_metric + - index: {} - metric: queue: 10 + type: logstash_metric - index: _index: _data - _type: logstash_info - info: license: basic + type: logstash_info - is_false: errors - do: @@ -125,10 +125,10 @@ teardown: system_api_version: "6" interval: "10s" body: - - index: - _type: logstash_metric + - index: {} - metric: queue: 10 + type: logstash_metric - match: { "error.type": "security_exception" } - match: { "error.reason": "action [cluster:admin/xpack/monitoring/bulk] is unauthorized for user [unknown_agent]" } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/rollup/rollup_search.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/rollup/rollup_search.yml index ca04327eab729..8da1c1800a7e8 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/rollup/rollup_search.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/rollup/rollup_search.yml @@ -965,7 +965,6 @@ setup: body: - index: _index: "tz_rollup" - _type: "_doc" - timestamp.date_histogram.timestamp: 1531221000000 timestamp.date_histogram.interval: "5m" timestamp.date_histogram.time_zone: "America/Edmonton" @@ -978,7 +977,6 @@ setup: - index: _index: "tz_rollup" - _type: "_doc" - timestamp.date_histogram.timestamp: 1531221300000 timestamp.date_histogram.interval: "5m" timestamp.date_histogram.time_zone: "America/Edmonton" @@ -991,7 +989,6 @@ setup: - index: _index: "tz_rollup" - _type: "_doc" - timestamp.date_histogram.timestamp: 1531221600000 timestamp.date_histogram.interval: "5m" timestamp.date_histogram.time_zone: "America/Edmonton" @@ -1118,7 +1115,6 @@ setup: body: - index: _index: "tz_rollup" - _type: "_doc" - timestamp.date_histogram.timestamp: 1531221000000 timestamp.date_histogram.interval: "5m" timestamp.date_histogram.time_zone: "Canada/Mountain" @@ -1131,7 +1127,6 @@ setup: - index: _index: "tz_rollup" - _type: "_doc" - timestamp.date_histogram.timestamp: 1531221300000 timestamp.date_histogram.interval: "5m" timestamp.date_histogram.time_zone: "Canada/Mountain" @@ -1144,7 +1139,6 @@ setup: - index: _index: "tz_rollup" - _type: "_doc" - timestamp.date_histogram.timestamp: 1531221600000 timestamp.date_histogram.interval: "5m" timestamp.date_histogram.time_zone: "Canada/Mountain" diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/sql/sql.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/sql/sql.yml index 9ac15b309b161..af45542eefb11 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/sql/sql.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/sql/sql.yml @@ -6,19 +6,16 @@ setup: body: - index: _index: test - _type: doc _id: 1 - str: test1 int: 1 - index: _index: test - _type: doc _id: 2 - str: test2 int: 2 - index: _index: test - _type: doc _id: 3 - str: test3 int: 3 diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/sql/translate.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/sql/translate.yml index 02926f469ff7c..3e61e2ed0e9eb 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/sql/translate.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/sql/translate.yml @@ -6,7 +6,6 @@ body: - index: _index: test - _type: doc _id: 1 - str: test1 int: 1 From daee751cb958a6782cfef169a4268ed9080febef Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 25 Sep 2019 15:15:19 +0100 Subject: [PATCH 08/35] bulk monitoring --- .../action/bulk/BulkRequest.java | 5 +++- .../action/bulk/BulkRequestParser.java | 24 ++++++++++------ .../action/bulk/BulkRequestParserTests.java | 26 +++++++++++++---- .../action/MonitoringBulkRequest.java | 6 ++-- .../test/monitoring/bulk/10_basic.yml | 28 +++++++++---------- .../test/monitoring/bulk/20_privileges.yml | 10 +++---- 6 files changed, 63 insertions(+), 36 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index eb7c6ee3bea1a..5646a47937209 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -27,6 +27,7 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.WriteRequest; +import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.action.support.replication.ReplicationRequest; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.common.Nullable; @@ -37,6 +38,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -239,6 +241,7 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, public BulkRequest add(BytesReference data, @Nullable String defaultIndex, boolean allowExplicitIndex, XContentType xContentType) throws IOException { return add(data, defaultIndex, null, null, null, allowExplicitIndex, xContentType); + } public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @@ -248,7 +251,7 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, String routing = valueOrDefault(defaultRouting, globalRouting); String pipeline = valueOrDefault(defaultPipeline, globalPipeline); new BulkRequestParser(true).parse(data, defaultIndex, routing, defaultFetchSourceContext, pipeline, - allowExplicitIndex, xContentType, this::internalAdd, this::internalAdd, this::add); + allowExplicitIndex, xContentType, (indexRequest, type) -> internalAdd(indexRequest), this::internalAdd, this::add); return this; } diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java index d01b6e3a1509e..eb37023a950f7 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.io.InputStream; +import java.util.function.BiConsumer; import java.util.function.Consumer; import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_PRIMARY_TERM; @@ -63,14 +64,14 @@ public final class BulkRequestParser { private static final ParseField IF_SEQ_NO = new ParseField("if_seq_no"); private static final ParseField IF_PRIMARY_TERM = new ParseField("if_primary_term"); - private final boolean warnOnTypeUsage; + private final boolean errorOnType; /** * Create a new parser. - * @param warnOnTypeUsage whether it warns upon types being explicitly specified + * @param errorOnType whether to allow _type information in the index line; used by BulkMonitoring */ - public BulkRequestParser(boolean warnOnTypeUsage) { - this.warnOnTypeUsage = warnOnTypeUsage; + public BulkRequestParser(boolean errorOnType) { + this.errorOnType = errorOnType; } private static int findNextMarker(byte marker, int from, BytesReference data) { @@ -110,7 +111,7 @@ public void parse( @Nullable String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable String defaultPipeline, boolean allowExplicitIndex, XContentType xContentType, - Consumer indexRequestConsumer, + BiConsumer indexRequestConsumer, Consumer updateRequestConsumer, Consumer deleteRequestConsumer) throws IOException { XContent xContent = xContentType.xContent(); @@ -150,6 +151,7 @@ public void parse( String action = parser.currentName(); String index = defaultIndex; + String type = null; String id = null; String routing = defaultRouting; FetchSourceContext fetchSourceContext = defaultFetchSourceContext; @@ -176,6 +178,12 @@ public void parse( throw new IllegalArgumentException("explicit index in bulk is not allowed"); } index = parser.text(); + } else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) { + if (errorOnType) { + throw new IllegalArgumentException("Action/metadata line [" + line + "] contains an unknown parameter [" + + currentFieldName + "]"); + } + type = parser.text(); } else if (ID.match(currentFieldName, parser.getDeprecationHandler())) { id = parser.text(); } else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) { @@ -233,19 +241,19 @@ public void parse( indexRequestConsumer.accept(new IndexRequest(index).id(id).routing(routing) .version(version).versionType(versionType) .setPipeline(pipeline).setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm) - .source(sliceTrimmingCarriageReturn(data, from, nextMarker,xContentType), xContentType)); + .source(sliceTrimmingCarriageReturn(data, from, nextMarker,xContentType), xContentType), type); } else { indexRequestConsumer.accept(new IndexRequest(index).id(id).routing(routing) .version(version).versionType(versionType) .create("create".equals(opType)).setPipeline(pipeline) .setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm) - .source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)); + .source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType), type); } } else if ("create".equals(action)) { indexRequestConsumer.accept(new IndexRequest(index).id(id).routing(routing) .version(version).versionType(versionType) .create(true).setPipeline(pipeline).setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm) - .source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)); + .source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType), type); } else if ("update".equals(action)) { if (version != Versions.MATCH_ANY || versionType != VersionType.INTERNAL) { throw new IllegalArgumentException("Update requests do not support versioning. " + diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java index 584c2f5da9e7c..e9e7fd0ecf3c3 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java @@ -33,7 +33,7 @@ public void testIndexRequest() throws IOException { BulkRequestParser parser = new BulkRequestParser(randomBoolean()); final AtomicBoolean parsed = new AtomicBoolean(); parser.parse(request, "foo", null, null, null, false, XContentType.JSON, - indexRequest -> { + (indexRequest, type) -> { assertFalse(parsed.get()); assertEquals("foo", indexRequest.index()); assertEquals("bar", indexRequest.id()); @@ -48,7 +48,7 @@ public void testDeleteRequest() throws IOException { BulkRequestParser parser = new BulkRequestParser(randomBoolean()); final AtomicBoolean parsed = new AtomicBoolean(); parser.parse(request, "foo", null, null, null, false, XContentType.JSON, - req -> fail(), req -> fail(), + (req, type) -> fail(), req -> fail(), deleteRequest -> { assertFalse(parsed.get()); assertEquals("foo", deleteRequest.index()); @@ -63,7 +63,7 @@ public void testUpdateRequest() throws IOException { BulkRequestParser parser = new BulkRequestParser(randomBoolean()); final AtomicBoolean parsed = new AtomicBoolean(); parser.parse(request, "foo", null, null, null, false, XContentType.JSON, - req -> fail(), + (req, type) -> fail(), updateRequest -> { assertFalse(parsed.get()); assertEquals("foo", updateRequest.index()); @@ -79,7 +79,7 @@ public void testBarfOnLackOfTrailingNewline() throws IOException { BulkRequestParser parser = new BulkRequestParser(randomBoolean()); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> parser.parse(request, "foo", null, null, null, false, XContentType.JSON, - indexRequest -> fail(), req -> fail(), req -> fail())); + (req, type) -> fail(), req -> fail(), req -> fail())); assertEquals("The bulk request must be terminated by a newline [\\n]", e.getMessage()); } @@ -89,8 +89,24 @@ public void testFailOnExplicitIndex() throws IOException { IllegalArgumentException ex = expectThrows(IllegalArgumentException.class, () -> parser.parse(request, null, null, null, null, false, XContentType.JSON, - req -> fail(), req -> fail(), req -> fail())); + (req, type) -> fail(), req -> fail(), req -> fail())); assertEquals("explicit index in bulk is not allowed", ex.getMessage()); } + public void testTypesStillParsedForBulkMonitoring() throws IOException { + BytesArray request = new BytesArray("{ \"index\":{ \"_type\": \"quux\", \"_id\": \"bar\" } }\n{}\n"); + BulkRequestParser parser = new BulkRequestParser(true); + final AtomicBoolean parsed = new AtomicBoolean(); + parser.parse(request, "foo", null, null, null, false, XContentType.JSON, + (indexRequest, type) -> { + assertFalse(parsed.get()); + assertEquals("foo", indexRequest.index()); + assertEquals("bar", indexRequest.id()); + assertEquals("quux", type); + parsed.set(true); + }, + req -> fail(), req -> fail()); + assertTrue(parsed.get()); + } + } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java index 5c1d700343fc8..9645a1817f403 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java @@ -80,7 +80,7 @@ public MonitoringBulkRequest add(final MonitoredSystem system, // MonitoringBulkRequest accepts a body request that has the same format as the BulkRequest new BulkRequestParser(false).parse(content, null, null, null, null, true, xContentType, - indexRequest -> { + (indexRequest, type) -> { // we no longer accept non-timestamped indexes from Kibana, LS, or Beats because we do not use the data // and it was duplicated anyway; by simply dropping it, we allow BWC for older clients that still send it if (MonitoringIndex.from(indexRequest.index()) != MonitoringIndex.TIMESTAMPED) { @@ -89,11 +89,11 @@ public MonitoringBulkRequest add(final MonitoredSystem system, final BytesReference source = indexRequest.source(); if (source.length() == 0) { throw new IllegalArgumentException("source is missing for monitoring document [" - + indexRequest.index() + "][" + indexRequest.type() + "][" + indexRequest.id() + "]"); + + indexRequest.index() + "][" + type + "][" + indexRequest.id() + "]"); } // builds a new monitoring document based on the index request - add(new MonitoringBulkDoc(system, indexRequest.type(), indexRequest.id(), timestamp, intervalMillis, source, + add(new MonitoringBulkDoc(system, type, indexRequest.id(), timestamp, intervalMillis, source, xContentType)); }, updateRequest -> { throw new IllegalArgumentException("monitoring bulk requests should only contain index requests"); }, diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml index ed0e8234dfc40..ce4751d690d80 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/10_basic.yml @@ -11,22 +11,22 @@ system_api_version: "6" interval: "10s" body: - - index: {} + - index: + _type: test_type - avg-cpu: user: 13.26 nice: 0.17 system: 1.51 iowait: 0.85 idle: 84.20 - type: test_type - - index: {} + - index: + _type: test_type - avg-cpu: user: 13.23 nice: 0.17 system: 1.51 iowait: 0.85 idle: 84.24 - type: test_type - is_false: errors @@ -50,11 +50,11 @@ body: - '{"index": {}}' - '{"field_1": "value_1"}' - - '{"index": {}}' + - '{"index": {"_type": "custom_type"}}' - '{"field_1": "value_2"}' - '{"index": {}}' - '{"field_1": "value_3"}' - - '{"index": {"_index": "_data"}}' + - '{"index": {"_index": "_data", "_type": "kibana"}}' - '{"field_1": "value_4"}' - is_false: errors @@ -99,11 +99,11 @@ body: - '{"index": {}}' - '{"field_1": "value_1"}' - - '{"index": {}}' + - '{"index": {"_type": "custom_type"}}' - '{"field_1": "value_2"}' - '{"index": {}}' - '{"field_1": "value_3"}' - - '{"index": {"_index": "_data"}}' + - '{"index": {"_index": "_data", "_type": "kibana"}}' - '{"field_1": "value_4"}' - is_false: errors @@ -177,16 +177,16 @@ system_api_version: "6" interval: "5s" body: - - index: {} + - index: + _type: metric_beat - modules: nginx: true mysql: false - type: metric_beat - - index: {} + - index: + _type: file_beat - file: path: /var/log/dmesg size: 31kb - type: file_beat - is_false: errors @@ -210,8 +210,8 @@ system_api_version: "6" interval: "5s" body: - - index: {} + - index: + _type: file_beat - file: path: /var/log/auth.log size: 5kb - type: file_beat diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml index 3f57cd97f22fd..437ce21d0c823 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/monitoring/bulk/20_privileges.yml @@ -87,15 +87,15 @@ teardown: system_api_version: "6" interval: "10s" body: - - index: {} + - index: + _type: logstash_metric - metric: queue: 10 - type: logstash_metric - index: _index: _data + _type: logstash_info - info: license: basic - type: logstash_info - is_false: errors - do: @@ -125,10 +125,10 @@ teardown: system_api_version: "6" interval: "10s" body: - - index: {} + - index: + _type: logstash_metric - metric: queue: 10 - type: logstash_metric - match: { "error.type": "security_exception" } - match: { "error.reason": "action [cluster:admin/xpack/monitoring/bulk] is unauthorized for user [unknown_agent]" } From 842ecfdf56ff81c3d05d83fe8a5084d2137c719c Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 25 Sep 2019 15:42:28 +0100 Subject: [PATCH 09/35] imports --- .../main/java/org/elasticsearch/action/bulk/BulkRequest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index 5646a47937209..9484e1582d93c 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -27,7 +27,6 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.action.support.replication.ReplicationRequest; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.common.Nullable; @@ -38,7 +37,6 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; From 45c6f5e24982dcd431019cdc970c4200aab9a975 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 25 Sep 2019 16:13:47 +0100 Subject: [PATCH 10/35] bulk tests --- .../xpack/monitoring/action/MonitoringBulkRequestTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java index 0a82faa9fe066..e14ef17153752 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java @@ -92,6 +92,8 @@ public void testAddRequestContent() throws IOException { builder.field("_index", ""); } + builder.field("_type", "_doc"); + if (randomBoolean()) { ids[i] = randomAlphaOfLength(10); builder.field("_id", ids[i]); @@ -153,6 +155,7 @@ public void testAddRequestContentWithEmptySource() throws IOException { builder.startObject("index"); { builder.field("_index", ""); + builder.field("_type", "_doc"); builder.field("_id", String.valueOf(i)); } builder.endObject(); From 100019de02ce4690e6b301111f95e29b3e0f5883 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 25 Sep 2019 16:40:15 +0100 Subject: [PATCH 11/35] tests --- .../resources/rest-api-spec/test/update_by_query/10_basic.yml | 1 - .../org/elasticsearch/action/bulk/BulkRequestParserTests.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml index 2a3696a4005c7..cf01efa98b418 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml @@ -144,7 +144,6 @@ - match: {version_conflicts: 1} - match: {batches: 1} - match: {failures.0.index: test} - - match: {failures.0.type: _doc} - match: {failures.0.id: "1"} - match: {failures.0.status: 409} - match: {failures.0.cause.type: version_conflict_engine_exception} diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java index e9e7fd0ecf3c3..1ddeecef7154d 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestParserTests.java @@ -95,7 +95,7 @@ public void testFailOnExplicitIndex() throws IOException { public void testTypesStillParsedForBulkMonitoring() throws IOException { BytesArray request = new BytesArray("{ \"index\":{ \"_type\": \"quux\", \"_id\": \"bar\" } }\n{}\n"); - BulkRequestParser parser = new BulkRequestParser(true); + BulkRequestParser parser = new BulkRequestParser(false); final AtomicBoolean parsed = new AtomicBoolean(); parser.parse(request, "foo", null, null, null, false, XContentType.JSON, (indexRequest, type) -> { From fdabe486f9b0fde1635f0320255021dbf7414b49 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 25 Sep 2019 16:41:26 +0100 Subject: [PATCH 12/35] monitoring again --- .../xpack/monitoring/integration/MonitoringIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index 6bcc3c8c09bf0..223f1e106e334 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -105,11 +105,11 @@ protected Collection> getPlugins() { } private String createBulkEntity() { - return "{\"index\":{}}\n" + + return "{\"index\":{\"_type\":\"monitoring_data_type\"}}\n" + "{\"foo\":{\"bar\":0}}\n" + - "{\"index\":{}}\n" + + "{\"index\":{\"_type\":\"monitoring_data_type\"}}\n" + "{\"foo\":{\"bar\":1}}\n" + - "{\"index\":{}}\n" + + "{\"index\":{\"_type\":\"monitoring_data_type\"}}\n" + "{\"foo\":{\"bar\":2}}\n" + "\n"; } From 9779d9bbf649cf54a23d0f1f3aa83709ad22442f Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 25 Sep 2019 17:17:31 +0100 Subject: [PATCH 13/35] sake --- .../resources/rest-api-spec/test/update_by_query/10_basic.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml index cf01efa98b418..1aaf664782101 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml @@ -104,7 +104,6 @@ - match: {version_conflicts: 1} - match: {batches: 1} - match: {failures.0.index: test} - - match: {failures.0.type: _doc} - match: {failures.0.id: "1"} - match: {failures.0.status: 409} - match: {failures.0.cause.type: version_conflict_engine_exception} From 4345c6af75d7b8684cfbe372b6e0d4bc09766596 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 26 Sep 2019 09:07:30 +0100 Subject: [PATCH 14/35] yaml test --- .../resources/rest-api-spec/test/delete_by_query/10_basic.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml b/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml index 1763baebe0277..d36511f3a1690 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml @@ -124,7 +124,6 @@ - match: {version_conflicts: 1} - match: {batches: 1} - match: {failures.0.index: test} - - match: {failures.0.type: _doc} - match: {failures.0.id: "1"} - match: {failures.0.status: 409} - match: {failures.0.cause.type: version_conflict_engine_exception} @@ -177,7 +176,6 @@ - match: {version_conflicts: 1} - match: {batches: 1} - match: {failures.0.index: test} - - match: {failures.0.type: _doc} - match: {failures.0.id: "1"} - match: {failures.0.status: 409} - match: {failures.0.cause.type: version_conflict_engine_exception} From 946c3136772f0b9b38db4cf706fd3e36e9b18888 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 26 Sep 2019 09:23:05 +0100 Subject: [PATCH 15/35] assertions --- .../java/org/elasticsearch/action/bulk/BulkItemResponse.java | 2 +- .../org/elasticsearch/action/bulk/BulkRequestParser.java | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index f443102a8bf92..c948aa64fd7f7 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -230,7 +230,7 @@ public Failure(StreamInput in) throws IOException { index = in.readString(); if (in.getVersion().before(Version.V_8_0_0)) { String type = in.readString(); - assert MapperService.SINGLE_MAPPING_NAME.equals(type); + assert type == null || MapperService.SINGLE_MAPPING_NAME.equals(type); } id = in.readOptionalString(); cause = in.readException(); diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java index eb37023a950f7..d51d2ba3f2812 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java @@ -19,14 +19,12 @@ package org.elasticsearch.action.bulk; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.bytes.BytesReference; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -49,8 +47,6 @@ */ public final class BulkRequestParser { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(BulkRequestParser.class)); - private static final ParseField INDEX = new ParseField("_index"); private static final ParseField TYPE = new ParseField("_type"); private static final ParseField ID = new ParseField("_id"); @@ -64,6 +60,7 @@ public final class BulkRequestParser { private static final ParseField IF_SEQ_NO = new ParseField("if_seq_no"); private static final ParseField IF_PRIMARY_TERM = new ParseField("if_primary_term"); + // TODO: Remove this parameter once the BulkMonitoring endpoint has been removed private final boolean errorOnType; /** From 5c2950fa191d54ffe5ada116bdc193c82909d341 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 26 Sep 2019 10:29:41 +0100 Subject: [PATCH 16/35] yaml test --- .../test/repository_s3/20_repository_permanent_credentials.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/repository-s3/src/test/resources/rest-api-spec/test/repository_s3/20_repository_permanent_credentials.yml b/plugins/repository-s3/src/test/resources/rest-api-spec/test/repository_s3/20_repository_permanent_credentials.yml index 57b2e42bb2503..eaf0c766464d4 100644 --- a/plugins/repository-s3/src/test/resources/rest-api-spec/test/repository_s3/20_repository_permanent_credentials.yml +++ b/plugins/repository-s3/src/test/resources/rest-api-spec/test/repository_s3/20_repository_permanent_credentials.yml @@ -133,17 +133,14 @@ setup: body: - index: _index: docs - _type: doc _id: 1 - snapshot: one - index: _index: docs - _type: doc _id: 2 - snapshot: one - index: _index: docs - _type: doc _id: 3 - snapshot: one From ca039354aafdfbe1720e1c650175d3ab3fd8ae60 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 26 Sep 2019 10:47:21 +0100 Subject: [PATCH 17/35] wtf --- .../java/org/elasticsearch/action/bulk/BulkItemResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index c948aa64fd7f7..590240b4b0a55 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -230,7 +230,7 @@ public Failure(StreamInput in) throws IOException { index = in.readString(); if (in.getVersion().before(Version.V_8_0_0)) { String type = in.readString(); - assert type == null || MapperService.SINGLE_MAPPING_NAME.equals(type); + assert type == null || MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expecting null or _doc but got [" + type + "]"; } id = in.readOptionalString(); cause = in.readException(); From 9baf0f59d95a59147c11f51868e30bbded5deca1 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 26 Sep 2019 12:06:27 +0100 Subject: [PATCH 18/35] relax assertion --- .../java/org/elasticsearch/action/bulk/BulkItemResponse.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index 590240b4b0a55..2243a95dc7a98 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -229,8 +229,9 @@ public Failure(String index, String id, Exception cause, RestStatus status, long public Failure(StreamInput in) throws IOException { index = in.readString(); if (in.getVersion().before(Version.V_8_0_0)) { - String type = in.readString(); - assert type == null || MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expecting null or _doc but got [" + type + "]"; + in.readString(); + // can't make an assertion about type names here because too many tests still set their own + // types bypassing various checks } id = in.readOptionalString(); cause = in.readException(); From db1e2239f49eebe3fcc0f0dc142a3c2a39fd6e3d Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 26 Sep 2019 17:11:35 +0100 Subject: [PATCH 19/35] Remove types from DocWriteRequest/IndexResponse --- .../noop/action/bulk/RestNoopBulkAction.java | 2 +- .../action/bulk/TransportNoopBulkAction.java | 2 +- .../client/RequestConverters.java | 18 +--- .../elasticsearch/client/BulkProcessorIT.java | 18 ++-- .../java/org/elasticsearch/client/CCRIT.java | 2 +- .../java/org/elasticsearch/client/CrudIT.java | 88 ------------------- .../client/MachineLearningIT.java | 6 +- .../client/RequestConvertersTests.java | 76 ---------------- .../org/elasticsearch/client/SearchIT.java | 16 ++-- .../MlClientDocumentationIT.java | 16 ++-- .../common/DateIndexNameProcessorTests.java | 12 +-- .../ingest/common/DissectProcessorTests.java | 8 +- .../ingest/common/ForEachProcessorTests.java | 18 ++-- .../geoip/GeoIpProcessorFactoryTests.java | 4 +- .../GeoIpProcessorNonIngestNodeTests.java | 2 +- .../reindex/AsyncBulkByScrollActionTests.java | 8 +- .../elasticsearch/backwards/IndexingIT.java | 4 +- .../elasticsearch/upgrades/RecoveryIT.java | 8 +- .../ingest/IngestDocumentMustacheIT.java | 8 +- .../ingest/ValueSourceMustacheIT.java | 2 +- .../elasticsearch/action/DocWriteRequest.java | 14 --- .../action/DocWriteResponse.java | 40 +++------ .../bulk/BulkPrimaryExecutionContext.java | 4 +- .../action/bulk/TransportBulkAction.java | 6 +- .../action/bulk/TransportShardBulkAction.java | 18 ++-- .../action/delete/DeleteRequest.java | 66 +++----------- .../action/delete/DeleteRequestBuilder.java | 3 +- .../action/delete/DeleteResponse.java | 11 ++- .../action/index/IndexRequest.java | 77 +++------------- .../action/index/IndexRequestBuilder.java | 3 +- .../action/index/IndexResponse.java | 11 ++- .../ingest/SimulatePipelineRequest.java | 4 +- .../action/update/TransportUpdateAction.java | 9 +- .../action/update/UpdateHelper.java | 18 ++-- .../action/update/UpdateRequest.java | 55 ++---------- .../action/update/UpdateRequestBuilder.java | 10 ++- .../action/update/UpdateResponse.java | 13 ++- .../org/elasticsearch/client/Requests.java | 5 +- .../engine/DocumentMissingException.java | 4 +- .../DocumentSourceMissingException.java | 4 +- .../index/reindex/ReindexRequest.java | 20 ----- .../elasticsearch/ingest/IngestDocument.java | 3 +- .../elasticsearch/ingest/IngestService.java | 4 +- .../action/document/RestDeleteAction.java | 18 +--- .../rest/action/document/RestIndexAction.java | 25 +----- .../action/document/RestUpdateAction.java | 20 +---- .../action/DocWriteResponseTests.java | 4 - .../action/IndicesRequestIT.java | 16 ++-- .../action/ListenerActionIT.java | 2 +- .../admin/indices/create/ShrinkIndexIT.java | 2 +- .../admin/indices/create/SplitIndexIT.java | 2 +- .../action/bulk/BulkIntegrationIT.java | 2 +- .../BulkPrimaryExecutionContextTests.java | 10 +-- .../action/bulk/BulkProcessorIT.java | 6 +- .../action/bulk/BulkRequestModifierTests.java | 8 +- .../action/bulk/BulkRequestTests.java | 21 ++--- .../action/bulk/BulkWithUpdatesIT.java | 36 ++++---- .../elasticsearch/action/bulk/RetryTests.java | 12 +-- ...ActionIndicesThatCannotBeCreatedTests.java | 4 +- .../bulk/TransportBulkActionIngestTests.java | 36 ++++---- .../action/bulk/TransportBulkActionTests.java | 16 ++-- .../bulk/TransportShardBulkActionTests.java | 48 +++++----- .../action/delete/DeleteRequestTests.java | 14 +-- .../action/delete/DeleteResponseTests.java | 8 +- .../action/index/IndexRequestTests.java | 6 +- .../action/index/IndexResponseTests.java | 10 +-- .../action/update/UpdateRequestTests.java | 72 +++++++-------- .../action/update/UpdateResponseTests.java | 18 ++-- .../elasticsearch/aliases/IndexAliasesIT.java | 80 ++++++++--------- .../broadcast/BroadcastActionsIT.java | 4 +- .../IndexNameExpressionResolverTests.java | 10 +-- .../document/DocumentActionsIT.java | 6 +- .../index/engine/InternalEngineMergeIT.java | 2 +- .../index/reindex/ReindexRequestTests.java | 4 - .../IndexLevelReplicationTests.java | 38 ++++---- .../RecoveryDuringReplicationTests.java | 30 +++---- .../breaker/CircuitBreakerServiceIT.java | 2 +- .../indices/recovery/RecoveryTests.java | 2 +- .../template/SimpleIndexTemplateIT.java | 4 +- .../elasticsearch/ingest/IngestClientIT.java | 8 +- .../ingest/IngestDocumentTests.java | 2 +- .../ingest/IngestServiceTests.java | 35 ++++---- .../recovery/SimpleRecoveryIT.java | 4 +- .../document/RestDeleteActionTests.java | 49 ----------- .../action/document/RestIndexActionTests.java | 32 ------- .../document/RestUpdateActionTests.java | 16 ---- .../routing/SimpleRoutingIT.java | 10 +-- .../basic/TransportSearchFailuresIT.java | 2 +- .../basic/TransportTwoNodesSearchIT.java | 2 +- .../search/fetch/FetchSubPhasePluginIT.java | 2 +- .../functionscore/DecayFunctionScoreIT.java | 28 +++--- .../functionscore/FunctionScorePluginIT.java | 4 +- .../search/geo/GeoShapeQueryTests.java | 6 +- .../search/morelikethis/MoreLikeThisIT.java | 36 ++++---- .../ConcurrentSeqNoVersioningIT.java | 2 +- .../versioning/SimpleVersioningIT.java | 4 - .../ESIndexLevelReplicationTestCase.java | 4 +- .../ingest/RandomDocumentPicks.java | 3 +- .../elasticsearch/test/ESIntegTestCase.java | 1 - .../xpack/ccr/IndexFollowingIT.java | 2 +- .../ShardFollowTaskReplicationTests.java | 4 +- .../history/SnapshotHistoryStoreTests.java | 2 - .../ml/integration/DelayedDataDetectorIT.java | 2 +- .../xpack/ml/datafeed/DatafeedJobTests.java | 6 +- .../integration/BasicDistributedJobsIT.java | 6 +- .../persistence/JobResultsPersisterTests.java | 2 +- .../AutodetectResultProcessorTests.java | 2 +- .../xpack/ml/support/BaseMlIntegTestCase.java | 2 +- .../xpack/rollup/job/IndexerUtils.java | 2 +- .../job/RollupIndexerIndexingTests.java | 14 --- .../DocumentLevelSecurityTests.java | 4 +- .../integration/FieldLevelSecurityTests.java | 4 +- ...ansportOpenIdConnectLogoutActionTests.java | 4 +- ...sportSamlInvalidateSessionActionTests.java | 2 +- .../saml/TransportSamlLogoutActionTests.java | 4 +- .../TransportCreateTokenActionTests.java | 2 +- .../authc/AuthenticationServiceTests.java | 2 +- .../security/authc/TokenServiceTests.java | 2 +- .../authz/AuthorizationServiceTests.java | 33 +++---- .../security/authz/WriteActionsTests.java | 26 +++--- .../store/NativePrivilegeStoreTests.java | 9 +- .../SeqNoPrimaryTermAndIndexTests.java | 1 - .../actions/index/ExecutableIndexAction.java | 8 +- .../actions/index/IndexActionTests.java | 11 +-- .../execution/ExecutionServiceTests.java | 2 +- .../execution/TriggeredWatchStoreTests.java | 4 +- .../put/TransportPutWatchActionTests.java | 2 +- 127 files changed, 563 insertions(+), 1169 deletions(-) delete mode 100644 server/src/test/java/org/elasticsearch/rest/action/document/RestDeleteActionTests.java diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java index 9a523d5f8ca39..ffc94a3507853 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java @@ -82,7 +82,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC private static class BulkRestBuilderListener extends RestBuilderListener { private final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocWriteRequest.OpType.UPDATE, - new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)); + new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)); private final RestRequest request; diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java index e7f22e2f5983f..fea307dd17a86 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java @@ -34,7 +34,7 @@ public class TransportNoopBulkAction extends HandledTransportAction { private static final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocWriteRequest.OpType.UPDATE, - new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)); + new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)); @Inject public TransportNoopBulkAction(TransportService transportService, ActionFilters actionFilters) { diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java index 0bf14d07c2e99..2a6883ed15dbd 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java @@ -70,7 +70,6 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.VersionType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.rankeval.RankEvalRequest; import org.elasticsearch.index.reindex.AbstractBulkByScrollRequest; import org.elasticsearch.index.reindex.DeleteByQueryRequest; @@ -102,7 +101,7 @@ private RequestConverters() { } static Request delete(DeleteRequest deleteRequest) { - String endpoint = endpoint(deleteRequest.index(), deleteRequest.type(), deleteRequest.id()); + String endpoint = endpoint(deleteRequest.index(), deleteRequest.id()); Request request = new Request(HttpDelete.METHOD_NAME, endpoint); Params parameters = new Params(); @@ -170,11 +169,6 @@ static Request bulk(BulkRequest bulkRequest) throws IOException { if (Strings.hasLength(action.index())) { metadata.field("_index", action.index()); } - if (Strings.hasLength(action.type())) { - if (MapperService.SINGLE_MAPPING_NAME.equals(action.type()) == false) { - metadata.field("_type", action.type()); - } - } if (Strings.hasLength(action.id())) { metadata.field("_id", action.id()); } @@ -311,11 +305,9 @@ static Request index(IndexRequest indexRequest) { String endpoint; if (indexRequest.opType() == DocWriteRequest.OpType.CREATE) { - endpoint = indexRequest.type().equals(MapperService.SINGLE_MAPPING_NAME) - ? endpoint(indexRequest.index(), "_create", indexRequest.id()) - : endpoint(indexRequest.index(), indexRequest.type(), indexRequest.id(), "_create"); + endpoint = endpoint(indexRequest.index(), "_create", indexRequest.id()); } else { - endpoint = endpoint(indexRequest.index(), indexRequest.type(), indexRequest.id()); + endpoint = endpoint(indexRequest.index(), indexRequest.id()); } Request request = new Request(method, endpoint); @@ -343,9 +335,7 @@ static Request ping() { } static Request update(UpdateRequest updateRequest) throws IOException { - String endpoint = updateRequest.type().equals(MapperService.SINGLE_MAPPING_NAME) - ? endpoint(updateRequest.index(), "_update", updateRequest.id()) - : endpoint(updateRequest.index(), updateRequest.type(), updateRequest.id(), "_update"); + String endpoint = endpoint(updateRequest.index(), "_update", updateRequest.id()); Request request = new Request(HttpPost.METHOD_NAME, endpoint); Params parameters = new Params(); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java index bfa2e20e2b7f7..6c3b7dbb1f456 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java @@ -320,8 +320,6 @@ public void testGlobalParametersAndBulkProcessor() throws Exception { { final CountDownLatch latch = new CountDownLatch(1); BulkProcessorTestListener listener = new BulkProcessorTestListener(latch); - //Check that untyped document additions inherit the global type - String localType = null; try (BulkProcessor processor = initBulkProcessorBuilder(listener) //let's make sure that the bulk action limit trips, one single execution will index all the documents .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) @@ -331,7 +329,7 @@ public void testGlobalParametersAndBulkProcessor() throws Exception { .setGlobalPipeline("pipeline_id") .build()) { - indexDocs(processor, numDocs, null, localType, "test", "pipeline_id"); + indexDocs(processor, numDocs, null, "test", "pipeline_id"); latch.await(); assertThat(listener.beforeCounts.get(), equalTo(1)); @@ -356,15 +354,15 @@ private Matcher[] expectedIds(int numDocs) { .>toArray(Matcher[]::new); } - private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String localType, + private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String globalIndex, String globalPipeline) throws Exception { MultiGetRequest multiGetRequest = new MultiGetRequest(); for (int i = 1; i <= numDocs; i++) { if (randomBoolean()) { - processor.add(new IndexRequest(localIndex, localType, Integer.toString(i)) + processor.add(new IndexRequest(localIndex).id(Integer.toString(i)) .source(XContentType.JSON, "field", randomRealisticUnicodeOfLengthBetween(1, 30))); } else { - BytesArray data = bytesBulkRequest(localIndex, localType, i); + BytesArray data = bytesBulkRequest(localIndex, i); processor.add(data, globalIndex, globalPipeline, XContentType.JSON); } multiGetRequest.add(localIndex, Integer.toString(i)); @@ -372,17 +370,13 @@ private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String l return multiGetRequest; } - private static BytesArray bytesBulkRequest(String localIndex, String localType, int id) throws IOException { + private static BytesArray bytesBulkRequest(String localIndex, int id) throws IOException { XContentBuilder action = jsonBuilder().startObject().startObject("index"); if (localIndex != null) { action.field("_index", localIndex); } - if (localType != null) { - action.field("_type", localType); - } - action.field("_id", Integer.toString(id)); action.endObject().endObject(); @@ -396,7 +390,7 @@ private static BytesArray bytesBulkRequest(String localIndex, String localType, } private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) throws Exception { - return indexDocs(processor, numDocs, "test", null, null, null); + return indexDocs(processor, numDocs, "test", null, null); } private static void assertResponseItems(List bulkItemResponses, int numDocs) { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java index 11650ca040635..6be2efe98c48b 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java @@ -111,7 +111,7 @@ public void testIndexFollowing() throws Exception { assertThat(putFollowResponse.isFollowIndexShardsAcked(), is(true)); assertThat(putFollowResponse.isIndexFollowingStarted(), is(true)); - IndexRequest indexRequest = new IndexRequest("leader", "_doc") + IndexRequest indexRequest = new IndexRequest("leader") .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .source("{}", XContentType.JSON); highLevelClient().index(indexRequest, RequestOptions.DEFAULT); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java index e2010aaece66b..41d370c1837a9 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java @@ -54,9 +54,6 @@ import org.elasticsearch.index.VersionType; import org.elasticsearch.index.get.GetResult; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.document.RestDeleteAction; -import org.elasticsearch.rest.action.document.RestIndexAction; -import org.elasticsearch.rest.action.document.RestUpdateAction; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; @@ -92,7 +89,6 @@ public void testDelete() throws IOException { } DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); - assertEquals("_doc", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); } @@ -102,7 +98,6 @@ public void testDelete() throws IOException { DeleteRequest deleteRequest = new DeleteRequest("index", docId); DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); - assertEquals("_doc", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); assertEquals(DocWriteResponse.Result.NOT_FOUND, deleteResponse.getResult()); } @@ -129,7 +124,6 @@ public void testDelete() throws IOException { DeleteRequest deleteRequest = new DeleteRequest("index", docId).versionType(VersionType.EXTERNAL).version(13); DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); - assertEquals("_doc", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); } @@ -156,34 +150,11 @@ public void testDelete() throws IOException { DeleteRequest deleteRequest = new DeleteRequest("index", docId).routing("foo"); DeleteResponse deleteResponse = execute(deleteRequest, highLevelClient()::delete, highLevelClient()::deleteAsync); assertEquals("index", deleteResponse.getIndex()); - assertEquals("_doc", deleteResponse.getType()); assertEquals(docId, deleteResponse.getId()); assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); } } - public void testDeleteWithTypes() throws IOException { - String docId = "id"; - IndexRequest indexRequest = new IndexRequest("index", "type", docId); - indexRequest.source(Collections.singletonMap("foo", "bar")); - execute(indexRequest, - highLevelClient()::index, - highLevelClient()::indexAsync, - expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE) - ); - - DeleteRequest deleteRequest = new DeleteRequest("index", "type", docId); - DeleteResponse deleteResponse = execute(deleteRequest, - highLevelClient()::delete, - highLevelClient()::deleteAsync, - expectWarnings(RestDeleteAction.TYPES_DEPRECATION_MESSAGE)); - - assertEquals("index", deleteResponse.getIndex()); - assertEquals("type", deleteResponse.getType()); - assertEquals(docId, deleteResponse.getId()); - assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); - } - public void testExists() throws IOException { { GetRequest getRequest = new GetRequest("index", "id"); @@ -336,18 +307,6 @@ public void testGet() throws IOException { } } - public void testGetWithTypes() throws IOException { - String document = "{\"field\":\"value\"}"; - IndexRequest indexRequest = new IndexRequest("index", "type", "id"); - indexRequest.source(document, XContentType.JSON); - indexRequest.setRefreshPolicy(RefreshPolicy.IMMEDIATE); - execute(indexRequest, - highLevelClient()::index, - highLevelClient()::indexAsync, - expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE) - ); - } - public void testMultiGet() throws IOException { { MultiGetRequest multiGetRequest = new MultiGetRequest(); @@ -410,7 +369,6 @@ public void testIndex() throws IOException { assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult()); assertEquals("index", indexResponse.getIndex()); - assertEquals("_doc", indexResponse.getType()); assertTrue(Strings.hasLength(indexResponse.getId())); assertEquals(1L, indexResponse.getVersion()); assertNotNull(indexResponse.getShardId()); @@ -430,7 +388,6 @@ public void testIndex() throws IOException { IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); - assertEquals("_doc", indexResponse.getType()); assertEquals("id", indexResponse.getId()); assertEquals(1L, indexResponse.getVersion()); @@ -440,7 +397,6 @@ public void testIndex() throws IOException { indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.OK, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); - assertEquals("_doc", indexResponse.getType()); assertEquals("id", indexResponse.getId()); assertEquals(2L, indexResponse.getVersion()); @@ -479,7 +435,6 @@ public void testIndex() throws IOException { IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); - assertEquals("_doc", indexResponse.getType()); assertEquals("external_version_type", indexResponse.getId()); assertEquals(12L, indexResponse.getVersion()); } @@ -491,7 +446,6 @@ public void testIndex() throws IOException { IndexResponse indexResponse = execute(indexRequest, highLevelClient()::index, highLevelClient()::indexAsync); assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals("index", indexResponse.getIndex()); - assertEquals("_doc", indexResponse.getType()); assertEquals("with_create_op_type", indexResponse.getId()); ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> { @@ -504,22 +458,6 @@ public void testIndex() throws IOException { } } - public void testIndexWithTypes() throws IOException { - final XContentType xContentType = randomFrom(XContentType.values()); - IndexRequest indexRequest = new IndexRequest("index", "some_type", "some_id"); - indexRequest.source(XContentBuilder.builder(xContentType.xContent()).startObject().field("test", "test").endObject()); - IndexResponse indexResponse = execute( - indexRequest, - highLevelClient()::index, - highLevelClient()::indexAsync, - expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE) - ); - assertEquals(RestStatus.CREATED, indexResponse.status()); - assertEquals("index", indexResponse.getIndex()); - assertEquals("some_type", indexResponse.getType()); - assertEquals("some_id",indexResponse.getId()); - } - public void testUpdate() throws IOException { { UpdateRequest updateRequest = new UpdateRequest("index", "does_not_exist"); @@ -651,7 +589,6 @@ public void testUpdate() throws IOException { UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); - assertEquals("_doc", updateResponse.getType()); assertEquals("with_upsert", updateResponse.getId()); GetResult getResult = updateResponse.getGetResult(); assertEquals(1L, updateResponse.getVersion()); @@ -666,7 +603,6 @@ public void testUpdate() throws IOException { UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); - assertEquals("_doc", updateResponse.getType()); assertEquals("with_doc_as_upsert", updateResponse.getId()); GetResult getResult = updateResponse.getGetResult(); assertEquals(1L, updateResponse.getVersion()); @@ -682,7 +618,6 @@ public void testUpdate() throws IOException { UpdateResponse updateResponse = execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync); assertEquals(RestStatus.CREATED, updateResponse.status()); assertEquals("index", updateResponse.getIndex()); - assertEquals("_doc", updateResponse.getType()); assertEquals("with_scripted_upsert", updateResponse.getId()); GetResult getResult = updateResponse.getGetResult(); @@ -701,26 +636,6 @@ public void testUpdate() throws IOException { } } - public void testUpdateWithTypes() throws IOException { - IndexRequest indexRequest = new IndexRequest("index", "type", "id"); - indexRequest.source(singletonMap("field", "value")); - IndexResponse indexResponse = execute(indexRequest, - highLevelClient()::index, - highLevelClient()::indexAsync, - expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE) - ); - - UpdateRequest updateRequest = new UpdateRequest("index", "type", "id"); - updateRequest.doc(singletonMap("field", "updated"), randomFrom(XContentType.values())); - UpdateResponse updateResponse = execute(updateRequest, - highLevelClient()::update, - highLevelClient()::updateAsync, - expectWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE)); - - assertEquals(RestStatus.OK, updateResponse.status()); - assertEquals(indexResponse.getVersion() + 1, updateResponse.getVersion()); - } - public void testBulk() throws IOException { int nbItems = randomIntBetween(10, 100); boolean[] errors = new boolean[nbItems]; @@ -907,7 +822,6 @@ public void testUrlEncode() throws IOException { indexRequest.source("field", "value"); IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals(expectedIndex, indexResponse.getIndex()); - assertEquals("_doc", indexResponse.getType()); assertEquals("id#1", indexResponse.getId()); } { @@ -924,7 +838,6 @@ public void testUrlEncode() throws IOException { indexRequest.source("field", "value"); IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals("index", indexResponse.getIndex()); - assertEquals("_doc", indexResponse.getType()); assertEquals(docId, indexResponse.getId()); } { @@ -947,7 +860,6 @@ public void testParamsEncode() throws IOException { indexRequest.routing(routing); IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); assertEquals("index", indexResponse.getIndex()); - assertEquals("_doc", indexResponse.getType()); assertEquals("id", indexResponse.getId()); } { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java index 9d1e04eb56309..040ff00878a19 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java @@ -2047,7 +2047,7 @@ private void updateModelSnapshotTimestamp(String jobId, String timestamp) throws String documentId = jobId + "_model_snapshot_" + snapshotId; String snapshotUpdate = "{ \"timestamp\": " + timestamp + "}"; - UpdateRequest updateSnapshotRequest = new UpdateRequest(".ml-anomalies-" + jobId, "_doc", documentId); + UpdateRequest updateSnapshotRequest = new UpdateRequest(".ml-anomalies-" + jobId, documentId); updateSnapshotRequest.doc(snapshotUpdate.getBytes(StandardCharsets.UTF_8), XContentType.JSON); highLevelClient().update(updateSnapshotRequest, RequestOptions.DEFAULT); } @@ -2067,7 +2067,7 @@ public void createModelSnapshot(String jobId, String snapshotId) throws IOExcept Job job = MachineLearningIT.buildJob(jobId); highLevelClient().machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc", documentId); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared").id(documentId); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"" + jobId + "\", \"timestamp\":1541587919000, " + "\"description\":\"State persisted due to job close at 2018-11-07T10:51:59+0000\", " + @@ -2087,7 +2087,7 @@ public void createModelSnapshots(String jobId, List snapshotIds) throws for(String snapshotId : snapshotIds) { String documentId = jobId + "_model_snapshot_" + snapshotId; - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc", documentId); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared").id(documentId); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"" + jobId + "\", \"timestamp\":1541587919000, " + "\"description\":\"State persisted due to job close at 2018-11-07T10:51:59+0000\", " + diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java index f75685b46fcbe..16f65da3dc16d 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java @@ -287,18 +287,6 @@ public void testDelete() { assertNull(request.getEntity()); } - public void testDeleteWithType() { - String index = randomAlphaOfLengthBetween(3, 10); - String type = randomAlphaOfLengthBetween(3, 10); - String id = randomAlphaOfLengthBetween(3, 10); - DeleteRequest deleteRequest = new DeleteRequest(index, type, id); - - Request request = RequestConverters.delete(deleteRequest); - assertEquals(HttpDelete.METHOD_NAME, request.getMethod()); - assertEquals("/" + index + "/" + type + "/" + id, request.getEndpoint()); - assertNull(request.getEntity()); - } - public void testExists() { getAndExistsTest(RequestConverters::exists, HttpHead.METHOD_NAME); } @@ -380,9 +368,6 @@ public void testReindex() throws IOException { if (randomBoolean()) { reindexRequest.setSourceBatchSize(randomInt(100)); } - if (randomBoolean()) { - reindexRequest.setDestDocType("tweet_and_doc"); - } if (randomBoolean()) { reindexRequest.setDestOpType("create"); } @@ -646,49 +631,6 @@ public void testIndex() throws IOException { } } - public void testIndexWithType() throws IOException { - String index = randomAlphaOfLengthBetween(3, 10); - String type = randomAlphaOfLengthBetween(3, 10); - IndexRequest indexRequest = new IndexRequest(index, type); - String id = randomBoolean() ? randomAlphaOfLengthBetween(3, 10) : null; - indexRequest.id(id); - - String method = HttpPost.METHOD_NAME; - if (id != null) { - method = HttpPut.METHOD_NAME; - if (randomBoolean()) { - indexRequest.opType(DocWriteRequest.OpType.CREATE); - } - } - XContentType xContentType = randomFrom(XContentType.values()); - int nbFields = randomIntBetween(0, 10); - try (XContentBuilder builder = XContentBuilder.builder(xContentType.xContent())) { - builder.startObject(); - for (int i = 0; i < nbFields; i++) { - builder.field("field_" + i, i); - } - builder.endObject(); - indexRequest.source(builder); - } - - Request request = RequestConverters.index(indexRequest); - if (indexRequest.opType() == DocWriteRequest.OpType.CREATE) { - assertEquals("/" + index + "/" + type + "/" + id + "/_create", request.getEndpoint()); - } else if (id != null) { - assertEquals("/" + index + "/" + type + "/" + id, request.getEndpoint()); - } else { - assertEquals("/" + index + "/" + type, request.getEndpoint()); - } - assertEquals(method, request.getMethod()); - - HttpEntity entity = request.getEntity(); - assertTrue(entity instanceof NByteArrayEntity); - assertEquals(indexRequest.getContentType().mediaTypeWithoutParameters(), entity.getContentType().getValue()); - try (XContentParser parser = createParser(xContentType.xContent(), entity.getContent())) { - assertEquals(nbFields, parser.map().size()); - } - } - public void testUpdate() throws IOException { XContentType xContentType = randomFrom(XContentType.values()); @@ -797,23 +739,6 @@ private static void setRandomIfSeqNoAndTerm(DocWriteRequest request, Map { UpdateRequest updateRequest = new UpdateRequest(); @@ -906,7 +831,6 @@ public void testBulk() throws IOException { assertEquals(originalRequest.opType(), parsedRequest.opType()); assertEquals(originalRequest.index(), parsedRequest.index()); - assertEquals(originalRequest.type(), parsedRequest.type()); assertEquals(originalRequest.id(), parsedRequest.id()); assertEquals(originalRequest.routing(), parsedRequest.routing()); assertEquals(originalRequest.version(), parsedRequest.version()); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java index adcb9083c2c56..0760a13ca87d9 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java @@ -52,7 +52,6 @@ import org.elasticsearch.join.aggregations.Children; import org.elasticsearch.join.aggregations.ChildrenAggregationBuilder; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.document.RestIndexAction; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; import org.elasticsearch.script.mustache.MultiSearchTemplateRequest; @@ -114,24 +113,19 @@ public class SearchIT extends ESRestHighLevelClientTestCase { @Before public void indexDocuments() throws IOException { { - Request doc1 = new Request(HttpPut.METHOD_NAME, "/index/type/1"); - doc1.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); + Request doc1 = new Request(HttpPut.METHOD_NAME, "/index/_doc/1"); doc1.setJsonEntity("{\"type\":\"type1\", \"num\":10, \"num2\":50}"); client().performRequest(doc1); - Request doc2 = new Request(HttpPut.METHOD_NAME, "/index/type/2"); - doc2.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); + Request doc2 = new Request(HttpPut.METHOD_NAME, "/index/_doc/2"); doc2.setJsonEntity("{\"type\":\"type1\", \"num\":20, \"num2\":40}"); client().performRequest(doc2); - Request doc3 = new Request(HttpPut.METHOD_NAME, "/index/type/3"); - doc3.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); + Request doc3 = new Request(HttpPut.METHOD_NAME, "/index/_doc/3"); doc3.setJsonEntity("{\"type\":\"type1\", \"num\":50, \"num2\":35}"); client().performRequest(doc3); - Request doc4 = new Request(HttpPut.METHOD_NAME, "/index/type/4"); - doc4.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); + Request doc4 = new Request(HttpPut.METHOD_NAME, "/index/_doc/4"); doc4.setJsonEntity("{\"type\":\"type2\", \"num\":100, \"num2\":10}"); client().performRequest(doc4); - Request doc5 = new Request(HttpPut.METHOD_NAME, "/index/type/5"); - doc5.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); + Request doc5 = new Request(HttpPut.METHOD_NAME, "/index/_doc/5"); doc5.setJsonEntity("{\"type\":\"type2\", \"num\":100, \"num2\":10}"); client().performRequest(doc5); } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java index f1017e86bd063..8e199935a2310 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java @@ -1149,7 +1149,7 @@ public void testGetBuckets() throws IOException, InterruptedException { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); // Let us index a bucket - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc"); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared"); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"test-get-buckets\", \"result_type\":\"bucket\", \"timestamp\": 1533081600000," + "\"bucket_span\": 600,\"is_interim\": false, \"anomaly_score\": 80.0}", XContentType.JSON); @@ -1617,7 +1617,7 @@ public void testGetRecords() throws IOException, InterruptedException { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); // Let us index a record - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc"); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared"); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"test-get-records\", \"result_type\":\"record\", \"timestamp\": 1533081600000," + "\"bucket_span\": 600,\"is_interim\": false, \"record_score\": 80.0}", XContentType.JSON); @@ -1836,7 +1836,7 @@ public void testGetInfluencers() throws IOException, InterruptedException { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); // Let us index a record - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc"); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared"); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"test-get-influencers\", \"result_type\":\"influencer\", \"timestamp\": 1533081600000," + "\"bucket_span\": 600,\"is_interim\": false, \"influencer_score\": 80.0, \"influencer_field_name\": \"my_influencer\"," + @@ -1927,7 +1927,7 @@ public void testGetCategories() throws IOException, InterruptedException { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); // Let us index a category - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc"); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared"); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\": \"test-get-categories\", \"category_id\": 1, \"terms\": \"AAL\"," + " \"regex\": \".*?AAL.*\", \"max_matching_length\": 3, \"examples\": [\"AAL\"]}", XContentType.JSON); @@ -2048,7 +2048,7 @@ public void testDeleteModelSnapshot() throws IOException, InterruptedException { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); // Let us index a snapshot - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc"); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared"); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"" + jobId + "\", \"timestamp\":1541587919000, " + "\"description\":\"State persisted due to job close at 2018-11-07T10:51:59+0000\", " + @@ -2114,7 +2114,7 @@ public void testGetModelSnapshots() throws IOException, InterruptedException { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); // Let us index a snapshot - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc"); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared"); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"test-get-model-snapshots\", \"timestamp\":1541587919000, " + "\"description\":\"State persisted due to job close at 2018-11-07T10:51:59+0000\", " + @@ -2212,7 +2212,7 @@ public void testRevertModelSnapshot() throws IOException, InterruptedException { // Let us index a snapshot String documentId = jobId + "_model_snapshot_" + snapshotId; - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc", documentId); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared").id(documentId); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"test-revert-model-snapshot\", \"timestamp\":1541587919000, " + "\"description\":\"State persisted due to job close at 2018-11-07T10:51:59+0000\", " + @@ -2288,7 +2288,7 @@ public void testUpdateModelSnapshot() throws IOException, InterruptedException { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); // Let us index a snapshot - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc", documentId); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared").id(documentId); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); indexRequest.source("{\"job_id\":\"test-update-model-snapshot\", \"timestamp\":1541587919000, " + "\"description\":\"State persisted due to job close at 2018-11-07T10:51:59+0000\", " + diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateIndexNameProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateIndexNameProcessorTests.java index 3d891ffb81f4f..9d79a14568583 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateIndexNameProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateIndexNameProcessorTests.java @@ -39,7 +39,7 @@ public void testJavaPattern() throws Exception { Function function = DateFormat.Java.getFunction("yyyy-MM-dd'T'HH:mm:ss.SSSXX", ZoneOffset.UTC, Locale.ROOT); DateIndexNameProcessor processor = createProcessor("_field", Collections.singletonList(function), ZoneOffset.UTC, "events-", "y", "yyyyMMdd"); - IngestDocument document = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", "2016-04-25T12:24:20.101Z")); processor.execute(document); assertThat(document.getSourceAndMetadata().get("_index"), equalTo("")); @@ -49,7 +49,7 @@ public void testTAI64N()throws Exception { Function function = DateFormat.Tai64n.getFunction(null, ZoneOffset.UTC, null); DateIndexNameProcessor dateProcessor = createProcessor("_field", Collections.singletonList(function), ZoneOffset.UTC, "events-", "m", "yyyyMMdd"); - IngestDocument document = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", (randomBoolean() ? "@" : "") + "4000000050d506482dbdf024")); dateProcessor.execute(document); assertThat(document.getSourceAndMetadata().get("_index"), equalTo("")); @@ -59,12 +59,12 @@ public void testUnixMs()throws Exception { Function function = DateFormat.UnixMs.getFunction(null, ZoneOffset.UTC, null); DateIndexNameProcessor dateProcessor = createProcessor("_field", Collections.singletonList(function), ZoneOffset.UTC, "events-", "m", "yyyyMMdd"); - IngestDocument document = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", "1000500")); dateProcessor.execute(document); assertThat(document.getSourceAndMetadata().get("_index"), equalTo("")); - document = new IngestDocument("_index", "_type", "_id", null, null, null, + document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", 1000500L)); dateProcessor.execute(document); assertThat(document.getSourceAndMetadata().get("_index"), equalTo("")); @@ -74,7 +74,7 @@ public void testUnix()throws Exception { Function function = DateFormat.Unix.getFunction(null, ZoneOffset.UTC, null); DateIndexNameProcessor dateProcessor = createProcessor("_field", Collections.singletonList(function), ZoneOffset.UTC, "events-", "m", "yyyyMMdd"); - IngestDocument document = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", "1000.5")); dateProcessor.execute(document); assertThat(document.getSourceAndMetadata().get("_index"), equalTo("")); @@ -91,7 +91,7 @@ public void testTemplatedFields() throws Exception { Collections.singletonList(dateTimeFunction), ZoneOffset.UTC, indexNamePrefix, dateRounding, indexNameFormat); - IngestDocument document = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument document = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("_field", date)); dateProcessor.execute(document); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DissectProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DissectProcessorTests.java index bb5d26d01a865..1910c6cd1d37a 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DissectProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DissectProcessorTests.java @@ -40,7 +40,7 @@ public class DissectProcessorTests extends ESTestCase { public void testMatch() { - IngestDocument ingestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("message", "foo,bar,baz")); DissectProcessor dissectProcessor = new DissectProcessor("", "message", "%{a},%{b},%{c}", "", true); dissectProcessor.execute(ingestDocument); @@ -50,7 +50,7 @@ public void testMatch() { } public void testMatchOverwrite() { - IngestDocument ingestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, MapBuilder.newMapBuilder() .put("message", "foo,bar,baz") .put("a", "willgetstompped") @@ -64,7 +64,7 @@ public void testMatchOverwrite() { } public void testAdvancedMatch() { - IngestDocument ingestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("message", "foo bar,,,,,,,baz nope:notagain 😊 🐇 🙃")); DissectProcessor dissectProcessor = new DissectProcessor("", "message", "%{a->} %{*b->},%{&b} %{}:%{?skipme} %{+smile/2} 🐇 %{+smile/1}", "::::", true); @@ -77,7 +77,7 @@ public void testAdvancedMatch() { } public void testMiss() { - IngestDocument ingestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, + IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, Collections.singletonMap("message", "foo:bar,baz")); DissectProcessor dissectProcessor = new DissectProcessor("", "message", "%{a},%{b},%{c}", "", true); DissectException e = expectThrows(DissectException.class, () -> dissectProcessor.execute(ingestDocument)); diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java index a4ee786315c03..894cab1295bee 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java @@ -46,7 +46,7 @@ public void testExecute() throws Exception { values.add("bar"); values.add("baz"); IngestDocument ingestDocument = new IngestDocument( - "_index", "_type", "_id", null, null, null, Collections.singletonMap("values", values) + "_index", "_id", null, null, null, Collections.singletonMap("values", values) ); ForEachProcessor processor = new ForEachProcessor( @@ -64,7 +64,7 @@ public void testExecute() throws Exception { public void testExecuteWithFailure() throws Exception { IngestDocument ingestDocument = new IngestDocument( - "_index", "_type", "_id", null, null, null, Collections.singletonMap("values", Arrays.asList("a", "b", "c")) + "_index", "_id", null, null, null, Collections.singletonMap("values", Arrays.asList("a", "b", "c")) ); TestProcessor testProcessor = new TestProcessor(id -> { @@ -102,7 +102,7 @@ public void testMetaDataAvailable() throws Exception { values.add(new HashMap<>()); values.add(new HashMap<>()); IngestDocument ingestDocument = new IngestDocument( - "_index", "_type", "_id", null, null, null, Collections.singletonMap("values", values) + "_index", "_id", null, null, null, Collections.singletonMap("values", values) ); TestProcessor innerProcessor = new TestProcessor(id -> { @@ -133,7 +133,7 @@ public void testRestOfTheDocumentIsAvailable() throws Exception { document.put("values", values); document.put("flat_values", new ArrayList<>()); document.put("other", "value"); - IngestDocument ingestDocument = new IngestDocument("_index", "_type", "_id", null, null, null, document); + IngestDocument ingestDocument = new IngestDocument("_index", "_id", null, null, null, document); ForEachProcessor processor = new ForEachProcessor( "_tag", "values", new SetProcessor("_tag", @@ -173,7 +173,7 @@ public String getTag() { values.add(""); } IngestDocument ingestDocument = new IngestDocument( - "_index", "_type", "_id", null, null, null, Collections.singletonMap("values", values) + "_index", "_id", null, null, null, Collections.singletonMap("values", values) ); ForEachProcessor processor = new ForEachProcessor("_tag", "values", innerProcessor, false); @@ -192,7 +192,7 @@ public void testModifyFieldsOutsideArray() throws Exception { values.add(1); values.add(null); IngestDocument ingestDocument = new IngestDocument( - "_index", "_type", "_id", null, null, null, Collections.singletonMap("values", values) + "_index", "_id", null, null, null, Collections.singletonMap("values", values) ); TemplateScript.Factory template = new TestTemplateService.MockTemplateScript.Factory("errors"); @@ -222,7 +222,7 @@ public void testScalarValueAllowsUnderscoreValueFieldToRemainAccessible() throws source.put("_value", "new_value"); source.put("values", values); IngestDocument ingestDocument = new IngestDocument( - "_index", "_type", "_id", null, null, null, source + "_index", "_id", null, null, null, source ); TestProcessor processor = new TestProcessor(doc -> doc.setFieldValue("_ingest._value", @@ -253,7 +253,7 @@ public void testNestedForEach() throws Exception { values.add(value); IngestDocument ingestDocument = new IngestDocument( - "_index", "_type", "_id", null, null, null, Collections.singletonMap("values1", values) + "_index", "_id", null, null, null, Collections.singletonMap("values1", values) ); TestProcessor testProcessor = new TestProcessor( @@ -274,7 +274,7 @@ public void testNestedForEach() throws Exception { public void testIgnoreMissing() throws Exception { IngestDocument originalIngestDocument = new IngestDocument( - "_index", "_type", "_id", null, null, null, Collections.emptyMap() + "_index", "_id", null, null, null, Collections.emptyMap() ); IngestDocument ingestDocument = new IngestDocument(originalIngestDocument); TestProcessor testProcessor = new TestProcessor(doc -> {}); diff --git a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java index 20a1362dd53a9..001248497f0f9 100644 --- a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java +++ b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java @@ -260,7 +260,7 @@ public void testLazyLoading() throws Exception { } final Map field = Collections.singletonMap("_field", "1.1.1.1"); - final IngestDocument document = new IngestDocument("index", "type", "id", "routing", 1L, VersionType.EXTERNAL, field); + final IngestDocument document = new IngestDocument("index", "id", "routing", 1L, VersionType.EXTERNAL, field); Map config = new HashMap<>(); config.put("field", "_field"); @@ -317,7 +317,7 @@ public void testLoadingCustomDatabase() throws IOException { } final Map field = Collections.singletonMap("_field", "1.1.1.1"); - final IngestDocument document = new IngestDocument("index", "type", "id", "routing", 1L, VersionType.EXTERNAL, field); + final IngestDocument document = new IngestDocument("index", "id", "routing", 1L, VersionType.EXTERNAL, field); Map config = new HashMap<>(); config.put("field", "_field"); diff --git a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorNonIngestNodeTests.java b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorNonIngestNodeTests.java index 5484f7f1f9c6b..ee1a3c6fd4438 100644 --- a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorNonIngestNodeTests.java +++ b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorNonIngestNodeTests.java @@ -149,7 +149,7 @@ public void testLazyLoading() throws IOException { internalCluster().getInstance(IngestService.class, ingestNode); // the geo-IP database should not be loaded yet as we have no indexed any documents using a pipeline that has a geo-IP processor assertDatabaseLoadStatus(ingestNode, false); - final IndexRequest indexRequest = new IndexRequest("index", "_doc"); + final IndexRequest indexRequest = new IndexRequest("index"); indexRequest.setPipeline("geoip"); indexRequest.source(Collections.singletonMap("ip", "1.1.1.1")); final IndexResponse indexResponse = client().index(indexRequest).actionGet(); diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java index 3a91aac0c6a3b..9a0565561b713 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java @@ -318,7 +318,7 @@ public void testBulkResponseSetsLotsOfStatus() throws Exception { final int seqNo = randomInt(20); final int primaryTerm = randomIntBetween(1, 16); final IndexResponse response = - new IndexResponse(shardId, "type", "id" + i, seqNo, primaryTerm, randomInt(), createdResponse); + new IndexResponse(shardId, "id" + i, seqNo, primaryTerm, randomInt(), createdResponse); responses[i] = new BulkItemResponse(i, opType, response); } assertExactlyOnce(onSuccess -> @@ -549,7 +549,7 @@ private void bulkRetryTestCase(boolean failWithRejection) throws Exception { DummyAsyncBulkByScrollAction action = new DummyActionWithoutBackoff(); BulkRequest request = new BulkRequest(); for (int i = 0; i < size + 1; i++) { - request.add(new IndexRequest("index", "type", "id" + i)); + request.add(new IndexRequest("index").id("id" + i)); } if (failWithRejection) { action.sendBulkRequest(request, Assert::fail); @@ -876,7 +876,6 @@ void doExecute(ActionType action, Request request, ActionListener action, Request request, ActionListener document = new HashMap<>(); document.put("foo", "bar"); - IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document); + IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, document); ingestDocument.setFieldValue(compile("field1"), ValueSource.wrap("1 {{foo}}", scriptService)); assertThat(ingestDocument.getFieldValue("field1", String.class), equalTo("1 bar")); @@ -48,7 +48,7 @@ public void testAccessMapMetaDataViaTemplate() { innerObject.put("baz", "hello baz"); innerObject.put("qux", Collections.singletonMap("fubar", "hello qux and fubar")); document.put("foo", innerObject); - IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document); + IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, document); ingestDocument.setFieldValue(compile("field1"), ValueSource.wrap("1 {{foo.bar}} {{foo.baz}} {{foo.qux.fubar}}", scriptService)); assertThat(ingestDocument.getFieldValue("field1", String.class), equalTo("1 hello bar hello baz hello qux and fubar")); @@ -67,7 +67,7 @@ public void testAccessListMetaDataViaTemplate() { list.add(value); list.add(null); document.put("list2", list); - IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document); + IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, document); ingestDocument.setFieldValue(compile("field1"), ValueSource.wrap("1 {{list1.0}} {{list2.0}}", scriptService)); assertThat(ingestDocument.getFieldValue("field1", String.class), equalTo("1 foo {field=value}")); } @@ -77,7 +77,7 @@ public void testAccessIngestMetadataViaTemplate() { Map ingestMap = new HashMap<>(); ingestMap.put("timestamp", "bogus_timestamp"); document.put("_ingest", ingestMap); - IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document); + IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, document); ingestDocument.setFieldValue(compile("ingest_timestamp"), ValueSource.wrap("{{_ingest.timestamp}} and {{_source._ingest.timestamp}}", scriptService)); assertThat(ingestDocument.getFieldValue("ingest_timestamp", String.class), diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/java/org/elasticsearch/ingest/ValueSourceMustacheIT.java b/qa/smoke-test-ingest-with-all-dependencies/src/test/java/org/elasticsearch/ingest/ValueSourceMustacheIT.java index e7005080ea88e..b8614f4394140 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/java/org/elasticsearch/ingest/ValueSourceMustacheIT.java +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/java/org/elasticsearch/ingest/ValueSourceMustacheIT.java @@ -64,7 +64,7 @@ public void testValueSourceWithTemplates() { } public void testAccessSourceViaTemplate() { - IngestDocument ingestDocument = new IngestDocument("marvel", "type", "id", null, null, null, new HashMap<>()); + IngestDocument ingestDocument = new IngestDocument("marvel", "id", null, null, null, new HashMap<>()); assertThat(ingestDocument.hasField("marvel"), is(false)); ingestDocument.setFieldValue(compile("{{_index}}"), ValueSource.wrap("{{_index}}", scriptService)); assertThat(ingestDocument.getFieldValue("marvel", String.class), equalTo("marvel")); diff --git a/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java b/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java index e99f8ddae31e2..a8a1daaaab10f 100644 --- a/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java +++ b/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java @@ -52,20 +52,6 @@ public interface DocWriteRequest extends IndicesRequest { */ String index(); - - /** - * Set the type for this request - * @return the Request - */ - T type(String type); - - /** - * Get the type that this request operates on - * @return the type - */ - String type(); - - /** * Get the id of the document for this request * @return the id diff --git a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java index 50036f95d16b7..34f9939a366e1 100644 --- a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java +++ b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java @@ -18,6 +18,7 @@ */ package org.elasticsearch.action; +import org.elasticsearch.Version; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.action.support.WriteResponse; @@ -32,6 +33,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.seqno.SequenceNumbers; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.rest.RestStatus; @@ -53,7 +55,6 @@ public abstract class DocWriteResponse extends ReplicationResponse implements Wr private static final String _SHARDS = "_shards"; private static final String _INDEX = "_index"; - private static final String _TYPE = "_type"; private static final String _ID = "_id"; private static final String _VERSION = "_version"; private static final String _SEQ_NO = "_seq_no"; @@ -114,16 +115,14 @@ public void writeTo(StreamOutput out) throws IOException { private final ShardId shardId; private final String id; - private final String type; private final long version; private final long seqNo; private final long primaryTerm; private boolean forcedRefresh; protected final Result result; - public DocWriteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) { + public DocWriteResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) { this.shardId = Objects.requireNonNull(shardId); - this.type = Objects.requireNonNull(type); this.id = Objects.requireNonNull(id); this.seqNo = seqNo; this.primaryTerm = primaryTerm; @@ -135,7 +134,10 @@ public DocWriteResponse(ShardId shardId, String type, String id, long seqNo, lon protected DocWriteResponse(StreamInput in) throws IOException { super(in); shardId = new ShardId(in); - type = in.readString(); + if (in.getVersion().before(Version.V_8_0_0)) { + String type = in.readString(); + assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]"; + } id = in.readString(); version = in.readZLong(); seqNo = in.readZLong(); @@ -165,16 +167,6 @@ public ShardId getShardId() { return this.shardId; } - /** - * The type of the document changed. - * - * @deprecated Types are in the process of being removed. - */ - @Deprecated - public String getType() { - return this.type; - } - /** * The id of the document changed. */ @@ -241,7 +233,7 @@ public String getLocation(@Nullable String routing) { try { // encode the path components separately otherwise the path separators will be encoded encodedIndex = URLEncoder.encode(getIndex(), "UTF-8"); - encodedType = URLEncoder.encode(getType(), "UTF-8"); + encodedType = URLEncoder.encode(MapperService.SINGLE_MAPPING_NAME, "UTF-8"); encodedId = URLEncoder.encode(getId(), "UTF-8"); encodedRouting = routing == null ? null : URLEncoder.encode(routing, "UTF-8"); } catch (final UnsupportedEncodingException e) { @@ -270,7 +262,9 @@ public String getLocation(@Nullable String routing) { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardId.writeTo(out); - out.writeString(type); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); out.writeZLong(version); out.writeZLong(seqNo); @@ -290,7 +284,6 @@ public final XContentBuilder toXContent(XContentBuilder builder, Params params) public XContentBuilder innerToXContent(XContentBuilder builder, Params params) throws IOException { ReplicationResponse.ShardInfo shardInfo = getShardInfo(); builder.field(_INDEX, shardId.getIndexName()); - builder.field(_TYPE, type); builder.field(_ID, id) .field(_VERSION, version) .field(RESULT, getResult().getLowercase()); @@ -323,8 +316,6 @@ protected static void parseInnerToXContent(XContentParser parser, Builder contex if (_INDEX.equals(currentFieldName)) { // index uuid and shard id are unknown and can't be parsed back for now. context.setShardId(new ShardId(new Index(parser.text(), IndexMetaData.INDEX_UUID_NA_VALUE), -1)); - } else if (_TYPE.equals(currentFieldName)) { - context.setType(parser.text()); } else if (_ID.equals(currentFieldName)) { context.setId(parser.text()); } else if (_VERSION.equals(currentFieldName)) { @@ -363,7 +354,6 @@ protected static void parseInnerToXContent(XContentParser parser, Builder contex public abstract static class Builder { protected ShardId shardId = null; - protected String type = null; protected String id = null; protected Long version = null; protected Result result = null; @@ -380,14 +370,6 @@ public void setShardId(ShardId shardId) { this.shardId = shardId; } - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - public String getId() { return id; } diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContext.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContext.java index 8967ba4f41b2c..25ee0e1dd1c62 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContext.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContext.java @@ -253,11 +253,11 @@ public void markOperationAsExecuted(Engine.Result result) { final DocWriteResponse response; if (result.getOperationType() == Engine.Operation.TYPE.INDEX) { Engine.IndexResult indexResult = (Engine.IndexResult) result; - response = new IndexResponse(primary.shardId(), requestToExecute.type(), requestToExecute.id(), + response = new IndexResponse(primary.shardId(), requestToExecute.id(), result.getSeqNo(), result.getTerm(), indexResult.getVersion(), indexResult.isCreated()); } else if (result.getOperationType() == Engine.Operation.TYPE.DELETE) { Engine.DeleteResult deleteResult = (Engine.DeleteResult) result; - response = new DeleteResponse(primary.shardId(), requestToExecute.type(), requestToExecute.id(), + response = new DeleteResponse(primary.shardId(), requestToExecute.id(), deleteResult.getSeqNo(), result.getTerm(), deleteResult.getVersion(), deleteResult.isFound()); } else { diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index 34dd3f0b11585..03b11f0a8ec48 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -778,7 +778,7 @@ synchronized void markItemAsDropped(int slot) { new BulkItemResponse(slot, indexRequest.opType(), new UpdateResponse( new ShardId(indexRequest.index(), IndexMetaData.INDEX_UUID_NA_VALUE, 0), - indexRequest.type(), id, SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, + id, SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, indexRequest.version(), DocWriteResponse.Result.NOOP ) ) @@ -787,8 +787,8 @@ synchronized void markItemAsDropped(int slot) { synchronized void markItemAsFailed(int slot, Exception e) { IndexRequest indexRequest = getIndexWriteRequest(bulkRequest.requests().get(slot)); - LOGGER.debug(() -> new ParameterizedMessage("failed to execute pipeline [{}] for document [{}/{}/{}]", - indexRequest.getPipeline(), indexRequest.index(), indexRequest.type(), indexRequest.id()), e); + LOGGER.debug(() -> new ParameterizedMessage("failed to execute pipeline [{}] for document [{}/{}]", + indexRequest.getPipeline(), indexRequest.index(), indexRequest.id()), e); // We hit a error during preprocessing a request, so we: // 1) Remember the request item slot from the bulk, so that we're done processing all requests we know what failed diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index 7f7a4d1e15bfc..25a880ad91a73 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -59,6 +59,7 @@ import org.elasticsearch.index.engine.VersionConflictEngineException; import org.elasticsearch.index.get.GetResult; import org.elasticsearch.index.mapper.MapperException; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.SourceToParse; import org.elasticsearch.index.seqno.SequenceNumbers; import org.elasticsearch.index.shard.IndexShard; @@ -253,17 +254,18 @@ static boolean executeBulkItemRequest(BulkPrimaryExecutionContext context, Updat final Engine.Result result; if (isDelete) { final DeleteRequest request = context.getRequestToExecute(); - result = primary.applyDeleteOperationOnPrimary(version, request.type(), request.id(), request.versionType(), + result = primary.applyDeleteOperationOnPrimary(version, MapperService.SINGLE_MAPPING_NAME, request.id(), request.versionType(), request.ifSeqNo(), request.ifPrimaryTerm()); } else { final IndexRequest request = context.getRequestToExecute(); result = primary.applyIndexOperationOnPrimary(version, request.versionType(), new SourceToParse( - request.index(), request.type(), request.id(), request.source(), request.getContentType(), request.routing()), + request.index(), MapperService.SINGLE_MAPPING_NAME, request.id(), request.source(), + request.getContentType(), request.routing()), request.ifSeqNo(), request.ifPrimaryTerm(), request.getAutoGeneratedTimestamp(), request.isRetry()); } if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) { mappingUpdater.updateMappings(result.getRequiredMappingUpdate(), primary.shardId(), - context.getRequestToExecute().type(), + MapperService.SINGLE_MAPPING_NAME, new ActionListener<>() { @Override public void onResponse(Void v) { @@ -354,7 +356,7 @@ private static BulkItemResponse processUpdateResponse(final UpdateRequest update final IndexRequest updateIndexRequest = translate.action(); final IndexResponse indexResponse = operationResponse.getResponse(); updateResponse = new UpdateResponse(indexResponse.getShardInfo(), indexResponse.getShardId(), - indexResponse.getType(), indexResponse.getId(), indexResponse.getSeqNo(), indexResponse.getPrimaryTerm(), + indexResponse.getId(), indexResponse.getSeqNo(), indexResponse.getPrimaryTerm(), indexResponse.getVersion(), indexResponse.getResult()); if (updateRequest.fetchSource() != null && updateRequest.fetchSource().fetchSource()) { @@ -368,7 +370,7 @@ private static BulkItemResponse processUpdateResponse(final UpdateRequest update } else if (translatedResult == DocWriteResponse.Result.DELETED) { final DeleteResponse deleteResponse = operationResponse.getResponse(); updateResponse = new UpdateResponse(deleteResponse.getShardInfo(), deleteResponse.getShardId(), - deleteResponse.getType(), deleteResponse.getId(), deleteResponse.getSeqNo(), deleteResponse.getPrimaryTerm(), + deleteResponse.getId(), deleteResponse.getSeqNo(), deleteResponse.getPrimaryTerm(), deleteResponse.getVersion(), deleteResponse.getResult()); final GetResult getResult = UpdateHelper.extractGetResult(updateRequest, concreteIndex, @@ -422,15 +424,15 @@ private static Engine.Result performOpOnReplica(DocWriteResponse primaryResponse case INDEX: final IndexRequest indexRequest = (IndexRequest) docWriteRequest; final ShardId shardId = replica.shardId(); - final SourceToParse sourceToParse = new SourceToParse(shardId.getIndexName(), indexRequest.type(), indexRequest.id(), - indexRequest.source(), indexRequest.getContentType(), indexRequest.routing()); + final SourceToParse sourceToParse = new SourceToParse(shardId.getIndexName(), MapperService.SINGLE_MAPPING_NAME, + indexRequest.id(), indexRequest.source(), indexRequest.getContentType(), indexRequest.routing()); result = replica.applyIndexOperationOnReplica(primaryResponse.getSeqNo(), primaryResponse.getVersion(), indexRequest.getAutoGeneratedTimestamp(), indexRequest.isRetry(), sourceToParse); break; case DELETE: DeleteRequest deleteRequest = (DeleteRequest) docWriteRequest; result = replica.applyDeleteOperationOnReplica(primaryResponse.getSeqNo(), primaryResponse.getVersion(), - deleteRequest.type(), deleteRequest.id()); + MapperService.SINGLE_MAPPING_NAME, deleteRequest.id()); break; default: assert false : "Unexpected request operation type on replica: " + docWriteRequest + ";primary result: " + primaryResponse; diff --git a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java index cc7e10469e024..28e22addd8e6d 100644 --- a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java +++ b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java @@ -19,6 +19,7 @@ package org.elasticsearch.action.delete; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; import org.elasticsearch.action.DocWriteRequest; @@ -42,7 +43,7 @@ * A request to delete a document from an index based on its type and id. Best created using * {@link org.elasticsearch.client.Requests#deleteRequest(String)}. *

- * The operation requires the {@link #index()}, {@link #type(String)} and {@link #id(String)} to + * The operation requires the {@link #index()} and {@link #id(String)} to * be set. * * @see DeleteResponse @@ -54,8 +55,6 @@ public class DeleteRequest extends ReplicatedWriteRequest private static final ShardId NO_SHARD_ID = null; - // Set to null initially so we can know to override in bulk requests that have a default type. - private String type; private String id; @Nullable private String routing; @@ -66,7 +65,10 @@ public class DeleteRequest extends ReplicatedWriteRequest public DeleteRequest(StreamInput in) throws IOException { super(in); - type = in.readString(); + if (in.getVersion().before(Version.V_8_0_0)) { + String type = in.readString(); + assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]"; + } id = in.readString(); routing = in.readOptionalString(); version = in.readLong(); @@ -80,7 +82,7 @@ public DeleteRequest() { } /** - * Constructs a new delete request against the specified index. The {@link #type(String)} and {@link #id(String)} + * Constructs a new delete request against the specified index. The {@link #id(String)} * must be set. */ public DeleteRequest(String index) { @@ -88,23 +90,6 @@ public DeleteRequest(String index) { this.index = index; } - /** - * Constructs a new delete request against the specified index with the type and id. - * - * @param index The index to get the document from - * @param type The type of the document - * @param id The id of the document - * - * @deprecated Types are in the process of being removed. Use {@link #DeleteRequest(String, String)} instead. - */ - @Deprecated - public DeleteRequest(String index, String type, String id) { - super(NO_SHARD_ID); - this.index = index; - this.type = type; - this.id = id; - } - /** * Constructs a new delete request against the specified index and id. * @@ -120,9 +105,6 @@ public DeleteRequest(String index, String id) { @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); - if (Strings.isEmpty(type())) { - validationException = addValidationError("type is missing", validationException); - } if (Strings.isEmpty(id)) { validationException = addValidationError("id is missing", validationException); } @@ -132,32 +114,6 @@ public ActionRequestValidationException validate() { return validationException; } - /** - * The type of the document to delete. - * - * @deprecated Types are in the process of being removed. - */ - @Deprecated - @Override - public String type() { - if (type == null) { - return MapperService.SINGLE_MAPPING_NAME; - } - return type; - } - - /** - * Sets the type of the document to delete. - * - * @deprecated Types are in the process of being removed. - */ - @Deprecated - @Override - public DeleteRequest type(String type) { - this.type = type; - return this; - } - /** * The id of the document to delete. */ @@ -276,9 +232,9 @@ public OpType opType() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. - // So we use the type accessor method here to make the type non-null (will default it to "_doc"). - out.writeString(type()); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); out.writeOptionalString(routing()); out.writeLong(version); @@ -289,6 +245,6 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return "delete {[" + index + "][" + type() + "][" + id + "]}"; + return "delete {[" + index + "][" + id + "]}"; } } diff --git a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java index 71a971111c0d7..edb4c24617f47 100644 --- a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequestBuilder.java @@ -41,9 +41,10 @@ public DeleteRequestBuilder(ElasticsearchClient client, DeleteAction action, @Nu /** * Sets the type of the document to delete. + * @deprecated types are being removed */ + @Deprecated public DeleteRequestBuilder setType(String type) { - request.type(type); return this; } diff --git a/server/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java b/server/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java index 5961797e3a084..f60b755c84617 100644 --- a/server/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java +++ b/server/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java @@ -41,12 +41,12 @@ public DeleteResponse(StreamInput in) throws IOException { super(in); } - public DeleteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, boolean found) { - this(shardId, type, id, seqNo, primaryTerm, version, found ? Result.DELETED : Result.NOT_FOUND); + public DeleteResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, boolean found) { + this(shardId, id, seqNo, primaryTerm, version, found ? Result.DELETED : Result.NOT_FOUND); } - private DeleteResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) { - super(shardId, type, id, seqNo, primaryTerm, version, assertDeletedOrNotFound(result)); + private DeleteResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) { + super(shardId, id, seqNo, primaryTerm, version, assertDeletedOrNotFound(result)); } private static Result assertDeletedOrNotFound(Result result) { @@ -64,7 +64,6 @@ public String toString() { StringBuilder builder = new StringBuilder(); builder.append("DeleteResponse["); builder.append("index=").append(getIndex()); - builder.append(",type=").append(getType()); builder.append(",id=").append(getId()); builder.append(",version=").append(getVersion()); builder.append(",result=").append(getResult().getLowercase()); @@ -98,7 +97,7 @@ public static class Builder extends DocWriteResponse.Builder { @Override public DeleteResponse build() { - DeleteResponse deleteResponse = new DeleteResponse(shardId, type, id, seqNo, primaryTerm, version, result); + DeleteResponse deleteResponse = new DeleteResponse(shardId, id, seqNo, primaryTerm, version, result); deleteResponse.setForcedRefresh(forcedRefresh); if (shardInfo != null) { deleteResponse.setShardInfo(shardInfo); diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 2d6c4f28c5d0d..c58831583dc15 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -31,7 +31,6 @@ import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.Strings; import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; @@ -61,7 +60,7 @@ * Index request to index a typed JSON document into a specific index and make it searchable. Best * created using {@link org.elasticsearch.client.Requests#indexRequest(String)}. * - * The index requires the {@link #index()}, {@link #type(String)}, {@link #id(String)} and + * The index requires the {@link #index()}, {@link #id(String)} and * {@link #source(byte[], XContentType)} to be set. * * The source (content to index) can be set in its bytes form using ({@link #source(byte[], XContentType)}), @@ -85,8 +84,6 @@ public class IndexRequest extends ReplicatedWriteRequest implement private static final ShardId NO_SHARD_ID = null; - // Set to null initially so we can know to override in bulk requests that have a default type. - private String type; private String id; @Nullable private String routing; @@ -118,7 +115,10 @@ public class IndexRequest extends ReplicatedWriteRequest implement public IndexRequest(StreamInput in) throws IOException { super(in); - type = in.readOptionalString(); + if (in.getVersion().before(Version.V_8_0_0)) { + String type = in.readOptionalString(); + assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]"; + } id = in.readOptionalString(); routing = in.readOptionalString(); source = in.readBytesReference(); @@ -145,7 +145,7 @@ public IndexRequest() { } /** - * Constructs a new index request against the specific index. The {@link #type(String)} + * Constructs a new index request against the specific index. The * {@link #source(byte[], XContentType)} must be set. */ public IndexRequest(String index) { @@ -153,44 +153,12 @@ public IndexRequest(String index) { this.index = index; } - /** - * Constructs a new index request against the specific index and type. The - * {@link #source(byte[], XContentType)} must be set. - * @deprecated Types are in the process of being removed. Use {@link #IndexRequest(String)} instead. - */ - @Deprecated - public IndexRequest(String index, String type) { - super(NO_SHARD_ID); - this.index = index; - this.type = type; - } - - /** - * Constructs a new index request against the index, type, id and using the source. - * - * @param index The index to index into - * @param type The type to index into - * @param id The id of document - * - * @deprecated Types are in the process of being removed. Use {@link #IndexRequest(String)} with {@link #id(String)} instead. - */ - @Deprecated - public IndexRequest(String index, String type, String id) { - super(NO_SHARD_ID); - this.index = index; - this.type = type; - this.id = id; - } - @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if (source == null) { validationException = addValidationError("source is missing", validationException); } - if (Strings.isEmpty(type())) { - validationException = addValidationError("type is missing", validationException); - } if (contentType == null) { validationException = addValidationError("content type is missing", validationException); } @@ -246,31 +214,6 @@ public XContentType getContentType() { return contentType; } - /** - * The type of the indexed document. - * @deprecated Types are in the process of being removed. - */ - @Deprecated - @Override - public String type() { - if (type == null) { - return MapperService.SINGLE_MAPPING_NAME; - } - return type; - } - - /** - * Sets the type of the indexed document. - * @deprecated Types are in the process of being removed. - */ - @Deprecated - @Override - public IndexRequest type(String type) { - this.type = type; - return this; - } - - /** * The id of the indexed document. If not set, will be automatically generated. */ @@ -628,9 +571,9 @@ public void resolveRouting(MetaData metaData) { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. - // So we use the type accessor method here to make the type non-null (will default it to "_doc"). - out.writeOptionalString(type()); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME); + } out.writeOptionalString(id); out.writeOptionalString(routing); out.writeBytesReference(source); @@ -666,7 +609,7 @@ public String toString() { } catch (Exception e) { // ignore } - return "index {[" + index + "][" + type() + "][" + id + "], source[" + sSource + "]}"; + return "index {[" + index + "][" + id + "], source[" + sSource + "]}"; } diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java index 19074bbd92eb7..cfb5e46b63f19 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java @@ -47,9 +47,10 @@ public IndexRequestBuilder(ElasticsearchClient client, IndexAction action, @Null /** * Sets the type to index the document to. + * @deprecated has no effect as types are being removed */ + @Deprecated public IndexRequestBuilder setType(String type) { - request.type(type); return this; } diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexResponse.java b/server/src/main/java/org/elasticsearch/action/index/IndexResponse.java index 75ad2e106a05d..592c6a97f835f 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexResponse.java @@ -42,12 +42,12 @@ public IndexResponse(StreamInput in) throws IOException { super(in); } - public IndexResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, boolean created) { - this(shardId, type, id, seqNo, primaryTerm, version, created ? Result.CREATED : Result.UPDATED); + public IndexResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, boolean created) { + this(shardId, id, seqNo, primaryTerm, version, created ? Result.CREATED : Result.UPDATED); } - private IndexResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) { - super(shardId, type, id, seqNo, primaryTerm, version, assertCreatedOrUpdated(result)); + private IndexResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) { + super(shardId, id, seqNo, primaryTerm, version, assertCreatedOrUpdated(result)); } private static Result assertCreatedOrUpdated(Result result) { @@ -65,7 +65,6 @@ public String toString() { StringBuilder builder = new StringBuilder(); builder.append("IndexResponse["); builder.append("index=").append(getIndex()); - builder.append(",type=").append(getType()); builder.append(",id=").append(getId()); builder.append(",version=").append(getVersion()); builder.append(",result=").append(getResult().getLowercase()); @@ -100,7 +99,7 @@ public static void parseXContentFields(XContentParser parser, Builder context) t public static class Builder extends DocWriteResponse.Builder { @Override public IndexResponse build() { - IndexResponse indexResponse = new IndexResponse(shardId, type, id, seqNo, primaryTerm, version, result); + IndexResponse indexResponse = new IndexResponse(shardId, id, seqNo, primaryTerm, version, result); indexResponse.setForcedRefresh(forcedRefresh); if (shardInfo != null) { indexResponse.setShardInfo(shardInfo); diff --git a/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java b/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java index de0b0c18a9113..884e1590d1640 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java @@ -183,8 +183,6 @@ private static List parseDocs(Map config) { deprecationLogger.deprecatedAndMaybeLog("simulate_pipeline_with_types", "[types removal] specifying _type in pipeline simulation requests is deprecated"); } - String type = ConfigurationUtils.readStringOrIntProperty(null, null, - dataMap, MetaData.TYPE.getFieldName(), "_doc"); String id = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, MetaData.ID.getFieldName(), "_id"); String routing = ConfigurationUtils.readOptionalStringOrIntProperty(null, null, @@ -199,7 +197,7 @@ private static List parseDocs(Map config) { MetaData.VERSION_TYPE.getFieldName())); } IngestDocument ingestDocument = - new IngestDocument(index, type, id, routing, version, versionType, document); + new IngestDocument(index, id, routing, version, versionType, document); ingestDocumentList.add(ingestDocument); } return ingestDocumentList; diff --git a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java index 2781fe5ab9a32..0de90aa7f58ba 100644 --- a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java @@ -50,6 +50,7 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.IndexService; import org.elasticsearch.index.engine.VersionConflictEngineException; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.IndicesService; @@ -182,7 +183,7 @@ protected void shardOperation(final UpdateRequest request, final ActionListener< client.bulk(toSingleItemBulkRequest(upsertRequest), wrapBulkResponse( ActionListener.wrap(response -> { UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(), - response.getType(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(), + response.getId(), response.getSeqNo(), response.getPrimaryTerm(), response.getVersion(), response.getResult()); if (request.fetchSource() != null && request.fetchSource().fetchSource()) { Tuple> sourceAndContent = @@ -206,7 +207,7 @@ protected void shardOperation(final UpdateRequest request, final ActionListener< client.bulk(toSingleItemBulkRequest(indexRequest), wrapBulkResponse( ActionListener.wrap(response -> { UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(), - response.getType(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(), + response.getId(), response.getSeqNo(), response.getPrimaryTerm(), response.getVersion(), response.getResult()); update.setGetResult(UpdateHelper.extractGetResult(request, request.concreteIndex(), response.getSeqNo(), response.getPrimaryTerm(), response.getVersion(), @@ -220,7 +221,7 @@ protected void shardOperation(final UpdateRequest request, final ActionListener< DeleteRequest deleteRequest = result.action(); client.bulk(toSingleItemBulkRequest(deleteRequest), wrapBulkResponse( ActionListener.wrap(response -> { - UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(), response.getType(), + UpdateResponse update = new UpdateResponse(response.getShardInfo(), response.getShardId(), response.getId(), response.getSeqNo(), response.getPrimaryTerm(), response.getVersion(), response.getResult()); update.setGetResult(UpdateHelper.extractGetResult(request, request.concreteIndex(), @@ -237,7 +238,7 @@ protected void shardOperation(final UpdateRequest request, final ActionListener< if (indexServiceOrNull != null) { IndexShard shard = indexService.getShardOrNull(shardId.getId()); if (shard != null) { - shard.noopUpdate(request.type()); + shard.noopUpdate(MapperService.SINGLE_MAPPING_NAME); } } listener.onResponse(update); diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateHelper.java b/server/src/main/java/org/elasticsearch/action/update/UpdateHelper.java index 92e320fe5c5f4..f2fe9a84e06a7 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateHelper.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateHelper.java @@ -85,7 +85,7 @@ protected Result prepare(ShardId shardId, UpdateRequest request, final GetResult return prepareUpsert(shardId, request, getResult, nowInMillis); } else if (getResult.internalSourceRef() == null) { // no source, we can't do anything, throw a failure... - throw new DocumentSourceMissingException(shardId, request.type(), request.id()); + throw new DocumentSourceMissingException(shardId, request.id()); } else if (request.script() == null && request.doc() != null) { // The request has no script, it is a new doc that should be merged with the old document return prepareUpdateIndexRequest(shardId, request, getResult, request.detectNoop()); @@ -127,7 +127,7 @@ Tuple> executeScriptedUpsert(IndexRequest upse */ Result prepareUpsert(ShardId shardId, UpdateRequest request, final GetResult getResult, LongSupplier nowInMillis) { if (request.upsertRequest() == null && !request.docAsUpsert()) { - throw new DocumentMissingException(shardId, request.type(), request.id()); + throw new DocumentMissingException(shardId, request.id()); } IndexRequest indexRequest = request.docAsUpsert() ? request.doc() : request.upsertRequest(); if (request.scriptedUpsert() && request.script() != null) { @@ -140,7 +140,7 @@ Result prepareUpsert(ShardId shardId, UpdateRequest request, final GetResult get indexRequest.source(upsertResult.v2()); break; case NONE: - UpdateResponse update = new UpdateResponse(shardId, MapperService.SINGLE_MAPPING_NAME, getResult.getId(), + UpdateResponse update = new UpdateResponse(shardId, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), DocWriteResponse.Result.NOOP); update.setGetResult(getResult); return new Result(update, DocWriteResponse.Result.NOOP, upsertResult.v2(), XContentType.JSON); @@ -151,7 +151,7 @@ Result prepareUpsert(ShardId shardId, UpdateRequest request, final GetResult get } indexRequest.index(request.index()) - .type(request.type()).id(request.id()).setRefreshPolicy(request.getRefreshPolicy()).routing(request.routing()) + .id(request.id()).setRefreshPolicy(request.getRefreshPolicy()).routing(request.routing()) .timeout(request.timeout()).waitForActiveShards(request.waitForActiveShards()) // it has to be a "create!" .create(true); @@ -194,14 +194,14 @@ Result prepareUpdateIndexRequest(ShardId shardId, UpdateRequest request, GetResu // We can only actually turn the update into a noop if detectNoop is true to preserve backwards compatibility and to handle cases // where users repopulating multi-fields or adding synonyms, etc. if (detectNoop && noop) { - UpdateResponse update = new UpdateResponse(shardId, MapperService.SINGLE_MAPPING_NAME, getResult.getId(), + UpdateResponse update = new UpdateResponse(shardId, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), DocWriteResponse.Result.NOOP); update.setGetResult(extractGetResult(request, request.index(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), updatedSourceAsMap, updateSourceContentType, getResult.internalSourceRef())); return new Result(update, DocWriteResponse.Result.NOOP, updatedSourceAsMap, updateSourceContentType); } else { final IndexRequest finalIndexRequest = Requests.indexRequest(request.index()) - .type(request.type()).id(request.id()).routing(routing) + .id(request.id()).routing(routing) .source(updatedSourceAsMap, updateSourceContentType) .setIfSeqNo(getResult.getSeqNo()).setIfPrimaryTerm(getResult.getPrimaryTerm()) .waitForActiveShards(request.waitForActiveShards()).timeout(request.timeout()) @@ -242,7 +242,7 @@ Result prepareUpdateScriptRequest(ShardId shardId, UpdateRequest request, GetRes switch (operation) { case INDEX: final IndexRequest indexRequest = Requests.indexRequest(request.index()) - .type(request.type()).id(request.id()).routing(routing) + .id(request.id()).routing(routing) .source(updatedSourceAsMap, updateSourceContentType) .setIfSeqNo(getResult.getSeqNo()).setIfPrimaryTerm(getResult.getPrimaryTerm()) .waitForActiveShards(request.waitForActiveShards()).timeout(request.timeout()) @@ -250,14 +250,14 @@ Result prepareUpdateScriptRequest(ShardId shardId, UpdateRequest request, GetRes return new Result(indexRequest, DocWriteResponse.Result.UPDATED, updatedSourceAsMap, updateSourceContentType); case DELETE: DeleteRequest deleteRequest = Requests.deleteRequest(request.index()) - .type(request.type()).id(request.id()).routing(routing) + .id(request.id()).routing(routing) .setIfSeqNo(getResult.getSeqNo()).setIfPrimaryTerm(getResult.getPrimaryTerm()) .waitForActiveShards(request.waitForActiveShards()) .timeout(request.timeout()).setRefreshPolicy(request.getRefreshPolicy()); return new Result(deleteRequest, DocWriteResponse.Result.DELETED, updatedSourceAsMap, updateSourceContentType); default: // If it was neither an INDEX or DELETE operation, treat it as a noop - UpdateResponse update = new UpdateResponse(shardId, MapperService.SINGLE_MAPPING_NAME, getResult.getId(), + UpdateResponse update = new UpdateResponse(shardId, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), DocWriteResponse.Result.NOOP); update.setGetResult(extractGetResult(request, request.index(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), updatedSourceAsMap, updateSourceContentType, getResult.internalSourceRef())); diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java b/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java index 00b850109e496..9847ed74112e9 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java @@ -19,6 +19,7 @@ package org.elasticsearch.action.update; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.DocWriteRequest; import org.elasticsearch.action.index.IndexRequest; @@ -96,8 +97,6 @@ public class UpdateRequest extends InstanceShardOperationRequest PARSER.declareLong(UpdateRequest::setIfPrimaryTerm, IF_PRIMARY_TERM); } - // Set to null initially so we can know to override in bulk requests that have a default type. - private String type; private String id; @Nullable private String routing; @@ -130,7 +129,10 @@ public UpdateRequest() {} public UpdateRequest(StreamInput in) throws IOException { super(in); waitForActiveShards = ActiveShardCount.readFrom(in); - type = in.readString(); + if (in.getVersion().before(Version.V_8_0_0)) { + String type = in.readString(); + assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected [_doc] but received [" + type + "]"; + } id = in.readString(); routing = in.readOptionalString(); if (in.readBoolean()) { @@ -157,25 +159,12 @@ public UpdateRequest(String index, String id) { this.id = id; } - /** - * @deprecated Types are in the process of being removed. Use {@link #UpdateRequest(String, String)} instead. - */ - @Deprecated - public UpdateRequest(String index, String type, String id) { - super(index); - this.type = type; - this.id = id; - } - @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); if(upsertRequest != null && upsertRequest.version() != Versions.MATCH_ANY) { validationException = addValidationError("can't provide version in upsert request", validationException); } - if (Strings.isEmpty(type())) { - validationException = addValidationError("type is missing", validationException); - } if (Strings.isEmpty(id)) { validationException = addValidationError("id is missing", validationException); } @@ -208,31 +197,6 @@ public ActionRequestValidationException validate() { return validationException; } - /** - * The type of the indexed document. - * - * @deprecated Types are in the process of being removed. - */ - @Deprecated - @Override - public String type() { - if (type == null) { - return MapperService.SINGLE_MAPPING_NAME; - } - return type; - } - - /** - * Sets the type of the indexed document. - * - * @deprecated Types are in the process of being removed. - */ - @Deprecated - public UpdateRequest type(String type) { - this.type = type; - return this; - } - /** * The id of the indexed document. */ @@ -840,9 +804,9 @@ public UpdateRequest scriptedUpsert(boolean scriptedUpsert) { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); waitForActiveShards.writeTo(out); - // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. - // So we use the type accessor method here to make the type non-null (will default it to "_doc"). - out.writeString(type()); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); out.writeOptionalString(routing); @@ -859,7 +823,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(true); // make sure the basics are set doc.index(index); - doc.type(type); doc.id(id); doc.writeTo(out); } @@ -870,7 +833,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(true); // make sure the basics are set upsertRequest.index(index); - upsertRequest.type(type); upsertRequest.id(id); upsertRequest.writeTo(out); } @@ -929,7 +891,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws public String toString() { StringBuilder res = new StringBuilder() .append("update {[").append(index) - .append("][").append(type()) .append("][").append(id).append("]"); res.append(", doc_as_upsert[").append(docAsUpsert).append("]"); if (doc != null) { diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java index 919f460e8c07b..116453ff24645 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateRequestBuilder.java @@ -40,15 +40,21 @@ public UpdateRequestBuilder(ElasticsearchClient client, UpdateAction action) { super(client, action, new UpdateRequest()); } + @Deprecated public UpdateRequestBuilder(ElasticsearchClient client, UpdateAction action, String index, String type, String id) { - super(client, action, new UpdateRequest(index, type, id)); + super(client, action, new UpdateRequest(index, id)); + } + + public UpdateRequestBuilder(ElasticsearchClient client, UpdateAction action, String index, String id) { + super(client, action, new UpdateRequest(index, id)); } /** * Sets the type of the indexed document. + * @deprecated types are being removed */ + @Deprecated public UpdateRequestBuilder setType(String type) { - request.type(type); return this; } diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateResponse.java b/server/src/main/java/org/elasticsearch/action/update/UpdateResponse.java index e27581480b732..5eba54544f9c4 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateResponse.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateResponse.java @@ -49,13 +49,13 @@ public UpdateResponse(StreamInput in) throws IOException { * Constructor to be used when a update didn't translate in a write. * For example: update script with operation set to none */ - public UpdateResponse(ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) { - this(new ShardInfo(0, 0), shardId, type, id, seqNo, primaryTerm, version, result); + public UpdateResponse(ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) { + this(new ShardInfo(0, 0), shardId, id, seqNo, primaryTerm, version, result); } public UpdateResponse( - ShardInfo shardInfo, ShardId shardId, String type, String id, long seqNo, long primaryTerm, long version, Result result) { - super(shardId, type, id, seqNo, primaryTerm, version, result); + ShardInfo shardInfo, ShardId shardId, String id, long seqNo, long primaryTerm, long version, Result result) { + super(shardId, id, seqNo, primaryTerm, version, result); setShardInfo(shardInfo); } @@ -99,7 +99,6 @@ public String toString() { StringBuilder builder = new StringBuilder(); builder.append("UpdateResponse["); builder.append("index=").append(getIndex()); - builder.append(",type=").append(getType()); builder.append(",id=").append(getId()); builder.append(",version=").append(getVersion()); builder.append(",seqNo=").append(getSeqNo()); @@ -152,9 +151,9 @@ public void setGetResult(GetResult getResult) { public UpdateResponse build() { UpdateResponse update; if (shardInfo != null) { - update = new UpdateResponse(shardInfo, shardId, type, id, seqNo, primaryTerm, version, result); + update = new UpdateResponse(shardInfo, shardId, id, seqNo, primaryTerm, version, result); } else { - update = new UpdateResponse(shardId, type, id, seqNo, primaryTerm, version, result); + update = new UpdateResponse(shardId, id, seqNo, primaryTerm, version, result); } if (getResult != null) { update.setGetResult(new GetResult(update.getIndex(), update.getId(), diff --git a/server/src/main/java/org/elasticsearch/client/Requests.java b/server/src/main/java/org/elasticsearch/client/Requests.java index 24f52b69f9f3c..01d04c64ae1b1 100644 --- a/server/src/main/java/org/elasticsearch/client/Requests.java +++ b/server/src/main/java/org/elasticsearch/client/Requests.java @@ -84,8 +84,7 @@ public static IndexRequest indexRequest() { } /** - * Create an index request against a specific index. Note the {@link IndexRequest#type(String)} must be - * set as well and optionally the {@link IndexRequest#id(String)}. + * Create an index request against a specific index. * * @param index The index name to index the request against * @return The index request @@ -96,7 +95,7 @@ public static IndexRequest indexRequest(String index) { } /** - * Creates a delete request against a specific index. Note the {@link DeleteRequest#type(String)} and + * Creates a delete request against a specific index. Note the * {@link DeleteRequest#id(String)} must be set. * * @param index The index name to delete from diff --git a/server/src/main/java/org/elasticsearch/index/engine/DocumentMissingException.java b/server/src/main/java/org/elasticsearch/index/engine/DocumentMissingException.java index 58e06e50a4676..0897aef8dc485 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/DocumentMissingException.java +++ b/server/src/main/java/org/elasticsearch/index/engine/DocumentMissingException.java @@ -26,8 +26,8 @@ public class DocumentMissingException extends EngineException { - public DocumentMissingException(ShardId shardId, String type, String id) { - super(shardId, "[" + type + "][" + id + "]: document missing"); + public DocumentMissingException(ShardId shardId, String id) { + super(shardId, "[" + id + "]: document missing"); } public DocumentMissingException(StreamInput in) throws IOException{ diff --git a/server/src/main/java/org/elasticsearch/index/engine/DocumentSourceMissingException.java b/server/src/main/java/org/elasticsearch/index/engine/DocumentSourceMissingException.java index 4fa53ed5a1e0d..3844e38fcfbe2 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/DocumentSourceMissingException.java +++ b/server/src/main/java/org/elasticsearch/index/engine/DocumentSourceMissingException.java @@ -26,8 +26,8 @@ public class DocumentSourceMissingException extends EngineException { - public DocumentSourceMissingException(ShardId shardId, String type, String id) { - super(shardId, "[" + type + "][" + id + "]: document source missing"); + public DocumentSourceMissingException(ShardId shardId, String id) { + super(shardId, "[" + id + "]: document source missing"); } public DocumentSourceMissingException(StreamInput in) throws IOException{ diff --git a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java index 85c64a379d181..524325c5c55f5 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java @@ -38,7 +38,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.VersionType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.script.Script; import org.elasticsearch.search.sort.SortOrder; @@ -195,14 +194,6 @@ public ReindexRequest setDestIndex(String destIndex) { return this; } - /** - * Set the document type for the destination index - */ - public ReindexRequest setDestDocType(String docType) { - this.getDestination().type(docType); - return this; - } - /** * Set the routing to decide which shard the documents need to be routed to */ @@ -281,9 +272,6 @@ public String toString() { } searchToString(b); b.append(" to [").append(destination.index()).append(']'); - if (destination.type() != null) { - b.append('[').append(destination.type()).append(']'); - } return b.toString(); } @@ -305,10 +293,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws // build destination builder.startObject("dest"); builder.field("index", getDestination().index()); - String type = getDestination().type(); - if (type != null && type.equals(MapperService.SINGLE_MAPPING_NAME) == false) { - builder.field("type", getDestination().type()); - } if (getDestination().routing() != null) { builder.field("routing", getDestination().routing()); } @@ -360,10 +344,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws ObjectParser destParser = new ObjectParser<>("dest"); destParser.declareString(IndexRequest::index, new ParseField("index")); - destParser.declareString((request, type) -> { - deprecationLogger.deprecatedAndMaybeLog("reindex_with_types", TYPES_DEPRECATION_MESSAGE); - request.type(type); - }, new ParseField("type")); destParser.declareString(IndexRequest::routing, new ParseField("routing")); destParser.declareString(IndexRequest::opType, new ParseField("op_type")); destParser.declareString(IndexRequest::setPipeline, new ParseField("pipeline")); diff --git a/server/src/main/java/org/elasticsearch/ingest/IngestDocument.java b/server/src/main/java/org/elasticsearch/ingest/IngestDocument.java index 34299cb475a27..6c8cacf14cdf5 100644 --- a/server/src/main/java/org/elasticsearch/ingest/IngestDocument.java +++ b/server/src/main/java/org/elasticsearch/ingest/IngestDocument.java @@ -62,12 +62,11 @@ public final class IngestDocument { // Contains all pipelines that have been executed for this document private final Set executedPipelines = Collections.newSetFromMap(new IdentityHashMap<>()); - public IngestDocument(String index, String type, String id, String routing, + public IngestDocument(String index, String id, String routing, Long version, VersionType versionType, Map source) { this.sourceAndMetadata = new HashMap<>(); this.sourceAndMetadata.putAll(source); this.sourceAndMetadata.put(MetaData.INDEX.getFieldName(), index); - this.sourceAndMetadata.put(MetaData.TYPE.getFieldName(), type); this.sourceAndMetadata.put(MetaData.ID.getFieldName(), id); if (routing != null) { this.sourceAndMetadata.put(MetaData.ROUTING.getFieldName(), routing); diff --git a/server/src/main/java/org/elasticsearch/ingest/IngestService.java b/server/src/main/java/org/elasticsearch/ingest/IngestService.java index 243d8d7c3e5d2..dc5285d0c48c1 100644 --- a/server/src/main/java/org/elasticsearch/ingest/IngestService.java +++ b/server/src/main/java/org/elasticsearch/ingest/IngestService.java @@ -464,13 +464,12 @@ private void innerExecute(int slot, IndexRequest indexRequest, Pipeline pipeline // (e.g. the pipeline may have been removed while we're ingesting a document totalMetrics.preIngest(); String index = indexRequest.index(); - String type = indexRequest.type(); String id = indexRequest.id(); String routing = indexRequest.routing(); Long version = indexRequest.version(); VersionType versionType = indexRequest.versionType(); Map sourceAsMap = indexRequest.sourceAsMap(); - IngestDocument ingestDocument = new IngestDocument(index, type, id, routing, version, versionType, sourceAsMap); + IngestDocument ingestDocument = new IngestDocument(index, id, routing, version, versionType, sourceAsMap); pipeline.execute(ingestDocument, (result, e) -> { long ingestTimeInMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTimeInNanos); totalMetrics.postIngest(ingestTimeInMillis); @@ -485,7 +484,6 @@ private void innerExecute(int slot, IndexRequest indexRequest, Pipeline pipeline //it's fine to set all metadata fields all the time, as ingest document holds their starting values //before ingestion, which might also get modified during ingestion. indexRequest.index((String) metadataMap.get(IngestDocument.MetaData.INDEX)); - indexRequest.type((String) metadataMap.get(IngestDocument.MetaData.TYPE)); indexRequest.id((String) metadataMap.get(IngestDocument.MetaData.ID)); indexRequest.routing((String) metadataMap.get(IngestDocument.MetaData.ROUTING)); indexRequest.version(((Number) metadataMap.get(IngestDocument.MetaData.VERSION)).longValue()); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java index 479e1eb73dc44..bf7cd0d8da6e4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java @@ -19,11 +19,9 @@ package org.elasticsearch.rest.action.document; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; @@ -36,16 +34,9 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestDeleteAction.class)); - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " + - "document index requests is deprecated, use the /{index}/_doc/{id} endpoint instead."; public RestDeleteAction(RestController controller) { controller.registerHandler(DELETE, "/{index}/_doc/{id}", this); - - // Deprecated typed endpoint. - controller.registerHandler(DELETE, "/{index}/{type}/{id}", this); } @Override @@ -55,14 +46,7 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - DeleteRequest deleteRequest; - if (request.hasParam("type")) { - deprecationLogger.deprecatedAndMaybeLog("delete_with_types", TYPES_DEPRECATION_MESSAGE); - deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id")); - } else { - deleteRequest = new DeleteRequest(request.param("index"), request.param("id")); - } - + DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("id")); deleteRequest.routing(request.param("routing")); deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT)); deleteRequest.setRefreshPolicy(request.param("refresh")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index 80794be982723..584708123f57a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -19,13 +19,10 @@ package org.elasticsearch.rest.action.document; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.VersionType; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; @@ -39,11 +36,6 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestIndexAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestDeleteAction.class)); - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in document " + - "index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, " + - "or /{index}/_create/{id})."; public RestIndexAction(RestController controller) { controller.registerHandler(POST, "/{index}/_doc", this); // auto id creation @@ -53,13 +45,6 @@ public RestIndexAction(RestController controller) { CreateHandler createHandler = new CreateHandler(); controller.registerHandler(PUT, "/{index}/_create/{id}", createHandler); controller.registerHandler(POST, "/{index}/_create/{id}/", createHandler); - - // Deprecated typed endpoints. - controller.registerHandler(POST, "/{index}/{type}", this); // auto id creation - controller.registerHandler(PUT, "/{index}/{type}/{id}", this); - controller.registerHandler(POST, "/{index}/{type}/{id}", this); - controller.registerHandler(PUT, "/{index}/{type}/{id}/_create", createHandler); - controller.registerHandler(POST, "/{index}/{type}/{id}/_create", createHandler); } @Override @@ -92,15 +77,7 @@ void validateOpType(String opType) { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - IndexRequest indexRequest; - final String type = request.param("type"); - if (type != null && type.equals(MapperService.SINGLE_MAPPING_NAME) == false) { - deprecationLogger.deprecatedAndMaybeLog("index_with_types", TYPES_DEPRECATION_MESSAGE); - indexRequest = new IndexRequest(request.param("index"), type, request.param("id")); - } else { - indexRequest = new IndexRequest(request.param("index")); - indexRequest.id(request.param("id")); - } + IndexRequest indexRequest = new IndexRequest(request.param("index")); indexRequest.routing(request.param("routing")); indexRequest.setPipeline(request.param("pipeline")); indexRequest.source(request.requiredContent(), request.getXContentType()); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java index 1409d7c3efaf3..82bcf1ffbaedb 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java @@ -19,13 +19,11 @@ package org.elasticsearch.rest.action.document; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; @@ -39,16 +37,9 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestUpdateAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = - new DeprecationLogger(LogManager.getLogger(RestUpdateAction.class)); - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " + - "document update requests is deprecated, use the endpoint /{index}/_update/{id} instead."; public RestUpdateAction(RestController controller) { controller.registerHandler(POST, "/{index}/_update/{id}", this); - - // Deprecated typed endpoint. - controller.registerHandler(POST, "/{index}/{type}/{id}/_update", this); } @Override @@ -58,16 +49,7 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - UpdateRequest updateRequest; - if (request.hasParam("type")) { - deprecationLogger.deprecatedAndMaybeLog("update_with_types", TYPES_DEPRECATION_MESSAGE); - updateRequest = new UpdateRequest(request.param("index"), - request.param("type"), - request.param("id")); - } else { - updateRequest = new UpdateRequest(request.param("index"), request.param("id")); - } - + UpdateRequest updateRequest = new UpdateRequest(request.param("index"), request.param("id")); updateRequest.routing(request.param("routing")); updateRequest.timeout(request.paramAsTime("timeout", updateRequest.timeout())); updateRequest.setRefreshPolicy(request.param("refresh")); diff --git a/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java b/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java index 80c1fa5113b5f..0b457139a98d3 100644 --- a/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java @@ -41,7 +41,6 @@ public void testGetLocation() { final DocWriteResponse response = new DocWriteResponse( new ShardId("index", "uuid", 0), - "type", "id", SequenceNumbers.UNASSIGNED_SEQ_NO, 17, @@ -55,7 +54,6 @@ public void testGetLocationNonAscii() { final DocWriteResponse response = new DocWriteResponse( new ShardId("index", "uuid", 0), - "type", "❤", SequenceNumbers.UNASSIGNED_SEQ_NO, 17, @@ -69,7 +67,6 @@ public void testGetLocationWithSpaces() { final DocWriteResponse response = new DocWriteResponse( new ShardId("index", "uuid", 0), - "type", "a b", SequenceNumbers.UNASSIGNED_SEQ_NO, 17, @@ -87,7 +84,6 @@ public void testToXContentDoesntIncludeForcedRefreshUnlessForced() throws IOExce DocWriteResponse response = new DocWriteResponse( new ShardId("index", "uuid", 0), - "type", "id", SequenceNumbers.UNASSIGNED_SEQ_NO, 17, diff --git a/server/src/test/java/org/elasticsearch/action/IndicesRequestIT.java b/server/src/test/java/org/elasticsearch/action/IndicesRequestIT.java index 1c6d6c9932a7b..c6329e0a098e3 100644 --- a/server/src/test/java/org/elasticsearch/action/IndicesRequestIT.java +++ b/server/src/test/java/org/elasticsearch/action/IndicesRequestIT.java @@ -218,7 +218,7 @@ public void testIndex() { String[] indexShardActions = new String[]{BulkAction.NAME + "[s][p]", BulkAction.NAME + "[s][r]"}; interceptTransportActions(indexShardActions); - IndexRequest indexRequest = new IndexRequest(randomIndexOrAlias(), "type", "id") + IndexRequest indexRequest = new IndexRequest(randomIndexOrAlias()).id("id") .source(Requests.INDEX_CONTENT_TYPE, "field", "value"); internalCluster().coordOnlyNodeClient().index(indexRequest).actionGet(); @@ -230,7 +230,7 @@ public void testDelete() { String[] deleteShardActions = new String[]{BulkAction.NAME + "[s][p]", BulkAction.NAME + "[s][r]"}; interceptTransportActions(deleteShardActions); - DeleteRequest deleteRequest = new DeleteRequest(randomIndexOrAlias(), "type", "id"); + DeleteRequest deleteRequest = new DeleteRequest(randomIndexOrAlias()).id("id"); internalCluster().coordOnlyNodeClient().delete(deleteRequest).actionGet(); clearInterceptedActions(); @@ -244,7 +244,7 @@ public void testUpdate() { String indexOrAlias = randomIndexOrAlias(); client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get(); - UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1"); + UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1"); UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet(); assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult()); @@ -258,7 +258,7 @@ public void testUpdateUpsert() { interceptTransportActions(updateShardActions); String indexOrAlias = randomIndexOrAlias(); - UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").upsert(Requests.INDEX_CONTENT_TYPE, "field", "value") + UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "id").upsert(Requests.INDEX_CONTENT_TYPE, "field", "value") .doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1"); UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet(); assertEquals(DocWriteResponse.Result.CREATED, updateResponse.getResult()); @@ -274,7 +274,7 @@ public void testUpdateDelete() { String indexOrAlias = randomIndexOrAlias(); client().prepareIndex(indexOrAlias, "type", "id").setSource("field", "value").get(); - UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id") + UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "id") .script(new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "ctx.op='delete'", Collections.emptyMap())); UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet(); assertEquals(DocWriteResponse.Result.DELETED, updateResponse.getResult()); @@ -292,19 +292,19 @@ public void testBulk() { int numIndexRequests = iterations(1, 10); for (int i = 0; i < numIndexRequests; i++) { String indexOrAlias = randomIndexOrAlias(); - bulkRequest.add(new IndexRequest(indexOrAlias, "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")); + bulkRequest.add(new IndexRequest(indexOrAlias).id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")); indices.add(indexOrAlias); } int numDeleteRequests = iterations(1, 10); for (int i = 0; i < numDeleteRequests; i++) { String indexOrAlias = randomIndexOrAlias(); - bulkRequest.add(new DeleteRequest(indexOrAlias, "type", "id")); + bulkRequest.add(new DeleteRequest(indexOrAlias).id("id")); indices.add(indexOrAlias); } int numUpdateRequests = iterations(1, 10); for (int i = 0; i < numUpdateRequests; i++) { String indexOrAlias = randomIndexOrAlias(); - bulkRequest.add(new UpdateRequest(indexOrAlias, "type", "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1")); + bulkRequest.add(new UpdateRequest(indexOrAlias, "id").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value1")); indices.add(indexOrAlias); } diff --git a/server/src/test/java/org/elasticsearch/action/ListenerActionIT.java b/server/src/test/java/org/elasticsearch/action/ListenerActionIT.java index 0dfc2fd58e86c..3e771b27eda8f 100644 --- a/server/src/test/java/org/elasticsearch/action/ListenerActionIT.java +++ b/server/src/test/java/org/elasticsearch/action/ListenerActionIT.java @@ -35,7 +35,7 @@ public void testThreadedListeners() throws Throwable { final AtomicReference threadName = new AtomicReference<>(); Client client = client(); - IndexRequest request = new IndexRequest("test", "type", "1"); + IndexRequest request = new IndexRequest("test").id("1"); if (randomBoolean()) { // set the source, without it, we will have a verification failure request.source(Requests.INDEX_CONTENT_TYPE, "field1", "value1"); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/create/ShrinkIndexIT.java b/server/src/test/java/org/elasticsearch/action/admin/indices/create/ShrinkIndexIT.java index 1ee344e326a00..b8959db4b9e9e 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/create/ShrinkIndexIT.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/create/ShrinkIndexIT.java @@ -197,7 +197,7 @@ public void testShrinkIndexPrimaryTerm() throws Exception { final int hash = Math.floorMod(Murmur3HashFunction.hash(s), numberOfShards); if (hash == shardId) { final IndexRequest request = - new IndexRequest("source", "type", s).source("{ \"f\": \"" + s + "\"}", XContentType.JSON); + new IndexRequest("source").id(s).source("{ \"f\": \"" + s + "\"}", XContentType.JSON); client().index(request).get(); break; } else { diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java b/server/src/test/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java index 1a8d234ebc403..94107e93d9fb5 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java @@ -310,7 +310,7 @@ public void testSplitIndexPrimaryTerm() throws Exception { final int hash = Math.floorMod(Murmur3HashFunction.hash(s), numberOfShards); if (hash == shardId) { final IndexRequest request = - new IndexRequest("source", "type", s).source("{ \"f\": \"" + s + "\"}", XContentType.JSON); + new IndexRequest("source").id(s).source("{ \"f\": \"" + s + "\"}", XContentType.JSON); client().index(request).get(); break; } else { diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java index 1e3cb0b364a1c..1cd9978232b10 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java @@ -79,7 +79,7 @@ public void testBulkWithWriteIndexAndRouting() { client().admin().indices().prepareCreate("index3") .addAlias(new Alias("alias1").indexRouting("1").writeIndex(true)).setSettings(twoShardsSettings).get(); - IndexRequest indexRequestWithAlias = new IndexRequest("alias1", "type", "id"); + IndexRequest indexRequestWithAlias = new IndexRequest("alias1").id("id"); if (randomBoolean()) { indexRequestWithAlias.routing("1"); } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContextTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContextTests.java index 892433d333efa..3fb6ab80f0974 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContextTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkPrimaryExecutionContextTests.java @@ -73,16 +73,16 @@ private BulkShardRequest generateRandomRequest() { final DocWriteRequest request; switch (randomFrom(DocWriteRequest.OpType.values())) { case INDEX: - request = new IndexRequest("index", "_doc", "id_" + i); + request = new IndexRequest("index").id("id_" + i); break; case CREATE: - request = new IndexRequest("index", "_doc", "id_" + i).create(true); + request = new IndexRequest("index").id("id_" + i).create(true); break; case UPDATE: - request = new UpdateRequest("index", "_doc", "id_" + i); + request = new UpdateRequest("index", "id_" + i); break; case DELETE: - request = new DeleteRequest("index", "_doc", "id_" + i); + request = new DeleteRequest("index", "id_" + i); break; default: throw new AssertionError("unknown type"); @@ -128,7 +128,7 @@ public void testTranslogLocation() { } break; case UPDATE: - context.setRequestToExecute(new IndexRequest(current.index(), current.type(), current.id())); + context.setRequestToExecute(new IndexRequest(current.index()).id(current.id())); if (failure) { result = new Engine.IndexResult(new ElasticsearchException("bla"), 1, 1, 1); } else { diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java index 0c080c193f4b6..db796be23f65b 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java @@ -210,12 +210,12 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception for (int i = 1; i <= numDocs; i++) { if (randomBoolean()) { testDocs++; - processor.add(new IndexRequest("test", "test", Integer.toString(testDocs)) + processor.add(new IndexRequest("test").id(Integer.toString(testDocs)) .source(Requests.INDEX_CONTENT_TYPE, "field", "value")); multiGetRequestBuilder.add("test", Integer.toString(testDocs)); } else { testReadOnlyDocs++; - processor.add(new IndexRequest("test-ro", "test", Integer.toString(testReadOnlyDocs)) + processor.add(new IndexRequest("test-ro").id(Integer.toString(testReadOnlyDocs)) .source(Requests.INDEX_CONTENT_TYPE, "field", "value")); } } @@ -253,7 +253,7 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception private static MultiGetRequestBuilder indexDocs(Client client, BulkProcessor processor, int numDocs) throws Exception { MultiGetRequestBuilder multiGetRequestBuilder = client.prepareMultiGet(); for (int i = 1; i <= numDocs; i++) { - processor.add(new IndexRequest("test", "test", Integer.toString(i)) + processor.add(new IndexRequest("test").id(Integer.toString(i)) .source(Requests.INDEX_CONTENT_TYPE, "field", randomRealisticUnicodeOfLengthBetween(1, 30))); multiGetRequestBuilder.add("test", Integer.toString(i)); } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestModifierTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestModifierTests.java index 9bb7732f4da48..fe1e298194dc4 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestModifierTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestModifierTests.java @@ -45,7 +45,7 @@ public void testBulkRequestModifier() { int numRequests = scaledRandomIntBetween(8, 64); BulkRequest bulkRequest = new BulkRequest(); for (int i = 0; i < numRequests; i++) { - bulkRequest.add(new IndexRequest("_index", "_type", String.valueOf(i)).source("{}", XContentType.JSON)); + bulkRequest.add(new IndexRequest("_index").id(String.valueOf(i)).source("{}", XContentType.JSON)); } CaptureActionListener actionListener = new CaptureActionListener(); TransportBulkAction.BulkRequestModifier bulkRequestModifier = new TransportBulkAction.BulkRequestModifier(bulkRequest); @@ -85,7 +85,7 @@ public void testBulkRequestModifier() { public void testPipelineFailures() { BulkRequest originalBulkRequest = new BulkRequest(); for (int i = 0; i < 32; i++) { - originalBulkRequest.add(new IndexRequest("index", "type", String.valueOf(i))); + originalBulkRequest.add(new IndexRequest("index").id(String.valueOf(i))); } TransportBulkAction.BulkRequestModifier modifier = new TransportBulkAction.BulkRequestModifier(originalBulkRequest); @@ -115,7 +115,7 @@ public void onFailure(Exception e) { List originalResponses = new ArrayList<>(); for (DocWriteRequest actionRequest : bulkRequest.requests()) { IndexRequest indexRequest = (IndexRequest) actionRequest; - IndexResponse indexResponse = new IndexResponse(new ShardId("index", "_na_", 0), indexRequest.type(), + IndexResponse indexResponse = new IndexResponse(new ShardId("index", "_na_", 0), indexRequest.id(), 1, 17, 1, true); originalResponses.add(new BulkItemResponse(Integer.parseInt(indexRequest.id()), indexRequest.opType(), indexResponse)); } @@ -130,7 +130,7 @@ public void onFailure(Exception e) { public void testNoFailures() { BulkRequest originalBulkRequest = new BulkRequest(); for (int i = 0; i < 32; i++) { - originalBulkRequest.add(new IndexRequest("index", "type", String.valueOf(i))); + originalBulkRequest.add(new IndexRequest("index").id(String.valueOf(i))); } TransportBulkAction.BulkRequestModifier modifier = new TransportBulkAction.BulkRequestModifier(originalBulkRequest); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java index 22a50231fdfca..a6105bdb9a4ef 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java @@ -124,9 +124,9 @@ public void testBulkAllowExplicitIndex() throws Exception { public void testBulkAddIterable() { BulkRequest bulkRequest = Requests.bulkRequest(); List> requests = new ArrayList<>(); - requests.add(new IndexRequest("test", "test", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")); - requests.add(new UpdateRequest("test", "test", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")); - requests.add(new DeleteRequest("test", "test", "id")); + requests.add(new IndexRequest("test").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")); + requests.add(new UpdateRequest("test", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")); + requests.add(new DeleteRequest("test", "id")); bulkRequest.add(requests); assertThat(bulkRequest.requests().size(), equalTo(3)); assertThat(bulkRequest.requests().get(0), instanceOf(IndexRequest.class)); @@ -215,19 +215,16 @@ public void testBulkEmptyObject() throws Exception { public void testBulkRequestWithRefresh() throws Exception { BulkRequest bulkRequest = new BulkRequest(); // We force here a "id is missing" validation error - bulkRequest.add(new DeleteRequest("index", "type", null).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); - // We force here a "type is missing" validation error - bulkRequest.add(new DeleteRequest("index", "", "id")); - bulkRequest.add(new DeleteRequest("index", "type", "id").setRefreshPolicy(RefreshPolicy.IMMEDIATE)); - bulkRequest.add(new UpdateRequest("index", "type", "id").doc("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); - bulkRequest.add(new IndexRequest("index", "type", "id").source("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); + bulkRequest.add(new DeleteRequest("index", null).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); + bulkRequest.add(new DeleteRequest("index", "id").setRefreshPolicy(RefreshPolicy.IMMEDIATE)); + bulkRequest.add(new UpdateRequest("index", "id").doc("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); + bulkRequest.add(new IndexRequest("index").id("id").source("{}", XContentType.JSON).setRefreshPolicy(RefreshPolicy.IMMEDIATE)); ActionRequestValidationException validate = bulkRequest.validate(); assertThat(validate, notNullValue()); assertThat(validate.validationErrors(), not(empty())); assertThat(validate.validationErrors(), contains( "RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.", "id is missing", - "type is missing", "RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.", "RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.", "RefreshPolicy is not supported on an item request. Set it on the BulkRequest instead.")); @@ -236,8 +233,8 @@ public void testBulkRequestWithRefresh() throws Exception { // issue 15120 public void testBulkNoSource() throws Exception { BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(new UpdateRequest("index", "type", "id")); - bulkRequest.add(new IndexRequest("index", "type", "id")); + bulkRequest.add(new UpdateRequest("index", "id")); + bulkRequest.add(new IndexRequest("index").id("id")); ActionRequestValidationException validate = bulkRequest.validate(); assertThat(validate, notNullValue()); assertThat(validate.validationErrors(), not(empty())); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java index e89bfc0f42922..977c990211508 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java @@ -526,21 +526,21 @@ public void testThatInvalidIndexNamesShouldNotBreakCompleteBulkRequest() { // issue 6630 public void testThatFailedUpdateRequestReturnsCorrectType() throws Exception { BulkResponse indexBulkItemResponse = client().prepareBulk() - .add(new IndexRequest("test", "type", "3").source("{ \"title\" : \"Great Title of doc 3\" }", XContentType.JSON)) - .add(new IndexRequest("test", "type", "4").source("{ \"title\" : \"Great Title of doc 4\" }", XContentType.JSON)) - .add(new IndexRequest("test", "type", "5").source("{ \"title\" : \"Great Title of doc 5\" }", XContentType.JSON)) - .add(new IndexRequest("test", "type", "6").source("{ \"title\" : \"Great Title of doc 6\" }", XContentType.JSON)) + .add(new IndexRequest("test").id("3").source("{ \"title\" : \"Great Title of doc 3\" }", XContentType.JSON)) + .add(new IndexRequest("test").id("4").source("{ \"title\" : \"Great Title of doc 4\" }", XContentType.JSON)) + .add(new IndexRequest("test").id("5").source("{ \"title\" : \"Great Title of doc 5\" }", XContentType.JSON)) + .add(new IndexRequest("test").id("6").source("{ \"title\" : \"Great Title of doc 6\" }", XContentType.JSON)) .setRefreshPolicy(RefreshPolicy.IMMEDIATE) .get(); assertNoFailures(indexBulkItemResponse); BulkResponse bulkItemResponse = client().prepareBulk() - .add(new IndexRequest("test", "type", "1").source("{ \"title\" : \"Great Title of doc 1\" }", XContentType.JSON)) - .add(new IndexRequest("test", "type", "2").source("{ \"title\" : \"Great Title of doc 2\" }", XContentType.JSON)) - .add(new UpdateRequest("test", "type", "3").doc("{ \"date\" : \"2014-01-30T23:59:57\"}", XContentType.JSON)) - .add(new UpdateRequest("test", "type", "4").doc("{ \"date\" : \"2014-13-30T23:59:57\"}", XContentType.JSON)) - .add(new DeleteRequest("test", "type", "5")) - .add(new DeleteRequest("test", "type", "6")) + .add(new IndexRequest("test").id("1").source("{ \"title\" : \"Great Title of doc 1\" }", XContentType.JSON)) + .add(new IndexRequest("test").id("2").source("{ \"title\" : \"Great Title of doc 2\" }", XContentType.JSON)) + .add(new UpdateRequest("test", "3").doc("{ \"date\" : \"2014-01-30T23:59:57\"}", XContentType.JSON)) + .add(new UpdateRequest("test", "4").doc("{ \"date\" : \"2014-13-30T23:59:57\"}", XContentType.JSON)) + .add(new DeleteRequest("test", "5")) + .add(new DeleteRequest("test", "6")) .get(); assertNoFailures(indexBulkItemResponse); @@ -561,11 +561,11 @@ private static String indexOrAlias() { public void testThatMissingIndexDoesNotAbortFullBulkRequest() throws Exception{ createIndex("bulkindex1", "bulkindex2"); BulkRequest bulkRequest = new BulkRequest(); - bulkRequest.add(new IndexRequest("bulkindex1", "index1_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1")) - .add(new IndexRequest("bulkindex2", "index2_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2")) - .add(new IndexRequest("bulkindex2", "index2_type").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2")) - .add(new UpdateRequest("bulkindex2", "index2_type", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar")) - .add(new DeleteRequest("bulkindex2", "index2_type", "3")) + bulkRequest.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1")) + .add(new IndexRequest("bulkindex2").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2")) + .add(new IndexRequest("bulkindex2").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2")) + .add(new UpdateRequest("bulkindex2", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar")) + .add(new DeleteRequest("bulkindex2", "3")) .setRefreshPolicy(RefreshPolicy.IMMEDIATE); client().bulk(bulkRequest).get(); @@ -587,9 +587,9 @@ public void testFailedRequestsOnClosedIndex() throws Exception { assertBusy(() -> assertAcked(client().admin().indices().prepareClose("bulkindex1"))); BulkRequest bulkRequest = new BulkRequest().setRefreshPolicy(RefreshPolicy.IMMEDIATE); - bulkRequest.add(new IndexRequest("bulkindex1", "index1_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1")) - .add(new UpdateRequest("bulkindex1", "index1_type", "1").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar")) - .add(new DeleteRequest("bulkindex1", "index1_type", "1")); + bulkRequest.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1")) + .add(new UpdateRequest("bulkindex1", "1").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar")) + .add(new DeleteRequest("bulkindex1", "1")); BulkResponse bulkResponse = client().bulk(bulkRequest).get(); assertThat(bulkResponse.hasFailures(), is(true)); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/RetryTests.java b/server/src/test/java/org/elasticsearch/action/bulk/RetryTests.java index 81da3d98b0840..47aedc05d1ea7 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/RetryTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/RetryTests.java @@ -73,11 +73,11 @@ public void tearDown() throws Exception { private BulkRequest createBulkRequest() { BulkRequest request = new BulkRequest(); - request.add(new UpdateRequest("shop", "products", "1")); - request.add(new UpdateRequest("shop", "products", "2")); - request.add(new UpdateRequest("shop", "products", "3")); - request.add(new UpdateRequest("shop", "products", "4")); - request.add(new UpdateRequest("shop", "products", "5")); + request.add(new UpdateRequest("shop", "1")); + request.add(new UpdateRequest("shop", "2")); + request.add(new UpdateRequest("shop", "3")); + request.add(new UpdateRequest("shop", "4")); + request.add(new UpdateRequest("shop", "5")); return request; } @@ -228,7 +228,7 @@ public void bulk(BulkRequest request, ActionListener listener) { private BulkItemResponse successfulResponse() { return new BulkItemResponse(1, OpType.DELETE, new DeleteResponse( - new ShardId("test", "test", 0), "_doc", "test", 0, 0, 0, false)); + new ShardId("test", "test", 0), "test", 0, 0, 0, false)); } private BulkItemResponse failedResponse() { diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java index fb71d33aa564f..334ed9a964ed8 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java @@ -58,7 +58,7 @@ public void testNonExceptional() { bulkRequest.add(new IndexRequest(randomAlphaOfLength(5))); bulkRequest.add(new IndexRequest(randomAlphaOfLength(5))); bulkRequest.add(new DeleteRequest(randomAlphaOfLength(5))); - bulkRequest.add(new UpdateRequest(randomAlphaOfLength(5), randomAlphaOfLength(5), randomAlphaOfLength(5))); + bulkRequest.add(new UpdateRequest(randomAlphaOfLength(5), randomAlphaOfLength(5))); // Test emulating auto_create_index=false indicesThatCannotBeCreatedTestCase(emptySet(), bulkRequest, null); // Test emulating auto_create_index=true @@ -74,7 +74,7 @@ public void testAllFail() { bulkRequest.add(new IndexRequest("no")); bulkRequest.add(new IndexRequest("can't")); bulkRequest.add(new DeleteRequest("do").version(0).versionType(VersionType.EXTERNAL)); - bulkRequest.add(new UpdateRequest("nothin", randomAlphaOfLength(5), randomAlphaOfLength(5))); + bulkRequest.add(new UpdateRequest("nothin", randomAlphaOfLength(5))); indicesThatCannotBeCreatedTestCase(new HashSet<>(Arrays.asList("no", "can't", "do", "nothin")), bulkRequest, index -> { throw new IndexNotFoundException("Can't make it because I say so"); }); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java index 2690b5200d19a..36f6a3b58048c 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java @@ -219,7 +219,7 @@ public void setupAction() { public void testIngestSkipped() throws Exception { BulkRequest bulkRequest = new BulkRequest(); - IndexRequest indexRequest = new IndexRequest("index", "type", "id"); + IndexRequest indexRequest = new IndexRequest("index").id("id"); indexRequest.source(Collections.emptyMap()); bulkRequest.add(indexRequest); ActionTestUtils.execute(action, null, bulkRequest, ActionListener.wrap(response -> {}, exception -> { @@ -230,7 +230,7 @@ public void testIngestSkipped() throws Exception { } public void testSingleItemBulkActionIngestSkipped() throws Exception { - IndexRequest indexRequest = new IndexRequest("index", "type", "id"); + IndexRequest indexRequest = new IndexRequest("index").id("id"); indexRequest.source(Collections.emptyMap()); ActionTestUtils.execute(singleItemBulkWriteAction, null, indexRequest, ActionListener.wrap(response -> {}, exception -> { throw new AssertionError(exception); @@ -242,10 +242,10 @@ public void testSingleItemBulkActionIngestSkipped() throws Exception { public void testIngestLocal() throws Exception { Exception exception = new Exception("fake exception"); BulkRequest bulkRequest = new BulkRequest(); - IndexRequest indexRequest1 = new IndexRequest("index", "type", "id"); + IndexRequest indexRequest1 = new IndexRequest("index").id("id"); indexRequest1.source(Collections.emptyMap()); indexRequest1.setPipeline("testpipeline"); - IndexRequest indexRequest2 = new IndexRequest("index", "type", "id"); + IndexRequest indexRequest2 = new IndexRequest("index").id("id"); indexRequest2.source(Collections.emptyMap()); indexRequest2.setPipeline("testpipeline"); bulkRequest.add(indexRequest1); @@ -285,7 +285,7 @@ public void testIngestLocal() throws Exception { public void testSingleItemBulkActionIngestLocal() throws Exception { Exception exception = new Exception("fake exception"); - IndexRequest indexRequest = new IndexRequest("index", "type", "id"); + IndexRequest indexRequest = new IndexRequest("index").id("id"); indexRequest.source(Collections.emptyMap()); indexRequest.setPipeline("testpipeline"); AtomicBoolean responseCalled = new AtomicBoolean(false); @@ -319,7 +319,7 @@ public void testSingleItemBulkActionIngestLocal() throws Exception { public void testIngestForward() throws Exception { localIngest = false; BulkRequest bulkRequest = new BulkRequest(); - IndexRequest indexRequest = new IndexRequest("index", "type", "id"); + IndexRequest indexRequest = new IndexRequest("index").id("id"); indexRequest.source(Collections.emptyMap()); indexRequest.setPipeline("testpipeline"); bulkRequest.add(indexRequest); @@ -364,7 +364,7 @@ public void testIngestForward() throws Exception { public void testSingleItemBulkActionIngestForward() throws Exception { localIngest = false; - IndexRequest indexRequest = new IndexRequest("index", "type", "id"); + IndexRequest indexRequest = new IndexRequest("index").id("id"); indexRequest.source(Collections.emptyMap()); indexRequest.setPipeline("testpipeline"); IndexResponse indexResponse = mock(IndexResponse.class); @@ -410,11 +410,11 @@ public void testSingleItemBulkActionIngestForward() throws Exception { } public void testUseDefaultPipeline() throws Exception { - validateDefaultPipeline(new IndexRequest(WITH_DEFAULT_PIPELINE, "type", "id")); + validateDefaultPipeline(new IndexRequest(WITH_DEFAULT_PIPELINE).id("id")); } public void testUseDefaultPipelineWithAlias() throws Exception { - validateDefaultPipeline(new IndexRequest(WITH_DEFAULT_PIPELINE_ALIAS, "type", "id")); + validateDefaultPipeline(new IndexRequest(WITH_DEFAULT_PIPELINE_ALIAS).id("id")); } public void testUseDefaultPipelineWithBulkUpsert() throws Exception { @@ -430,16 +430,16 @@ public void testUseDefaultPipelineWithBulkUpsertWithAlias() throws Exception { private void validatePipelineWithBulkUpsert(@Nullable String indexRequestIndexName, String updateRequestIndexName) throws Exception { Exception exception = new Exception("fake exception"); BulkRequest bulkRequest = new BulkRequest(); - IndexRequest indexRequest1 = new IndexRequest(indexRequestIndexName, "type", "id1").source(Collections.emptyMap()); - IndexRequest indexRequest2 = new IndexRequest(indexRequestIndexName, "type", "id2").source(Collections.emptyMap()); - IndexRequest indexRequest3 = new IndexRequest(indexRequestIndexName, "type", "id3").source(Collections.emptyMap()); - UpdateRequest upsertRequest = new UpdateRequest(updateRequestIndexName, "type", "id1") + IndexRequest indexRequest1 = new IndexRequest(indexRequestIndexName).id("id1").source(Collections.emptyMap()); + IndexRequest indexRequest2 = new IndexRequest(indexRequestIndexName).id("id2").source(Collections.emptyMap()); + IndexRequest indexRequest3 = new IndexRequest(indexRequestIndexName).id("id3").source(Collections.emptyMap()); + UpdateRequest upsertRequest = new UpdateRequest(updateRequestIndexName, "id1") .upsert(indexRequest1).script(mockScript("1")); - UpdateRequest docAsUpsertRequest = new UpdateRequest(updateRequestIndexName, "type", "id2") + UpdateRequest docAsUpsertRequest = new UpdateRequest(updateRequestIndexName, "id2") .doc(indexRequest2).docAsUpsert(true); // this test only covers the mechanics that scripted bulk upserts will execute a default pipeline. However, in practice scripted // bulk upserts with a default pipeline are a bit surprising since the script executes AFTER the pipeline. - UpdateRequest scriptedUpsert = new UpdateRequest(updateRequestIndexName, "type", "id2") + UpdateRequest scriptedUpsert = new UpdateRequest(updateRequestIndexName, "id2") .upsert(indexRequest3).script(mockScript("1")) .scriptedUpsert(true); bulkRequest.add(upsertRequest).add(docAsUpsertRequest).add(scriptedUpsert); @@ -484,7 +484,7 @@ private void validatePipelineWithBulkUpsert(@Nullable String indexRequestIndexNa public void testDoExecuteCalledTwiceCorrectly() throws Exception { Exception exception = new Exception("fake exception"); - IndexRequest indexRequest = new IndexRequest("missing_index", "type", "id"); + IndexRequest indexRequest = new IndexRequest("missing_index").id("id"); indexRequest.setPipeline("testpipeline"); indexRequest.source(Collections.emptyMap()); AtomicBoolean responseCalled = new AtomicBoolean(false); @@ -520,7 +520,7 @@ public void testDoExecuteCalledTwiceCorrectly() throws Exception { public void testNotFindDefaultPipelineFromTemplateMatches(){ Exception exception = new Exception("fake exception"); - IndexRequest indexRequest = new IndexRequest("missing_index", "type", "id"); + IndexRequest indexRequest = new IndexRequest("missing_index").id("id"); indexRequest.source(Collections.emptyMap()); AtomicBoolean responseCalled = new AtomicBoolean(false); AtomicBoolean failureCalled = new AtomicBoolean(false); @@ -556,7 +556,7 @@ public void testFindDefaultPipelineFromTemplateMatch(){ when(metaData.getTemplates()).thenReturn(templateMetaDataBuilder.build()); when(metaData.indices()).thenReturn(ImmutableOpenMap.of()); - IndexRequest indexRequest = new IndexRequest("missing_index", "type", "id"); + IndexRequest indexRequest = new IndexRequest("missing_index").id("id"); indexRequest.source(Collections.emptyMap()); AtomicBoolean responseCalled = new AtomicBoolean(false); AtomicBoolean failureCalled = new AtomicBoolean(false); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java index 8ef668c01b727..7160146871a53 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java @@ -110,7 +110,7 @@ public void tearDown() throws Exception { } public void testDeleteNonExistingDocDoesNotCreateIndex() throws Exception { - BulkRequest bulkRequest = new BulkRequest().add(new DeleteRequest("index", "type", "id")); + BulkRequest bulkRequest = new BulkRequest().add(new DeleteRequest("index").id("id")); ActionTestUtils.execute(bulkAction, null, bulkRequest, ActionListener.wrap(response -> { assertFalse(bulkAction.indexCreated); @@ -126,7 +126,7 @@ public void testDeleteNonExistingDocDoesNotCreateIndex() throws Exception { public void testDeleteNonExistingDocExternalVersionCreatesIndex() throws Exception { BulkRequest bulkRequest = new BulkRequest() - .add(new DeleteRequest("index", "type", "id").versionType(VersionType.EXTERNAL).version(0)); + .add(new DeleteRequest("index").id("id").versionType(VersionType.EXTERNAL).version(0)); ActionTestUtils.execute(bulkAction, null, bulkRequest, ActionListener.wrap(response -> { assertTrue(bulkAction.indexCreated); @@ -137,7 +137,7 @@ public void testDeleteNonExistingDocExternalVersionCreatesIndex() throws Excepti public void testDeleteNonExistingDocExternalGteVersionCreatesIndex() throws Exception { BulkRequest bulkRequest = new BulkRequest() - .add(new DeleteRequest("index2", "type", "id").versionType(VersionType.EXTERNAL_GTE).version(0)); + .add(new DeleteRequest("index2").id("id").versionType(VersionType.EXTERNAL_GTE).version(0)); ActionTestUtils.execute(bulkAction, null, bulkRequest, ActionListener.wrap(response -> { assertTrue(bulkAction.indexCreated); @@ -147,10 +147,10 @@ public void testDeleteNonExistingDocExternalGteVersionCreatesIndex() throws Exce } public void testGetIndexWriteRequest() throws Exception { - IndexRequest indexRequest = new IndexRequest("index", "type", "id1").source(Collections.emptyMap()); - UpdateRequest upsertRequest = new UpdateRequest("index", "type", "id1").upsert(indexRequest).script(mockScript("1")); - UpdateRequest docAsUpsertRequest = new UpdateRequest("index", "type", "id2").doc(indexRequest).docAsUpsert(true); - UpdateRequest scriptedUpsert = new UpdateRequest("index", "type", "id2").upsert(indexRequest).script(mockScript("1")) + IndexRequest indexRequest = new IndexRequest("index").id("id1").source(Collections.emptyMap()); + UpdateRequest upsertRequest = new UpdateRequest("index", "id1").upsert(indexRequest).script(mockScript("1")); + UpdateRequest docAsUpsertRequest = new UpdateRequest("index", "id2").doc(indexRequest).docAsUpsert(true); + UpdateRequest scriptedUpsert = new UpdateRequest("index", "id2").upsert(indexRequest).script(mockScript("1")) .scriptedUpsert(true); assertEquals(TransportBulkAction.getIndexWriteRequest(indexRequest), indexRequest); @@ -161,7 +161,7 @@ public void testGetIndexWriteRequest() throws Exception { DeleteRequest deleteRequest = new DeleteRequest("index", "id"); assertNull(TransportBulkAction.getIndexWriteRequest(deleteRequest)); - UpdateRequest badUpsertRequest = new UpdateRequest("index", "type", "id1"); + UpdateRequest badUpsertRequest = new UpdateRequest("index", "id1"); assertNull(TransportBulkAction.getIndexWriteRequest(badUpsertRequest)); } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportShardBulkActionTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportShardBulkActionTests.java index fab305327027a..d4df97d3119c8 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportShardBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportShardBulkActionTests.java @@ -98,7 +98,7 @@ public void testExecuteBulkIndexRequest() throws Exception { BulkItemRequest[] items = new BulkItemRequest[1]; boolean create = randomBoolean(); - DocWriteRequest writeRequest = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE) + DocWriteRequest writeRequest = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE) .create(create); BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest); items[0] = primaryRequest; @@ -126,7 +126,7 @@ public void testExecuteBulkIndexRequest() throws Exception { // Assert that the document actually made it there assertDocCount(shard, 1); - writeRequest = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE).create(true); + writeRequest = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE).create(true); primaryRequest = new BulkItemRequest(0, writeRequest); items[0] = primaryRequest; bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items); @@ -171,7 +171,7 @@ public void testSkipBulkIndexRequestIfAborted() throws Exception { BulkItemRequest[] items = new BulkItemRequest[randomIntBetween(2, 5)]; for (int i = 0; i < items.length; i++) { - DocWriteRequest writeRequest = new IndexRequest("index", "_doc", "id_" + i) + DocWriteRequest writeRequest = new IndexRequest("index").id("id_" + i) .source(Requests.INDEX_CONTENT_TYPE) .opType(DocWriteRequest.OpType.INDEX); items[i] = new BulkItemRequest(i, writeRequest); @@ -226,7 +226,7 @@ public void testSkipBulkIndexRequestIfAborted() throws Exception { public void testExecuteBulkIndexRequestWithMappingUpdates() throws Exception { BulkItemRequest[] items = new BulkItemRequest[1]; - DocWriteRequest writeRequest = new IndexRequest("index", "_doc", "id") + DocWriteRequest writeRequest = new IndexRequest("index").id("id") .source(Requests.INDEX_CONTENT_TYPE, "foo", "bar"); items[0] = new BulkItemRequest(0, writeRequest); BulkShardRequest bulkShardRequest = @@ -289,7 +289,7 @@ public void testExecuteBulkIndexRequestWithErrorWhileUpdatingMapping() throws Ex IndexShard shard = newStartedShard(true); BulkItemRequest[] items = new BulkItemRequest[1]; - DocWriteRequest writeRequest = new IndexRequest("index", "_doc", "id") + DocWriteRequest writeRequest = new IndexRequest("index").id("id") .source(Requests.INDEX_CONTENT_TYPE, "foo", "bar"); items[0] = new BulkItemRequest(0, writeRequest); BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items); @@ -344,7 +344,7 @@ public void testExecuteBulkDeleteRequest() throws Exception { IndexShard shard = newStartedShard(true); BulkItemRequest[] items = new BulkItemRequest[1]; - DocWriteRequest writeRequest = new DeleteRequest("index", "_doc", "id"); + DocWriteRequest writeRequest = new DeleteRequest("index").id("id"); items[0] = new BulkItemRequest(0, writeRequest); BulkShardRequest bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items); @@ -378,7 +378,6 @@ public void testExecuteBulkDeleteRequest() throws Exception { assertThat(response.getResult(), equalTo(DocWriteResponse.Result.NOT_FOUND)); assertThat(response.getShardId(), equalTo(shard.shardId())); assertThat(response.getIndex(), equalTo("index")); - assertThat(response.getType(), equalTo("_doc")); assertThat(response.getId(), equalTo("id")); assertThat(response.getVersion(), equalTo(1L)); assertThat(response.getSeqNo(), equalTo(0L)); @@ -387,7 +386,7 @@ public void testExecuteBulkDeleteRequest() throws Exception { // Now do the same after indexing the document, it should now find and delete the document indexDoc(shard, "_doc", "id", "{}"); - writeRequest = new DeleteRequest("index", "_doc", "id"); + writeRequest = new DeleteRequest("index", "id"); items[0] = new BulkItemRequest(0, writeRequest); bulkShardRequest = new BulkShardRequest(shardId, RefreshPolicy.NONE, items); @@ -420,7 +419,6 @@ public void testExecuteBulkDeleteRequest() throws Exception { assertThat(response.getResult(), equalTo(DocWriteResponse.Result.DELETED)); assertThat(response.getShardId(), equalTo(shard.shardId())); assertThat(response.getIndex(), equalTo("index")); - assertThat(response.getType(), equalTo("_doc")); assertThat(response.getId(), equalTo("id")); assertThat(response.getVersion(), equalTo(3L)); assertThat(response.getSeqNo(), equalTo(2L)); @@ -431,11 +429,11 @@ public void testExecuteBulkDeleteRequest() throws Exception { } public void testNoopUpdateRequest() throws Exception { - DocWriteRequest writeRequest = new UpdateRequest("index", "_doc", "id") + DocWriteRequest writeRequest = new UpdateRequest("index", "id") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value"); BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest); - DocWriteResponse noopUpdateResponse = new UpdateResponse(shardId, "_doc", "id", 0, 2, 1, DocWriteResponse.Result.NOOP); + DocWriteResponse noopUpdateResponse = new UpdateResponse(shardId, "id", 0, 2, 1, DocWriteResponse.Result.NOOP); IndexShard shard = mock(IndexShard.class); @@ -472,11 +470,11 @@ public void testNoopUpdateRequest() throws Exception { public void testUpdateRequestWithFailure() throws Exception { IndexSettings indexSettings = new IndexSettings(indexMetaData(), Settings.EMPTY); - DocWriteRequest writeRequest = new UpdateRequest("index", "_doc", "id") + DocWriteRequest writeRequest = new UpdateRequest("index", "id") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value"); BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest); - IndexRequest updateResponse = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"); + IndexRequest updateResponse = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"); Exception err = new ElasticsearchException("I'm dead <(x.x)>"); Engine.IndexResult indexResult = new Engine.IndexResult(err, 0, 0, 0); @@ -520,11 +518,11 @@ public void testUpdateRequestWithFailure() throws Exception { public void testUpdateRequestWithConflictFailure() throws Exception { IndexSettings indexSettings = new IndexSettings(indexMetaData(), Settings.EMPTY); - DocWriteRequest writeRequest = new UpdateRequest("index", "_doc", "id") + DocWriteRequest writeRequest = new UpdateRequest("index", "id") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value"); BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest); - IndexRequest updateResponse = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"); + IndexRequest updateResponse = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"); Exception err = new VersionConflictEngineException(shardId, "id", "I'm conflicted <(;_;)>"); @@ -566,11 +564,11 @@ public void testUpdateRequestWithConflictFailure() throws Exception { public void testUpdateRequestWithSuccess() throws Exception { IndexSettings indexSettings = new IndexSettings(indexMetaData(), Settings.EMPTY); - DocWriteRequest writeRequest = new UpdateRequest("index", "_doc", "id") + DocWriteRequest writeRequest = new UpdateRequest("index", "id") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value"); BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest); - IndexRequest updateResponse = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"); + IndexRequest updateResponse = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"); boolean created = randomBoolean(); Translog.Location resultLocation = new Translog.Location(42, 42, 42); @@ -613,11 +611,11 @@ public void testUpdateRequestWithSuccess() throws Exception { public void testUpdateWithDelete() throws Exception { IndexSettings indexSettings = new IndexSettings(indexMetaData(), Settings.EMPTY); - DocWriteRequest writeRequest = new UpdateRequest("index", "_doc", "id") + DocWriteRequest writeRequest = new UpdateRequest("index", "id") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value"); BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest); - DeleteRequest updateResponse = new DeleteRequest("index", "_doc", "id"); + DeleteRequest updateResponse = new DeleteRequest("index", "id"); boolean found = randomBoolean(); Translog.Location resultLocation = new Translog.Location(42, 42, 42); @@ -658,7 +656,7 @@ public void testUpdateWithDelete() throws Exception { public void testFailureDuringUpdateProcessing() throws Exception { - DocWriteRequest writeRequest = new UpdateRequest("index", "_doc", "id") + DocWriteRequest writeRequest = new UpdateRequest("index", "id") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value"); BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest); @@ -697,7 +695,7 @@ public void testTranslogPositionToSync() throws Exception { BulkItemRequest[] items = new BulkItemRequest[randomIntBetween(2, 5)]; for (int i = 0; i < items.length; i++) { - DocWriteRequest writeRequest = new IndexRequest("index", "_doc", "id_" + i) + DocWriteRequest writeRequest = new IndexRequest("index").id("id_" + i) .source(Requests.INDEX_CONTENT_TYPE) .opType(DocWriteRequest.OpType.INDEX); items[i] = new BulkItemRequest(i, writeRequest); @@ -729,7 +727,7 @@ public void testTranslogPositionToSync() throws Exception { public void testNoOpReplicationOnPrimaryDocumentFailure() throws Exception { final IndexShard shard = spy(newStartedShard(false)); - BulkItemRequest itemRequest = new BulkItemRequest(0, new IndexRequest("index", "_doc").source(Requests.INDEX_CONTENT_TYPE)); + BulkItemRequest itemRequest = new BulkItemRequest(0, new IndexRequest("index").source(Requests.INDEX_CONTENT_TYPE)); final String failureMessage = "simulated primary failure"; final IOException exception = new IOException(failureMessage); itemRequest.setPrimaryResponse(new BulkItemResponse(0, @@ -751,13 +749,13 @@ public void testNoOpReplicationOnPrimaryDocumentFailure() throws Exception { public void testRetries() throws Exception { IndexSettings indexSettings = new IndexSettings(indexMetaData(), Settings.EMPTY); - UpdateRequest writeRequest = new UpdateRequest("index", "_doc", "id") + UpdateRequest writeRequest = new UpdateRequest("index", "id") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value"); // the beating will continue until success has come. writeRequest.retryOnConflict(Integer.MAX_VALUE); BulkItemRequest primaryRequest = new BulkItemRequest(0, writeRequest); - IndexRequest updateResponse = new IndexRequest("index", "_doc", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"); + IndexRequest updateResponse = new IndexRequest("index").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value"); Exception err = new VersionConflictEngineException(shardId, "id", "I'm conflicted <(;_;)>"); @@ -811,7 +809,7 @@ public void testRetries() throws Exception { private void randomlySetIgnoredPrimaryResponse(BulkItemRequest primaryRequest) { if (randomBoolean()) { // add a response to the request and thereby check that it is ignored for the primary. - primaryRequest.setPrimaryResponse(new BulkItemResponse(0, DocWriteRequest.OpType.INDEX, new IndexResponse(shardId, "_doc", + primaryRequest.setPrimaryResponse(new BulkItemResponse(0, DocWriteRequest.OpType.INDEX, new IndexResponse(shardId, "ignore-primary-response-on-primary", 42, 42, 42, false))); } } diff --git a/server/src/test/java/org/elasticsearch/action/delete/DeleteRequestTests.java b/server/src/test/java/org/elasticsearch/action/delete/DeleteRequestTests.java index 4fe4c3548c224..cf5bc6a2a68a1 100644 --- a/server/src/test/java/org/elasticsearch/action/delete/DeleteRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/delete/DeleteRequestTests.java @@ -29,27 +29,19 @@ public class DeleteRequestTests extends ESTestCase { public void testValidation() { { - final DeleteRequest request = new DeleteRequest("index4", "_doc", "0"); + final DeleteRequest request = new DeleteRequest("index4", "0"); final ActionRequestValidationException validate = request.validate(); assertThat(validate, nullValue()); } { - //Empty types are accepted but fail validation - final DeleteRequest request = new DeleteRequest("index4", "", randomBoolean() ? "" : null); + final DeleteRequest request = new DeleteRequest("index4", null); final ActionRequestValidationException validate = request.validate(); assertThat(validate, not(nullValue())); - assertThat(validate.validationErrors(), hasItems("type is missing", "id is missing")); + assertThat(validate.validationErrors(), hasItems("id is missing")); } - { - // Null types are defaulted - final DeleteRequest request = new DeleteRequest("index4", randomBoolean() ? "" : null); - final ActionRequestValidationException validate = request.validate(); - assertThat(validate, not(nullValue())); - assertThat(validate.validationErrors(), hasItems("id is missing")); - } } } diff --git a/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java b/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java index 8e40c5ea2aad6..99fc584487fe0 100644 --- a/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java @@ -42,13 +42,13 @@ public class DeleteResponseTests extends ESTestCase { public void testToXContent() { { - DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "type", "id", 3, 17, 5, true); + DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "id", 3, 17, 5, true); String output = Strings.toString(response); assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\"," + "\"_shards\":null,\"_seq_no\":3,\"_primary_term\":17}", output); } { - DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "type", "id", -1, 0, 7, true); + DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "id", -1, 0, 7, true); response.setForcedRefresh(true); response.setShardInfo(new ReplicationResponse.ShardInfo(10, 5)); String output = Strings.toString(response); @@ -122,12 +122,12 @@ public static Tuple randomDeleteResponse() { Tuple shardInfos = RandomObjects.randomShardInfo(random()); - DeleteResponse actual = new DeleteResponse(new ShardId(index, indexUUid, shardId), type, id, seqNo, primaryTerm, version, found); + DeleteResponse actual = new DeleteResponse(new ShardId(index, indexUUid, shardId), id, seqNo, primaryTerm, version, found); actual.setForcedRefresh(forcedRefresh); actual.setShardInfo(shardInfos.v1()); DeleteResponse expected = - new DeleteResponse(new ShardId(index, INDEX_UUID_NA_VALUE, -1), type, id, seqNo, primaryTerm, version, found); + new DeleteResponse(new ShardId(index, INDEX_UUID_NA_VALUE, -1), id, seqNo, primaryTerm, version, found); expected.setForcedRefresh(forcedRefresh); expected.setShardInfo(shardInfos.v2()); diff --git a/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index e01cc511ba136..97b0a8c4b03da 100644 --- a/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -125,11 +125,10 @@ public void testAutoGenIdTimestampIsSet() { public void testIndexResponse() { ShardId shardId = new ShardId(randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), randomIntBetween(0, 1000)); - String type = randomAlphaOfLengthBetween(3, 10); String id = randomAlphaOfLengthBetween(3, 10); long version = randomLong(); boolean created = randomBoolean(); - IndexResponse indexResponse = new IndexResponse(shardId, type, id, SequenceNumbers.UNASSIGNED_SEQ_NO, 0, version, created); + IndexResponse indexResponse = new IndexResponse(shardId, id, SequenceNumbers.UNASSIGNED_SEQ_NO, 0, version, created); int total = randomIntBetween(1, 10); int successful = randomIntBetween(1, 10); ReplicationResponse.ShardInfo shardInfo = new ReplicationResponse.ShardInfo(total, successful); @@ -139,7 +138,6 @@ public void testIndexResponse() { forcedRefresh = randomBoolean(); indexResponse.setForcedRefresh(forcedRefresh); } - assertEquals(type, indexResponse.getType()); assertEquals(id, indexResponse.getId()); assertEquals(version, indexResponse.getVersion()); assertEquals(shardId, indexResponse.getShardId()); @@ -147,7 +145,7 @@ public void testIndexResponse() { assertEquals(total, indexResponse.getShardInfo().getTotal()); assertEquals(successful, indexResponse.getShardInfo().getSuccessful()); assertEquals(forcedRefresh, indexResponse.forcedRefresh()); - assertEquals("IndexResponse[index=" + shardId.getIndexName() + ",type=" + type + ",id="+ id + + assertEquals("IndexResponse[index=" + shardId.getIndexName() + ",id="+ id + ",version=" + version + ",result=" + (created ? "created" : "updated") + ",seqNo=" + SequenceNumbers.UNASSIGNED_SEQ_NO + ",primaryTerm=" + 0 + diff --git a/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java b/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java index 926f272ed8339..608234051fa0e 100644 --- a/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java @@ -43,13 +43,13 @@ public class IndexResponseTests extends ESTestCase { public void testToXContent() { { - IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "type", "id", 3, 17, 5, true); + IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "id", 3, 17, 5, true); String output = Strings.toString(indexResponse); assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"created\",\"_shards\":null," + "\"_seq_no\":3,\"_primary_term\":17}", output); } { - IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "type", "id", -1, 17, 7, true); + IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "id", -1, 17, 7, true); indexResponse.setForcedRefresh(true); indexResponse.setShardInfo(new ReplicationResponse.ShardInfo(10, 5)); String output = Strings.toString(indexResponse); @@ -105,7 +105,6 @@ private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws public static void assertDocWriteResponse(DocWriteResponse expected, DocWriteResponse actual) { assertEquals(expected.getIndex(), actual.getIndex()); - assertEquals(expected.getType(), actual.getType()); assertEquals(expected.getId(), actual.getId()); assertEquals(expected.getSeqNo(), actual.getSeqNo()); assertEquals(expected.getResult(), actual.getResult()); @@ -125,7 +124,6 @@ public static Tuple randomIndexResponse() { String index = randomAlphaOfLength(5); String indexUUid = randomAlphaOfLength(5); int shardId = randomIntBetween(0, 5); - String type = randomAlphaOfLength(5); String id = randomAlphaOfLength(5); long seqNo = randomFrom(SequenceNumbers.UNASSIGNED_SEQ_NO, randomNonNegativeLong(), (long) randomIntBetween(0, 10000)); long primaryTerm = seqNo == SequenceNumbers.UNASSIGNED_SEQ_NO ? 0 : randomIntBetween(1, 10000); @@ -135,12 +133,12 @@ public static Tuple randomIndexResponse() { Tuple shardInfos = RandomObjects.randomShardInfo(random()); - IndexResponse actual = new IndexResponse(new ShardId(index, indexUUid, shardId), type, id, seqNo, primaryTerm, version, created); + IndexResponse actual = new IndexResponse(new ShardId(index, indexUUid, shardId), id, seqNo, primaryTerm, version, created); actual.setForcedRefresh(forcedRefresh); actual.setShardInfo(shardInfos.v1()); IndexResponse expected = - new IndexResponse(new ShardId(index, INDEX_UUID_NA_VALUE, -1), type, id, seqNo, primaryTerm, version, created); + new IndexResponse(new ShardId(index, INDEX_UUID_NA_VALUE, -1), id, seqNo, primaryTerm, version, created); expected.setForcedRefresh(forcedRefresh); expected.setShardInfo(shardInfos.v2()); diff --git a/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java b/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java index 37a1979fbd7b3..aaa3313c8ccff 100644 --- a/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java @@ -143,7 +143,7 @@ public void setUp() throws Exception { @SuppressWarnings("unchecked") public void testFromXContent() throws Exception { - UpdateRequest request = new UpdateRequest("test", "type", "1"); + UpdateRequest request = new UpdateRequest("test", "1"); // simple script request.fromXContent(createParser(XContentFactory.jsonBuilder() .startObject() @@ -170,7 +170,7 @@ public void testFromXContent() throws Exception { assertThat(params, equalTo(emptyMap())); // script with params - request = new UpdateRequest("test", "type", "1"); + request = new UpdateRequest("test", "1"); request.fromXContent(createParser(XContentFactory.jsonBuilder().startObject() .startObject("script") .field("source", "script1") @@ -188,7 +188,7 @@ public void testFromXContent() throws Exception { assertThat(params.size(), equalTo(1)); assertThat(params.get("param1").toString(), equalTo("value1")); - request = new UpdateRequest("test", "type", "1"); + request = new UpdateRequest("test", "1"); request.fromXContent(createParser(XContentFactory.jsonBuilder() .startObject() .startObject("script") @@ -209,7 +209,7 @@ public void testFromXContent() throws Exception { assertThat(params.get("param1").toString(), equalTo("value1")); // script with params and upsert - request = new UpdateRequest("test", "type", "1"); + request = new UpdateRequest("test", "1"); request.fromXContent(createParser(XContentFactory.jsonBuilder().startObject() .startObject("script") .startObject("params") @@ -237,7 +237,7 @@ public void testFromXContent() throws Exception { assertThat(upsertDoc.get("field1").toString(), equalTo("value1")); assertThat(((Map) upsertDoc.get("compound")).get("field2").toString(), equalTo("value2")); - request = new UpdateRequest("test", "type", "1"); + request = new UpdateRequest("test", "1"); request.fromXContent(createParser(XContentFactory.jsonBuilder().startObject() .startObject("upsert") .field("field1", "value1") @@ -265,7 +265,7 @@ public void testFromXContent() throws Exception { assertThat(((Map) upsertDoc.get("compound")).get("field2").toString(), equalTo("value2")); // script with doc - request = new UpdateRequest("test", "type", "1"); + request = new UpdateRequest("test", "1"); request.fromXContent(createParser(XContentFactory.jsonBuilder() .startObject() .startObject("doc") @@ -281,7 +281,7 @@ public void testFromXContent() throws Exception { } public void testUnknownFieldParsing() throws Exception { - UpdateRequest request = new UpdateRequest("test", "type", "1"); + UpdateRequest request = new UpdateRequest("test", "1"); XContentParser contentParser = createParser(XContentFactory.jsonBuilder() .startObject() .field("unknown_field", "test") @@ -290,7 +290,7 @@ public void testUnknownFieldParsing() throws Exception { XContentParseException ex = expectThrows(XContentParseException.class, () -> request.fromXContent(contentParser)); assertEquals("[1:2] [UpdateRequest] unknown field [unknown_field], parser not found", ex.getMessage()); - UpdateRequest request2 = new UpdateRequest("test", "type", "1"); + UpdateRequest request2 = new UpdateRequest("test", "1"); XContentParser unknownObject = createParser(XContentFactory.jsonBuilder() .startObject() .field("script", "ctx.op = ctx._source.views == params.count ? 'delete' : 'none'") @@ -303,7 +303,7 @@ public void testUnknownFieldParsing() throws Exception { } public void testFetchSourceParsing() throws Exception { - UpdateRequest request = new UpdateRequest("test", "type1", "1"); + UpdateRequest request = new UpdateRequest("test", "1"); request.fromXContent(createParser(XContentFactory.jsonBuilder() .startObject() .field("_source", true) @@ -349,11 +349,11 @@ public void testFetchSourceParsing() throws Exception { public void testNowInScript() throws IOException { // We just upsert one document with now() using a script - IndexRequest indexRequest = new IndexRequest("test", "type1", "2") + IndexRequest indexRequest = new IndexRequest("test").id("2") .source(jsonBuilder().startObject().field("foo", "bar").endObject()); { - UpdateRequest updateRequest = new UpdateRequest("test", "type1", "2") + UpdateRequest updateRequest = new UpdateRequest("test", "2") .upsert(indexRequest) .script(mockInlineScript("ctx._source.update_timestamp = ctx._now")) .scriptedUpsert(true); @@ -367,7 +367,7 @@ public void testNowInScript() throws IOException { assertEquals(nowInMillis, indexAction.sourceAsMap().get("update_timestamp")); } { - UpdateRequest updateRequest = new UpdateRequest("test", "type1", "2") + UpdateRequest updateRequest = new UpdateRequest("test", "2") .upsert(indexRequest) .script(mockInlineScript("ctx._timestamp = ctx._now")) .scriptedUpsert(true); @@ -383,7 +383,7 @@ public void testIndexTimeout() { final GetResult getResult = new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); final UpdateRequest updateRequest = - new UpdateRequest("test", "type", "1") + new UpdateRequest("test", "1") .script(mockInlineScript("return")) .timeout(randomTimeValue()); runTimeoutTest(getResult, updateRequest); @@ -393,7 +393,7 @@ public void testDeleteTimeout() { final GetResult getResult = new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); final UpdateRequest updateRequest = - new UpdateRequest("test", "type", "1") + new UpdateRequest("test", "1") .script(mockInlineScript("ctx.op = delete")) .timeout(randomTimeValue()); runTimeoutTest(getResult, updateRequest); @@ -409,9 +409,9 @@ public void testUpsertTimeout() throws IOException { sourceBuilder.field("f", "v"); } sourceBuilder.endObject(); - final IndexRequest upsert = new IndexRequest("test", "type", "1").source(sourceBuilder); + final IndexRequest upsert = new IndexRequest("test").id("1").source(sourceBuilder); final UpdateRequest updateRequest = - new UpdateRequest("test", "type", "1") + new UpdateRequest("test", "1") .upsert(upsert) .script(mockInlineScript("return")) .timeout(randomTimeValue()); @@ -501,53 +501,43 @@ public void testToAndFromXContent() throws IOException { } public void testToValidateUpsertRequestAndCAS() { - UpdateRequest updateRequest = new UpdateRequest("index", "type", "id"); + UpdateRequest updateRequest = new UpdateRequest("index", "id"); updateRequest.setIfSeqNo(1L); updateRequest.setIfPrimaryTerm(1L); updateRequest.doc("{}", XContentType.JSON); - updateRequest.upsert(new IndexRequest("index","type", "id")); + updateRequest.upsert(new IndexRequest("index").id("id")); assertThat(updateRequest.validate().validationErrors(), contains("upsert requests don't support `if_seq_no` and `if_primary_term`")); } public void testToValidateUpsertRequestWithVersion() { - UpdateRequest updateRequest = new UpdateRequest("index", "type", "id"); + UpdateRequest updateRequest = new UpdateRequest("index", "id"); updateRequest.doc("{}", XContentType.JSON); - updateRequest.upsert(new IndexRequest("index", "type", "1").version(1L)); + updateRequest.upsert(new IndexRequest("index").id("1").version(1L)); assertThat(updateRequest.validate().validationErrors(), contains("can't provide version in upsert request")); } public void testValidate() { { - UpdateRequest request = new UpdateRequest("index", "type", "id"); + UpdateRequest request = new UpdateRequest("index", "id"); request.doc("{}", XContentType.JSON); ActionRequestValidationException validate = request.validate(); assertThat(validate, nullValue()); } { - // Null types are defaulted to "_doc" - UpdateRequest request = new UpdateRequest("index", null, randomBoolean() ? "" : null); + UpdateRequest request = new UpdateRequest("index", null); request.doc("{}", XContentType.JSON); ActionRequestValidationException validate = request.validate(); assertThat(validate, not(nullValue())); assertThat(validate.validationErrors(), hasItems("id is missing")); } - { - // Non-null types are accepted but fail validation - UpdateRequest request = new UpdateRequest("index", "", randomBoolean() ? "" : null); - request.doc("{}", XContentType.JSON); - ActionRequestValidationException validate = request.validate(); - - assertThat(validate, not(nullValue())); - assertThat(validate.validationErrors(), hasItems("type is missing", "id is missing")); - } } public void testRoutingExtraction() throws Exception { GetResult getResult = new GetResult("test", "1", UNASSIGNED_SEQ_NO, 0, 0, false, null, null, null); - IndexRequest indexRequest = new IndexRequest("test", "type", "1"); + IndexRequest indexRequest = new IndexRequest("test").id("1"); // There is no routing and parent because the document doesn't exist assertNull(UpdateHelper.calculateRouting(getResult, null)); @@ -577,7 +567,7 @@ public void testNoopDetection() throws Exception { new BytesArray("{\"body\": \"foo\"}"), null, null); - UpdateRequest request = new UpdateRequest("test", "type1", "1").fromXContent( + UpdateRequest request = new UpdateRequest("test", "1").fromXContent( createParser(JsonXContent.jsonXContent, new BytesArray("{\"doc\": {\"body\": \"foo\"}}"))); UpdateHelper.Result result = updateHelper.prepareUpdateIndexRequest(shardId, request, getResult, true); @@ -592,7 +582,7 @@ public void testNoopDetection() throws Exception { assertThat(result.updatedSourceAsMap().get("body").toString(), equalTo("foo")); // Change the request to be a different doc - request = new UpdateRequest("test", "type1", "1").fromXContent( + request = new UpdateRequest("test", "1").fromXContent( createParser(JsonXContent.jsonXContent, new BytesArray("{\"doc\": {\"body\": \"bar\"}}"))); result = updateHelper.prepareUpdateIndexRequest(shardId, request, getResult, true); @@ -608,7 +598,7 @@ public void testUpdateScript() throws Exception { new BytesArray("{\"body\": \"bar\"}"), null, null); - UpdateRequest request = new UpdateRequest("test", "type1", "1") + UpdateRequest request = new UpdateRequest("test", "1") .script(mockInlineScript("ctx._source.body = \"foo\"")); UpdateHelper.Result result = updateHelper.prepareUpdateScriptRequest(shardId, request, getResult, @@ -619,7 +609,7 @@ public void testUpdateScript() throws Exception { assertThat(result.updatedSourceAsMap().get("body").toString(), equalTo("foo")); // Now where the script changes the op to "delete" - request = new UpdateRequest("test", "type1", "1").script(mockInlineScript("ctx.op = delete")); + request = new UpdateRequest("test", "1").script(mockInlineScript("ctx.op = delete")); result = updateHelper.prepareUpdateScriptRequest(shardId, request, getResult, ESTestCase::randomNonNegativeLong); @@ -630,9 +620,9 @@ public void testUpdateScript() throws Exception { // We treat everything else as a No-op boolean goodNoop = randomBoolean(); if (goodNoop) { - request = new UpdateRequest("test", "type1", "1").script(mockInlineScript("ctx.op = none")); + request = new UpdateRequest("test", "1").script(mockInlineScript("ctx.op = none")); } else { - request = new UpdateRequest("test", "type1", "1").script(mockInlineScript("ctx.op = bad")); + request = new UpdateRequest("test", "1").script(mockInlineScript("ctx.op = bad")); } result = updateHelper.prepareUpdateScriptRequest(shardId, request, getResult, @@ -643,12 +633,12 @@ public void testUpdateScript() throws Exception { } public void testToString() throws IOException { - UpdateRequest request = new UpdateRequest("test", "type1", "1") + UpdateRequest request = new UpdateRequest("test", "1") .script(mockInlineScript("ctx._source.body = \"foo\"")); assertThat(request.toString(), equalTo("update {[test][type1][1], doc_as_upsert[false], " + "script[Script{type=inline, lang='mock', idOrCode='ctx._source.body = \"foo\"', options={}, params={}}], " + "scripted_upsert[false], detect_noop[true]}")); - request = new UpdateRequest("test", "type1", "1").fromXContent( + request = new UpdateRequest("test", "1").fromXContent( createParser(JsonXContent.jsonXContent, new BytesArray("{\"doc\": {\"body\": \"bar\"}}"))); assertThat(request.toString(), equalTo("update {[test][type1][1], doc_as_upsert[false], " + "doc[index {[null][_doc][null], source[{\"body\":\"bar\"}]}], scripted_upsert[false], detect_noop[true]}")); diff --git a/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java b/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java index 7c33abe3ee6dc..666776cf85de0 100644 --- a/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java @@ -55,16 +55,16 @@ public class UpdateResponseTests extends ESTestCase { public void testToXContent() throws IOException { { - UpdateResponse updateResponse = new UpdateResponse(new ShardId("index", "index_uuid", 0), "type", "id", -2, 0, 0, NOT_FOUND); + UpdateResponse updateResponse = new UpdateResponse(new ShardId("index", "index_uuid", 0), "id", -2, 0, 0, NOT_FOUND); String output = Strings.toString(updateResponse); assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":0,\"result\":\"not_found\"," + "\"_shards\":{\"total\":0,\"successful\":0,\"failed\":0}}", output); } { UpdateResponse updateResponse = new UpdateResponse(new ReplicationResponse.ShardInfo(10, 6), - new ShardId("index", "index_uuid", 1), "type", "id", 3, 17, 1, DELETED); + new ShardId("index", "index_uuid", 1), "id", 3, 17, 1, DELETED); String output = Strings.toString(updateResponse); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"result\":\"deleted\"," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"result\":\"deleted\"," + "\"_shards\":{\"total\":10,\"successful\":6,\"failed\":0},\"_seq_no\":3,\"_primary_term\":17}", output); } { @@ -74,11 +74,11 @@ public void testToXContent() throws IOException { fields.put("isbn", new DocumentField("isbn", Collections.singletonList("ABC-123"))); UpdateResponse updateResponse = new UpdateResponse(new ReplicationResponse.ShardInfo(3, 2), - new ShardId("books", "books_uuid", 2), "book", "1", 7, 17, 2, UPDATED); + new ShardId("books", "books_uuid", 2), "1", 7, 17, 2, UPDATED); updateResponse.setGetResult(new GetResult("books", "1",0, 1, 2, true, source, fields, null)); String output = Strings.toString(updateResponse); - assertEquals("{\"_index\":\"books\",\"_type\":\"book\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\"," + + assertEquals("{\"_index\":\"books\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\"," + "\"_shards\":{\"total\":3,\"successful\":2,\"failed\":0},\"_seq_no\":7,\"_primary_term\":17,\"get\":{" + "\"_seq_no\":0,\"_primary_term\":1,\"found\":true," + "\"_source\":{\"title\":\"Book title\",\"isbn\":\"ABC-123\"},\"fields\":{\"isbn\":[\"ABC-123\"],\"title\":[\"Book " + @@ -172,11 +172,11 @@ public static Tuple randomUpdateResponse(XConten if (seqNo != SequenceNumbers.UNASSIGNED_SEQ_NO) { Tuple shardInfos = RandomObjects.randomShardInfo(random()); - actual = new UpdateResponse(shardInfos.v1(), actualShardId, "_doc", id, seqNo, primaryTerm, version, result); - expected = new UpdateResponse(shardInfos.v2(), expectedShardId, "_doc", id, seqNo, primaryTerm, version, result); + actual = new UpdateResponse(shardInfos.v1(), actualShardId, id, seqNo, primaryTerm, version, result); + expected = new UpdateResponse(shardInfos.v2(), expectedShardId, id, seqNo, primaryTerm, version, result); } else { - actual = new UpdateResponse(actualShardId, "_doc", id, seqNo, primaryTerm, version, result); - expected = new UpdateResponse(expectedShardId, "_doc", id, seqNo, primaryTerm, version, result); + actual = new UpdateResponse(actualShardId, id, seqNo, primaryTerm, version, result); + expected = new UpdateResponse(expectedShardId, id, seqNo, primaryTerm, version, result); } if (actualGetResult.isExists()) { diff --git a/server/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java b/server/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java index a10829fa47322..cc81522772bc9 100644 --- a/server/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java +++ b/server/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java @@ -97,7 +97,7 @@ public void testAliases() throws Exception { logger.info("--> indexing against [alias1], should fail now"); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, - () -> client().index(indexRequest("alias1").type("type1").id("1").source(source("2", "test"), + () -> client().index(indexRequest("alias1").id("1").source(source("2", "test"), XContentType.JSON)).actionGet()); assertThat(exception.getMessage(), equalTo("no write index is defined for alias [alias1]." + " The write index may be explicitly disabled using is_write_index=false or the alias points to multiple" + @@ -112,7 +112,7 @@ public void testAliases() throws Exception { ); logger.info("--> indexing against [alias1], should work now"); - IndexResponse indexResponse = client().index(indexRequest("alias1").type("type1").id("1") + IndexResponse indexResponse = client().index(indexRequest("alias1").id("1") .source(source("1", "test"), XContentType.JSON)).actionGet(); assertThat(indexResponse.getIndex(), equalTo("test")); @@ -128,7 +128,7 @@ public void testAliases() throws Exception { logger.info("--> indexing against [alias1], should fail now"); exception = expectThrows(IllegalArgumentException.class, - () -> client().index(indexRequest("alias1").type("type1").id("1").source(source("2", "test"), + () -> client().index(indexRequest("alias1").id("1").source(source("2", "test"), XContentType.JSON)).actionGet()); assertThat(exception.getMessage(), equalTo("no write index is defined for alias [alias1]." + " The write index may be explicitly disabled using is_write_index=false or the alias points to multiple" + @@ -136,7 +136,7 @@ public void testAliases() throws Exception { logger.info("--> deleting against [alias1], should fail now"); exception = expectThrows(IllegalArgumentException.class, - () -> client().delete(deleteRequest("alias1").type("type1").id("1")).actionGet()); + () -> client().delete(deleteRequest("alias1").id("1")).actionGet()); assertThat(exception.getMessage(), equalTo("no write index is defined for alias [alias1]." + " 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")); @@ -147,7 +147,7 @@ public void testAliases() throws Exception { }); logger.info("--> indexing against [alias1], should work now"); - indexResponse = client().index(indexRequest("alias1").type("type1").id("1") + indexResponse = client().index(indexRequest("alias1").id("1") .source(source("1", "test"), XContentType.JSON)).actionGet(); assertThat(indexResponse.getIndex(), equalTo("test")); @@ -157,12 +157,12 @@ public void testAliases() throws Exception { }); logger.info("--> indexing against [alias1], should work now"); - indexResponse = client().index(indexRequest("alias1").type("type1").id("1") + indexResponse = client().index(indexRequest("alias1").id("1") .source(source("1", "test"), XContentType.JSON)).actionGet(); assertThat(indexResponse.getIndex(), equalTo("test_x")); logger.info("--> deleting against [alias1], should fail now"); - DeleteResponse deleteResponse = client().delete(deleteRequest("alias1").type("type1").id("1")).actionGet(); + DeleteResponse deleteResponse = client().delete(deleteRequest("alias1").id("1")).actionGet(); assertThat(deleteResponse.getIndex(), equalTo("test_x")); assertAliasesVersionIncreases("test_x", () -> { @@ -171,7 +171,7 @@ public void testAliases() throws Exception { }); logger.info("--> indexing against [alias1], should work against [test_x]"); - indexResponse = client().index(indexRequest("alias1").type("type1").id("1") + indexResponse = client().index(indexRequest("alias1").id("1") .source(source("1", "test"), XContentType.JSON)).actionGet(); assertThat(indexResponse.getIndex(), equalTo("test_x")); } @@ -242,13 +242,13 @@ public void testSearchingFilteringAliasesSingleIndex() throws Exception { () -> assertAcked(admin().indices().prepareAliases().addAlias("test", "tests", termQuery("name", "test")))); logger.info("--> indexing against [test]"); - client().index(indexRequest("test").type("type1").id("1").source(source("1", "foo test"), XContentType.JSON) + client().index(indexRequest("test").id("1").source(source("1", "foo test"), XContentType.JSON) .setRefreshPolicy(RefreshPolicy.IMMEDIATE)).actionGet(); - client().index(indexRequest("test").type("type1").id("2").source(source("2", "bar test"), XContentType.JSON) + client().index(indexRequest("test").id("2").source(source("2", "bar test"), XContentType.JSON) .setRefreshPolicy(RefreshPolicy.IMMEDIATE)).actionGet(); - client().index(indexRequest("test").type("type1").id("3").source(source("3", "baz test"), XContentType.JSON) + client().index(indexRequest("test").id("3").source(source("3", "baz test"), XContentType.JSON) .setRefreshPolicy(RefreshPolicy.IMMEDIATE)).actionGet(); - client().index(indexRequest("test").type("type1").id("4").source(source("4", "something else"), XContentType.JSON) + client().index(indexRequest("test").id("4").source(source("4", "something else"), XContentType.JSON) .setRefreshPolicy(RefreshPolicy.IMMEDIATE)).actionGet(); logger.info("--> checking single filtering alias search"); @@ -337,16 +337,16 @@ public void testSearchingFilteringAliasesTwoIndices() throws Exception { () -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "foos", termQuery("name", "foo")))); logger.info("--> indexing against [test1]"); - client().index(indexRequest("test1").type("type1").id("1").source(source("1", "foo test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").type("type1").id("2").source(source("2", "bar test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").type("type1").id("3").source(source("3", "baz test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").type("type1").id("4").source(source("4", "something else"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("1").source(source("1", "foo test"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("2").source(source("2", "bar test"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("3").source(source("3", "baz test"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("4").source(source("4", "something else"), XContentType.JSON)).get(); logger.info("--> indexing against [test2]"); - client().index(indexRequest("test2").type("type1").id("5").source(source("5", "foo test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("6").source(source("6", "bar test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("7").source(source("7", "baz test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("8").source(source("8", "something else"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("5").source(source("5", "foo test"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("6").source(source("6", "bar test"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("7").source(source("7", "baz test"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("8").source(source("8", "something else"), XContentType.JSON)).get(); refresh(); @@ -421,17 +421,17 @@ public void testSearchingFilteringAliasesMultipleIndices() throws Exception { () -> assertAcked(admin().indices().prepareAliases().addAlias("test3", "filter13", termQuery("name", "baz")))); logger.info("--> indexing against [test1]"); - client().index(indexRequest("test1").type("type1").id("11").source(source("11", "foo test1"), XContentType.JSON)).get(); - client().index(indexRequest("test1").type("type1").id("12").source(source("12", "bar test1"), XContentType.JSON)).get(); - client().index(indexRequest("test1").type("type1").id("13").source(source("13", "baz test1"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("11").source(source("11", "foo test1"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("12").source(source("12", "bar test1"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("13").source(source("13", "baz test1"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("21").source(source("21", "foo test2"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("22").source(source("22", "bar test2"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("23").source(source("23", "baz test2"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("21").source(source("21", "foo test2"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("22").source(source("22", "bar test2"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("23").source(source("23", "baz test2"), XContentType.JSON)).get(); - client().index(indexRequest("test3").type("type1").id("31").source(source("31", "foo test3"), XContentType.JSON)).get(); - client().index(indexRequest("test3").type("type1").id("32").source(source("32", "bar test3"), XContentType.JSON)).get(); - client().index(indexRequest("test3").type("type1").id("33").source(source("33", "baz test3"), XContentType.JSON)).get(); + client().index(indexRequest("test3").id("31").source(source("31", "foo test3"), XContentType.JSON)).get(); + client().index(indexRequest("test3").id("32").source(source("32", "bar test3"), XContentType.JSON)).get(); + client().index(indexRequest("test3").id("33").source(source("33", "baz test3"), XContentType.JSON)).get(); refresh(); @@ -497,16 +497,16 @@ public void testDeletingByQueryFilteringAliases() throws Exception { () -> assertAcked(admin().indices().prepareAliases().addAlias("test2", "tests", termQuery("name", "test")))); logger.info("--> indexing against [test1]"); - client().index(indexRequest("test1").type("type1").id("1").source(source("1", "foo test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").type("type1").id("2").source(source("2", "bar test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").type("type1").id("3").source(source("3", "baz test"), XContentType.JSON)).get(); - client().index(indexRequest("test1").type("type1").id("4").source(source("4", "something else"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("1").source(source("1", "foo test"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("2").source(source("2", "bar test"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("3").source(source("3", "baz test"), XContentType.JSON)).get(); + client().index(indexRequest("test1").id("4").source(source("4", "something else"), XContentType.JSON)).get(); logger.info("--> indexing against [test2]"); - client().index(indexRequest("test2").type("type1").id("5").source(source("5", "foo test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("6").source(source("6", "bar test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("7").source(source("7", "baz test"), XContentType.JSON)).get(); - client().index(indexRequest("test2").type("type1").id("8").source(source("8", "something else"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("5").source(source("5", "foo test"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("6").source(source("6", "bar test"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("7").source(source("7", "baz test"), XContentType.JSON)).get(); + client().index(indexRequest("test2").id("8").source(source("8", "something else"), XContentType.JSON)).get(); refresh(); @@ -582,7 +582,7 @@ public void testWaitForAliasCreationMultipleShards() throws Exception { for (int i = 0; i < 10; i++) { final String aliasName = "alias" + i; assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName))); - client().index(indexRequest(aliasName).type("type1").id("1").source(source("1", "test"), XContentType.JSON)).get(); + client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get(); } } @@ -598,7 +598,7 @@ public void testWaitForAliasCreationSingleShard() throws Exception { for (int i = 0; i < 10; i++) { final String aliasName = "alias" + i; assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName))); - client().index(indexRequest(aliasName).type("type1").id("1").source(source("1", "test"), + client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)).get(); } } @@ -620,7 +620,7 @@ public void run() { assertAliasesVersionIncreases( "test", () -> assertAcked(admin().indices().prepareAliases().addAlias("test", aliasName))); - client().index(indexRequest(aliasName).type("type1").id("1").source(source("1", "test"), XContentType.JSON)) + client().index(indexRequest(aliasName).id("1").source(source("1", "test"), XContentType.JSON)) .actionGet(); } }); diff --git a/server/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java b/server/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java index ab9ac6075cf4b..90d7efa19b7fb 100644 --- a/server/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java +++ b/server/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java @@ -44,9 +44,9 @@ public void testBroadcastOperations() throws IOException { NumShards numShards = getNumShards("test"); logger.info("Running Cluster Health"); - client().index(indexRequest("test").type("type1").id("1").source(source("1", "test"))).actionGet(); + client().index(indexRequest("test").id("1").source(source("1", "test"))).actionGet(); flush(); - client().index(indexRequest("test").type("type1").id("2").source(source("2", "test"))).actionGet(); + client().index(indexRequest("test").id("2").source(source("2", "test"))).actionGet(); refresh(); logger.info("Count"); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java index e53b7ae064679..371ce0be6aa87 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java @@ -594,7 +594,7 @@ public void testConcreteIndicesIgnoreIndicesEmptyRequest() { public void testConcreteIndicesNoIndicesErrorMessage() { MetaData.Builder mdBuilder = MetaData.builder(); ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build(); - IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, + IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.fromOptions(false, false, true, true)); IndexNotFoundException infe = expectThrows(IndexNotFoundException.class, () -> indexNameExpressionResolver.concreteIndices(context, new String[]{})); @@ -604,13 +604,13 @@ public void testConcreteIndicesNoIndicesErrorMessage() { public void testConcreteIndicesNoIndicesErrorMessageNoExpand() { MetaData.Builder mdBuilder = MetaData.builder(); ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build(); - IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, + IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.fromOptions(false, false, false, false)); IndexNotFoundException infe = expectThrows(IndexNotFoundException.class, () -> indexNameExpressionResolver.concreteIndices(context, new String[]{})); assertThat(infe.getMessage(), is("no such index [_all] and no indices exist")); } - + public void testConcreteIndicesWildcardExpansion() { MetaData.Builder mdBuilder = MetaData.builder() .put(indexBuilder("testXXX").state(State.OPEN)) @@ -1207,7 +1207,7 @@ public void testConcreteWriteIndexWithNoWriteIndexWithSingleIndex() { Arrays.sort(strings); assertArrayEquals(new String[] {"test-alias"}, strings); DocWriteRequest request = randomFrom(new IndexRequest("test-alias"), - new UpdateRequest("test-alias", "_type", "_id"), new DeleteRequest("test-alias")); + new UpdateRequest("test-alias", "_id"), new DeleteRequest("test-alias")); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> indexNameExpressionResolver.concreteWriteIndex(state, request)); assertThat(exception.getMessage(), equalTo("no write index is defined for alias [test-alias]." + @@ -1227,7 +1227,7 @@ public void testConcreteWriteIndexWithNoWriteIndexWithMultipleIndices() { Arrays.sort(strings); assertArrayEquals(new String[] {"test-alias"}, strings); DocWriteRequest request = randomFrom(new IndexRequest("test-alias"), - new UpdateRequest("test-alias", "_type", "_id"), new DeleteRequest("test-alias")); + new UpdateRequest("test-alias", "_id"), new DeleteRequest("test-alias")); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> indexNameExpressionResolver.concreteWriteIndex(state, request)); assertThat(exception.getMessage(), equalTo("no write index is defined for alias [test-alias]." + diff --git a/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java b/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java index 363af3ea87f02..7b34d57536a63 100644 --- a/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java +++ b/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java @@ -71,7 +71,6 @@ public void testIndexActions() throws Exception { .setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); assertThat(indexResponse.getIndex(), equalTo(getConcreteIndexName())); assertThat(indexResponse.getId(), equalTo("1")); - assertThat(indexResponse.getType(), equalTo("type1")); logger.info("Refreshing"); RefreshResponse refreshResponse = refresh(); assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards)); @@ -124,7 +123,6 @@ public void testIndexActions() throws Exception { DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "1").execute().actionGet(); assertThat(deleteResponse.getIndex(), equalTo(getConcreteIndexName())); assertThat(deleteResponse.getId(), equalTo("1")); - assertThat(deleteResponse.getType(), equalTo("type1")); logger.info("Refreshing"); client().admin().indices().refresh(refreshRequest("test")).actionGet(); @@ -135,9 +133,9 @@ public void testIndexActions() throws Exception { } logger.info("Index [type1/1]"); - client().index(indexRequest("test").type("type1").id("1").source(source("1", "test"))).actionGet(); + client().index(indexRequest("test").id("1").source(source("1", "test"))).actionGet(); logger.info("Index [type1/2]"); - client().index(indexRequest("test").type("type1").id("2").source(source("2", "test2"))).actionGet(); + client().index(indexRequest("test").id("2").source(source("2", "test2"))).actionGet(); logger.info("Flushing"); FlushResponse flushResult = client().admin().indices().prepareFlush("test").execute().actionGet(); diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java index 328efd8174615..2a9d14a280fd1 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineMergeIT.java @@ -52,7 +52,7 @@ public void testMergesHappening() throws Exception { final int numDocs = scaledRandomIntBetween(100, 1000); BulkRequestBuilder request = client().prepareBulk(); for (int j = 0; j < numDocs; ++j) { - request.add(Requests.indexRequest("test").type("type1").id(Long.toString(id++)) + request.add(Requests.indexRequest("test").id(Long.toString(id++)) .source(jsonBuilder().startObject().field("l", randomLong()).endObject())); } BulkResponse response = request.execute().actionGet(); diff --git a/server/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java b/server/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java index 23a9880046001..90fe2dac38d71 100644 --- a/server/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java +++ b/server/src/test/java/org/elasticsearch/index/reindex/ReindexRequestTests.java @@ -87,9 +87,6 @@ protected ReindexRequest createTestInstance() { if (randomBoolean()) { reindexRequest.setSourceBatchSize(randomInt(100)); } - if (randomBoolean()) { - reindexRequest.setDestDocType("type"); - } if (randomBoolean()) { reindexRequest.setDestOpType("create"); } @@ -135,7 +132,6 @@ protected void assertEqualInstances(ReindexRequest expectedInstance, ReindexRequ assertEquals(expectedInstance.getDestination().getPipeline(), newInstance.getDestination().getPipeline()); assertEquals(expectedInstance.getDestination().routing(), newInstance.getDestination().routing()); assertEquals(expectedInstance.getDestination().opType(), newInstance.getDestination().opType()); - assertEquals(expectedInstance.getDestination().type(), newInstance.getDestination().type()); } public void testReindexFromRemoteDoesNotSupportSearchQuery() { diff --git a/server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java b/server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java index 2817c51d33aa1..fb1854c93294a 100644 --- a/server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java +++ b/server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java @@ -154,7 +154,7 @@ public void cleanFiles(int totalTranslogOps, long globalCheckpoint, public void testRetryAppendOnlyAfterRecovering() throws Exception { try (ReplicationGroup shards = createGroup(0)) { shards.startAll(); - final IndexRequest originalRequest = new IndexRequest(index.getName(), "type").source("{}", XContentType.JSON); + final IndexRequest originalRequest = new IndexRequest(index.getName()).source("{}", XContentType.JSON); originalRequest.process(Version.CURRENT, null, index.getName()); final IndexRequest retryRequest = copyIndexRequest(originalRequest); retryRequest.onRetry(); @@ -195,7 +195,7 @@ public IndexResult index(Index op) throws IOException { }) { shards.startAll(); Thread thread = new Thread(() -> { - IndexRequest indexRequest = new IndexRequest(index.getName(), "type").source("{}", XContentType.JSON); + IndexRequest indexRequest = new IndexRequest(index.getName()).source("{}", XContentType.JSON); try { shards.index(indexRequest); } catch (Exception e) { @@ -226,7 +226,7 @@ public void prepareForTranslogOperations(int totalTranslogOps, ActionListener replicas = shards.getReplicas(); IndexShard replica1 = replicas.get(0); - IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "1").source("{ \"f\": \"1\"}", XContentType.JSON); + IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", XContentType.JSON); logger.info("--> isolated replica " + replica1.routingEntry()); BulkShardRequest replicationRequest = indexOnPrimary(indexRequest, shards.getPrimary()); for (int i = 1; i < replicas.size(); i++) { @@ -310,7 +310,7 @@ public void testConflictingOpsOnReplica() throws Exception { logger.info("--> promoting replica to primary " + replica1.routingEntry()); shards.promoteReplicaToPrimary(replica1).get(); - indexRequest = new IndexRequest(index.getName(), "type", "1").source("{ \"f\": \"2\"}", XContentType.JSON); + indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"2\"}", XContentType.JSON); shards.index(indexRequest); shards.refresh("test"); for (IndexShard shard : shards) { @@ -338,7 +338,7 @@ public void testReplicaTermIncrementWithConcurrentPrimaryPromotion() throws Exce assertEquals(primaryPrimaryTerm, replica2.getPendingPrimaryTerm()); - IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "1").source("{ \"f\": \"1\"}", XContentType.JSON); + IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", XContentType.JSON); BulkShardRequest replicationRequest = indexOnPrimary(indexRequest, replica1); CyclicBarrier barrier = new CyclicBarrier(2); @@ -376,7 +376,7 @@ public void testReplicaOperationWithConcurrentPrimaryPromotion() throws Exceptio try (ReplicationGroup shards = new ReplicationGroup(buildIndexMetaData(1, mappings))) { shards.startAll(); long primaryPrimaryTerm = shards.getPrimary().getPendingPrimaryTerm(); - IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "1").source("{ \"f\": \"1\"}", XContentType.JSON); + IndexRequest indexRequest = new IndexRequest(index.getName()).id("1").source("{ \"f\": \"1\"}", XContentType.JSON); BulkShardRequest replicationRequest = indexOnPrimary(indexRequest, shards.getPrimary()); List replicas = shards.getReplicas(); @@ -451,7 +451,7 @@ public long addDocument(Iterable doc) throws IOExcepti shards.startPrimary(); long primaryTerm = shards.getPrimary().getPendingPrimaryTerm(); List expectedTranslogOps = new ArrayList<>(); - BulkItemResponse indexResp = shards.index(new IndexRequest(index.getName(), "type", "1").source("{}", XContentType.JSON)); + BulkItemResponse indexResp = shards.index(new IndexRequest(index.getName()).id("1").source("{}", XContentType.JSON)); assertThat(indexResp.isFailed(), equalTo(true)); assertThat(indexResp.getFailure().getCause(), equalTo(indexException)); expectedTranslogOps.add(new Translog.NoOp(0, primaryTerm, indexException.toString())); @@ -479,7 +479,7 @@ public long addDocument(Iterable doc) throws IOExcepti } } // the failure replicated directly from the replication channel. - indexResp = shards.index(new IndexRequest(index.getName(), "type", "any").source("{}", XContentType.JSON)); + indexResp = shards.index(new IndexRequest(index.getName()).id("any").source("{}", XContentType.JSON)); assertThat(indexResp.getFailure().getCause(), equalTo(indexException)); Translog.NoOp noop2 = new Translog.NoOp(1, primaryTerm, indexException.toString()); expectedTranslogOps.add(noop2); @@ -507,7 +507,7 @@ public void testRequestFailureReplication() throws Exception { try (ReplicationGroup shards = createGroup(0)) { shards.startAll(); BulkItemResponse response = shards.index( - new IndexRequest(index.getName(), "type", "1") + new IndexRequest(index.getName()).id("1") .source("{}", XContentType.JSON) .version(2) ); @@ -526,7 +526,7 @@ public void testRequestFailureReplication() throws Exception { } shards.startReplicas(nReplica); response = shards.index( - new IndexRequest(index.getName(), "type", "1") + new IndexRequest(index.getName()).id("1") .source("{}", XContentType.JSON) .version(2) ); @@ -550,7 +550,7 @@ public void testSeqNoCollision() throws Exception { shards.syncGlobalCheckpoint(); logger.info("--> Isolate replica1"); - IndexRequest indexDoc1 = new IndexRequest(index.getName(), "type", "d1").source("{}", XContentType.JSON); + IndexRequest indexDoc1 = new IndexRequest(index.getName()).id("d1").source("{}", XContentType.JSON); BulkShardRequest replicationRequest = indexOnPrimary(indexDoc1, shards.getPrimary()); indexOnReplica(replicationRequest, shards, replica2); @@ -572,7 +572,7 @@ public void testSeqNoCollision() throws Exception { // and does not overwrite its stale operation (op1) as it is trimmed. logger.info("--> Promote replica1 as the primary"); shards.promoteReplicaToPrimary(replica1).get(); // wait until resync completed. - shards.index(new IndexRequest(index.getName(), "type", "d2").source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id("d2").source("{}", XContentType.JSON)); final Translog.Operation op2; try (Translog.Snapshot snapshot = getTranslog(replica2).newSnapshot()) { assertThat(snapshot.totalOperations(), equalTo(initDocs + 2)); @@ -620,8 +620,8 @@ public void testLateDeliveryAfterGCTriggeredOnReplica() throws Exception { updateGCDeleteCycle(replica, gcInterval); final BulkShardRequest indexRequest = indexOnPrimary( - new IndexRequest(index.getName(), "type", "d1").source("{}", XContentType.JSON), primary); - final BulkShardRequest deleteRequest = deleteOnPrimary(new DeleteRequest(index.getName(), "type", "d1"), primary); + new IndexRequest(index.getName()).id("d1").source("{}", XContentType.JSON), primary); + final BulkShardRequest deleteRequest = deleteOnPrimary(new DeleteRequest(index.getName()).id("d1"), primary); deleteOnReplica(deleteRequest, shards, replica); // delete arrives on replica first. final long deleteTimestamp = threadPool.relativeTimeInMillis(); replica.refresh("test"); @@ -656,9 +656,9 @@ public void testOutOfOrderDeliveryForAppendOnlyOperations() throws Exception { final IndexShard replica = shards.getReplicas().get(0); // Append-only request - without id final BulkShardRequest indexRequest = indexOnPrimary( - new IndexRequest(index.getName(), "type", null).source("{}", XContentType.JSON), primary); + new IndexRequest(index.getName()).source("{}", XContentType.JSON), primary); final String docId = Iterables.get(getShardDocUIDs(primary), 0); - final BulkShardRequest deleteRequest = deleteOnPrimary(new DeleteRequest(index.getName(), "type", docId), primary); + final BulkShardRequest deleteRequest = deleteOnPrimary(new DeleteRequest(index.getName()).id(docId), primary); deleteOnReplica(deleteRequest, shards, replica); indexOnReplica(indexRequest, shards, replica); shards.assertAllEqual(0); @@ -674,12 +674,12 @@ public void testIndexingOptimizationUsingSequenceNumbers() throws Exception { for (int i = 0; i < numDocs; i++) { String id = Integer.toString(randomIntBetween(1, 100)); if (randomBoolean()) { - group.index(new IndexRequest(index.getName(), "type", id).source("{}", XContentType.JSON)); + group.index(new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON)); if (liveDocs.add(id) == false) { versionLookups++; } } else { - group.delete(new DeleteRequest(index.getName(), "type", id)); + group.delete(new DeleteRequest(index.getName()).id(id)); liveDocs.remove(id); versionLookups++; } diff --git a/server/src/test/java/org/elasticsearch/index/replication/RecoveryDuringReplicationTests.java b/server/src/test/java/org/elasticsearch/index/replication/RecoveryDuringReplicationTests.java index b0ed3361bcea3..c44eb5b051d6d 100644 --- a/server/src/test/java/org/elasticsearch/index/replication/RecoveryDuringReplicationTests.java +++ b/server/src/test/java/org/elasticsearch/index/replication/RecoveryDuringReplicationTests.java @@ -183,7 +183,7 @@ public void testRecoveryToReplicaThatReceivedExtraDocument() throws Exception { final int docs = randomIntBetween(0, 16); for (int i = 0; i < docs; i++) { shards.index( - new IndexRequest("index", "type", Integer.toString(i)).source("{}", XContentType.JSON)); + new IndexRequest("index").id(Integer.toString(i)).source("{}", XContentType.JSON)); } shards.flush(); @@ -243,7 +243,7 @@ public void testRecoveryAfterPrimaryPromotion() throws Exception { final int rollbackDocs = randomIntBetween(1, 5); logger.info("--> indexing {} rollback docs", rollbackDocs); for (int i = 0; i < rollbackDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "rollback_" + i) + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("rollback_" + i) .source("{}", XContentType.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); indexOnReplica(bulkShardRequest, shards, replica); @@ -346,7 +346,7 @@ public void testReplicaRollbackStaleDocumentsInPeerRecovery() throws Exception { int staleDocs = scaledRandomIntBetween(1, 10); logger.info("--> indexing {} stale docs", staleDocs); for (int i = 0; i < staleDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "stale_" + i) + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("stale_" + i) .source("{}", XContentType.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); indexOnReplica(bulkShardRequest, shards, replica); @@ -385,7 +385,7 @@ public void testResyncAfterPrimaryPromotion() throws Exception { int initialDocs = randomInt(10); for (int i = 0; i < initialDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "initial_doc_" + i) + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("initial_doc_" + i) .source("{ \"f\": \"normal\"}", XContentType.JSON); shards.index(indexRequest); } @@ -403,7 +403,7 @@ public void testResyncAfterPrimaryPromotion() throws Exception { final int extraDocs = randomInt(5); logger.info("--> indexing {} extra docs", extraDocs); for (int i = 0; i < extraDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "extra_doc_" + i) + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("extra_doc_" + i) .source("{ \"f\": \"normal\"}", XContentType.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); indexOnReplica(bulkShardRequest, shards, newPrimary); @@ -412,7 +412,7 @@ public void testResyncAfterPrimaryPromotion() throws Exception { final int extraDocsToBeTrimmed = randomIntBetween(0, 10); logger.info("--> indexing {} extra docs to be trimmed", extraDocsToBeTrimmed); for (int i = 0; i < extraDocsToBeTrimmed; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "extra_trimmed_" + i) + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("extra_trimmed_" + i) .source("{ \"f\": \"trimmed\"}", XContentType.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); // have to replicate to another replica != newPrimary one - the subject to trim @@ -480,7 +480,7 @@ protected EngineFactory getEngineFactory(ShardRouting routing) { final String id = "pending_" + i; threadPool.generic().submit(() -> { try { - shards.index(new IndexRequest(index.getName(), "type", id).source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON)); } catch (Exception e) { throw new AssertionError(e); } finally { @@ -571,7 +571,7 @@ public void indexTranslogOperations( replicaEngineFactory.latchIndexers(1); threadPool.generic().submit(() -> { try { - shards.index(new IndexRequest(index.getName(), "type", "pending").source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id("pending").source("{}", XContentType.JSON)); } catch (final Exception e) { throw new RuntimeException(e); } finally { @@ -583,7 +583,7 @@ public void indexTranslogOperations( replicaEngineFactory.awaitIndexersLatch(); // unblock indexing for the next doc replicaEngineFactory.allowIndexing(); - shards.index(new IndexRequest(index.getName(), "type", "completed").source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id("completed").source("{}", XContentType.JSON)); pendingDocActiveWithExtraDocIndexed.countDown(); } catch (final Exception e) { throw new AssertionError(e); @@ -621,7 +621,7 @@ public void indexTranslogOperations( // wait for the translog phase to complete and the recovery to block global checkpoint advancement assertBusy(() -> assertTrue(shards.getPrimary().pendingInSync())); { - shards.index(new IndexRequest(index.getName(), "type", "last").source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id("last").source("{}", XContentType.JSON)); final long expectedDocs = docs + 3L; assertThat(shards.getPrimary().getLocalCheckpoint(), equalTo(expectedDocs - 1)); // recovery is now in the process of being completed, therefore the global checkpoint can not have advanced on the primary @@ -656,7 +656,7 @@ public void testTransferMaxSeenAutoIdTimestampOnResync() throws Exception { long maxTimestampOnReplica2 = -1; List replicationRequests = new ArrayList<>(); for (int numDocs = between(1, 10), i = 0; i < numDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type").source("{}", XContentType.JSON); + final IndexRequest indexRequest = new IndexRequest(index.getName()).source("{}", XContentType.JSON); indexRequest.process(Version.CURRENT, null, index.getName()); final IndexRequest copyRequest; if (randomBoolean()) { @@ -715,13 +715,13 @@ public void testAddNewReplicas() throws Exception { int nextId = docId.incrementAndGet(); if (appendOnly) { String id = randomBoolean() ? Integer.toString(nextId) : null; - shards.index(new IndexRequest(index.getName(), "type", id).source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON)); } else if (frequently()) { String id = Integer.toString(frequently() ? nextId : between(0, nextId)); - shards.index(new IndexRequest(index.getName(), "type", id).source("{}", XContentType.JSON)); + shards.index(new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON)); } else { String id = Integer.toString(between(0, nextId)); - shards.delete(new DeleteRequest(index.getName(), "type", id)); + shards.delete(new DeleteRequest(index.getName()).id(id)); } if (randomInt(100) < 10) { shards.getPrimary().flush(new FlushRequest()); @@ -756,7 +756,7 @@ public void testRollbackOnPromotion() throws Exception { int inFlightOps = scaledRandomIntBetween(10, 200); for (int i = 0; i < inFlightOps; i++) { String id = "extra-" + i; - IndexRequest primaryRequest = new IndexRequest(index.getName(), "type", id).source("{}", XContentType.JSON); + IndexRequest primaryRequest = new IndexRequest(index.getName()).id(id).source("{}", XContentType.JSON); BulkShardRequest replicationRequest = indexOnPrimary(primaryRequest, shards.getPrimary()); for (IndexShard replica : shards.getReplicas()) { if (randomBoolean()) { diff --git a/server/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/server/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java index 99eaba4a77572..38319fcf1907f 100644 --- a/server/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java +++ b/server/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java @@ -392,7 +392,7 @@ public void testLimitsRequestSize() throws Exception { int numRequests = inFlightRequestsLimit.bytesAsInt(); BulkRequest bulkRequest = new BulkRequest(); for (int i = 0; i < numRequests; i++) { - IndexRequest indexRequest = new IndexRequest("index", "type", Integer.toString(i)); + IndexRequest indexRequest = new IndexRequest("index").id(Integer.toString(i)); indexRequest.source(Requests.INDEX_CONTENT_TYPE, "field", "value", "num", i); bulkRequest.add(indexRequest); } diff --git a/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryTests.java b/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryTests.java index b340d8c52bec4..5cfb9e228d955 100644 --- a/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryTests.java +++ b/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryTests.java @@ -479,7 +479,7 @@ public void testRecoveryTrimsLocalTranslog() throws Exception { } int inflightDocs = scaledRandomIntBetween(1, 100); for (int i = 0; i < inflightDocs; i++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "extra_" + i).source("{}", XContentType.JSON); + final IndexRequest indexRequest = new IndexRequest(index.getName()).id("extra_" + i).source("{}", XContentType.JSON); final BulkShardRequest bulkShardRequest = indexOnPrimary(indexRequest, oldPrimary); for (IndexShard replica : randomSubsetOf(shards.getReplicas())) { indexOnReplica(bulkShardRequest, shards, replica); diff --git a/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java index ec59f4c4c5a70..aa7c81684ddad 100644 --- a/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java @@ -633,7 +633,7 @@ public void testStrictAliasParsingInIndicesCreatedViaTemplates() throws Exceptio .addAlias(new Alias("alias4").filter(termQuery("field", "value"))).get(); client().prepareIndex("a1", "test", "test").setSource("{}", XContentType.JSON).get(); - BulkResponse response = client().prepareBulk().add(new IndexRequest("a2", "test", "test").source("{}", XContentType.JSON)).get(); + BulkResponse response = client().prepareBulk().add(new IndexRequest("a2").id("test").source("{}", XContentType.JSON)).get(); assertThat(response.hasFailures(), is(false)); assertThat(response.getItems()[0].isFailed(), equalTo(false)); assertThat(response.getItems()[0].getIndex(), equalTo("a2")); @@ -650,7 +650,7 @@ public void testStrictAliasParsingInIndicesCreatedViaTemplates() throws Exceptio // an index that doesn't exist yet will succeed client().prepareIndex("b1", "test", "test").setSource("{}", XContentType.JSON).get(); - response = client().prepareBulk().add(new IndexRequest("b2", "test", "test").source("{}", XContentType.JSON)).get(); + response = client().prepareBulk().add(new IndexRequest("b2").id("test").source("{}", XContentType.JSON)).get(); assertThat(response.hasFailures(), is(false)); assertThat(response.getItems()[0].isFailed(), equalTo(false)); assertThat(response.getItems()[0].getId(), equalTo("test")); diff --git a/server/src/test/java/org/elasticsearch/ingest/IngestClientIT.java b/server/src/test/java/org/elasticsearch/ingest/IngestClientIT.java index 71a613628ed57..79b823251a92e 100644 --- a/server/src/test/java/org/elasticsearch/ingest/IngestClientIT.java +++ b/server/src/test/java/org/elasticsearch/ingest/IngestClientIT.java @@ -120,7 +120,7 @@ public void testSimulate() throws Exception { source.put("foo", "bar"); source.put("fail", false); source.put("processed", true); - IngestDocument ingestDocument = new IngestDocument("index", "type", "id", null, null, null, source); + IngestDocument ingestDocument = new IngestDocument("index", "id", null, null, null, source); assertThat(simulateDocumentBaseResult.getIngestDocument().getSourceAndMetadata(), equalTo(ingestDocument.getSourceAndMetadata())); assertThat(simulateDocumentBaseResult.getFailure(), nullValue()); @@ -147,7 +147,7 @@ public void testBulkWithIngestFailures() throws Exception { int numRequests = scaledRandomIntBetween(32, 128); BulkRequest bulkRequest = new BulkRequest(); for (int i = 0; i < numRequests; i++) { - IndexRequest indexRequest = new IndexRequest("index", "type", Integer.toString(i)).setPipeline("_id"); + IndexRequest indexRequest = new IndexRequest("index").id(Integer.toString(i)).setPipeline("_id"); indexRequest.source(Requests.INDEX_CONTENT_TYPE, "field", "value", "fail", i % 2 == 0); bulkRequest.add(indexRequest); } @@ -191,10 +191,10 @@ public void testBulkWithUpsert() throws Exception { client().admin().cluster().putPipeline(putPipelineRequest).get(); BulkRequest bulkRequest = new BulkRequest(); - IndexRequest indexRequest = new IndexRequest("index", "type", "1").setPipeline("_id"); + IndexRequest indexRequest = new IndexRequest("index").id("1").setPipeline("_id"); indexRequest.source(Requests.INDEX_CONTENT_TYPE, "field1", "val1"); bulkRequest.add(indexRequest); - UpdateRequest updateRequest = new UpdateRequest("index", "type", "2"); + UpdateRequest updateRequest = new UpdateRequest("index", "2"); updateRequest.doc("{}", Requests.INDEX_CONTENT_TYPE); updateRequest.upsert("{\"field1\":\"upserted_val\"}", XContentType.JSON).upsertRequest().setPipeline("_id"); bulkRequest.add(updateRequest); diff --git a/server/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java b/server/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java index b27d3f7bf9706..4d2f0b84b6562 100644 --- a/server/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java +++ b/server/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java @@ -75,7 +75,7 @@ public void setTestIngestDocument() { list.add(null); document.put("list", list); - ingestDocument = new IngestDocument("index", "type", "id", null, null, null, document); + ingestDocument = new IngestDocument("index", "id", null, null, null, document); } public void testSimpleGetFieldValue() { diff --git a/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java b/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java index ec521e4761497..9afd15b6a6767 100644 --- a/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java +++ b/server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java @@ -134,7 +134,7 @@ public void testExecuteIndexPipelineDoesNotExist() { when(threadPool.executor(anyString())).thenReturn(executorService); IngestService ingestService = new IngestService(mock(ClusterService.class), threadPool, null, null, null, Collections.singletonList(DUMMY_PLUGIN), client); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); final SetOnce failure = new SetOnce<>(); final BiConsumer failureHandler = (slot, e) -> { @@ -623,7 +623,7 @@ public String getType() { clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); final SetOnce failure = new SetOnce<>(); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline(id); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline(id); final BiConsumer failureHandler = (slot, e) -> { assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); assertThat(e.getCause().getCause(), instanceOf(IllegalStateException.class)); @@ -653,10 +653,10 @@ public void testExecuteBulkPipelineDoesNotExist() { BulkRequest bulkRequest = new BulkRequest(); - IndexRequest indexRequest1 = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + IndexRequest indexRequest1 = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); bulkRequest.add(indexRequest1); IndexRequest indexRequest2 = - new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("does_not_exist"); + new IndexRequest("_index").id("_id").source(Collections.emptyMap()).setPipeline("does_not_exist"); bulkRequest.add(indexRequest2); @SuppressWarnings("unchecked") BiConsumer failureHandler = mock(BiConsumer.class); @@ -691,7 +691,7 @@ public void testExecuteSuccess() { ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); @SuppressWarnings("unchecked") final BiConsumer failureHandler = mock(BiConsumer.class); @SuppressWarnings("unchecked") @@ -709,7 +709,7 @@ public void testExecuteEmptyPipeline() throws Exception { ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); @SuppressWarnings("unchecked") final BiConsumer failureHandler = mock(BiConsumer.class); @SuppressWarnings("unchecked") @@ -748,7 +748,7 @@ public void testExecutePropagateAllMetaDataUpdates() throws Exception { handler.accept(ingestDocument, null); return null; }).when(processor).execute(any(), any()); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); @SuppressWarnings("unchecked") final BiConsumer failureHandler = mock(BiConsumer.class); @SuppressWarnings("unchecked") @@ -758,7 +758,6 @@ public void testExecutePropagateAllMetaDataUpdates() throws Exception { verify(failureHandler, never()).accept(any(), any()); verify(completionHandler, times(1)).accept(Thread.currentThread(), null); assertThat(indexRequest.index(), equalTo("update_index")); - assertThat(indexRequest.type(), equalTo("update_type")); assertThat(indexRequest.id(), equalTo("update_id")); assertThat(indexRequest.routing(), equalTo("update_routing")); assertThat(indexRequest.version(), equalTo(newVersion)); @@ -775,7 +774,7 @@ public void testExecuteFailure() throws Exception { ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); doThrow(new RuntimeException()) .when(processor) .execute(eqIndexTypeId(indexRequest.version(), indexRequest.versionType(), emptyMap()), any()); @@ -819,7 +818,7 @@ public void testExecuteSuccessWithOnFailure() throws Exception { ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); @SuppressWarnings("unchecked") final BiConsumer failureHandler = mock(BiConsumer.class); @SuppressWarnings("unchecked") @@ -847,7 +846,7 @@ public void testExecuteFailureWithNestedOnFailure() throws Exception { ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); doThrow(new RuntimeException()) .when(onFailureOnFailureProcessor) .execute(eqIndexTypeId(indexRequest.version(), indexRequest.versionType(), emptyMap()), any()); @@ -877,12 +876,12 @@ public void testBulkRequestExecutionWithFailures() throws Exception { DocWriteRequest request; if (randomBoolean()) { if (randomBoolean()) { - request = new DeleteRequest("_index", "_type", "_id"); + request = new DeleteRequest("_index", "_id"); } else { - request = new UpdateRequest("_index", "_type", "_id"); + request = new UpdateRequest("_index", "_id"); } } else { - IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").setPipeline(pipelineId); + IndexRequest indexRequest = new IndexRequest("_index").id("_id").setPipeline(pipelineId); indexRequest.source(Requests.INDEX_CONTENT_TYPE, "field1", "value1"); request = indexRequest; numIndexRequests++; @@ -935,7 +934,7 @@ public void testBulkRequestExecution() throws Exception { logger.info("Using [{}], not randomly determined default [{}]", xContentType, Requests.INDEX_CONTENT_TYPE); int numRequest = scaledRandomIntBetween(8, 64); for (int i = 0; i < numRequest; i++) { - IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").setPipeline(pipelineId); + IndexRequest indexRequest = new IndexRequest("_index").id("_id").setPipeline(pipelineId); indexRequest.source(xContentType, "field1", "value1"); bulkRequest.add(indexRequest); } @@ -1146,7 +1145,7 @@ public String getTag() { ClusterState previousClusterState = clusterState; clusterState = IngestService.innerPut(putRequest, clusterState); ingestService.applyClusterState(new ClusterChangedEvent("", clusterState, previousClusterState)); - final IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(emptyMap()).setPipeline("_id"); + final IndexRequest indexRequest = new IndexRequest("_index").id("_id").source(emptyMap()).setPipeline("_id"); @SuppressWarnings("unchecked") final BiConsumer failureHandler = mock(BiConsumer.class); @SuppressWarnings("unchecked") @@ -1250,11 +1249,11 @@ private class IngestDocumentMatcher extends ArgumentMatcher { private final IngestDocument ingestDocument; IngestDocumentMatcher(String index, String type, String id, Map source) { - this.ingestDocument = new IngestDocument(index, type, id, null, null, null, source); + this.ingestDocument = new IngestDocument(index, id, null, null, null, source); } IngestDocumentMatcher(String index, String type, String id, Long version, VersionType versionType, Map source) { - this.ingestDocument = new IngestDocument(index, type, id, null, version, versionType, source); + this.ingestDocument = new IngestDocument(index, id, null, version, versionType, source); } @Override diff --git a/server/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java b/server/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java index 4fab90cf4e3ed..6fb07b55edaa5 100644 --- a/server/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java +++ b/server/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java @@ -53,12 +53,12 @@ public void testSimpleRecovery() throws Exception { NumShards numShards = getNumShards("test"); - client().index(indexRequest("test").type("type1").id("1").source(source("1", "test"), XContentType.JSON)).actionGet(); + client().index(indexRequest("test").id("1").source(source("1", "test"), XContentType.JSON)).actionGet(); FlushResponse flushResponse = client().admin().indices().flush(flushRequest("test")).actionGet(); assertThat(flushResponse.getTotalShards(), equalTo(numShards.totalNumShards)); assertThat(flushResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries)); assertThat(flushResponse.getFailedShards(), equalTo(0)); - client().index(indexRequest("test").type("type1").id("2").source(source("2", "test"), XContentType.JSON)).actionGet(); + client().index(indexRequest("test").id("2").source(source("2", "test"), XContentType.JSON)).actionGet(); RefreshResponse refreshResponse = client().admin().indices().refresh(refreshRequest("test")).actionGet(); assertThat(refreshResponse.getTotalShards(), equalTo(numShards.totalNumShards)); assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries)); diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestDeleteActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestDeleteActionTests.java deleted file mode 100644 index d95af547e8da1..0000000000000 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestDeleteActionTests.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.rest.action.document; - -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestRequest.Method; -import org.elasticsearch.test.rest.RestActionTestCase; -import org.elasticsearch.test.rest.FakeRestRequest; -import org.junit.Before; - -public class RestDeleteActionTests extends RestActionTestCase { - - @Before - public void setUpAction() { - new RestDeleteAction(controller()); - } - - public void testTypeInPath() { - RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(Method.DELETE) - .withPath("/some_index/some_type/some_id") - .build(); - dispatchRequest(deprecatedRequest); - assertWarnings(RestDeleteAction.TYPES_DEPRECATION_MESSAGE); - - RestRequest validRequest = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(Method.DELETE) - .withPath("/some_index/_doc/some_id") - .build(); - dispatchRequest(validRequest); - } -} diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java index 2fd0ce2580519..034f0f0d52bc8 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java @@ -21,8 +21,6 @@ import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.test.rest.RestActionTestCase; import org.junit.Before; @@ -37,36 +35,6 @@ public void setUpAction() { action = new RestIndexAction(controller()); } - public void testTypeInPath() { - RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.PUT) - .withPath("/some_index/some_type/some_id") - .build(); - dispatchRequest(deprecatedRequest); - assertWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE); - - RestRequest validRequest = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.PUT) - .withPath("/some_index/_doc/some_id") - .build(); - dispatchRequest(validRequest); - } - - public void testCreateWithTypeInPath() { - RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.PUT) - .withPath("/some_index/some_type/some_id/_create") - .build(); - dispatchRequest(deprecatedRequest); - assertWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE); - - RestRequest validRequest = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.PUT) - .withPath("/some_index/_create/some_id") - .build(); - dispatchRequest(validRequest); - } - public void testCreateOpTypeValidation() { Settings settings = settings(Version.CURRENT).build(); RestIndexAction.CreateHandler create = action.new CreateHandler(); diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestUpdateActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestUpdateActionTests.java index 639cbcde5621a..b5104bb4cfc00 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestUpdateActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestUpdateActionTests.java @@ -25,7 +25,6 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestRequest.Method; import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.test.rest.RestActionTestCase; import org.junit.Before; @@ -45,21 +44,6 @@ public void setUpAction() { action = new RestUpdateAction(controller()); } - public void testTypeInPath() { - RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(Method.POST) - .withPath("/some_index/some_type/some_id/_update") - .build(); - dispatchRequest(deprecatedRequest); - assertWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE); - - RestRequest validRequest = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(Method.POST) - .withPath("/some_index/_update/some_id") - .build(); - dispatchRequest(validRequest); - } - public void testUpdateDocVersion() { Map params = new HashMap<>(); if (randomBoolean()) { diff --git a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java index 9811c8b4a5628..a61f03b969069 100644 --- a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -452,7 +452,6 @@ public void testRequiredRoutingBulk() throws Exception { BulkResponse bulkResponse = client() .prepareBulk() .add(Requests.indexRequest(indexOrAlias()) - .type("type1") .id("1") .source(Requests.INDEX_CONTENT_TYPE, "field", "value")) .execute() @@ -473,7 +472,6 @@ public void testRequiredRoutingBulk() throws Exception { BulkResponse bulkResponse = client() .prepareBulk() .add(Requests.indexRequest(indexOrAlias()) - .type("type1") .id("1") .routing("0") .source(Requests.INDEX_CONTENT_TYPE, "field", "value")) @@ -483,7 +481,7 @@ public void testRequiredRoutingBulk() throws Exception { } { - BulkResponse bulkResponse = client().prepareBulk().add(new UpdateRequest(indexOrAlias(), "type1", "1") + BulkResponse bulkResponse = client().prepareBulk().add(new UpdateRequest(indexOrAlias(), "1") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value2")) .execute().actionGet(); assertThat(bulkResponse.getItems().length, equalTo(1)); @@ -499,14 +497,14 @@ public void testRequiredRoutingBulk() throws Exception { } { - BulkResponse bulkResponse = client().prepareBulk().add(new UpdateRequest(indexOrAlias(), "type1", "1") + BulkResponse bulkResponse = client().prepareBulk().add(new UpdateRequest(indexOrAlias(), "1") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value2") .routing("0")).execute().actionGet(); assertThat(bulkResponse.hasFailures(), equalTo(false)); } { - BulkResponse bulkResponse = client().prepareBulk().add(Requests.deleteRequest(indexOrAlias()).type("type1").id("1")) + BulkResponse bulkResponse = client().prepareBulk().add(Requests.deleteRequest(indexOrAlias()).id("1")) .execute().actionGet(); assertThat(bulkResponse.getItems().length, equalTo(1)); assertThat(bulkResponse.hasFailures(), equalTo(true)); @@ -521,7 +519,7 @@ public void testRequiredRoutingBulk() throws Exception { } { - BulkResponse bulkResponse = client().prepareBulk().add(Requests.deleteRequest(indexOrAlias()).type("type1").id("1") + BulkResponse bulkResponse = client().prepareBulk().add(Requests.deleteRequest(indexOrAlias()).id("1") .routing("0")).execute().actionGet(); assertThat(bulkResponse.getItems().length, equalTo(1)); assertThat(bulkResponse.hasFailures(), equalTo(false)); diff --git a/server/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java b/server/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java index 03e856ba8b68b..ca84dcbc4a640 100644 --- a/server/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java +++ b/server/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java @@ -117,7 +117,7 @@ public void testFailedSearchWithWrongQuery() throws Exception { } private void index(Client client, String id, String nameValue, int age) throws IOException { - client.index(Requests.indexRequest("test").type("type").id(id).source(source(id, nameValue, age))).actionGet(); + client.index(Requests.indexRequest("test").id(id).source(source(id, nameValue, age))).actionGet(); } private XContentBuilder source(String id, String nameValue, int age) throws IOException { diff --git a/server/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java b/server/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java index 5d3b19697d788..bd9a1816c25b9 100644 --- a/server/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java +++ b/server/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java @@ -98,7 +98,7 @@ private Set prepareData(int numShards) throws Exception { } private void index(String id, String nameValue, int age) throws IOException { - client().index(Requests.indexRequest("test").type("type").id(id).source(source(id, nameValue, age))).actionGet(); + client().index(Requests.indexRequest("test").id(id).source(source(id, nameValue, age))).actionGet(); } private XContentBuilder source(String id, String nameValue, int age) throws IOException { diff --git a/server/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java b/server/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java index da16eeb039c8a..7122c17aecd58 100644 --- a/server/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java +++ b/server/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java @@ -81,7 +81,7 @@ public void testPlugin() throws Exception { .endObject().endObject()).get(); client().index( - indexRequest("test").type("type1").id("1") + indexRequest("test").id("1") .source(jsonBuilder().startObject().field("test", "I am sam i am").endObject())).actionGet(); client().admin().indices().prepareRefresh().get(); diff --git a/server/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java b/server/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java index 0b8deef0831c6..f120e7414cf87 100644 --- a/server/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java +++ b/server/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java @@ -450,10 +450,10 @@ public void testExceptionThrownIfScaleLE0() throws Exception { jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num1").field("type", "date").endObject().endObject().endObject().endObject())); client().index( - indexRequest("test").type("type1").id("1") + indexRequest("test").id("1") .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").endObject())).actionGet(); client().index( - indexRequest("test").type("type1").id("2") + indexRequest("test").id("2") .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-28").endObject())).actionGet(); refresh(); @@ -485,10 +485,10 @@ public void testParseDateMath() throws Exception { .endObject() .endObject() .endObject())); - client().index(indexRequest("test").type("type1").id("1") + client().index(indexRequest("test").id("1") .source(jsonBuilder().startObject().field("test", "value").field("num1", System.currentTimeMillis()).endObject())) .actionGet(); - client().index(indexRequest("test").type("type1").id("2").source(jsonBuilder().startObject().field("test", "value") + client().index(indexRequest("test").id("2").source(jsonBuilder().startObject().field("test", "value") .field("num1", System.currentTimeMillis() - (1000 * 60 * 60 * 24)).endObject())).actionGet(); refresh(); @@ -520,18 +520,18 @@ public void testValueMissingLin() throws Exception { client().index( - indexRequest("test").type("type1").id("1") + indexRequest("test").id("1") .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").field("num2", "1.0") .endObject())).actionGet(); client().index( - indexRequest("test").type("type1").id("2") + indexRequest("test").id("2") .source(jsonBuilder().startObject().field("test", "value").field("num2", "1.0").endObject())).actionGet(); client().index( - indexRequest("test").type("type1").id("3") + indexRequest("test").id("3") .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-30").field("num2", "1.0") .endObject())).actionGet(); client().index( - indexRequest("test").type("type1").id("4") + indexRequest("test").id("4") .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-30").endObject())).actionGet(); refresh(); @@ -570,19 +570,19 @@ public void testDateWithoutOrigin() throws Exception { String docDateString = docDate.getYear() + "-" + String.format(Locale.ROOT, "%02d", docDate.getMonthValue()) + "-" + String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth()); client().index( - indexRequest("test").type("type1").id("1") + indexRequest("test").id("1") .source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())).actionGet(); docDate = dt.minusDays(2); docDateString = docDate.getYear() + "-" + String.format(Locale.ROOT, "%02d", docDate.getMonthValue()) + "-" + String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth()); client().index( - indexRequest("test").type("type1").id("2") + indexRequest("test").id("2") .source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())).actionGet(); docDate = dt.minusDays(3); docDateString = docDate.getYear() + "-" + String.format(Locale.ROOT, "%02d", docDate.getMonthValue()) + "-" + String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth()); client().index( - indexRequest("test").type("type1").id("3") + indexRequest("test").id("3") .source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())).actionGet(); refresh(); @@ -670,7 +670,7 @@ public void testParsingExceptionIfFieldDoesNotExist() throws Exception { .endObject().startObject("geo").field("type", "geo_point").endObject().endObject().endObject().endObject())); int numDocs = 2; client().index( - indexRequest("test").type("type").source( + indexRequest("test").source( jsonBuilder().startObject().field("test", "value").startObject("geo").field("lat", 1).field("lon", 2).endObject() .endObject())).actionGet(); refresh(); @@ -697,7 +697,7 @@ public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception { jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num").field("type", "text").endObject().endObject().endObject().endObject())); client().index( - indexRequest("test").type("type").source( + indexRequest("test").source( jsonBuilder().startObject().field("test", "value").field("num", Integer.toString(1)).endObject())).actionGet(); refresh(); // so, we indexed a string field, but now we try to score a num field @@ -718,7 +718,7 @@ public void testNoQueryGiven() throws Exception { jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num").field("type", "double").endObject().endObject().endObject().endObject())); client().index( - indexRequest("test").type("type").source(jsonBuilder().startObject().field("test", "value").field("num", 1.0).endObject())) + indexRequest("test").source(jsonBuilder().startObject().field("test", "value").field("num", 1.0).endObject())) .actionGet(); refresh(); // so, we indexed a string field, but now we try to score a num field diff --git a/server/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java b/server/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java index bfbf04a7f5ad8..ba68cb6dac2a1 100644 --- a/server/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java +++ b/server/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java @@ -71,10 +71,10 @@ public void testPlugin() throws Exception { client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().get(); client().index( - indexRequest("test").type("type1").id("1") + indexRequest("test").id("1") .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-26").endObject())).actionGet(); client().index( - indexRequest("test").type("type1").id("2") + indexRequest("test").id("2") .source(jsonBuilder().startObject().field("test", "value").field("num1", "2013-05-27").endObject())).actionGet(); client().admin().indices().prepareRefresh().get(); diff --git a/server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java b/server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java index 1fe6d42bef0f6..31cac14a3927c 100644 --- a/server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java +++ b/server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java @@ -710,15 +710,15 @@ public void testEnvelopeSpanningDateline() throws IOException { String doc1 = "{\"geo\": {\r\n" + "\"coordinates\": [\r\n" + "-33.918711,\r\n" + "18.847685\r\n" + "],\r\n" + "\"type\": \"Point\"\r\n" + "}}"; - client().index(new IndexRequest("test", "doc", "1").source(doc1, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); + client().index(new IndexRequest("test").id("1").source(doc1, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); String doc2 = "{\"geo\": {\r\n" + "\"coordinates\": [\r\n" + "-49.0,\r\n" + "18.847685\r\n" + "],\r\n" + "\"type\": \"Point\"\r\n" + "}}"; - client().index(new IndexRequest("test", "doc", "2").source(doc2, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); + client().index(new IndexRequest("test").id("2").source(doc2, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); String doc3 = "{\"geo\": {\r\n" + "\"coordinates\": [\r\n" + "49.0,\r\n" + "18.847685\r\n" + "],\r\n" + "\"type\": \"Point\"\r\n" + "}}"; - client().index(new IndexRequest("test", "doc", "3").source(doc3, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); + client().index(new IndexRequest("test").id("3").source(doc3, XContentType.JSON).setRefreshPolicy(IMMEDIATE)).actionGet(); @SuppressWarnings("unchecked") CheckedSupplier querySupplier = randomFrom( () -> QueryBuilders.geoShapeQuery( diff --git a/server/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java b/server/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java index e82100f4f5f87..ad3148d7874ca 100644 --- a/server/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java +++ b/server/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java @@ -81,9 +81,9 @@ public void testSimpleMoreLikeThis() throws Exception { assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); logger.info("Indexing..."); - client().index(indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("text", "lucene").endObject())) + client().index(indexRequest("test").id("1").source(jsonBuilder().startObject().field("text", "lucene").endObject())) .actionGet(); - client().index(indexRequest("test").type("type1").id("2") + client().index(indexRequest("test").id("2") .source(jsonBuilder().startObject().field("text", "lucene release").endObject())).actionGet(); client().admin().indices().refresh(refreshRequest()).actionGet(); @@ -104,9 +104,9 @@ public void testSimpleMoreLikeThisWithTypes() throws Exception { assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); logger.info("Indexing..."); - client().index(indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("text", "lucene").endObject())) + client().index(indexRequest("test").id("1").source(jsonBuilder().startObject().field("text", "lucene").endObject())) .actionGet(); - client().index(indexRequest("test").type("type1").id("2") + client().index(indexRequest("test").id("2") .source(jsonBuilder().startObject().field("text", "lucene release").endObject())).actionGet(); client().admin().indices().refresh(refreshRequest()).actionGet(); @@ -132,9 +132,9 @@ public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Excep ensureGreen(); - client().index(indexRequest("test").type("type").id("1").source(jsonBuilder().startObject() + client().index(indexRequest("test").id("1").source(jsonBuilder().startObject() .field("myField", "and_foo").field("empty", "").endObject())).actionGet(); - client().index(indexRequest("test").type("type").id("2").source(jsonBuilder().startObject() + client().index(indexRequest("test").id("2").source(jsonBuilder().startObject() .field("myField", "and_foo").field("empty", "").endObject())).actionGet(); client().admin().indices().refresh(refreshRequest()).actionGet(); @@ -155,11 +155,11 @@ public void testSimpleMoreLikeOnLongField() throws Exception { assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); logger.info("Indexing..."); - client().index(indexRequest("test").type("type1").id("1") + client().index(indexRequest("test").id("1") .source(jsonBuilder().startObject().field("some_long", 1367484649580L).endObject())).actionGet(); - client().index(indexRequest("test").type("type1").id("2") + client().index(indexRequest("test").id("2") .source(jsonBuilder().startObject().field("some_long", 0).endObject())).actionGet(); - client().index(indexRequest("test").type("type1").id("3") + client().index(indexRequest("test").id("3") .source(jsonBuilder().startObject().field("some_long", -666).endObject())).actionGet(); client().admin().indices().refresh(refreshRequest()).actionGet(); @@ -185,13 +185,13 @@ public void testMoreLikeThisWithAliases() throws Exception { assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); logger.info("Indexing..."); - client().index(indexRequest("test").type("type1").id("1") + client().index(indexRequest("test").id("1") .source(jsonBuilder().startObject().field("text", "lucene beta").endObject())).actionGet(); - client().index(indexRequest("test").type("type1").id("2") + client().index(indexRequest("test").id("2") .source(jsonBuilder().startObject().field("text", "lucene release").endObject())).actionGet(); - client().index(indexRequest("test").type("type1").id("3") + client().index(indexRequest("test").id("3") .source(jsonBuilder().startObject().field("text", "elasticsearch beta").endObject())).actionGet(); - client().index(indexRequest("test").type("type1").id("4") + client().index(indexRequest("test").id("4") .source(jsonBuilder().startObject().field("text", "elasticsearch release").endObject())).actionGet(); client().admin().indices().refresh(refreshRequest()).actionGet(); @@ -234,11 +234,11 @@ public void testMoreLikeThisWithAliasesInLikeDocuments() throws Exception { assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); - client().index(indexRequest(indexName).type(typeName).id("1") + client().index(indexRequest(indexName).id("1") .source(jsonBuilder().startObject().field("text", "elasticsearch index").endObject())).actionGet(); - client().index(indexRequest(indexName).type(typeName).id("2") + client().index(indexRequest(indexName).id("2") .source(jsonBuilder().startObject().field("text", "lucene index").endObject())).actionGet(); - client().index(indexRequest(indexName).type(typeName).id("3") + client().index(indexRequest(indexName).id("3") .source(jsonBuilder().startObject().field("text", "elasticsearch index").endObject())).actionGet(); refresh(indexName); @@ -429,11 +429,11 @@ public void testSimpleMoreLikeInclude() throws Exception { assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); logger.info("Indexing..."); - client().index(indexRequest("test").type("type1").id("1").source( + client().index(indexRequest("test").id("1").source( jsonBuilder().startObject() .field("text", "Apache Lucene is a free/open source information retrieval software library").endObject())) .actionGet(); - client().index(indexRequest("test").type("type1").id("2").source( + client().index(indexRequest("test").id("2").source( jsonBuilder().startObject() .field("text", "Lucene has been ported to other programming languages").endObject())) .actionGet(); diff --git a/server/src/test/java/org/elasticsearch/versioning/ConcurrentSeqNoVersioningIT.java b/server/src/test/java/org/elasticsearch/versioning/ConcurrentSeqNoVersioningIT.java index 6074bde2684b7..0cd55738d6f25 100644 --- a/server/src/test/java/org/elasticsearch/versioning/ConcurrentSeqNoVersioningIT.java +++ b/server/src/test/java/org/elasticsearch/versioning/ConcurrentSeqNoVersioningIT.java @@ -246,7 +246,7 @@ public void run() { version = version.previousTerm(); } - IndexRequest indexRequest = new IndexRequest("test", "type", partition.id) + IndexRequest indexRequest = new IndexRequest("test").id(partition.id) .source("value", random.nextInt()) .setIfPrimaryTerm(version.primaryTerm) .setIfSeqNo(version.seqNo); diff --git a/server/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java b/server/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java index 4f653300f4892..e8a6380cb16c0 100644 --- a/server/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java +++ b/server/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java @@ -467,8 +467,6 @@ public String toString() { sb.append(deleteResponse.getIndex()); sb.append(" id="); sb.append(deleteResponse.getId()); - sb.append(" type="); - sb.append(deleteResponse.getType()); sb.append(" version="); sb.append(deleteResponse.getVersion()); sb.append(" found="); @@ -479,8 +477,6 @@ public String toString() { sb.append(indexResponse.getIndex()); sb.append(" id="); sb.append(indexResponse.getId()); - sb.append(" type="); - sb.append(indexResponse.getType()); sb.append(" version="); sb.append(indexResponse.getVersion()); sb.append(" created="); diff --git a/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java index cf8a9ff206de7..7a757f5d2ab66 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java @@ -220,7 +220,7 @@ protected EngineFactory getEngineFactory(ShardRouting routing) { public int indexDocs(final int numOfDoc) throws Exception { for (int doc = 0; doc < numOfDoc; doc++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", Integer.toString(docId.incrementAndGet())) + final IndexRequest indexRequest = new IndexRequest(index.getName()).id(Integer.toString(docId.incrementAndGet())) .source("{}", XContentType.JSON); final BulkItemResponse response = index(indexRequest); if (response.isFailed()) { @@ -234,7 +234,7 @@ public int indexDocs(final int numOfDoc) throws Exception { public int appendDocs(final int numOfDoc) throws Exception { for (int doc = 0; doc < numOfDoc; doc++) { - final IndexRequest indexRequest = new IndexRequest(index.getName(), "type").source("{}", XContentType.JSON); + final IndexRequest indexRequest = new IndexRequest(index.getName()).source("{}", XContentType.JSON); final BulkItemResponse response = index(indexRequest); if (response.isFailed()) { throw response.getFailure().getCause(); diff --git a/test/framework/src/main/java/org/elasticsearch/ingest/RandomDocumentPicks.java b/test/framework/src/main/java/org/elasticsearch/ingest/RandomDocumentPicks.java index 58eb1df129291..d6ecff4d0368b 100644 --- a/test/framework/src/main/java/org/elasticsearch/ingest/RandomDocumentPicks.java +++ b/test/framework/src/main/java/org/elasticsearch/ingest/RandomDocumentPicks.java @@ -136,7 +136,6 @@ public static IngestDocument randomIngestDocument(Random random) { */ public static IngestDocument randomIngestDocument(Random random, Map source) { String index = randomString(random); - String type = randomString(random); String id = randomString(random); String routing = null; Long version = randomNonNegtiveLong(random); @@ -145,7 +144,7 @@ public static IngestDocument randomIngestDocument(Random random, Map randomSource(Random random) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 2109c9d3eff76..7c2fcdc293773 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -1292,7 +1292,6 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma Map> indicesAndTypes = new HashMap<>(); for (IndexRequestBuilder builder : builders) { final Set types = indicesAndTypes.computeIfAbsent(builder.request().index(), index -> new HashSet<>()); - types.add(builder.request().type()); } Set> bogusIds = new HashSet<>(); // (index, type, id) if (random.nextBoolean() && !builders.isEmpty() && dummyDocuments) { diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java index 4a6c00505ca09..36a401d455e42 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java @@ -500,7 +500,7 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure) throw new AssertionError(e); } final String source = String.format(Locale.ROOT, "{\"f\":%d}", counter++); - IndexRequest indexRequest = new IndexRequest("index1", "doc") + IndexRequest indexRequest = new IndexRequest("index1") .source(source, XContentType.JSON) .timeout(TimeValue.timeValueSeconds(1)); bulkProcessor.add(indexRequest); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java index 1d3e5ad7e4f6a..a2717905503c4 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java @@ -115,7 +115,7 @@ public void testSimpleCcrReplication() throws Exception { // Deletes should be replicated to the follower List deleteDocIds = randomSubsetOf(indexedDocIds); for (String deleteId : deleteDocIds) { - BulkItemResponse resp = leaderGroup.delete(new DeleteRequest(index.getName(), "type", deleteId)); + BulkItemResponse resp = leaderGroup.delete(new DeleteRequest(index.getName(), deleteId)); assertThat(resp.getResponse().getResult(), equalTo(DocWriteResponse.Result.DELETED)); } leaderGroup.syncGlobalCheckpoint(); @@ -278,7 +278,7 @@ public void testRetryBulkShardOperations() throws Exception { } } for (String deleteId : randomSubsetOf(IndexShardTestCase.getShardDocUIDs(leaderGroup.getPrimary()))) { - BulkItemResponse resp = leaderGroup.delete(new DeleteRequest("test", "type", deleteId)); + BulkItemResponse resp = leaderGroup.delete(new DeleteRequest("test", deleteId)); assertThat(resp.getFailure(), nullValue()); } leaderGroup.syncGlobalCheckpoint(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/slm/history/SnapshotHistoryStoreTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/slm/history/SnapshotHistoryStoreTests.java index 0a6a635490e2c..353359c5feebb 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/slm/history/SnapshotHistoryStoreTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/slm/history/SnapshotHistoryStoreTests.java @@ -118,7 +118,6 @@ public void testPut() throws Exception { return new IndexResponse( new ShardId(randomAlphaOfLength(5), randomAlphaOfLength(5), randomInt(100)), randomAlphaOfLength(5), - randomAlphaOfLength(5), randomLongBetween(1, 1000), randomLongBetween(1, 1000), randomLongBetween(1, 1000), @@ -158,7 +157,6 @@ public void testPut() throws Exception { return new IndexResponse( new ShardId(randomAlphaOfLength(5), randomAlphaOfLength(5), randomInt(100)), randomAlphaOfLength(5), - randomAlphaOfLength(5), randomLongBetween(1, 1000), randomLongBetween(1, 1000), randomLongBetween(1, 1000), diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/DelayedDataDetectorIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/DelayedDataDetectorIT.java index 6fcd020ff3b9b..c6508d540b4ba 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/DelayedDataDetectorIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/DelayedDataDetectorIT.java @@ -219,7 +219,7 @@ private void writeData(Logger logger, String index, long numDocs, long start, lo int maxDelta = (int) (end - start - 1); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); for (int i = 0; i < numDocs; i++) { - IndexRequest indexRequest = new IndexRequest(index, "type"); + IndexRequest indexRequest = new IndexRequest(index); long timestamp = start + randomIntBetween(0, maxDelta); assert timestamp >= start && timestamp < end; indexRequest.source("time", timestamp, "value", i); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java index b7f960cc4b8a5..47f8a386d3384 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobTests.java @@ -69,7 +69,7 @@ public class DatafeedJobTests extends ESTestCase { private static final String jobId = "_job_id"; - + private AnomalyDetectionAuditor auditor; private DataExtractorFactory dataExtractorFactory; private DataExtractor dataExtractor; @@ -115,7 +115,7 @@ public void setup() throws Exception { byte[] contentBytes = "content".getBytes(StandardCharsets.UTF_8); InputStream inputStream = new ByteArrayInputStream(contentBytes); when(dataExtractor.next()).thenReturn(Optional.of(inputStream)); - DataCounts dataCounts = new DataCounts(jobId, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, new Date(0), new Date(0), + DataCounts dataCounts = new DataCounts(jobId, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, new Date(0), new Date(0), new Date(0), new Date(0), new Date(0)); PostDataAction.Request expectedRequest = new PostDataAction.Request(jobId); @@ -128,7 +128,7 @@ public void setup() throws Exception { when(flushJobFuture.actionGet()).thenReturn(flushJobResponse); when(client.execute(same(FlushJobAction.INSTANCE), flushJobRequests.capture())).thenReturn(flushJobFuture); - when(indexFuture.actionGet()).thenReturn(new IndexResponse(new ShardId("index", "uuid", 0), "doc", annotationDocId, 0, 0, 0, true)); + when(indexFuture.actionGet()).thenReturn(new IndexResponse(new ShardId("index", "uuid", 0), annotationDocId, 0, 0, 0, true)); when(client.index(any())).thenReturn(indexFuture); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java index 3a9430bd7fb5e..133b73810e0ee 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java @@ -152,13 +152,13 @@ public void testJobAutoClose() throws Exception { .addMapping("type", "time", "type=date") .get(); - IndexRequest indexRequest = new IndexRequest("data", "type"); + IndexRequest indexRequest = new IndexRequest("data"); indexRequest.source("time", 1407081600L); client().index(indexRequest).get(); - indexRequest = new IndexRequest("data", "type"); + indexRequest = new IndexRequest("data"); indexRequest.source("time", 1407082600L); client().index(indexRequest).get(); - indexRequest = new IndexRequest("data", "type"); + indexRequest = new IndexRequest("data"); indexRequest.source("time", 1407083600L); client().index(indexRequest).get(); refresh(); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java index a6814c46c0e65..09e5cf9ce6331 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersisterTests.java @@ -250,7 +250,7 @@ public void testPersistDatafeedTimingStats() { // Take the listener passed to client::index as 2nd argument ActionListener listener = (ActionListener) invocationOnMock.getArguments()[1]; // Handle the response on the listener - listener.onResponse(new IndexResponse(new ShardId("test", "test", 0), "_doc", "test", 0, 0, 0, false)); + listener.onResponse(new IndexResponse(new ShardId("test", "test", 0), "test", 0, 0, 0, false)); return null; }) .when(client).index(any(), any(ActionListener.class)); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java index 66f145d405c49..63ca73444b540 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java @@ -319,7 +319,7 @@ public void testProcessResult_modelSnapshot() { when(result.getModelSnapshot()).thenReturn(modelSnapshot); when(persister.persistModelSnapshot(any(), any())) - .thenReturn(new IndexResponse(new ShardId("ml", "uid", 0), "doc", "1", 0L, 0L, 0L, true)); + .thenReturn(new IndexResponse(new ShardId("ml", "uid", 0), "1", 0L, 0L, 0L, true)); processorUnderTest.setDeleteInterimRequired(false); processorUnderTest.processResult(result); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index b2c62b5ffb230..e934f7aa1b696 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -209,7 +209,7 @@ public static void indexDocs(Logger logger, String index, long numDocs, long sta int maxDelta = (int) (end - start - 1); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); for (int i = 0; i < numDocs; i++) { - IndexRequest indexRequest = new IndexRequest(index, "type"); + IndexRequest indexRequest = new IndexRequest(index); long timestamp = start + randomIntBetween(0, maxDelta); assert timestamp >= start && timestamp < end; indexRequest.source("time", timestamp); diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java index 4e3789afa0133..6d7e712698254 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/job/IndexerUtils.java @@ -68,7 +68,7 @@ static List processBuckets(CompositeAggregation agg, String rollup doc.put(RollupField.ROLLUP_META + "." + RollupField.VERSION_FIELD, Rollup.CURRENT_ROLLUP_VERSION ); doc.put(RollupField.ROLLUP_META + "." + RollupField.ID.getPreferredName(), jobId); - IndexRequest request = new IndexRequest(rollupIndex, RollupField.TYPE_NAME, idGenerator.getID()); + IndexRequest request = new IndexRequest(rollupIndex).id(idGenerator.getID()); request.source(doc); return request; }).collect(Collectors.toList()); diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java index 1b3bbd9bcec24..6de6b66ab7156 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerIndexingTests.java @@ -111,7 +111,6 @@ public void testSimpleDateHisto() throws Exception { assertThat(resp.size(), equalTo(2)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -124,7 +123,6 @@ public void testSimpleDateHisto() throws Exception { )); request = resp.get(1); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -169,7 +167,6 @@ public void testDateHistoAndMetrics() throws Exception { assertThat(resp.size(), equalTo(5)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -187,7 +184,6 @@ public void testDateHistoAndMetrics() throws Exception { )); request = resp.get(1); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -205,7 +201,6 @@ public void testDateHistoAndMetrics() throws Exception { )); request = resp.get(2); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -223,7 +218,6 @@ public void testDateHistoAndMetrics() throws Exception { )); request = resp.get(3); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -241,7 +235,6 @@ public void testDateHistoAndMetrics() throws Exception { )); request = resp.get(4); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -287,7 +280,6 @@ public void testSimpleDateHistoWithDelay() throws Exception { assertThat(resp.size(), equalTo(3)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -300,7 +292,6 @@ public void testSimpleDateHistoWithDelay() throws Exception { )); request = resp.get(1); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -313,7 +304,6 @@ public void testSimpleDateHistoWithDelay() throws Exception { )); request = resp.get(2); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -404,7 +394,6 @@ public void testSimpleDateHistoWithTimeZone() throws Exception { assertThat(resp.size(), equalTo(1)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -423,7 +412,6 @@ public void testSimpleDateHistoWithTimeZone() throws Exception { assertThat(resp.size(), equalTo(2)); IndexRequest request = resp.get(0); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -436,7 +424,6 @@ public void testSimpleDateHistoWithTimeZone() throws Exception { )); request = resp.get(1); assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); assertThat(request.sourceAsMap(), equalTo( asMap( "_rollup.version", 2, @@ -474,7 +461,6 @@ public void testRandomizedDateHisto() throws Exception { assertThat(resp.size(), greaterThan(0)); for (DocWriteRequest request : resp) { assertThat(request.index(), equalTo(rollupIndex)); - assertThat(request.type(), equalTo("_doc")); Map source = ((IndexRequest) request).sourceAsMap(); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java index fa98f4d20dd2b..881ae262404f8 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java @@ -826,7 +826,7 @@ public void testUpdateApiIsBlocked() throws Exception { BulkResponse bulkResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue ("user1", USERS_PASSWD))) .prepareBulk() - .add(new UpdateRequest("test", "type", "1").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value3")) + .add(new UpdateRequest("test", "1").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value3")) .get(); assertEquals(1, bulkResponse.getItems().length); BulkItemResponse bulkItem = bulkResponse.getItems()[0]; @@ -840,7 +840,7 @@ public void testUpdateApiIsBlocked() throws Exception { assertThat(client().prepareGet("test", "1").get().getSource().get("field1").toString(), equalTo("value2")); client().prepareBulk() - .add(new UpdateRequest("test", "type", "1").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value3")) + .add(new UpdateRequest("test", "1").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value3")) .get(); assertThat(client().prepareGet("test", "1").get().getSource().get("field1").toString(), equalTo("value3")); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java index e89830f56fec9..d2de763dd2637 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java @@ -1431,7 +1431,7 @@ public void testUpdateApiIsBlocked() throws Exception { BulkResponse bulkResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue ("user1", USERS_PASSWD))) .prepareBulk() - .add(new UpdateRequest("test", "type", "1").doc(Requests.INDEX_CONTENT_TYPE, "field2", "value3")) + .add(new UpdateRequest("test", "1").doc(Requests.INDEX_CONTENT_TYPE, "field2", "value3")) .get(); assertEquals(1, bulkResponse.getItems().length); BulkItemResponse bulkItem = bulkResponse.getItems()[0]; @@ -1445,7 +1445,7 @@ public void testUpdateApiIsBlocked() throws Exception { assertThat(client().prepareGet("test", "1").get().getSource().get("field2").toString(), equalTo("value2")); client().prepareBulk() - .add(new UpdateRequest("test", "type", "1").doc(Requests.INDEX_CONTENT_TYPE, "field2", "value3")) + .add(new UpdateRequest("test", "1").doc(Requests.INDEX_CONTENT_TYPE, "field2", "value3")) .get(); assertThat(client().prepareGet("test", "1").get().getSource().get("field2").toString(), equalTo("value3")); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java index 15babf25d390a..75b04d09b60b5 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java @@ -134,7 +134,7 @@ public void setup() throws Exception { ActionListener listener = (ActionListener) invocationOnMock.getArguments()[1]; indexRequests.add(indexRequest); final IndexResponse response = new IndexResponse( - indexRequest.shardId(), indexRequest.type(), indexRequest.id(), 1, 1, 1, true); + indexRequest.shardId(), indexRequest.id(), 1, 1, 1, true); listener.onResponse(response); return Void.TYPE; }).when(client).index(any(IndexRequest.class), any(ActionListener.class)); @@ -143,7 +143,7 @@ public void setup() throws Exception { ActionListener listener = (ActionListener) invocationOnMock.getArguments()[2]; indexRequests.add(indexRequest); final IndexResponse response = new IndexResponse( - new ShardId("test", "test", 0), indexRequest.type(), indexRequest.id(), 1, 1, 1, true); + new ShardId("test", "test", 0), indexRequest.id(), 1, 1, 1, true); listener.onResponse(response); return Void.TYPE; }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), any(ActionListener.class)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java index f0337a7a72bc6..810428e3c0a50 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java @@ -150,7 +150,7 @@ void doExecute(ActionType action, Request request, ActionListener listener = (ActionListener) invocationOnMock.getArguments()[1]; indexRequests.add(indexRequest); final IndexResponse response = new IndexResponse( - new ShardId("test", "test", 0), indexRequest.type(), indexRequest.id(), 1, 1, 1, true); + new ShardId("test", "test", 0), indexRequest.id(), 1, 1, 1, true); listener.onResponse(response); return Void.TYPE; }).when(client).index(any(IndexRequest.class), any(ActionListener.class)); @@ -179,7 +179,7 @@ public void setup() throws Exception { ActionListener listener = (ActionListener) invocationOnMock.getArguments()[2]; indexRequests.add(indexRequest); final IndexResponse response = new IndexResponse( - new ShardId("test", "test", 0), indexRequest.type(), indexRequest.id(), 1, 1, 1, true); + new ShardId("test", "test", 0), indexRequest.id(), 1, 1, 1, true); listener.onResponse(response); return Void.TYPE; }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), any(ActionListener.class)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java index 34e18542cc7f6..50f0d3dd8e7fd 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java @@ -120,7 +120,7 @@ public void setupClient() { doAnswer(invocationOnMock -> { idxReqReference.set((IndexRequest) invocationOnMock.getArguments()[1]); ActionListener responseActionListener = (ActionListener) invocationOnMock.getArguments()[2]; - responseActionListener.onResponse(new IndexResponse(new ShardId(".security", UUIDs.randomBase64UUID(), randomInt()), "_doc", + responseActionListener.onResponse(new IndexResponse(new ShardId(".security", UUIDs.randomBase64UUID(), randomInt()), randomAlphaOfLength(4), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), true)); return null; }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), any(ActionListener.class)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java index 1243316a297e3..81e0922fa9cc5 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java @@ -203,7 +203,7 @@ public void init() throws Exception { .thenReturn(new UpdateRequestBuilder(client, UpdateAction.INSTANCE)); doAnswer(invocationOnMock -> { ActionListener responseActionListener = (ActionListener) invocationOnMock.getArguments()[2]; - responseActionListener.onResponse(new IndexResponse(new ShardId(".security", UUIDs.randomBase64UUID(), randomInt()), "_doc", + responseActionListener.onResponse(new IndexResponse(new ShardId(".security", UUIDs.randomBase64UUID(), randomInt()), randomAlphaOfLength(4), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), true)); return null; }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), any(ActionListener.class)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java index a68a5647c3a08..4f2590fe36c17 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java @@ -121,7 +121,7 @@ public void setupClient() { .thenReturn(new UpdateRequestBuilder(client, UpdateAction.INSTANCE)); doAnswer(invocationOnMock -> { ActionListener responseActionListener = (ActionListener) invocationOnMock.getArguments()[2]; - responseActionListener.onResponse(new IndexResponse(new ShardId(".security", UUIDs.randomBase64UUID(), randomInt()), "_doc", + responseActionListener.onResponse(new IndexResponse(new ShardId(".security", UUIDs.randomBase64UUID(), randomInt()), randomAlphaOfLength(4), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(), true)); return null; }).when(client).execute(eq(IndexAction.INSTANCE), any(IndexRequest.class), any(ActionListener.class)); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 89fcc394a2c5b..0d5daa7a9a87a 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -76,7 +76,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.TriFunction; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.ClusterSettings; @@ -150,6 +149,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.CountDownLatch; +import java.util.function.BiFunction; import java.util.function.Predicate; import static java.util.Arrays.asList; @@ -1013,7 +1013,8 @@ public void testSuperusersCanExecuteOperationAgainstSecurityIndex() throws IOExc new Tuple<>(UpdateAction.NAME, new UpdateRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id"))); requests.add(new Tuple<>(IndexAction.NAME, new IndexRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7)))); requests.add(new Tuple<>(BulkAction.NAME + "[s]", - createBulkShardRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), IndexRequest::new))); + createBulkShardRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), + (index, id) -> new IndexRequest(index).id(id)))); requests.add(new Tuple<>(SearchAction.NAME, new SearchRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7)))); requests.add(new Tuple<>(TermVectorsAction.NAME, new TermVectorsRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id"))); @@ -1131,7 +1132,7 @@ public void testCompositeActionsIndicesAreCheckedAtTheShardLevel() throws IOExce break; case 3: action = BulkAction.NAME + "[s]"; - request = createBulkShardRequest("index", IndexRequest::new); + request = createBulkShardRequest("index", (index, id) -> new IndexRequest(index).id(id)); break; case 4: action = "indices:data/read/mpercolate[s]"; @@ -1160,12 +1161,12 @@ public void testCompositeActionsIndicesAreCheckedAtTheShardLevel() throws IOExce public void testAuthorizationOfIndividualBulkItems() throws IOException { final String action = BulkAction.NAME + "[s]"; final BulkItemRequest[] items = { - new BulkItemRequest(1, new DeleteRequest("concrete-index", "doc", "c1")), - new BulkItemRequest(2, new IndexRequest("concrete-index", "doc", "c2")), - new BulkItemRequest(3, new DeleteRequest("alias-1", "doc", "a1a")), - new BulkItemRequest(4, new IndexRequest("alias-1", "doc", "a1b")), - new BulkItemRequest(5, new DeleteRequest("alias-2", "doc", "a2a")), - new BulkItemRequest(6, new IndexRequest("alias-2", "doc", "a2b")) + new BulkItemRequest(1, new DeleteRequest("concrete-index", "c1")), + new BulkItemRequest(2, new IndexRequest("concrete-index").id("c2")), + new BulkItemRequest(3, new DeleteRequest("alias-1", "a1a")), + new BulkItemRequest(4, new IndexRequest("alias-1").id("a1b")), + new BulkItemRequest(5, new DeleteRequest("alias-2", "a2a")), + new BulkItemRequest(6, new IndexRequest("alias-2").id("a2b")) }; final ShardId shardId = new ShardId("concrete-index", UUID.randomUUID().toString(), 1); final TransportRequest request = new BulkShardRequest(shardId, WriteRequest.RefreshPolicy.IMMEDIATE, items); @@ -1208,12 +1209,12 @@ public void testAuthorizationOfIndividualBulkItems() throws IOException { public void testAuthorizationOfIndividualBulkItemsWithDateMath() throws IOException { final String action = BulkAction.NAME + "[s]"; final BulkItemRequest[] items = { - new BulkItemRequest(1, new IndexRequest("", "doc", "dy1")), + new BulkItemRequest(1, new IndexRequest("").id("dy1")), new BulkItemRequest(2, - new DeleteRequest("", "doc", "dy2")), // resolves to same as above - new BulkItemRequest(3, new IndexRequest("", "doc", "dm1")), + new DeleteRequest("", "dy2")), // resolves to same as above + new BulkItemRequest(3, new IndexRequest("").id("dm1")), new BulkItemRequest(4, - new DeleteRequest("", "doc", "dm2")), // resolves to same as above + new DeleteRequest("", "dm2")), // resolves to same as above }; final ShardId shardId = new ShardId("concrete-index", UUID.randomUUID().toString(), 1); final TransportRequest request = new BulkShardRequest(shardId, WriteRequest.RefreshPolicy.IMMEDIATE, items); @@ -1240,8 +1241,8 @@ public void testAuthorizationOfIndividualBulkItemsWithDateMath() throws IOExcept verifyNoMoreInteractions(auditTrail); } - private BulkShardRequest createBulkShardRequest(String indexName, TriFunction> req) { - final BulkItemRequest[] items = {new BulkItemRequest(1, req.apply(indexName, "type", "id"))}; + private BulkShardRequest createBulkShardRequest(String indexName, BiFunction> req) { + final BulkItemRequest[] items = {new BulkItemRequest(1, req.apply(indexName, "id"))}; return new BulkShardRequest(new ShardId(indexName, UUID.randomUUID().toString(), 1), WriteRequest.RefreshPolicy.IMMEDIATE, items); } @@ -1255,7 +1256,7 @@ private static Tuple randomCompositeRequest() { case 2: return Tuple.tuple(MultiTermVectorsAction.NAME, new MultiTermVectorsRequest().add("index", "id")); case 3: - return Tuple.tuple(BulkAction.NAME, new BulkRequest().add(new DeleteRequest("index", "type", "id"))); + return Tuple.tuple(BulkAction.NAME, new BulkRequest().add(new DeleteRequest("index", "id"))); case 4: return Tuple.tuple("indices:data/read/mpercolate", new MockCompositeIndicesRequest()); case 5: diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java index e095eea09d152..e7f5a8fa9e4d1 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java @@ -90,19 +90,19 @@ public void testUpdate() { public void testBulk() { createIndex("test1", "test2", "test3", "index1"); BulkResponse bulkResponse = client().prepareBulk() - .add(new IndexRequest("test1", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) - .add(new IndexRequest("index1", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) - .add(new IndexRequest("test4", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) - .add(new IndexRequest("missing", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) - .add(new DeleteRequest("test1", "type", "id")) - .add(new DeleteRequest("index1", "type", "id")) - .add(new DeleteRequest("test4", "type", "id")) - .add(new DeleteRequest("missing", "type", "id")) - .add(new IndexRequest("test1", "type", "id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) - .add(new UpdateRequest("test1", "type", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")) - .add(new UpdateRequest("index1", "type", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")) - .add(new UpdateRequest("test4", "type", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")) - .add(new UpdateRequest("missing", "type", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")).get(); + .add(new IndexRequest("test1").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .add(new IndexRequest("index1").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .add(new IndexRequest("test4").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .add(new IndexRequest("missing").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .add(new DeleteRequest("test1", "id")) + .add(new DeleteRequest("index1", "id")) + .add(new DeleteRequest("test4", "id")) + .add(new DeleteRequest("missing", "id")) + .add(new IndexRequest("test1").id("id").source(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .add(new UpdateRequest("test1", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .add(new UpdateRequest("index1", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .add(new UpdateRequest("test4", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .add(new UpdateRequest("missing", "id").doc(Requests.INDEX_CONTENT_TYPE, "field", "value")).get(); assertTrue(bulkResponse.hasFailures()); assertThat(bulkResponse.getItems().length, equalTo(13)); assertThat(bulkResponse.getItems()[0].getFailure(), nullValue()); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStoreTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStoreTests.java index 1ba2ff637f354..f0cfe173a083a 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStoreTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStoreTests.java @@ -6,10 +6,10 @@ package org.elasticsearch.xpack.security.authz.store; import org.apache.lucene.search.TotalHits; -import org.elasticsearch.action.ActionType; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.get.GetRequest; @@ -30,7 +30,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.get.GetResult; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; @@ -268,7 +267,6 @@ public void testPutPrivileges() throws Exception { ApplicationPrivilegeDescriptor privilege = putPrivileges.get(i); IndexRequest request = indexRequests.get(i); assertThat(request.indices(), arrayContaining(RestrictedIndicesNames.SECURITY_MAIN_ALIAS)); - assertThat(request.type(), equalTo(MapperService.SINGLE_MAPPING_NAME)); assertThat(request.id(), equalTo( "application-privilege_" + privilege.getApplication() + ":" + privilege.getName() )); @@ -277,7 +275,7 @@ public void testPutPrivileges() throws Exception { final boolean created = privilege.getName().equals("user") == false; indexListener.onResponse(new IndexResponse( new ShardId(RestrictedIndicesNames.SECURITY_MAIN_ALIAS, uuid, i), - request.type(), request.id(), 1, 1, 1, created + request.id(), 1, 1, 1, created )); } @@ -313,12 +311,11 @@ public void testDeletePrivileges() throws Exception { String name = privilegeNames.get(i); DeleteRequest request = deletes.get(i); assertThat(request.indices(), arrayContaining(RestrictedIndicesNames.SECURITY_MAIN_ALIAS)); - assertThat(request.type(), equalTo(MapperService.SINGLE_MAPPING_NAME)); assertThat(request.id(), equalTo("application-privilege_app1:" + name)); final boolean found = name.equals("p2") == false; deleteListener.onResponse(new DeleteResponse( new ShardId(RestrictedIndicesNames.SECURITY_MAIN_ALIAS, uuid, i), - request.type(), request.id(), 1, 1, 1, found + request.id(), 1, 1, 1, found )); } diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/SeqNoPrimaryTermAndIndexTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/SeqNoPrimaryTermAndIndexTests.java index 63fa5e3a77d1c..8a1e1c00583ad 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/SeqNoPrimaryTermAndIndexTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/persistence/SeqNoPrimaryTermAndIndexTests.java @@ -43,7 +43,6 @@ public void testFromIndexResponse() { long primaryTerm = randomLongBetween(-2, 10_000); String index = randomAlphaOfLength(10); IndexResponse indexResponse = new IndexResponse(new ShardId(index, randomAlphaOfLength(10), 1), - "_doc", "asdf", seqNo, primaryTerm, diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java index ee299d05b09b0..f705c74ded67c 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/ExecutableIndexAction.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.watcher.actions.Action; import org.elasticsearch.xpack.core.watcher.actions.Action.Result.Status; @@ -82,7 +83,6 @@ public Action.Result execute(String actionId, WatchExecutionContext ctx, Payload } indexRequest.index(getField(actionId, ctx.id().watchId(), "index", data, INDEX_FIELD, action.index)); - indexRequest.type(getField(actionId, ctx.id().watchId(), "type",data, TYPE_FIELD, action.docType)); indexRequest.id(getField(actionId, ctx.id().watchId(), "id",data, ID_FIELD, action.docId)); data = addTimestampToDocument(data, ctx.executionTime()); @@ -92,8 +92,8 @@ public Action.Result execute(String actionId, WatchExecutionContext ctx, Payload } if (ctx.simulateAction(actionId)) { - return new IndexAction.Simulated(indexRequest.index(), indexRequest.type(), indexRequest.id(), action.refreshPolicy, - new XContentSource(indexRequest.source(), XContentType.JSON)); + return new IndexAction.Simulated(indexRequest.index(), MapperService.SINGLE_MAPPING_NAME, indexRequest.id(), + action.refreshPolicy, new XContentSource(indexRequest.source(), XContentType.JSON)); } IndexResponse response = ClientHelper.executeWithHeaders(ctx.watch().status().getHeaders(), ClientHelper.WATCHER_ORIGIN, client, @@ -128,7 +128,6 @@ Action.Result indexBulk(Iterable list, String actionId, WatchExecutionContext ct IndexRequest indexRequest = new IndexRequest(); indexRequest.index(getField(actionId, ctx.id().watchId(), "index", doc, INDEX_FIELD, action.index)); - indexRequest.type(getField(actionId, ctx.id().watchId(), "type",doc, TYPE_FIELD, action.docType)); indexRequest.id(getField(actionId, ctx.id().watchId(), "id",doc, ID_FIELD, action.docId)); doc = addTimestampToDocument(doc, ctx.executionTime()); @@ -214,7 +213,6 @@ static void indexResponseToXContent(XContentBuilder builder, IndexResponse respo .field("result", response.getResult().getLowercase()) .field("id", response.getId()) .field("version", response.getVersion()) - .field("type", response.getType()) .field("index", response.getIndex()) .endObject(); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java index 6edfdf221499c..559f7a927498f 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java @@ -222,7 +222,7 @@ public void testThatIndexTypeIdDynamically() throws Exception { ArgumentCaptor captor = ArgumentCaptor.forClass(IndexRequest.class); PlainActionFuture listener = PlainActionFuture.newFuture(); - listener.onResponse(new IndexResponse(new ShardId(new Index("foo", "bar"), 0), "whatever", "whatever", 1, 1, 1, true)); + listener.onResponse(new IndexResponse(new ShardId(new Index("foo", "bar"), 0), "whatever", 1, 1, 1, true)); when(client.index(captor.capture())).thenReturn(listener); Action.Result result = executable.execute("_id", ctx, ctx.payload()); @@ -230,7 +230,6 @@ public void testThatIndexTypeIdDynamically() throws Exception { assertThat(captor.getAllValues(), hasSize(1)); assertThat(captor.getValue().index(), is(configureIndexDynamically ? "my_dynamic_index" : "my_index")); - assertThat(captor.getValue().type(), is(configureTypeDynamically ? "my_dynamic_type" : "my_type")); assertThat(captor.getValue().id(), is(configureIdDynamically ? "my_dynamic_id" : "my_id")); } @@ -246,7 +245,7 @@ public void testThatIndexActionCanBeConfiguredWithDynamicIndexNameAndBulk() thro ArgumentCaptor captor = ArgumentCaptor.forClass(BulkRequest.class); PlainActionFuture listener = PlainActionFuture.newFuture(); - IndexResponse indexResponse = new IndexResponse(new ShardId(new Index("foo", "bar"), 0), "whatever", "whatever", 1, 1, 1, true); + IndexResponse indexResponse = new IndexResponse(new ShardId(new Index("foo", "bar"), 0), "whatever", 1, 1, 1, true); BulkItemResponse response = new BulkItemResponse(0, DocWriteRequest.OpType.INDEX, indexResponse); BulkResponse bulkResponse = new BulkResponse(new BulkItemResponse[]{response}, 1); listener.onResponse(bulkResponse); @@ -256,9 +255,7 @@ public void testThatIndexActionCanBeConfiguredWithDynamicIndexNameAndBulk() thro assertThat(result.status(), is(Status.SUCCESS)); assertThat(captor.getAllValues(), hasSize(1)); assertThat(captor.getValue().requests(), hasSize(2)); - assertThat(captor.getValue().requests().get(0).type(), is("my-type")); assertThat(captor.getValue().requests().get(0).index(), is("my-index")); - assertThat(captor.getValue().requests().get(1).type(), is("my-type")); assertThat(captor.getValue().requests().get(1).index(), is("my-other-index")); } @@ -303,7 +300,7 @@ public void testIndexActionExecuteSingleDoc() throws Exception { ArgumentCaptor captor = ArgumentCaptor.forClass(IndexRequest.class); PlainActionFuture listener = PlainActionFuture.newFuture(); - listener.onResponse(new IndexResponse(new ShardId(new Index("test-index", "uuid"), 0), "test-type", docId, 1, 1, 1, true)); + listener.onResponse(new IndexResponse(new ShardId(new Index("test-index", "uuid"), 0), docId, 1, 1, 1, true)); when(client.index(captor.capture())).thenReturn(listener); Action.Result result = executable.execute("_id", ctx, ctx.payload()); @@ -358,7 +355,7 @@ public void testFailureResult() throws Exception { BulkItemResponse secondResponse; if (isPartialFailure) { ShardId shardId = new ShardId(new Index("foo", "bar"), 0); - IndexResponse indexResponse = new IndexResponse(shardId, "whatever", "whatever", 1, 1, 1, true); + IndexResponse indexResponse = new IndexResponse(shardId, "whatever", 1, 1, 1, true); secondResponse = new BulkItemResponse(1, DocWriteRequest.OpType.INDEX, indexResponse); } else { secondResponse = new BulkItemResponse(1, DocWriteRequest.OpType.INDEX, failure); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java index 9f848961acb57..4416e124e10fa 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java @@ -1099,7 +1099,7 @@ public void testUpdateWatchStatusDoesNotUpdateState() throws Exception { } PlainActionFuture future = PlainActionFuture.newFuture(); - future.onResponse(new UpdateResponse(null, new ShardId("test", "test", 0), "_doc", "test", 0, 0, 0, + future.onResponse(new UpdateResponse(null, new ShardId("test", "test", 0), "test", 0, 0, 0, DocWriteResponse.Result.CREATED)); return future; }).when(client).update(any()); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java index f520dead2ee63..d9915fc4a6d44 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/TriggeredWatchStoreTests.java @@ -429,7 +429,7 @@ public void testPutTriggeredWatches() throws Exception { for (int i = 0; i < size; i++) { DocWriteRequest writeRequest = bulkRequest.requests().get(i); ShardId shardId = new ShardId(TriggeredWatchStoreField.INDEX_NAME, "uuid", 0); - IndexResponse indexResponse = new IndexResponse(shardId, writeRequest.type(), writeRequest.id(), 1, 1, 1, true); + IndexResponse indexResponse = new IndexResponse(shardId, writeRequest.id(), 1, 1, 1, true); bulkItemResponse[i] = new BulkItemResponse(0, writeRequest.opType(), indexResponse); } @@ -455,7 +455,7 @@ public void testDeleteTriggeredWatches() throws Exception { for (int i = 0; i < size; i++) { DocWriteRequest writeRequest = bulkRequest.requests().get(i); ShardId shardId = new ShardId(TriggeredWatchStoreField.INDEX_NAME, "uuid", 0); - IndexResponse indexResponse = new IndexResponse(shardId, writeRequest.type(), writeRequest.id(), 1, 1, 1, true); + IndexResponse indexResponse = new IndexResponse(shardId, writeRequest.id(), 1, 1, 1, true); bulkItemResponse[i] = new BulkItemResponse(0, writeRequest.opType(), indexResponse); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java index 0ee82d86c76a9..deb1f5340ed9c 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/put/TransportPutWatchActionTests.java @@ -70,7 +70,7 @@ public void setupAction() throws Exception { ActionListener listener = (ActionListener) invocation.getArguments()[2]; ShardId shardId = new ShardId(new Index(Watch.INDEX, "uuid"), 0); - listener.onResponse(new IndexResponse(shardId, request.type(), request.id(), 1, 1, 1, true)); + listener.onResponse(new IndexResponse(shardId, request.id(), 1, 1, 1, true)); return null; }).when(client).execute(any(), any(), any()); From d5d878f05aacfd1798ebaf311eb88a410c03e324 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 7 Oct 2019 14:01:25 +0100 Subject: [PATCH 20/35] tests --- .../ingest/WriteableIngestDocument.java | 18 +++++++-------- .../action/DocWriteResponseTests.java | 12 +++++----- .../action/bulk/BulkIntegrationIT.java | 2 +- .../action/bulk/BulkWithUpdatesIT.java | 10 ++++---- .../action/delete/DeleteResponseTests.java | 4 ++-- .../action/index/IndexRequestTests.java | 4 ++-- .../action/index/IndexResponseTests.java | 4 ++-- .../SimulatePipelineRequestParsingTests.java | 23 +------------------ .../action/update/UpdateRequestTests.java | 6 ++--- .../action/update/UpdateResponseTests.java | 2 +- .../ingest/IngestDocumentTests.java | 22 ++++++++---------- 11 files changed, 41 insertions(+), 66 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/ingest/WriteableIngestDocument.java b/server/src/main/java/org/elasticsearch/action/ingest/WriteableIngestDocument.java index bd0ded551a69f..b2a6cd4eb62a7 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/WriteableIngestDocument.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/WriteableIngestDocument.java @@ -54,24 +54,22 @@ final class WriteableIngestDocument implements Writeable, ToXContentFragment { a -> { HashMap sourceAndMetadata = new HashMap<>(); sourceAndMetadata.put(MetaData.INDEX.getFieldName(), a[0]); - sourceAndMetadata.put(MetaData.TYPE.getFieldName(), a[1]); - sourceAndMetadata.put(MetaData.ID.getFieldName(), a[2]); + sourceAndMetadata.put(MetaData.ID.getFieldName(), a[1]); + if (a[2] != null) { + sourceAndMetadata.put(MetaData.ROUTING.getFieldName(), a[2]); + } if (a[3] != null) { - sourceAndMetadata.put(MetaData.ROUTING.getFieldName(), a[3]); + sourceAndMetadata.put(MetaData.VERSION.getFieldName(), a[3]); } if (a[4] != null) { - sourceAndMetadata.put(MetaData.VERSION.getFieldName(), a[4]); - } - if (a[5] != null) { - sourceAndMetadata.put(MetaData.VERSION_TYPE.getFieldName(), a[5]); + sourceAndMetadata.put(MetaData.VERSION_TYPE.getFieldName(), a[4]); } - sourceAndMetadata.putAll((Map)a[6]); - return new WriteableIngestDocument(new IngestDocument(sourceAndMetadata, (Map)a[7])); + sourceAndMetadata.putAll((Map)a[5]); + return new WriteableIngestDocument(new IngestDocument(sourceAndMetadata, (Map)a[6])); } ); static { INGEST_DOC_PARSER.declareString(constructorArg(), new ParseField(MetaData.INDEX.getFieldName())); - INGEST_DOC_PARSER.declareString(constructorArg(), new ParseField(MetaData.TYPE.getFieldName())); INGEST_DOC_PARSER.declareString(constructorArg(), new ParseField(MetaData.ID.getFieldName())); INGEST_DOC_PARSER.declareString(optionalConstructorArg(), new ParseField(MetaData.ROUTING.getFieldName())); INGEST_DOC_PARSER.declareLong(optionalConstructorArg(), new ParseField(MetaData.VERSION.getFieldName())); diff --git a/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java b/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java index 0b457139a98d3..bb1208bc3bba1 100644 --- a/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java @@ -46,8 +46,8 @@ public void testGetLocation() { 17, 0, Result.CREATED) {}; - assertEquals("/index/type/id", response.getLocation(null)); - assertEquals("/index/type/id?routing=test_routing", response.getLocation("test_routing")); + assertEquals("/index/_doc/id", response.getLocation(null)); + assertEquals("/index/_doc/id?routing=test_routing", response.getLocation("test_routing")); } public void testGetLocationNonAscii() { @@ -59,8 +59,8 @@ public void testGetLocationNonAscii() { 17, 0, Result.CREATED) {}; - assertEquals("/index/type/%E2%9D%A4", response.getLocation(null)); - assertEquals("/index/type/%E2%9D%A4?routing=%C3%A4", response.getLocation("ä")); + assertEquals("/index/_doc/%E2%9D%A4", response.getLocation(null)); + assertEquals("/index/_doc/%E2%9D%A4?routing=%C3%A4", response.getLocation("ä")); } public void testGetLocationWithSpaces() { @@ -72,8 +72,8 @@ public void testGetLocationWithSpaces() { 17, 0, Result.CREATED) {}; - assertEquals("/index/type/a+b", response.getLocation(null)); - assertEquals("/index/type/a+b?routing=c+d", response.getLocation("c d")); + assertEquals("/index/_doc/a+b", response.getLocation(null)); + assertEquals("/index/_doc/a+b?routing=c+d", response.getLocation("c d")); } /** diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java index e5ce049a119c5..0272a374dee76 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java @@ -103,7 +103,7 @@ public void testBulkWithWriteIndexAndRouting() { // allowing the auto-generated timestamp to externally be set would allow making the index inconsistent with duplicate docs public void testExternallySetAutoGeneratedTimestamp() { - IndexRequest indexRequest = new IndexRequest("index1", "_doc").source(Collections.singletonMap("foo", "baz")); + IndexRequest indexRequest = new IndexRequest("index1").source(Collections.singletonMap("foo", "baz")); indexRequest.process(Version.CURRENT, null, null); // sets the timestamp if (randomBoolean()) { indexRequest.id("test"); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java index 649f0c8dd71e2..8d394c06245e2 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java @@ -575,11 +575,11 @@ public void testThatMissingIndexDoesNotAbortFullBulkRequest() throws Exception{ assertBusy(() -> assertAcked(client().admin().indices().prepareClose("bulkindex2"))); BulkRequest bulkRequest2 = new BulkRequest(); - bulkRequest2.add(new IndexRequest("bulkindex1", "index1_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1")) - .add(new IndexRequest("bulkindex2", "index2_type", "1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2")) - .add(new IndexRequest("bulkindex2", "index2_type").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2")) - .add(new UpdateRequest("bulkindex2", "index2_type", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar")) - .add(new DeleteRequest("bulkindex2", "index2_type", "3")) + bulkRequest2.add(new IndexRequest("bulkindex1").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo1")) + .add(new IndexRequest("bulkindex2").id("1").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2")) + .add(new IndexRequest("bulkindex2").source(Requests.INDEX_CONTENT_TYPE, "text", "hallo2")) + .add(new UpdateRequest("bulkindex2", "2").doc(Requests.INDEX_CONTENT_TYPE, "foo", "bar")) + .add(new DeleteRequest("bulkindex2", "3")) .setRefreshPolicy(RefreshPolicy.IMMEDIATE); BulkResponse bulkResponse = client().bulk(bulkRequest2).get(); diff --git a/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java b/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java index 99fc584487fe0..ebd7c9cc23ee0 100644 --- a/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java @@ -44,7 +44,7 @@ public void testToXContent() { { DeleteResponse response = new DeleteResponse(new ShardId("index", "index_uuid", 0), "id", 3, 17, 5, true); String output = Strings.toString(response); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\"," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":5,\"result\":\"deleted\"," + "\"_shards\":null,\"_seq_no\":3,\"_primary_term\":17}", output); } { @@ -52,7 +52,7 @@ public void testToXContent() { response.setForcedRefresh(true); response.setShardInfo(new ReplicationResponse.ShardInfo(10, 5)); String output = Strings.toString(response); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\"," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":7,\"result\":\"deleted\"," + "\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}", output); } } diff --git a/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index 97b0a8c4b03da..9d8518f23d750 100644 --- a/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -187,12 +187,12 @@ public void testToStringSizeLimit() throws UnsupportedEncodingException { String source = "{\"name\":\"value\"}"; request.source(source, XContentType.JSON); - assertEquals("index {[index][_doc][null], source[" + source + "]}", request.toString()); + assertEquals("index {[index][null], source[" + source + "]}", request.toString()); source = "{\"name\":\"" + randomUnicodeOfLength(IndexRequest.MAX_SOURCE_LENGTH_IN_TOSTRING) + "\"}"; request.source(source, XContentType.JSON); int actualBytes = source.getBytes("UTF-8").length; - assertEquals("index {[index][_doc][null], source[n/a, actual length: [" + new ByteSizeValue(actualBytes).toString() + + assertEquals("index {[index][null], source[n/a, actual length: [" + new ByteSizeValue(actualBytes).toString() + "], max length: " + new ByteSizeValue(IndexRequest.MAX_SOURCE_LENGTH_IN_TOSTRING).toString() + "]}", request.toString()); } diff --git a/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java b/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java index 608234051fa0e..ba3ab85cd8c67 100644 --- a/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java @@ -45,7 +45,7 @@ public void testToXContent() { { IndexResponse indexResponse = new IndexResponse(new ShardId("index", "index_uuid", 0), "id", 3, 17, 5, true); String output = Strings.toString(indexResponse); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":5,\"result\":\"created\",\"_shards\":null," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":5,\"result\":\"created\",\"_shards\":null," + "\"_seq_no\":3,\"_primary_term\":17}", output); } { @@ -53,7 +53,7 @@ public void testToXContent() { indexResponse.setForcedRefresh(true); indexResponse.setShardInfo(new ReplicationResponse.ShardInfo(10, 5)); String output = Strings.toString(indexResponse); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":7,\"result\":\"created\"," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":7,\"result\":\"created\"," + "\"forced_refresh\":true,\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0}}", output); } } diff --git a/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java b/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java index 8e313e7cdbb1a..d3965e2cf35c5 100644 --- a/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java +++ b/server/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestParsingTests.java @@ -67,15 +67,7 @@ public void init() throws IOException { when(ingestService.getProcessorFactories()).thenReturn(registry); } - public void testParseUsingPipelineStoreNoType() throws Exception { - innerTestParseUsingPipelineStore(false); - } - - public void testParseUsingPipelineStoreWithType() throws Exception { - innerTestParseUsingPipelineStore(true); - } - - private void innerTestParseUsingPipelineStore(boolean useExplicitType) throws Exception { + public void testParseUsingPipelineStore() throws Exception { int numDocs = randomIntBetween(1, 10); Map requestContent = new HashMap<>(); @@ -85,12 +77,8 @@ private void innerTestParseUsingPipelineStore(boolean useExplicitType) throws Ex for (int i = 0; i < numDocs; i++) { Map doc = new HashMap<>(); String index = randomAlphaOfLengthBetween(1, 10); - String type = randomAlphaOfLengthBetween(1, 10); String id = randomAlphaOfLengthBetween(1, 10); doc.put(INDEX.getFieldName(), index); - if (useExplicitType) { - doc.put(TYPE.getFieldName(), type); - } doc.put(ID.getFieldName(), id); String fieldName = randomAlphaOfLengthBetween(1, 10); String fieldValue = randomAlphaOfLengthBetween(1, 10); @@ -98,11 +86,6 @@ private void innerTestParseUsingPipelineStore(boolean useExplicitType) throws Ex docs.add(doc); Map expectedDoc = new HashMap<>(); expectedDoc.put(INDEX.getFieldName(), index); - if (useExplicitType) { - expectedDoc.put(TYPE.getFieldName(), type); - } else { - expectedDoc.put(TYPE.getFieldName(), "_doc"); - } expectedDoc.put(ID.getFieldName(), id); expectedDoc.put(Fields.SOURCE, Collections.singletonMap(fieldName, fieldValue)); expectedDocs.add(expectedDoc); @@ -117,7 +100,6 @@ private void innerTestParseUsingPipelineStore(boolean useExplicitType) throws Ex Map expectedDocument = expectedDocsIterator.next(); Map metadataMap = ingestDocument.extractMetadata(); assertThat(metadataMap.get(INDEX), equalTo(expectedDocument.get(INDEX.getFieldName()))); - assertThat(metadataMap.get(TYPE), equalTo(expectedDocument.get(TYPE.getFieldName()))); assertThat(metadataMap.get(ID), equalTo(expectedDocument.get(ID.getFieldName()))); assertThat(ingestDocument.getSourceAndMetadata(), equalTo(expectedDocument.get(Fields.SOURCE))); } @@ -125,9 +107,6 @@ private void innerTestParseUsingPipelineStore(boolean useExplicitType) throws Ex assertThat(actualRequest.getPipeline().getId(), equalTo(SIMULATED_PIPELINE_ID)); assertThat(actualRequest.getPipeline().getDescription(), nullValue()); assertThat(actualRequest.getPipeline().getProcessors().size(), equalTo(1)); - if (useExplicitType) { - assertWarnings("[types removal] specifying _type in pipeline simulation requests is deprecated"); - } } public void testParseWithProvidedPipelineNoType() throws Exception { diff --git a/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java b/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java index aaa3313c8ccff..2d76256c91a85 100644 --- a/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java @@ -635,12 +635,12 @@ public void testUpdateScript() throws Exception { public void testToString() throws IOException { UpdateRequest request = new UpdateRequest("test", "1") .script(mockInlineScript("ctx._source.body = \"foo\"")); - assertThat(request.toString(), equalTo("update {[test][type1][1], doc_as_upsert[false], " + assertThat(request.toString(), equalTo("update {[test][1], doc_as_upsert[false], " + "script[Script{type=inline, lang='mock', idOrCode='ctx._source.body = \"foo\"', options={}, params={}}], " + "scripted_upsert[false], detect_noop[true]}")); request = new UpdateRequest("test", "1").fromXContent( createParser(JsonXContent.jsonXContent, new BytesArray("{\"doc\": {\"body\": \"bar\"}}"))); - assertThat(request.toString(), equalTo("update {[test][type1][1], doc_as_upsert[false], " - + "doc[index {[null][_doc][null], source[{\"body\":\"bar\"}]}], scripted_upsert[false], detect_noop[true]}")); + assertThat(request.toString(), equalTo("update {[test][1], doc_as_upsert[false], " + + "doc[index {[null][null], source[{\"body\":\"bar\"}]}], scripted_upsert[false], detect_noop[true]}")); } } diff --git a/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java b/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java index 666776cf85de0..dcc22c1d5411d 100644 --- a/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java @@ -57,7 +57,7 @@ public void testToXContent() throws IOException { { UpdateResponse updateResponse = new UpdateResponse(new ShardId("index", "index_uuid", 0), "id", -2, 0, 0, NOT_FOUND); String output = Strings.toString(updateResponse); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":0,\"result\":\"not_found\"," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":0,\"result\":\"not_found\"," + "\"_shards\":{\"total\":0,\"successful\":0,\"failed\":0}}", output); } { diff --git a/server/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java b/server/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java index 4d2f0b84b6562..de807a484c805 100644 --- a/server/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java +++ b/server/src/test/java/org/elasticsearch/ingest/IngestDocumentTests.java @@ -84,7 +84,6 @@ public void testSimpleGetFieldValue() { assertThat(ingestDocument.getFieldValue("_source.foo", String.class), equalTo("bar")); assertThat(ingestDocument.getFieldValue("_source.int", Integer.class), equalTo(123)); assertThat(ingestDocument.getFieldValue("_index", String.class), equalTo("index")); - assertThat(ingestDocument.getFieldValue("_type", String.class), equalTo("type")); assertThat(ingestDocument.getFieldValue("_id", String.class), equalTo("id")); assertThat(ingestDocument.getFieldValue("_ingest.timestamp", ZonedDateTime.class), both(notNullValue()).and(not(equalTo(BOGUS_TIMESTAMP)))); @@ -218,7 +217,6 @@ public void testGetFieldValueEmpty() { public void testHasField() { assertTrue(ingestDocument.hasField("fizz")); assertTrue(ingestDocument.hasField("_index")); - assertTrue(ingestDocument.hasField("_type")); assertTrue(ingestDocument.hasField("_id")); assertTrue(ingestDocument.hasField("_source.fizz")); assertTrue(ingestDocument.hasField("_ingest.timestamp")); @@ -753,23 +751,23 @@ public void testSetFieldValueEmptyName() { public void testRemoveField() { ingestDocument.removeField("foo"); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(7)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(6)); assertThat(ingestDocument.getSourceAndMetadata().containsKey("foo"), equalTo(false)); ingestDocument.removeField("_index"); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(6)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(5)); assertThat(ingestDocument.getSourceAndMetadata().containsKey("_index"), equalTo(false)); ingestDocument.removeField("_source.fizz"); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(5)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(4)); assertThat(ingestDocument.getSourceAndMetadata().containsKey("fizz"), equalTo(false)); assertThat(ingestDocument.getIngestMetadata().size(), equalTo(1)); ingestDocument.removeField("_ingest.timestamp"); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(5)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(4)); assertThat(ingestDocument.getIngestMetadata().size(), equalTo(0)); } public void testRemoveInnerField() { ingestDocument.removeField("fizz.buzz"); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(8)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(7)); assertThat(ingestDocument.getSourceAndMetadata().get("fizz"), instanceOf(Map.class)); @SuppressWarnings("unchecked") Map map = (Map) ingestDocument.getSourceAndMetadata().get("fizz"); @@ -778,17 +776,17 @@ public void testRemoveInnerField() { ingestDocument.removeField("fizz.foo_null"); assertThat(map.size(), equalTo(2)); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(8)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(7)); assertThat(ingestDocument.getSourceAndMetadata().containsKey("fizz"), equalTo(true)); ingestDocument.removeField("fizz.1"); assertThat(map.size(), equalTo(1)); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(8)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(7)); assertThat(ingestDocument.getSourceAndMetadata().containsKey("fizz"), equalTo(true)); ingestDocument.removeField("fizz.list"); assertThat(map.size(), equalTo(0)); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(8)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(7)); assertThat(ingestDocument.getSourceAndMetadata().containsKey("fizz"), equalTo(true)); } @@ -822,7 +820,7 @@ public void testRemoveSourceObject() { public void testRemoveIngestObject() { ingestDocument.removeField("_ingest"); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(7)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(6)); assertThat(ingestDocument.getSourceAndMetadata().containsKey("_ingest"), equalTo(false)); } @@ -844,7 +842,7 @@ public void testRemoveEmptyPathAfterStrippingOutPrefix() { public void testListRemoveField() { ingestDocument.removeField("list.0.field"); - assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(8)); + assertThat(ingestDocument.getSourceAndMetadata().size(), equalTo(7)); assertThat(ingestDocument.getSourceAndMetadata().containsKey("list"), equalTo(true)); Object object = ingestDocument.getSourceAndMetadata().get("list"); assertThat(object, instanceOf(List.class)); From d280f75a92f9fd73dcf04667432d0ca2466e5617 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 7 Oct 2019 15:10:02 +0100 Subject: [PATCH 21/35] test failures --- .../broadcast/BroadcastActionsIT.java | 4 +-- .../document/DocumentActionsIT.java | 1 - .../index/mapper/DynamicMappingIT.java | 8 +++--- .../index/shard/IndexShardIT.java | 4 +-- .../mapping/UpdateMappingIntegrationIT.java | 12 ++++----- .../org/elasticsearch/update/UpdateIT.java | 2 +- .../elasticsearch/test/ESIntegTestCase.java | 27 +++++++++---------- 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java b/server/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java index 90d7efa19b7fb..d3dd9168cbd05 100644 --- a/server/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java +++ b/server/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java @@ -27,7 +27,7 @@ import java.io.IOException; import static org.elasticsearch.client.Requests.indexRequest; -import static org.elasticsearch.index.query.QueryBuilders.termQuery; +import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; @@ -54,7 +54,7 @@ public void testBroadcastOperations() throws IOException { for (int i = 0; i < 5; i++) { // test successful SearchResponse countResponse = client().prepareSearch("test").setSize(0) - .setQuery(termQuery("_type", "type1")) + .setQuery(matchAllQuery()) .get(); assertThat(countResponse.getHits().getTotalHits().value, equalTo(2L)); assertThat(countResponse.getTotalShards(), equalTo(numShards.numPrimaries)); diff --git a/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java b/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java index 377f47c85dd6e..a7c9c058d945e 100644 --- a/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java +++ b/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java @@ -213,7 +213,6 @@ public void testBulk() throws Exception { assertThat(bulkResponse.getItems()[3].isFailed(), equalTo(false)); assertThat(bulkResponse.getItems()[3].getOpType(), equalTo(OpType.CREATE)); assertThat(bulkResponse.getItems()[3].getIndex(), equalTo(getConcreteIndexName())); - assertThat(bulkResponse.getItems()[3].getId(), equalTo("1")); String generatedId4 = bulkResponse.getItems()[3].getId(); assertThat(bulkResponse.getItems()[4].isFailed(), equalTo(false)); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIT.java b/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIT.java index f51363cf8df34..877cca9cdbb5c 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIT.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIT.java @@ -72,10 +72,10 @@ public void testConflictingDynamicMappingsBulk() { assertTrue(bulkResponse.hasFailures()); } - private static void assertMappingsHaveField(GetMappingsResponse mappings, String index, String type, String field) throws IOException { + private static void assertMappingsHaveField(GetMappingsResponse mappings, String index, String field) throws IOException { ImmutableOpenMap indexMappings = mappings.getMappings().get("index"); assertNotNull(indexMappings); - MappingMetaData typeMappings = indexMappings.get(type); + MappingMetaData typeMappings = indexMappings.get("_doc"); assertNotNull(typeMappings); Map typeMappingsMap = typeMappings.getSourceAsMap(); Map properties = (Map) typeMappingsMap.get("properties"); @@ -111,9 +111,9 @@ public void run() { throw error.get(); } Thread.sleep(2000); - GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").setTypes("type").get(); + GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").get(); for (int i = 0; i < indexThreads.length; ++i) { - assertMappingsHaveField(mappings, "index", "type", "field" + i); + assertMappingsHaveField(mappings, "index", "field" + i); } for (int i = 0; i < indexThreads.length; ++i) { assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists()); diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java index 8c20b1ee97722..4fc3793d64e0d 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardIT.java @@ -353,11 +353,11 @@ public void testMaybeFlush() throws Exception { client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder() .put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(190 /* size of the operation + two generations header&footer*/, ByteSizeUnit.BYTES)).build()).get(); - client().prepareIndex("test", "test", "0") + client().prepareIndex("test", "_doc", "0") .setSource("{}", XContentType.JSON).setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get(); assertFalse(shard.shouldPeriodicallyFlush()); shard.applyIndexOperationOnPrimary(Versions.MATCH_ANY, VersionType.INTERNAL, - new SourceToParse("test", "test", "1", new BytesArray("{}"), XContentType.JSON), + new SourceToParse("test", "_doc", "1", new BytesArray("{}"), XContentType.JSON), SequenceNumbers.UNASSIGNED_SEQ_NO, 0, IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, false); assertTrue(shard.shouldPeriodicallyFlush()); final Translog translog = getTranslog(shard); diff --git a/server/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java b/server/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java index 19f7324db435d..d3037a7853f38 100644 --- a/server/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java @@ -105,7 +105,7 @@ public void testDynamicUpdates() throws Exception { for (int rec = 0; rec < recCount; rec++) { String type = "type"; String fieldName = "field_" + type + "_" + rec; - assertConcreteMappingsOnAll("test", type, fieldName); + assertConcreteMappingsOnAll("test", fieldName); } client().admin().cluster().prepareUpdateSettings().setTransientSettings( @@ -295,7 +295,7 @@ public void testPutMappingsWithBlocks() { * Waits until mappings for the provided fields exist on all nodes. Note, this waits for the current * started shards and checks for concrete mappings. */ - private void assertConcreteMappingsOnAll(final String index, final String type, final String... fieldNames) { + private void assertConcreteMappingsOnAll(final String index, final String... fieldNames) { Set nodes = internalCluster().nodesInclude(index); assertThat(nodes, Matchers.not(Matchers.emptyIterable())); for (String node : nodes) { @@ -308,17 +308,17 @@ private void assertConcreteMappingsOnAll(final String index, final String type, assertNotNull("field " + fieldName + " doesn't exists on " + node, fieldType); } } - assertMappingOnMaster(index, type, fieldNames); + assertMappingOnMaster(index, fieldNames); } /** * Waits for the given mapping type to exists on the master node. */ - private void assertMappingOnMaster(final String index, final String type, final String... fieldNames) { - GetMappingsResponse response = client().admin().indices().prepareGetMappings(index).setTypes(type).get(); + private void assertMappingOnMaster(final String index, final String... fieldNames) { + GetMappingsResponse response = client().admin().indices().prepareGetMappings(index).get(); ImmutableOpenMap mappings = response.getMappings().get(index); assertThat(mappings, notNullValue()); - MappingMetaData mappingMetaData = mappings.get(type); + MappingMetaData mappingMetaData = mappings.get(MapperService.SINGLE_MAPPING_NAME); assertThat(mappingMetaData, notNullValue()); Map mappingSource = mappingMetaData.getSourceAsMap(); diff --git a/server/src/test/java/org/elasticsearch/update/UpdateIT.java b/server/src/test/java/org/elasticsearch/update/UpdateIT.java index 61c0ff6ebe9fa..633ef999dceb5 100644 --- a/server/src/test/java/org/elasticsearch/update/UpdateIT.java +++ b/server/src/test/java/org/elasticsearch/update/UpdateIT.java @@ -299,7 +299,7 @@ public void testUpdate() throws Exception { Script fieldIncScript = new Script(ScriptType.INLINE, UPDATE_SCRIPTS, FIELD_INC_SCRIPT, Collections.singletonMap("field", "field")); DocumentMissingException ex = expectThrows(DocumentMissingException.class, () -> client().prepareUpdate(indexOrAlias(), "type1", "1").setScript(fieldIncScript).execute().actionGet()); - assertEquals("[type1][1]: document missing", ex.getMessage()); + assertEquals("[1]: document missing", ex.getMessage()); client().prepareIndex("test", "type1", "1").setSource("field", 1).execute().actionGet(); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 7c2fcdc293773..42ea514f3ebf6 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -151,7 +151,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.List; @@ -1289,9 +1288,9 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, List builders) throws InterruptedException { Random random = random(); - Map> indicesAndTypes = new HashMap<>(); + Set indices = new HashSet<>(); for (IndexRequestBuilder builder : builders) { - final Set types = indicesAndTypes.computeIfAbsent(builder.request().index(), index -> new HashSet<>()); + indices.add(builder.request().index()); } Set> bogusIds = new HashSet<>(); // (index, type, id) if (random.nextBoolean() && !builders.isEmpty() && dummyDocuments) { @@ -1302,33 +1301,31 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma for (int i = 0; i < numBogusDocs; i++) { String id = "bogus_doc_" + randomRealisticUnicodeOfLength(unicodeLen) - + Integer.toString(dummmyDocIdGenerator.incrementAndGet()); - Map.Entry> indexAndTypes = RandomPicks.randomFrom(random, indicesAndTypes.entrySet()); - String index = indexAndTypes.getKey(); - String type = RandomPicks.randomFrom(random, indexAndTypes.getValue()); - bogusIds.add(Arrays.asList(index, type, id)); + + dummmyDocIdGenerator.incrementAndGet(); + String index = RandomPicks.randomFrom(random, indices); + bogusIds.add(Arrays.asList(index, id)); // We configure a routing key in case the mapping requires it - builders.add(client().prepareIndex(index, type, id).setSource("{}", XContentType.JSON).setRouting(id)); + builders.add(client().prepareIndex().setIndex(index).setId(id).setSource("{}", XContentType.JSON).setRouting(id)); } } Collections.shuffle(builders, random()); final CopyOnWriteArrayList> errors = new CopyOnWriteArrayList<>(); List inFlightAsyncOperations = new ArrayList<>(); // If you are indexing just a few documents then frequently do it one at a time. If many then frequently in bulk. - final String[] indices = indicesAndTypes.keySet().toArray(new String[0]); + final String[] indicesArray = indices.toArray(new String[]{}); if (builders.size() < FREQUENT_BULK_THRESHOLD ? frequently() : builders.size() < ALWAYS_BULK_THRESHOLD ? rarely() : false) { if (frequently()) { logger.info("Index [{}] docs async: [{}] bulk: [{}]", builders.size(), true, false); for (IndexRequestBuilder indexRequestBuilder : builders) { indexRequestBuilder.execute( new PayloadLatchedActionListener<>(indexRequestBuilder, newLatch(inFlightAsyncOperations), errors)); - postIndexAsyncActions(indices, inFlightAsyncOperations, maybeFlush); + postIndexAsyncActions(indicesArray, inFlightAsyncOperations, maybeFlush); } } else { logger.info("Index [{}] docs async: [{}] bulk: [{}]", builders.size(), false, false); for (IndexRequestBuilder indexRequestBuilder : builders) { indexRequestBuilder.execute().actionGet(); - postIndexAsyncActions(indices, inFlightAsyncOperations, maybeFlush); + postIndexAsyncActions(indicesArray, inFlightAsyncOperations, maybeFlush); } } } else { @@ -1361,13 +1358,13 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma if (!bogusIds.isEmpty()) { // delete the bogus types again - it might trigger merges or at least holes in the segments and enforces deleted docs! for (List doc : bogusIds) { - assertEquals("failed to delete a dummy doc [" + doc.get(0) + "][" + doc.get(2) + "]", + assertEquals("failed to delete a dummy doc [" + doc.get(0) + "][" + doc.get(1) + "]", DocWriteResponse.Result.DELETED, - client().prepareDelete(doc.get(0), doc.get(1), doc.get(2)).setRouting(doc.get(2)).get().getResult()); + client().prepareDelete(doc.get(0), null, doc.get(1)).setRouting(doc.get(1)).get().getResult()); } } if (forceRefresh) { - assertNoFailures(client().admin().indices().prepareRefresh(indices) + assertNoFailures(client().admin().indices().prepareRefresh(indicesArray) .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .get()); } From 25a5bf409cdc2bf4a8e39f01811c750e2ae87942 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 7 Oct 2019 15:33:35 +0100 Subject: [PATCH 22/35] imports --- .../org/elasticsearch/action/update/TransportUpdateAction.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java index 580c1673faeef..78584dc0390e2 100644 --- a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java @@ -50,7 +50,6 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.IndexService; import org.elasticsearch.index.engine.VersionConflictEngineException; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.IndicesService; From b724b443b2ea0e1b4357c047c001247310d5657f Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 7 Oct 2019 16:31:02 +0100 Subject: [PATCH 23/35] rest handler --- .../resources/rest-api-spec/api/index.json | 47 ------------------- .../rest/action/document/RestIndexAction.java | 1 + 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/index.json b/rest-api-spec/src/main/resources/rest-api-spec/api/index.json index 7ecd7a0e9279e..34608160c915e 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/index.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/index.json @@ -35,53 +35,6 @@ "description":"The name of the index" } } - }, - { - "path":"/{index}/{type}", - "methods":[ - "POST" - ], - "parts":{ - "index":{ - "type":"string", - "description":"The name of the index" - }, - "type":{ - "type":"string", - "description":"The type of the document", - "deprecated":true - } - }, - "deprecated":{ - "version":"7.0.0", - "description":"Specifying types in urls has been deprecated" - } - }, - { - "path":"/{index}/{type}/{id}", - "methods":[ - "PUT", - "POST" - ], - "parts":{ - "id":{ - "type":"string", - "description":"Document ID" - }, - "index":{ - "type":"string", - "description":"The name of the index" - }, - "type":{ - "type":"string", - "description":"The type of the document", - "deprecated":true - } - }, - "deprecated":{ - "version":"7.0.0", - "description":"Specifying types in urls has been deprecated" - } } ] }, diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index 9c1fe86280ed8..03ae85e380e82 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -105,6 +105,7 @@ public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { IndexRequest indexRequest = new IndexRequest(request.param("index")); + indexRequest.id(request.param("id")); indexRequest.routing(request.param("routing")); indexRequest.setPipeline(request.param("pipeline")); indexRequest.source(request.requiredContent(), request.getXContentType()); From 9b97d95f8c163933e6ec3f6a15214a3cd199d512 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 8 Oct 2019 09:13:18 +0100 Subject: [PATCH 24/35] Workaround for weird SLM failure --- .../main/java/org/elasticsearch/test/rest/ESRestTestCase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index 9e2bdbab1e564..b9437defa1f7a 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -707,7 +707,8 @@ private static void deleteAllSLMPolicies() throws IOException { Response response = adminClient().performRequest(new Request("GET", "/_slm/policy")); policies = entityAsMap(response); } catch (ResponseException e) { - if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { + if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode() || + RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { // If bad request returned, SLM is not enabled. return; } From 1ab2ac1d9398bb67ad2f6e35072d7fab00b5d126 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 8 Oct 2019 11:02:05 +0100 Subject: [PATCH 25/35] tests --- .../autodatehistogram-aggregation.asciidoc | 6 +-- docs/reference/api-conventions.asciidoc | 6 +-- docs/reference/cat/count.asciidoc | 2 +- docs/reference/cat/segments.asciidoc | 2 +- docs/reference/docs/bulk.asciidoc | 6 +-- .../docs/concurrency-control.asciidoc | 1 - docs/reference/docs/delete.asciidoc | 1 - docs/reference/docs/index_.asciidoc | 2 - docs/reference/docs/reindex.asciidoc | 2 +- docs/reference/docs/update.asciidoc | 1 - docs/reference/getting-started.asciidoc | 1 - .../reference/indices/rollover-index.asciidoc | 1 - docs/reference/indices/segments.asciidoc | 4 +- docs/reference/indices/shard-stores.asciidoc | 2 +- docs/reference/ingest.asciidoc | 1 - .../ingest/apis/simulate-pipeline.asciidoc | 8 ---- docs/reference/ingest/ingest-node.asciidoc | 1 - .../processors/date-index-name.asciidoc | 2 - .../reference/ingest/processors/grok.asciidoc | 2 - .../ingest/processors/pipeline.asciidoc | 1 - .../ingest/processors/script.asciidoc | 8 ++-- docs/reference/ingest/processors/set.asciidoc | 1 - .../mapping/removal_of_types.asciidoc | 40 ------------------- .../query-dsl/percolate-query.asciidoc | 1 - .../test/search-as-you-type/10_basic.yml | 2 - .../search-as-you-type/20_highlighting.yml | 1 - qa/os/bats/default/certgen.bash | 2 +- .../ingest_mustache/10_ingest_disabled.yml | 1 - .../10_pipeline_with_mustache_templates.yml | 6 --- .../test/ingest/20_combine_processors.yml | 2 - .../ingest/30_update_by_query_with_ingest.yml | 1 - .../test/ingest/40_reindex_with_ingest.yml | 1 - .../50_script_processor_using_painless.yml | 2 - .../test/rest/ESRestTestCase.java | 3 +- .../ccr/action/ShardChangesActionTests.java | 3 +- .../actions/index/IndexActionTests.java | 6 +-- ...storyTemplateIndexActionMappingsTests.java | 14 ++----- 37 files changed, 25 insertions(+), 121 deletions(-) diff --git a/docs/reference/aggregations/bucket/autodatehistogram-aggregation.asciidoc b/docs/reference/aggregations/bucket/autodatehistogram-aggregation.asciidoc index 8da1000dc2d47..8021c084ffab4 100644 --- a/docs/reference/aggregations/bucket/autodatehistogram-aggregation.asciidoc +++ b/docs/reference/aggregations/bucket/autodatehistogram-aggregation.asciidoc @@ -119,17 +119,17 @@ Consider the following example: [source,console] --------------------------------- -PUT my_index/log/1?refresh +PUT my_index/_doc/1?refresh { "date": "2015-10-01T00:30:00Z" } -PUT my_index/log/2?refresh +PUT my_index/_doc/2?refresh { "date": "2015-10-01T01:30:00Z" } -PUT my_index/log/3?refresh +PUT my_index/_doc/3?refresh { "date": "2015-10-01T02:30:00Z" } diff --git a/docs/reference/api-conventions.asciidoc b/docs/reference/api-conventions.asciidoc index e9259f9ee9f61..6fbfc5548719e 100644 --- a/docs/reference/api-conventions.asciidoc +++ b/docs/reference/api-conventions.asciidoc @@ -335,11 +335,11 @@ parameter like this: [source,console] -------------------------------------------------- -POST /library/book?refresh +POST /library/_create?refresh {"title": "Book #1", "rating": 200.1} -POST /library/book?refresh +POST /library/_create?refresh {"title": "Book #2", "rating": 1.7} -POST /library/book?refresh +POST /library/_create?refresh {"title": "Book #3", "rating": 0.1} GET /_search?filter_path=hits.hits._source&_source=title&sort=rating:desc -------------------------------------------------- diff --git a/docs/reference/cat/count.asciidoc b/docs/reference/cat/count.asciidoc index e38151ce4b55b..fe3888708bf1d 100644 --- a/docs/reference/cat/count.asciidoc +++ b/docs/reference/cat/count.asciidoc @@ -77,7 +77,7 @@ the cluster. GET /_cat/count?v -------------------------------------------------- // TEST[setup:big_twitter] -// TEST[s/^/POST test\/test\?refresh\n{"test": "test"}\n/] +// TEST[s/^/POST test\/_create\?refresh\n{"test": "test"}\n/] The API returns the following response: diff --git a/docs/reference/cat/segments.asciidoc b/docs/reference/cat/segments.asciidoc index 4ed1408239247..7e90c6806590b 100644 --- a/docs/reference/cat/segments.asciidoc +++ b/docs/reference/cat/segments.asciidoc @@ -106,7 +106,7 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-v] -------------------------------------------------- GET /_cat/segments?v -------------------------------------------------- -// TEST[s/^/PUT \/test\/test\/1?refresh\n{"test":"test"}\nPUT \/test1\/test\/1?refresh\n{"test":"test"}\n/] +// TEST[s/^/PUT \/test\/1?refresh\n{"test":"test"}\nPUT \/test1\/test\/1?refresh\n{"test":"test"}\n/] The API returns the following response: diff --git a/docs/reference/docs/bulk.asciidoc b/docs/reference/docs/bulk.asciidoc index 6e6b61d73574f..5dfb02c53344e 100644 --- a/docs/reference/docs/bulk.asciidoc +++ b/docs/reference/docs/bulk.asciidoc @@ -120,7 +120,7 @@ $ cat requests { "index" : { "_index" : "test", "_id" : "1" } } { "field1" : "value1" } $ curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@requests"; echo -{"took":7, "errors": false, "items":[{"index":{"_index":"test","_type":"_doc","_id":"1","_version":1,"result":"created","forced_refresh":false}}]} +{"took":7, "errors": false, "items":[{"index":{"_index":"test","_id":"1","_version":1,"result":"created","forced_refresh":false}}]} -------------------------------------------------- // NOTCONSOLE // Not converting to console because this shows how curl works @@ -240,7 +240,6 @@ The API returns the following result: { "index": { "_index": "test", - "_type": "_doc", "_id": "1", "_version": 1, "result": "created", @@ -257,7 +256,6 @@ The API returns the following result: { "delete": { "_index": "test", - "_type": "_doc", "_id": "2", "_version": 1, "result": "not_found", @@ -274,7 +272,6 @@ The API returns the following result: { "create": { "_index": "test", - "_type": "_doc", "_id": "3", "_version": 1, "result": "created", @@ -291,7 +288,6 @@ The API returns the following result: { "update": { "_index": "test", - "_type": "_doc", "_id": "1", "_version": 2, "result": "updated", diff --git a/docs/reference/docs/concurrency-control.asciidoc b/docs/reference/docs/concurrency-control.asciidoc index 8e29c0d6054e2..fd59b79c23d20 100644 --- a/docs/reference/docs/concurrency-control.asciidoc +++ b/docs/reference/docs/concurrency-control.asciidoc @@ -42,7 +42,6 @@ You can see the assigned sequence number and primary term in the }, "_index" : "products", "_id" : "1567", - "_type" : "_doc", "_version" : 1, "_seq_no" : 362, "_primary_term" : 2, diff --git a/docs/reference/docs/delete.asciidoc b/docs/reference/docs/delete.asciidoc index 479db4a453e17..f6fa7542fd5b5 100644 --- a/docs/reference/docs/delete.asciidoc +++ b/docs/reference/docs/delete.asciidoc @@ -181,7 +181,6 @@ The API returns the following result: "successful" : 2 }, "_index" : "twitter", - "_type" : "_doc", "_id" : "1", "_version" : 2, "_primary_term": 1, diff --git a/docs/reference/docs/index_.asciidoc b/docs/reference/docs/index_.asciidoc index 02abf6913044e..86645a2944167 100644 --- a/docs/reference/docs/index_.asciidoc +++ b/docs/reference/docs/index_.asciidoc @@ -211,7 +211,6 @@ The API returns the following result: "successful" : 2 }, "_index" : "twitter", - "_type" : "_doc", "_id" : "W0tpsmIBdwcYyG50zbta", "_version" : 1, "_seq_no" : 0, @@ -470,7 +469,6 @@ The API returns the following result: "successful" : 2 }, "_index" : "twitter", - "_type" : "_doc", "_id" : "1", "_version" : 1, "_seq_no" : 0, diff --git a/docs/reference/docs/reindex.asciidoc b/docs/reference/docs/reindex.asciidoc index 009c8deb7785c..c6d1f4755c7de 100644 --- a/docs/reference/docs/reindex.asciidoc +++ b/docs/reference/docs/reindex.asciidoc @@ -666,7 +666,7 @@ POST _reindex } -------------------------------------------------- // TEST[setup:twitter] -// TEST[s/^/PUT blog\/post\/post1?refresh\n{"test": "foo"}\n/] +// TEST[s/^/PUT blog\/_doc\/post1?refresh\n{"test": "foo"}\n/] NOTE: The Reindex API makes no effort to handle ID collisions so the last document written will "win" but the order isn't usually predictable so it is diff --git a/docs/reference/docs/update.asciidoc b/docs/reference/docs/update.asciidoc index 3b6e94c7afa41..5394eb56c6a11 100644 --- a/docs/reference/docs/update.asciidoc +++ b/docs/reference/docs/update.asciidoc @@ -237,7 +237,6 @@ request is ignored and the `result` element in the response returns `noop`: "failed": 0 }, "_index": "test", - "_type": "_doc", "_id": "1", "_version": 7, "_primary_term": 1, diff --git a/docs/reference/getting-started.asciidoc b/docs/reference/getting-started.asciidoc index f70f2c938ddcc..ad67dcc0e6eb8 100755 --- a/docs/reference/getting-started.asciidoc +++ b/docs/reference/getting-started.asciidoc @@ -230,7 +230,6 @@ operation was that version 1 of the document was created: { "_index" : "customer", "_id" : "1", - "_type" : "_doc", "_version" : 1, "result" : "created", "_shards" : { diff --git a/docs/reference/indices/rollover-index.asciidoc b/docs/reference/indices/rollover-index.asciidoc index 294c38790e1b7..060d3335fea67 100644 --- a/docs/reference/indices/rollover-index.asciidoc +++ b/docs/reference/indices/rollover-index.asciidoc @@ -409,7 +409,6 @@ PUT logs/_doc/2 <2> -------------------------------------------------- { "_index" : "my_logs_index-000002", - "_type" : "_doc", "_id" : "2", "_version" : 1, "result" : "created", diff --git a/docs/reference/indices/segments.asciidoc b/docs/reference/indices/segments.asciidoc index 3bdeaa8b648f6..bafb3a40892d1 100644 --- a/docs/reference/indices/segments.asciidoc +++ b/docs/reference/indices/segments.asciidoc @@ -106,7 +106,7 @@ Contains information about whether high compression was enabled. -------------------------------------------------- GET /test/_segments -------------------------------------------------- -// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/test\?refresh\n{"test": "test"}\n/] +// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/_create\?refresh\n{"test": "test"}\n/] ===== Get segment information for several indices @@ -124,7 +124,7 @@ GET /test1,test2/_segments -------------------------------------------------- GET /_segments -------------------------------------------------- -// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/test\?refresh\n{"test": "test"}\n/] +// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/_create\?refresh\n{"test": "test"}\n/] The API returns the following response: diff --git a/docs/reference/indices/shard-stores.asciidoc b/docs/reference/indices/shard-stores.asciidoc index a1d3f7f224dd4..c581fe3fa5c1b 100644 --- a/docs/reference/indices/shard-stores.asciidoc +++ b/docs/reference/indices/shard-stores.asciidoc @@ -136,7 +136,7 @@ for assigned primary and replica shards. GET /_shard_stores?status=green -------------------------------------------------- // TEST[setup:node] -// TEST[s/^/PUT my-index\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST my-index\/test\?refresh\n{"test": "test"}\n/] +// TEST[s/^/PUT my-index\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST my-index\/_create\?refresh\n{"test": "test"}\n/] The API returns the following response: diff --git a/docs/reference/ingest.asciidoc b/docs/reference/ingest.asciidoc index 8b1cadd4d7e31..c5e7be1ed54a4 100644 --- a/docs/reference/ingest.asciidoc +++ b/docs/reference/ingest.asciidoc @@ -61,7 +61,6 @@ Response: -------------------------------------------------- { "_index" : "my-index", - "_type" : "_doc", "_id" : "my-id", "_version" : 1, "result" : "created", diff --git a/docs/reference/ingest/apis/simulate-pipeline.asciidoc b/docs/reference/ingest/apis/simulate-pipeline.asciidoc index c05bc2fa3ceaa..1b2317b83ecd6 100644 --- a/docs/reference/ingest/apis/simulate-pipeline.asciidoc +++ b/docs/reference/ingest/apis/simulate-pipeline.asciidoc @@ -176,7 +176,6 @@ The API returns the following response: "doc": { "_id": "id", "_index": "index", - "_type": "_doc", "_source": { "field2": "_value", "foo": "bar" @@ -190,7 +189,6 @@ The API returns the following response: "doc": { "_id": "id", "_index": "index", - "_type": "_doc", "_source": { "field2": "_value", "foo": "rab" @@ -255,7 +253,6 @@ The API returns the following response: "doc": { "_id": "id", "_index": "index", - "_type": "_doc", "_source": { "field2": "_value", "foo": "bar" @@ -269,7 +266,6 @@ The API returns the following response: "doc": { "_id": "id", "_index": "index", - "_type": "_doc", "_source": { "field2": "_value", "foo": "rab" @@ -349,7 +345,6 @@ The API returns the following response: "doc": { "_id": "id", "_index": "index", - "_type": "_doc", "_source": { "field2": "_value2", "foo": "bar" @@ -363,7 +358,6 @@ The API returns the following response: "doc": { "_id": "id", "_index": "index", - "_type": "_doc", "_source": { "field3": "_value3", "field2": "_value2", @@ -382,7 +376,6 @@ The API returns the following response: "doc": { "_id": "id", "_index": "index", - "_type": "_doc", "_source": { "field2": "_value2", "foo": "rab" @@ -396,7 +389,6 @@ The API returns the following response: "doc": { "_id": "id", "_index": "index", - "_type": "_doc", "_source": { "field3": "_value3", "field2": "_value2", diff --git a/docs/reference/ingest/ingest-node.asciidoc b/docs/reference/ingest/ingest-node.asciidoc index 15a750da43159..6e88f75d5919c 100644 --- a/docs/reference/ingest/ingest-node.asciidoc +++ b/docs/reference/ingest/ingest-node.asciidoc @@ -198,7 +198,6 @@ Results in nothing indexed since the conditional evaluated to `true`. -------------------------------------------------- { "_index": "test", - "_type": "_doc", "_id": "1", "_version": -3, "result": "noop", diff --git a/docs/reference/ingest/processors/date-index-name.asciidoc b/docs/reference/ingest/processors/date-index-name.asciidoc index 7ffae4909a349..394c66a076e77 100644 --- a/docs/reference/ingest/processors/date-index-name.asciidoc +++ b/docs/reference/ingest/processors/date-index-name.asciidoc @@ -49,7 +49,6 @@ PUT /myindex/_doc/1?pipeline=monthlyindex -------------------------------------------------- { "_index" : "myindex-2016-04-01", - "_type" : "_doc", "_id" : "1", "_version" : 1, "result" : "created", @@ -109,7 +108,6 @@ and the result: "doc" : { "_id" : "_id", "_index" : "", - "_type" : "_doc", "_source" : { "date1" : "2016-04-25T12:02:01.789Z" }, diff --git a/docs/reference/ingest/processors/grok.asciidoc b/docs/reference/ingest/processors/grok.asciidoc index 1ea259e7cb9a3..c1f2ae9645a38 100644 --- a/docs/reference/ingest/processors/grok.asciidoc +++ b/docs/reference/ingest/processors/grok.asciidoc @@ -192,7 +192,6 @@ response: "docs": [ { "doc": { - "_type": "_doc", "_index": "_index", "_id": "_id", "_source": { @@ -252,7 +251,6 @@ POST _ingest/pipeline/_simulate "docs": [ { "doc": { - "_type": "_doc", "_index": "_index", "_id": "_id", "_source": { diff --git a/docs/reference/ingest/processors/pipeline.asciidoc b/docs/reference/ingest/processors/pipeline.asciidoc index ff0744b337221..573ab3b88d3c4 100644 --- a/docs/reference/ingest/processors/pipeline.asciidoc +++ b/docs/reference/ingest/processors/pipeline.asciidoc @@ -83,7 +83,6 @@ Response from the index request: -------------------------------------------------- { "_index": "myindex", - "_type": "_doc", "_id": "1", "_version": 1, "result": "created", diff --git a/docs/reference/ingest/processors/script.asciidoc b/docs/reference/ingest/processors/script.asciidoc index d9aed04f57deb..873469844ccc2 100644 --- a/docs/reference/ingest/processors/script.asciidoc +++ b/docs/reference/ingest/processors/script.asciidoc @@ -42,21 +42,20 @@ numeric fields `field_a` and `field_b` multiplied by the parameter param_c: -------------------------------------------------- // NOTCONSOLE -It is possible to use the Script Processor to manipulate document metadata like `_index` and `_type` during -ingestion. Here is an example of an Ingest Pipeline that renames the index and type to `my_index` no matter what +It is possible to use the Script Processor to manipulate document metadata like `_index` during +ingestion. Here is an example of an Ingest Pipeline that renames the index to `my_index` no matter what was provided in the original index request: [source,console] -------------------------------------------------- PUT _ingest/pipeline/my_index { - "description": "use index:my_index and type:_doc", + "description": "use index:my_index", "processors": [ { "script": { "source": """ ctx._index = 'my_index'; - ctx._type = '_doc'; """ } } @@ -81,7 +80,6 @@ The response from the above index request: -------------------------------------------------- { "_index": "my_index", - "_type": "_doc", "_id": "1", "_version": 1, "result": "created", diff --git a/docs/reference/ingest/processors/set.asciidoc b/docs/reference/ingest/processors/set.asciidoc index 9aba07b73f657..349b8acd469c8 100644 --- a/docs/reference/ingest/processors/set.asciidoc +++ b/docs/reference/ingest/processors/set.asciidoc @@ -64,7 +64,6 @@ Result: { "doc" : { "_index" : "_index", - "_type" : "_doc", "_id" : "_id", "_source" : { "host" : { diff --git a/docs/reference/mapping/removal_of_types.asciidoc b/docs/reference/mapping/removal_of_types.asciidoc index e048ccd33250f..a095eac203308 100644 --- a/docs/reference/mapping/removal_of_types.asciidoc +++ b/docs/reference/mapping/removal_of_types.asciidoc @@ -532,7 +532,6 @@ PUT index/_doc/1 { "_index": "index", "_id": "1", - "_type": "_doc", "_version": 1, "result": "created", "_shards": { @@ -593,45 +592,6 @@ When calling a search API such `_search`, `_msearch`, or `_explain`, types should not be included in the URL. Additionally, the `_type` field should not be used in queries, aggregations, or scripts. -[float] -==== Types in responses - -The document and search APIs will continue to return a `_type` key in -responses, to avoid breaks to response parsing. However, the key is -considered deprecated and should no longer be referenced. Types will -be completely removed from responses in 8.0. - -Note that when a deprecated typed API is used, the index's mapping type will be -returned as normal, but that typeless APIs will return the dummy type `_doc` -in the response. For example, the following typeless `get` call will always -return `_doc` as the type, even if the mapping has a custom type name like -`my_type`: - -[source,console] --------------------------------------------------- -PUT index/my_type/1 -{ - "foo": "baz" -} - -GET index/_doc/1 --------------------------------------------------- - -[source,console-result] --------------------------------------------------- -{ - "_index" : "index", - "_id" : "1", - "_version" : 1, - "_seq_no" : 0, - "_primary_term" : 1, - "found": true, - "_source" : { - "foo" : "baz" - } -} --------------------------------------------------- - [float] ==== Index templates diff --git a/docs/reference/query-dsl/percolate-query.asciidoc b/docs/reference/query-dsl/percolate-query.asciidoc index e9b919a1cb588..2094be0ccd996 100644 --- a/docs/reference/query-dsl/percolate-query.asciidoc +++ b/docs/reference/query-dsl/percolate-query.asciidoc @@ -293,7 +293,6 @@ Index response: -------------------------------------------------- { "_index": "my-index", - "_type": "_doc", "_id": "2", "_version": 1, "_shards": { diff --git a/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/10_basic.yml b/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/10_basic.yml index f1851d9c35757..21843dad1d177 100644 --- a/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/10_basic.yml +++ b/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/10_basic.yml @@ -19,7 +19,6 @@ setup: - do: index: index: test - type: _doc id: 1 body: a_field: "quick brown fox jump lazy dog" @@ -28,7 +27,6 @@ setup: - do: index: index: test - type: _doc id: 2 body: a_field: "xylophone xylophone xylophone" diff --git a/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/20_highlighting.yml b/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/20_highlighting.yml index 15778393959e5..58441abac8f88 100644 --- a/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/20_highlighting.yml +++ b/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/20_highlighting.yml @@ -22,7 +22,6 @@ setup: - do: index: index: test - type: _doc id: 1 body: a_field: "quick brown fox jump lazy dog" diff --git a/qa/os/bats/default/certgen.bash b/qa/os/bats/default/certgen.bash index 8d6f085806d68..bcefb9303c86d 100644 --- a/qa/os/bats/default/certgen.bash +++ b/qa/os/bats/default/certgen.bash @@ -382,7 +382,7 @@ DATA_SETTINGS testIndex=$(sudo curl -u "elastic:changeme" \ -H "Content-Type: application/json" \ --cacert "$ESCONFIG/certs/ca/ca.crt" \ - -XPOST "https://127.0.0.1:9200/books/book/0?refresh" \ + -XPOST "https://127.0.0.1:9200/books/0?refresh" \ -d '{"title": "Elasticsearch The Definitive Guide"}') debug_collect_logs diff --git a/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml b/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml index fb29017c3605e..7a0cdcbef0786 100644 --- a/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml +++ b/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yml @@ -73,7 +73,6 @@ catch: /There are no ingest nodes in this cluster, unable to forward request to an ingest node./ index: index: test - type: test id: 1 pipeline: "my_pipeline_1" body: { diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml index 8c3252f72c73a..ae7632a2a9c6a 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml @@ -30,7 +30,6 @@ - do: index: index: test - type: test id: 1 pipeline: "my_pipeline_1" body: {} @@ -109,7 +108,6 @@ - do: index: index: test - type: test id: 1 pipeline: "my_pipeline_1" body: { @@ -133,7 +131,6 @@ - do: index: index: test - type: test id: 1 pipeline: "my_pipeline_2" body: { @@ -151,7 +148,6 @@ - do: index: index: test - type: test id: 1 pipeline: "my_pipeline_3" body: { @@ -200,7 +196,6 @@ - do: index: index: test - type: test id: 1 pipeline: "my_handled_pipeline" body: { @@ -241,7 +236,6 @@ - do: index: index: test - type: test id: 1 pipeline: "_id" body: { diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml index 2a68724fa8def..27f7f804ead1c 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml @@ -43,7 +43,6 @@ - do: index: index: test - type: test id: 1 pipeline: "_id" body: { @@ -131,7 +130,6 @@ - do: index: index: test - type: test id: 1 pipeline: "_id" body: { diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/30_update_by_query_with_ingest.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/30_update_by_query_with_ingest.yml index 0f187cc439016..5ba68cb932a17 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/30_update_by_query_with_ingest.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/30_update_by_query_with_ingest.yml @@ -18,7 +18,6 @@ - do: index: index: twitter - type: _doc id: 1 body: { "user": "kimchy" } - do: diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/40_reindex_with_ingest.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/40_reindex_with_ingest.yml index 8703eca4a5ae3..61f290f91bc42 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/40_reindex_with_ingest.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/40_reindex_with_ingest.yml @@ -18,7 +18,6 @@ - do: index: index: twitter - type: tweet id: 1 body: { "user": "kimchy" } - do: diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/50_script_processor_using_painless.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/50_script_processor_using_painless.yml index ff0ccb5c340bf..eaf6b24030a06 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/50_script_processor_using_painless.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/50_script_processor_using_painless.yml @@ -22,7 +22,6 @@ - do: index: index: test - type: test id: 1 pipeline: "my_pipeline" body: { bytes_in: 1234, bytes_out: 4321 } @@ -71,7 +70,6 @@ - do: index: index: test - type: test id: 1 pipeline: "my_pipeline" body: { bytes_in: 1234, bytes_out: 4321 } diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index b9437defa1f7a..ad2c234765f75 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -684,7 +684,8 @@ private static void deleteAllILMPolicies() throws IOException { Response response = adminClient().performRequest(new Request("GET", "/_ilm/policy")); policies = entityAsMap(response); } catch (ResponseException e) { - if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { + if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode() || + RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { // If bad request returned, ILM is not enabled. return; } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesActionTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesActionTests.java index aeabcb325b996..96831011e717e 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesActionTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardChangesActionTests.java @@ -147,7 +147,7 @@ public void testGetOperationsExceedByteLimit() throws Exception { final IndexShard indexShard = indexService.getShard(0); final Translog.Operation[] operations = ShardChangesAction.getOperations(indexShard, indexShard.getLastKnownGlobalCheckpoint(), 0, 12, indexShard.getHistoryUUID(), new ByteSizeValue(256, ByteSizeUnit.BYTES)); - assertThat(operations.length, equalTo(12)); + assertThat(operations.length, equalTo(11)); assertThat(operations[0].seqNo(), equalTo(0L)); assertThat(operations[1].seqNo(), equalTo(1L)); assertThat(operations[2].seqNo(), equalTo(2L)); @@ -159,7 +159,6 @@ public void testGetOperationsExceedByteLimit() throws Exception { assertThat(operations[8].seqNo(), equalTo(8L)); assertThat(operations[9].seqNo(), equalTo(9L)); assertThat(operations[10].seqNo(), equalTo(10L)); - assertThat(operations[11].seqNo(), equalTo(11L)); } public void testGetOperationsAlwaysReturnAtLeastOneOp() throws Exception { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java index 559f7a927498f..1ee821a1d53fa 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java @@ -260,9 +260,8 @@ public void testThatIndexActionCanBeConfiguredWithDynamicIndexNameAndBulk() thro } public void testConfigureIndexInMapAndAction() { - String fieldName = randomFrom("_index", "_type"); - final IndexAction action = new IndexAction(fieldName.equals("_index") ? "my_index" : null, - fieldName.equals("_type") ? "my_type" : null, + String fieldName = "_index"; + final IndexAction action = new IndexAction("my_index", null,null, null, null, refreshPolicy); final ExecutableIndexAction executable = new ExecutableIndexAction(action, logger, client, TimeValue.timeValueSeconds(30), TimeValue.timeValueSeconds(30)); @@ -311,7 +310,6 @@ public void testIndexActionExecuteSingleDoc() throws Exception { XContentSource response = successResult.response(); assertThat(response.getValue("created"), equalTo((Object)Boolean.TRUE)); assertThat(response.getValue("version"), equalTo((Object) 1)); - assertThat(response.getValue("type").toString(), equalTo("test-type")); assertThat(response.getValue("index").toString(), equalTo("test-index")); assertThat(captor.getAllValues(), hasSize(1)); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java index 0b8205935dfe6..b72545e9e032f 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/history/HistoryTemplateIndexActionMappingsTests.java @@ -14,7 +14,6 @@ import org.elasticsearch.xpack.core.watcher.transport.actions.put.PutWatchRequestBuilder; import org.elasticsearch.xpack.watcher.test.AbstractWatcherIntegrationTestCase; -import static org.elasticsearch.index.mapper.MapperService.SINGLE_MAPPING_NAME; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.indexAction; @@ -25,8 +24,8 @@ import static org.hamcrest.Matchers.notNullValue; /** - * This test makes sure that the index action response `index` and `type` fields in the watch_record action result are - * not analyzed so they can be used in aggregations + * This test makes sure that the index action response `index` field in the watch_record action result is + * not analyzed so it can be used in aggregations */ public class HistoryTemplateIndexActionMappingsTests extends AbstractWatcherIntegrationTestCase { @@ -49,8 +48,7 @@ public void testIndexActionFields() throws Exception { refresh(); SearchResponse response = client().prepareSearch(HistoryStoreField.INDEX_PREFIX_WITH_TEMPLATE + "*").setSource(searchSource() - .aggregation(terms("index_action_indices").field("result.actions.index.response.index")) - .aggregation(terms("index_action_types").field("result.actions.index.response.type"))) + .aggregation(terms("index_action_indices").field("result.actions.index.response.index"))) .get(); assertThat(response, notNullValue()); @@ -63,11 +61,5 @@ public void testIndexActionFields() throws Exception { assertThat(terms.getBuckets().size(), is(1)); assertThat(terms.getBucketByKey(index), notNullValue()); assertThat(terms.getBucketByKey(index).getDocCount(), is(1L)); - - terms = aggs.get("index_action_types"); - assertThat(terms, notNullValue()); - assertThat(terms.getBuckets().size(), is(1)); - assertThat(terms.getBucketByKey(SINGLE_MAPPING_NAME), notNullValue()); - assertThat(terms.getBucketByKey(SINGLE_MAPPING_NAME).getDocCount(), is(1L)); } } From 64abbcca1c4733ccdb027bc199ea4f288c25ceb7 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 8 Oct 2019 12:32:16 +0100 Subject: [PATCH 26/35] tests --- .../test/rest/RequestsWithoutContentIT.java | 2 +- docs/reference/api-conventions.asciidoc | 6 +- docs/reference/cat/count.asciidoc | 2 +- docs/reference/cat/segments.asciidoc | 2 +- docs/reference/indices/segments.asciidoc | 4 +- docs/reference/indices/shard-stores.asciidoc | 2 +- qa/os/bats/default/bootstrap_password.bash | 2 +- .../10_pipeline_with_mustache_templates.yml | 8 +- .../test/create/11_with_id_with_types.yml | 31 ---- .../test/create/15_without_id_with_types.yml | 8 - .../create/36_external_version_with_types.yml | 30 ---- .../test/create/41_routing_with_types.yml | 41 ----- .../test/create/61_refresh_with_types.yml | 82 ---------- .../test/create/71_nested_with_types.yml | 38 ----- .../test/delete/11_shard_header.yml | 1 - .../test/delete/13_basic_with_types.yml | 19 --- .../delete/14_shard_header_with_types.yml | 36 ----- .../test/delete/15_result_with_types.yml | 26 --- .../test/delete/21_cas_with_types.yml | 30 ---- .../delete/27_external_version_with_types.yml | 32 ---- .../28_external_gte_version_with_types.yml | 53 ------- .../test/delete/31_routing_with_types.yml | 32 ---- .../test/delete/51_refresh_with_types.yml | 148 ------------------ .../test/delete/61_missing_with_types.yml | 19 --- .../test/delete/70_mix_typeless_typeful.yml | 30 ---- .../rest-api-spec/test/index/10_with_id.yml | 1 - .../test/index/11_with_id_with_types.yml | 32 ---- .../test/index/13_result_with_types.yml | 21 --- .../test/index/16_without_id_with_types.yml | 24 --- .../test/index/21_optype_with_types.yml | 29 ---- .../index/37_external_version_with_types.yml | 55 ------- .../38_external_gte_version_with_types.yml | 56 ------- .../test/index/41_routing_with_types.yml | 41 ----- .../test/index/61_refresh_with_types.yml | 83 ---------- .../test/indices.flush/10_basic.yml | 1 - .../test/indices.rollover/10_basic.yml | 1 - .../indices.rollover/20_max_doc_condition.yml | 2 - .../30_max_size_condition.yml | 1 - .../41_mapping_with_types.yml | 44 ------ .../test/indices.segments/10_basic.yml | 2 - .../test/indices.shard_stores/10_basic.yml | 3 - .../test/search/300_sequence_numbers.yml | 2 - .../test/search/40_indices_boost.yml | 2 - .../rest-api-spec/test/update/10_doc.yml | 1 - .../test/update/11_shard_header.yml | 1 - .../test/update/13_legacy_doc.yml | 1 - .../update/14_shard_header_with_types.yml | 39 ----- .../test/update/15_result_with_types.yml | 52 ------ .../rest-api-spec/test/update/16_noop.yml | 3 - .../test/update/21_doc_upsert_with_types.yml | 39 ----- .../update/24_doc_as_upsert_with_types.yml | 39 ----- .../test/update/41_routing_with_types.yml | 57 ------- .../test/update/61_refresh_with_types.yml | 115 -------------- .../update/81_source_filtering_with_types.yml | 19 --- .../test/update/86_fields_meta_with_types.yml | 33 ---- .../test/update/90_mix_typeless_typeful.yml | 75 --------- .../rest-api/watcher/execute-watch.asciidoc | 1 - .../authorization/alias-privileges.asciidoc | 2 +- .../docs/en/watcher/getting-started.asciidoc | 2 +- .../xpack/ccr/IndexFollowingIT.java | 2 +- .../test/mixed_cluster/10_basic.yml | 3 - 61 files changed, 17 insertions(+), 1551 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/create/11_with_id_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/create/15_without_id_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/create/36_external_version_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/create/41_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/create/61_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/create/71_nested_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/13_basic_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/14_shard_header_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/15_result_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/21_cas_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/27_external_version_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/28_external_gte_version_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/31_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/51_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/61_missing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/delete/70_mix_typeless_typeful.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/13_result_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/21_optype_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/37_external_version_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/38_external_gte_version_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/61_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/41_mapping_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/14_shard_header_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/61_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/90_mix_typeless_typeful.yml diff --git a/distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/RequestsWithoutContentIT.java b/distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/RequestsWithoutContentIT.java index 4d27f156b3826..aa92110a1a43d 100644 --- a/distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/RequestsWithoutContentIT.java +++ b/distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/RequestsWithoutContentIT.java @@ -30,7 +30,7 @@ public class RequestsWithoutContentIT extends ESRestTestCase { public void testIndexMissingBody() throws IOException { ResponseException responseException = expectThrows(ResponseException.class, () -> - client().performRequest(new Request(randomBoolean() ? "POST" : "PUT", "/idx/type/123"))); + client().performRequest(new Request(randomBoolean() ? "POST" : "PUT", "/idx/_doc/123"))); assertResponseException(responseException, "request body is required"); } diff --git a/docs/reference/api-conventions.asciidoc b/docs/reference/api-conventions.asciidoc index 6fbfc5548719e..40421ad34502e 100644 --- a/docs/reference/api-conventions.asciidoc +++ b/docs/reference/api-conventions.asciidoc @@ -335,11 +335,11 @@ parameter like this: [source,console] -------------------------------------------------- -POST /library/_create?refresh +POST /library/_doc?refresh {"title": "Book #1", "rating": 200.1} -POST /library/_create?refresh +POST /library/_doc?refresh {"title": "Book #2", "rating": 1.7} -POST /library/_create?refresh +POST /library/_doc?refresh {"title": "Book #3", "rating": 0.1} GET /_search?filter_path=hits.hits._source&_source=title&sort=rating:desc -------------------------------------------------- diff --git a/docs/reference/cat/count.asciidoc b/docs/reference/cat/count.asciidoc index fe3888708bf1d..f91f452dbe90f 100644 --- a/docs/reference/cat/count.asciidoc +++ b/docs/reference/cat/count.asciidoc @@ -77,7 +77,7 @@ the cluster. GET /_cat/count?v -------------------------------------------------- // TEST[setup:big_twitter] -// TEST[s/^/POST test\/_create\?refresh\n{"test": "test"}\n/] +// TEST[s/^/POST test\/_doc\?refresh\n{"test": "test"}\n/] The API returns the following response: diff --git a/docs/reference/cat/segments.asciidoc b/docs/reference/cat/segments.asciidoc index 7e90c6806590b..bb9788f993c8e 100644 --- a/docs/reference/cat/segments.asciidoc +++ b/docs/reference/cat/segments.asciidoc @@ -106,7 +106,7 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-v] -------------------------------------------------- GET /_cat/segments?v -------------------------------------------------- -// TEST[s/^/PUT \/test\/1?refresh\n{"test":"test"}\nPUT \/test1\/test\/1?refresh\n{"test":"test"}\n/] +// TEST[s/^/PUT \/test\/_doc\/1?refresh\n{"test":"test"}\nPUT \/test1\/_doc\/1?refresh\n{"test":"test"}\n/] The API returns the following response: diff --git a/docs/reference/indices/segments.asciidoc b/docs/reference/indices/segments.asciidoc index bafb3a40892d1..35260624c6e77 100644 --- a/docs/reference/indices/segments.asciidoc +++ b/docs/reference/indices/segments.asciidoc @@ -106,7 +106,7 @@ Contains information about whether high compression was enabled. -------------------------------------------------- GET /test/_segments -------------------------------------------------- -// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/_create\?refresh\n{"test": "test"}\n/] +// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/_doc\?refresh\n{"test": "test"}\n/] ===== Get segment information for several indices @@ -124,7 +124,7 @@ GET /test1,test2/_segments -------------------------------------------------- GET /_segments -------------------------------------------------- -// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/_create\?refresh\n{"test": "test"}\n/] +// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/_doc\?refresh\n{"test": "test"}\n/] The API returns the following response: diff --git a/docs/reference/indices/shard-stores.asciidoc b/docs/reference/indices/shard-stores.asciidoc index c581fe3fa5c1b..894304df7a690 100644 --- a/docs/reference/indices/shard-stores.asciidoc +++ b/docs/reference/indices/shard-stores.asciidoc @@ -136,7 +136,7 @@ for assigned primary and replica shards. GET /_shard_stores?status=green -------------------------------------------------- // TEST[setup:node] -// TEST[s/^/PUT my-index\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST my-index\/_create\?refresh\n{"test": "test"}\n/] +// TEST[s/^/PUT my-index\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST my-index\/_doc\?refresh\n{"test": "test"}\n/] The API returns the following response: diff --git a/qa/os/bats/default/bootstrap_password.bash b/qa/os/bats/default/bootstrap_password.bash index 2e62635b6baad..471d61af0228d 100644 --- a/qa/os/bats/default/bootstrap_password.bash +++ b/qa/os/bats/default/bootstrap_password.bash @@ -128,7 +128,7 @@ SETUP_OK @test "[$GROUP] test elasticsearch-sql-cli" { password=$(grep "PASSWORD elastic = " /tmp/setup-passwords-output-with-bootstrap | sed "s/PASSWORD elastic = //") - curl -s -u "elastic:$password" -H "Content-Type: application/json" -XPUT 'localhost:9200/library/book/1?refresh&pretty' -d'{ + curl -s -u "elastic:$password" -H "Content-Type: application/json" -XPUT 'localhost:9200/library/_doc/1?refresh&pretty' -d'{ "name": "Ender'"'"'s Game", "author": "Orson Scott Card", "release_date": "1985-06-01", diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml index ae7632a2a9c6a..0235a346ad3d7 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml @@ -14,13 +14,13 @@ { "set" : { "field" : "index_type_id", - "value": "{{_index}}/{{_type}}/{{_id}}" + "value": "{{_index}}/{{_id}}" } }, { "append" : { "field" : "metadata", - "value": ["{{_index}}", "{{_type}}", "{{_id}}"] + "value": ["{{_index}}", "{{_id}}"] } } ] @@ -39,8 +39,8 @@ index: test id: 1 - length: { _source: 2 } - - match: { _source.index_type_id: "test/test/1" } - - match: { _source.metadata: ["test", "test", "1"] } + - match: { _source.index_type_id: "test/1" } + - match: { _source.metadata: ["test", "1"] } --- "Test templating": diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/create/11_with_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/create/11_with_id_with_types.yml deleted file mode 100644 index ecc5d0c89b23b..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/create/11_with_id_with_types.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -"Create with ID": - - do: - create: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - - match: { _index: test_1 } - - match: { _type: test } - - match: { _id: "1"} - - match: { _version: 1} - - - do: - get: - index: test_1 - id: 1 - - - match: { _index: test_1 } - - match: { _id: "1"} - - match: { _version: 1} - - match: { _source: { foo: bar }} - - - do: - catch: conflict - create: - index: test_1 - type: test - id: 1 - body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/create/15_without_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/create/15_without_id_with_types.yml deleted file mode 100644 index ab9932819381f..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/create/15_without_id_with_types.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -"Create without ID": - - do: - catch: param - create: - index: test_1 - type: test - body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/create/36_external_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/create/36_external_version_with_types.yml deleted file mode 100644 index cb8c041d7102c..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/create/36_external_version_with_types.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -"External version": - - - do: - catch: bad_request - create: - index: test - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 0 - - - match: { status: 400 } - - match: { error.type: action_request_validation_exception } - - match: { error.reason: "Validation Failed: 1: create operations only support internal versioning. use index instead;" } - - - do: - catch: bad_request - create: - index: test - type: test - id: 2 - body: { foo: bar } - version_type: external - version: 5 - - - match: { status: 400 } - - match: { error.type: action_request_validation_exception } - - match: { error.reason: "Validation Failed: 1: create operations only support internal versioning. use index instead;" } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/create/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/create/41_routing_with_types.yml deleted file mode 100644 index 0e27bb9640c05..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/create/41_routing_with_types.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -"Routing": - - - do: - indices.create: - index: test_1 - body: - settings: - index: - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - - do: - cluster.health: - wait_for_status: green - - - do: - create: - index: test_1 - type: test - id: 1 - routing: 5 - body: { foo: bar } - - - do: - get: - index: test_1 - id: 1 - routing: 5 - stored_fields: [_routing] - - - match: { _id: "1"} - - match: { _routing: "5"} - - - do: - catch: missing - get: - index: test_1 - id: 1 - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/create/61_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/create/61_refresh_with_types.yml deleted file mode 100644 index e24bdf4260340..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/create/61_refresh_with_types.yml +++ /dev/null @@ -1,82 +0,0 @@ ---- -"Refresh": - - - do: - indices.create: - index: test_1 - body: - settings: - index.refresh_interval: -1 - number_of_replicas: 0 - - do: - create: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 1 }} - - - match: { hits.total: 0 } - - - do: - create: - index: test_1 - type: test - id: 2 - refresh: true - body: { foo: bar } - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 2 }} - - - match: { hits.total: 1 } - ---- -"When refresh url parameter is an empty string that means \"refresh immediately\"": - - do: - create: - index: test_1 - type: test - id: 1 - refresh: "" - body: { foo: bar } - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 1 }} - - - match: { hits.total: 1 } - ---- -"refresh=wait_for waits until changes are visible in search": - - do: - index: - index: create_60_refresh_1 - type: test - id: create_60_refresh_id1 - body: { foo: bar } - refresh: wait_for - - is_false: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: create_60_refresh_1 - body: - query: { term: { _id: create_60_refresh_id1 }} - - match: { hits.total: 1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/create/71_nested_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/create/71_nested_with_types.yml deleted file mode 100644 index 1b8c549942730..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/create/71_nested_with_types.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -setup: - - do: - indices.create: - include_type_name: true - index: test_1 - body: - settings: - index.mapping.nested_objects.limit: 2 - mappings: - test_type: - properties: - nested1: - type: nested - ---- -"Indexing a doc with No. nested objects less or equal to index.mapping.nested_objects.limit should succeed": - - - do: - create: - index: test_1 - type: test_type - id: 1 - body: - "nested1" : [ { "foo": "bar" }, { "foo": "bar2" } ] - - match: { _version: 1} - ---- -"Indexing a doc with No. nested objects more than index.mapping.nested_objects.limit should fail": - - - do: - catch: /The number of nested documents has exceeded the allowed limit of \[2\]. This limit can be set by changing the \[index.mapping.nested_objects.limit\] index level setting\./ - create: - index: test_1 - type: test_type - id: 1 - body: - "nested1" : [ { "foo": "bar" }, { "foo": "bar2" }, { "foo": "bar3" } ] diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/11_shard_header.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/11_shard_header.yml index 673897af1d62e..fea1779b99d21 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/11_shard_header.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/11_shard_header.yml @@ -27,7 +27,6 @@ id: 1 - match: { _index: foobar } - - match: { _type: _doc } - match: { _id: "1"} - match: { _version: 2} - match: { _shards.total: 1} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/13_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/13_basic_with_types.yml deleted file mode 100644 index a3671d5ac24b0..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/13_basic_with_types.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -"Basic": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - - match: { _version: 1 } - - - do: - delete: - index: test_1 - type: test - id: 1 - - - match: { _version: 2 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/14_shard_header_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/14_shard_header_with_types.yml deleted file mode 100644 index d1bb4c0df347d..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/14_shard_header_with_types.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -"Delete check shard header": - - - do: - indices.create: - index: foobar - body: - settings: - number_of_shards: "1" - number_of_replicas: "0" - - - do: - cluster.health: - wait_for_status: green - - - do: - index: - index: foobar - type: baz - id: 1 - body: { foo: bar } - - - do: - delete: - index: foobar - type: baz - id: 1 - - - match: { _index: foobar } - - match: { _type: baz } - - match: { _id: "1"} - - match: { _version: 2} - - match: { _shards.total: 1} - - match: { _shards.successful: 1} - - match: { _shards.failed: 0} - - is_false: _shards.pending diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/15_result_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/15_result_with_types.yml deleted file mode 100644 index d01e88be8ad0b..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/15_result_with_types.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -"Delete result field": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - - do: - delete: - index: test_1 - type: test - id: 1 - - - match: { result: deleted } - - - do: - catch: missing - delete: - index: test_1 - type: test - id: 1 - - - match: { result: not_found } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/21_cas_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/21_cas_with_types.yml deleted file mode 100644 index ef352a9bad6b1..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/21_cas_with_types.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -"Internal version": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - - match: { _seq_no: 0 } - - - do: - catch: conflict - delete: - index: test_1 - type: test - id: 1 - if_seq_no: 2 - if_primary_term: 1 - - - do: - delete: - index: test_1 - type: test - id: 1 - if_seq_no: 0 - if_primary_term: 1 - - - match: { _seq_no: 1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/27_external_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/27_external_version_with_types.yml deleted file mode 100644 index 453d64d85bbc1..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/27_external_version_with_types.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -"External version": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 5 - - - match: { _version: 5} - - - do: - catch: conflict - delete: - index: test_1 - type: test - id: 1 - version_type: external - version: 4 - - - do: - delete: - index: test_1 - type: test - id: 1 - version_type: external - version: 6 - - - match: { _version: 6} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/28_external_gte_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/28_external_gte_version_with_types.yml deleted file mode 100644 index 70f78c17faa63..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/28_external_gte_version_with_types.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- -"External GTE version": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external_gte - version: 5 - - - match: { _version: 5} - - - do: - catch: conflict - delete: - index: test_1 - type: test - id: 1 - version_type: external_gte - version: 4 - - - do: - delete: - index: test_1 - type: test - id: 1 - version_type: external_gte - version: 6 - - - match: { _version: 6} - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external_gte - version: 6 - - - match: { _version: 6} - - - do: - delete: - index: test_1 - type: test - id: 1 - version_type: external_gte - version: 6 - - - match: { _version: 6} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/31_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/31_routing_with_types.yml deleted file mode 100644 index 6f67b3a03f401..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/31_routing_with_types.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -"Routing": - - - do: - indices.create: - index: test_1 - body: - settings: - number_of_shards: 5 - - do: - index: - index: test_1 - type: test - id: 1 - routing: 5 - body: { foo: bar } - - - do: - catch: missing - delete: - index: test_1 - type: test - id: 1 - routing: 4 - - - do: - delete: - index: test_1 - type: test - id: 1 - routing: 5 - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/51_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/51_refresh_with_types.yml deleted file mode 100644 index a901c1033f7c0..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/51_refresh_with_types.yml +++ /dev/null @@ -1,148 +0,0 @@ ---- -"Refresh": - - - do: - indices.create: - index: test_1 - body: - settings: - refresh_interval: -1 - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - do: - cluster.health: - wait_for_status: green - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - refresh: true - -# If you wonder why this document get 3 as an id instead of 2, it is because the -# current routing algorithm would route 1 and 2 to the same shard while we need -# them to be different for this test to pass - - do: - index: - index: test_1 - type: test - id: 3 - body: { foo: bar } - refresh: true - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { terms: { _id: [1,3] }} - - - match: { hits.total: 2 } - - - do: - delete: - index: test_1 - type: test - id: 1 - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { terms: { _id: [1,3] }} - - - match: { hits.total: 2 } - - - do: - delete: - index: test_1 - type: test - id: 3 - refresh: true - -# If a replica shard where doc 1 is located gets initialized at this point, doc 1 -# won't be found by the following search as the shard gets automatically refreshed -# right before getting started. This is why this test only works with 0 replicas. - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { terms: { _id: [1,3] }} - - - match: { hits.total: 1 } - ---- -"When refresh url parameter is an empty string that means \"refresh immediately\"": - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - refresh: true - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 1 }} - - match: { hits.total: 1 } - - - do: - delete: - index: test_1 - type: test - id: 1 - refresh: "" - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 1 }} - - match: { hits.total: 0 } - ---- -"refresh=wait_for waits until changes are visible in search": - - do: - index: - index: delete_50_refresh_1 - type: test - id: delete_50_refresh_id1 - body: { foo: bar } - refresh: true - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: delete_50_refresh_1 - body: - query: { term: { _id: delete_50_refresh_id1 }} - - match: { hits.total: 1 } - - - do: - delete: - index: delete_50_refresh_1 - type: test - id: delete_50_refresh_id1 - refresh: wait_for - - is_false: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: delete_50_refresh_1 - body: - query: { term: { _id: delete_50_refresh_id1 }} - - match: { hits.total: 0 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/61_missing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/61_missing_with_types.yml deleted file mode 100644 index 9cfdb48ae20aa..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/61_missing_with_types.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -"Missing document with catch": - - - do: - catch: missing - delete: - index: test_1 - type: test - id: 1 - ---- -"Missing document with ignore": - - - do: - delete: - index: test_1 - type: test - id: 1 - ignore: 404 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/70_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/70_mix_typeless_typeful.yml deleted file mode 100644 index 52d967e80f39e..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/70_mix_typeless_typeful.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -"DELETE with typeless API on an index that has types": - - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - - do: - index: - index: index - type: not_doc - id: 1 - body: { foo: bar } - - - do: - delete: - index: index - id: 1 - - - match: { _index: "index" } - - match: { _type: "_doc" } - - match: { _id: "1"} - - match: { _version: 2} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml index bae38ab41cbc2..06d9eda9b2732 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml @@ -10,7 +10,6 @@ body: { foo: bar } - match: { _index: test-weird-index-中文 } - - match: { _type: _doc } - match: { _id: "1"} - match: { _version: 1} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml deleted file mode 100644 index 1617cd9e09369..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -"Index with ID": - - - do: - index: - index: test-weird-index-中文 - type: weird.type - id: 1 - body: { foo: bar } - - - match: { _index: test-weird-index-中文 } - - match: { _type: weird.type } - - match: { _id: "1"} - - match: { _version: 1} - - - do: - get: - index: test-weird-index-中文 - id: 1 - - - match: { _index: test-weird-index-中文 } - - match: { _id: "1"} - - match: { _version: 1} - - match: { _source: { foo: bar }} - - - do: - catch: bad_request - index: - index: idx - type: type - id: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/13_result_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/13_result_with_types.yml deleted file mode 100644 index 45ebe0bbd3dc1..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/13_result_with_types.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -"Index result field": - - - do: - index: - index: test_index - type: test - id: 1 - body: { foo: bar } - - - match: { result: created } - - - do: - index: - index: test_index - type: test - id: 1 - body: { foo: bar } - op_type: index - - - match: { result: updated } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml deleted file mode 100644 index 56b1ee1fe7b08..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -"Index without ID": - - - do: - index: - index: test_1 - type: test - body: { foo: bar } - - - is_true: _id - - match: { _index: test_1 } - - match: { _type: test } - - match: { _version: 1 } - - set: { _id: id } - - - do: - get: - index: test_1 - id: '$id' - - - match: { _index: test_1 } - - match: { _id: $id } - - match: { _version: 1 } - - match: { _source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/21_optype_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/21_optype_with_types.yml deleted file mode 100644 index 60ae26d46d07d..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/21_optype_with_types.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -"Optype": - - - do: - index: - index: test_1 - type: test - id: 1 - op_type: create - body: { foo: bar } - - - do: - catch: conflict - index: - index: test_1 - type: test - id: 1 - op_type: create - body: { foo: bar } - - - do: - index: - index: test_1 - type: test - id: 1 - op_type: index - body: { foo: bar } - - - match: { _version: 2 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/37_external_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/37_external_version_with_types.yml deleted file mode 100644 index f17e6b749319d..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/37_external_version_with_types.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- -"External version": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 0 - - - match: { _version: 0 } - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 5 - - - match: { _version: 5 } - - - do: - catch: conflict - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 5 - - - do: - catch: conflict - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 0 - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 6 - - - match: { _version: 6} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/38_external_gte_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/38_external_gte_version_with_types.yml deleted file mode 100644 index dccbe02ea1400..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/38_external_gte_version_with_types.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -"External GTE version": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external_gte - version: 0 - - - match: { _version: 0} - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external_gte - version: 5 - - - match: { _version: 5} - - - do: - catch: conflict - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external_gte - version: 0 - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar2 } - version_type: external_gte - version: 5 - - - match: { _version: 5} - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar2 } - version_type: external_gte - version: 6 - - - match: { _version: 6} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml deleted file mode 100644 index 4032ea1226829..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -"Routing": - - - do: - indices.create: - index: test_1 - body: - settings: - index: - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - - do: - cluster.health: - wait_for_status: green - - - do: - index: - index: test_1 - type: test - id: 1 - routing: 5 - body: { foo: bar } - - - do: - get: - index: test_1 - id: 1 - routing: 5 - stored_fields: [_routing] - - - match: { _id: "1"} - - match: { _routing: "5"} - - - do: - catch: missing - get: - index: test_1 - id: 1 - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/61_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/61_refresh_with_types.yml deleted file mode 100644 index be44cafd43020..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/61_refresh_with_types.yml +++ /dev/null @@ -1,83 +0,0 @@ ---- -"Refresh": - - - do: - indices.create: - index: test_1 - body: - settings: - index.refresh_interval: -1 - number_of_replicas: 0 - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 1 }} - - - match: { hits.total: 0 } - - - do: - index: - index: test_1 - type: test - id: 2 - refresh: true - body: { foo: bar } - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 2 }} - - - match: { hits.total: 1 } - ---- -"When refresh url parameter is an empty string that means \"refresh immediately\"": - - do: - index: - index: test_1 - type: test - id: 1 - refresh: "" - body: { foo: bar } - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 1 }} - - - match: { hits.total: 1 } - ---- -"refresh=wait_for waits until changes are visible in search": - - do: - index: - index: index_60_refresh_1 - type: test - id: index_60_refresh_id1 - body: { foo: bar } - refresh: wait_for - - is_false: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: index_60_refresh_1 - body: - query: { term: { _id: index_60_refresh_id1 }} - - match: { hits.total: 1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.flush/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.flush/10_basic.yml index 213b3c587363c..ff99d20e9b761 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.flush/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.flush/10_basic.yml @@ -42,7 +42,6 @@ - do: index: index: test - type: doc id: 1 body: { "message": "a long message to make a periodic flush happen after this index operation" } - do: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml index 9a364b5296bbe..185ac1d09fb01 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml @@ -16,7 +16,6 @@ - do: index: index: logs-1 - type: test id: "1" body: { "foo": "hello world" } # make this doc visible in index stats diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/20_max_doc_condition.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/20_max_doc_condition.yml index 50409fb983c4f..161c7c4c446fa 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/20_max_doc_condition.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/20_max_doc_condition.yml @@ -14,7 +14,6 @@ - do: index: index: logs-1 - type: test id: "1" body: { "foo": "hello world" } refresh: true @@ -35,7 +34,6 @@ - do: index: index: logs-1 - type: test id: "2" body: { "foo": "hello world" } refresh: true diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/30_max_size_condition.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/30_max_size_condition.yml index 08bae450ea756..14ed0877e4952 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/30_max_size_condition.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/30_max_size_condition.yml @@ -14,7 +14,6 @@ - do: index: index: logs-1 - type: doc id: "1" body: { "foo": "hello world" } refresh: true diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/41_mapping_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/41_mapping_with_types.yml deleted file mode 100644 index 8522b87b0b3f9..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/41_mapping_with_types.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- -"Typeless mapping": - - - do: - indices.create: - index: logs-1 - body: - aliases: - logs_search: {} - - # index first document and wait for refresh - - do: - index: - index: logs-1 - type: test - id: "1" - body: { "foo": "hello world" } - refresh: true - - # index second document and wait for refresh - - do: - index: - index: logs-1 - type: test - id: "2" - body: { "foo": "hello world" } - refresh: true - - # perform alias rollover with new typeless mapping - - do: - indices.rollover: - include_type_name: true - alias: "logs_search" - body: - conditions: - max_docs: 2 - mappings: - _doc: - properties: - foo2: - type: keyword - - - match: { conditions: { "[max_docs: 2]": true } } - - match: { rolled_over: true } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.segments/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.segments/10_basic.yml index 37602774474a1..bda7788354b47 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.segments/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.segments/10_basic.yml @@ -25,7 +25,6 @@ - do: index: index: index1 - type: type body: { foo: bar } refresh: true @@ -53,7 +52,6 @@ - do: index: index: index1 - type: type body: { foo: bar } refresh: true diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shard_stores/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shard_stores/10_basic.yml index db90bf29624a1..227ca2662f2b6 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shard_stores/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shard_stores/10_basic.yml @@ -24,7 +24,6 @@ - do: index: index: index1 - type: type body: { foo: bar } refresh: true @@ -59,13 +58,11 @@ - do: index: index: index1 - type: type body: { foo: bar } refresh: true - do: index: index: index2 - type: type body: { foo: bar } refresh: true - do: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/300_sequence_numbers.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/300_sequence_numbers.yml index 61bbfdcc267ac..56871bfe02645 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/300_sequence_numbers.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/300_sequence_numbers.yml @@ -6,7 +6,6 @@ setup: - do: index: index: test_1 - type: test id: 1 body: { foo: foo } @@ -14,7 +13,6 @@ setup: - do: index: index: test_1 - type: test id: 1 body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/40_indices_boost.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/40_indices_boost.yml index 614fedf7fc82e..fffef33cf65b4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/40_indices_boost.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/40_indices_boost.yml @@ -19,14 +19,12 @@ setup: - do: index: index: test_1 - type: test id: 1 body: { foo: bar } - do: index: index: test_2 - type: test id: 1 body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/10_doc.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/10_doc.yml index 13788af7e35c5..dda545d56e350 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/10_doc.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/10_doc.yml @@ -23,7 +23,6 @@ one: 3 - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - match: { _version: 2 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/11_shard_header.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/11_shard_header.yml index 5782c8286fb60..5a0dc0485b103 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/11_shard_header.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/11_shard_header.yml @@ -30,7 +30,6 @@ foo: baz - match: { _index: foobar } - - match: { _type: _doc } - match: { _id: "1"} - match: { _version: 2} - match: { _shards.total: 1} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/13_legacy_doc.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/13_legacy_doc.yml index 08f3457400d4f..a97c68ba6ee3f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/13_legacy_doc.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/13_legacy_doc.yml @@ -21,7 +21,6 @@ one: 3 - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - match: { _version: 2 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/14_shard_header_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/14_shard_header_with_types.yml deleted file mode 100644 index eb2e4ff9a9117..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/14_shard_header_with_types.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -"Update check shard header": - - - do: - indices.create: - index: foobar - body: - settings: - number_of_shards: "1" - number_of_replicas: "0" - - - do: - cluster.health: - wait_for_status: green - - - do: - index: - index: foobar - type: baz - id: 1 - body: { foo: bar } - - - do: - update: - index: foobar - type: baz - id: 1 - body: - doc: - foo: baz - - - match: { _index: foobar } - - match: { _type: baz } - - match: { _id: "1"} - - match: { _version: 2} - - match: { _shards.total: 1} - - match: { _shards.successful: 1} - - match: { _shards.failed: 0} - - is_false: _shards.pending diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml deleted file mode 100644 index 9adada6d54b4f..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -"Update result field": - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar } - doc_as_upsert: true - - - match: { _version: 1 } - - match: { result: created } - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar } - doc_as_upsert: true - - - match: { _version: 1 } - - match: { result: noop } - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar } - doc_as_upsert: true - detect_noop: false - - - match: { _version: 2 } - - match: { result: updated } - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: baz } - doc_as_upsert: true - detect_noop: true - - - match: { _version: 3 } - - match: { result: updated } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/16_noop.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/16_noop.yml index 0f8a1b10d12b2..12f118ac28d01 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/16_noop.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/16_noop.yml @@ -6,7 +6,6 @@ - do: index: index: test_1 - type: test id: 1 body: { foo: bar } @@ -18,7 +17,6 @@ - do: update: index: test_1 - type: test id: 1 body: doc: { foo: bar } @@ -31,7 +29,6 @@ - do: update: index: test_1 - type: test id: 1 body: doc: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml deleted file mode 100644 index 5e702c5a2b6bd..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -"Doc upsert": - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar, count: 1 } - upsert: { foo: baz } - - - do: - get: - index: test_1 - id: 1 - - - match: { _source.foo: baz } - - is_false: _source.count - - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar, count: 1 } - upsert: { foo: baz } - - - do: - get: - index: test_1 - id: 1 - - - match: { _source.foo: bar } - - match: { _source.count: 1 } - - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml deleted file mode 100644 index 8331ad64e100c..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -"Doc as upsert": - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar, count: 1 } - doc_as_upsert: true - - - do: - get: - index: test_1 - id: 1 - - - match: { _source.foo: bar } - - match: { _source.count: 1 } - - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { count: 2 } - doc_as_upsert: true - - - do: - get: - index: test_1 - id: 1 - - - match: { _source.foo: bar } - - match: { _source.count: 2 } - - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml deleted file mode 100644 index 5bf883c031013..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -"Routing": - - - do: - indices.create: - index: test_1 - body: - settings: - index: - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - - do: - cluster.health: - wait_for_status: green - - - do: - update: - index: test_1 - type: test - id: 1 - routing: 5 - body: - doc: { foo: baz } - upsert: { foo: bar } - - - do: - get: - index: test_1 - id: 1 - routing: 5 - stored_fields: _routing - - - match: { _routing: "5"} - - - do: - catch: missing - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: baz } - - - do: - update: - index: test_1 - type: test - id: 1 - routing: 5 - _source: foo - body: - doc: { foo: baz } - - - match: { get._source.foo: baz } - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/61_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/61_refresh_with_types.yml deleted file mode 100644 index be2d9f9f7969e..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/61_refresh_with_types.yml +++ /dev/null @@ -1,115 +0,0 @@ ---- -"Refresh": - - - do: - indices.create: - index: test_1 - body: - settings: - index.refresh_interval: -1 - number_of_replicas: 0 - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: baz } - upsert: { foo: bar } - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 1 }} - - - match: { hits.total: 0 } - - - do: - update: - index: test_1 - type: test - id: 2 - refresh: true - body: - doc: { foo: baz } - upsert: { foo: bar } - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { _id: 2 }} - - - match: { hits.total: 1 } - ---- -"When refresh url parameter is an empty string that means \"refresh immediately\"": - - do: - index: - index: test_1 - type: test - id: 1 - refresh: true - body: { foo: bar } - - is_true: forced_refresh - - - do: - update: - index: test_1 - type: test - id: 1 - refresh: "" - body: - doc: {cat: dog} - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: test_1 - body: - query: { term: { cat: dog }} - - - match: { hits.total: 1 } - ---- -"refresh=wait_for waits until changes are visible in search": - - do: - index: - index: update_60_refresh_1 - type: test - id: update_60_refresh_id1 - body: { foo: bar } - refresh: true - - is_true: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: update_60_refresh_1 - body: - query: { term: { _id: update_60_refresh_id1 }} - - match: { hits.total: 1 } - - - do: - update: - index: update_60_refresh_1 - type: test - id: update_60_refresh_id1 - refresh: wait_for - body: - doc: { test: asdf } - - is_false: forced_refresh - - - do: - search: - rest_total_hits_as_int: true - index: update_60_refresh_1 - body: - query: { match: { test: asdf } } - - match: { hits.total: 1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml deleted file mode 100644 index 4bb22e6b8012e..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -"Source filtering": - - - do: - update: - index: test_1 - type: test - id: 1 - _source: [foo, bar] - body: - doc: { foo: baz } - upsert: { foo: bar } - - - match: { get._source.foo: bar } - - is_false: get._source.bar - -# TODO: -# -# - Add _routing diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml deleted file mode 100644 index f7791d0986399..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -"Metadata Fields": - - - skip: - version: "all" - reason: "Update doesn't return metadata fields, waiting for #3259" - - - do: - indices.create: - index: test_1 - - - do: - update: - index: test_1 - type: test - id: 1 - parent: 5 - fields: [ _routing ] - body: - doc: { foo: baz } - upsert: { foo: bar } - - - match: { get._routing: "5" } - - - do: - get: - index: test_1 - type: test - id: 1 - parent: 5 - stored_fields: [ _routing ] - - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/90_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/90_mix_typeless_typeful.yml deleted file mode 100644 index a76ed8a65933e..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/90_mix_typeless_typeful.yml +++ /dev/null @@ -1,75 +0,0 @@ ---- -"Update with typeless API on an index that has types": - - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - - do: - index: - index: index - type: not_doc - id: 1 - body: { foo: bar } - - - do: - update: - index: index - id: 1 - body: - doc: - foo: baz - - - do: - get: - index: index - id: 1 - - - match: { _source.foo: baz } - ---- -"Update call that introduces new field mappings": - - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - - do: - index: - index: index - type: not_doc - id: 1 - body: { foo: bar } - - - do: - update: - index: index - id: 1 - body: - doc: - foo: baz - new_field: value - - do: - get: # using typeful API on purpose - index: index - id: 1 - - - match: { _index: "index" } - - match: { _id: "1" } - - match: { _version: 2} - - match: { _source.foo: baz } - - match: { _source.new_field: value } diff --git a/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc index 3a98a4c547f95..c2db6667f604e 100644 --- a/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc @@ -259,7 +259,6 @@ This is an example of the output: "index": { "response": { "index": "test", - "type": "_doc", "version": 1, "created": true, "result": "created", diff --git a/x-pack/docs/en/security/authorization/alias-privileges.asciidoc b/x-pack/docs/en/security/authorization/alias-privileges.asciidoc index 11183a7bbe5a4..16216192cd46b 100644 --- a/x-pack/docs/en/security/authorization/alias-privileges.asciidoc +++ b/x-pack/docs/en/security/authorization/alias-privileges.asciidoc @@ -29,7 +29,7 @@ The user attempts to retrieve a document from `current_year`: ------------------------------------------------------------------------------- GET /current_year/_doc/1 ------------------------------------------------------------------------------- -// TEST[s/^/PUT 2015\n{"aliases": {"current_year": {}}}\nPUT 2015\/event\/1\n{}\n/] +// TEST[s/^/PUT 2015\n{"aliases": {"current_year": {}}}\nPUT 2015\/_doc\/1\n{}\n/] The above request gets rejected, although the user has `read` privilege on the concrete index that the `current_year` alias points to. The correct permission diff --git a/x-pack/docs/en/watcher/getting-started.asciidoc b/x-pack/docs/en/watcher/getting-started.asciidoc index 7001097aab12e..bf07015a3155d 100644 --- a/x-pack/docs/en/watcher/getting-started.asciidoc +++ b/x-pack/docs/en/watcher/getting-started.asciidoc @@ -117,7 +117,7 @@ adds a 404 error to the `logs` index: [source,console] -------------------------------------------------- -POST logs/event +POST logs/_doc { "timestamp" : "2015-05-17T18:12:07.613Z", "request" : "GET index.html", diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java index 780258168e918..5ff897807496f 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java @@ -408,7 +408,7 @@ public void testNoMappingDefined() throws Exception { pauseFollow("index2"); MappingMetaData mappingMetaData = followerClient().admin().indices().prepareGetMappings("index2").get().getMappings() - .get("index2").get("doc"); + .get("index2").get("_doc"); assertThat(XContentMapValues.extractValue("properties.f.type", mappingMetaData.sourceAsMap()), equalTo("long")); assertThat(XContentMapValues.extractValue("properties.k", mappingMetaData.sourceAsMap()), nullValue()); } diff --git a/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/10_basic.yml b/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/10_basic.yml index 0cd2a9bf1faa1..d24c118971187 100644 --- a/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/10_basic.yml +++ b/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/10_basic.yml @@ -15,14 +15,12 @@ - do: index: index: upgraded_scroll - type: test id: 42 body: { foo: 1 } - do: index: index: upgraded_scroll - type: test id: 43 body: { foo: 2 } @@ -47,6 +45,5 @@ - do: index: index: scroll_index - type: doc id: 1 body: { value: $scroll_id } From 4a61b4bfda72c4225e8e041dd207c6f17a696037 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 8 Oct 2019 12:46:40 +0100 Subject: [PATCH 27/35] tests --- .../main/resources/rest-api-spec/test/index/15_without_id.yml | 1 - .../resources/rest-api-spec/test/indices.rollover/10_basic.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml index 6471856c6df1c..2f675014cfa46 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml @@ -10,7 +10,6 @@ - is_true: _id - match: { _index: test_1 } - - match: { _type: _doc } - match: { _version: 1 } - set: { _id: id } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml index 185ac1d09fb01..e989577c98d42 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml @@ -56,7 +56,6 @@ - do: index: index: logs-000002 - type: test id: "2" body: { "foo": "hello world" } From d34189f841d222d79488ab981b5ae1261796aeba Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 8 Oct 2019 12:52:49 +0100 Subject: [PATCH 28/35] bats --- qa/os/bats/upgrade/80_upgrade.bats | 18 +++++++++--------- qa/os/bats/utils/utils.bash | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/qa/os/bats/upgrade/80_upgrade.bats b/qa/os/bats/upgrade/80_upgrade.bats index 61d1d7d39de1b..764b8ee6d991a 100644 --- a/qa/os/bats/upgrade/80_upgrade.bats +++ b/qa/os/bats/upgrade/80_upgrade.bats @@ -78,21 +78,21 @@ setup() { } @test "[UPGRADE] index some documents into a few indexes" { - curl -s -H "Content-Type: application/json" -XPOST localhost:9200/library/book/1?pretty -d '{ + curl -s -H "Content-Type: application/json" -XPOST localhost:9200/library/_doc/1?pretty -d '{ "title": "Elasticsearch - The Definitive Guide" }' - curl -s -H "Content-Type: application/json" -XPOST localhost:9200/library/book/2?pretty -d '{ + curl -s -H "Content-Type: application/json" -XPOST localhost:9200/library/_doc/2?pretty -d '{ "title": "Brave New World" }' - curl -s -H "Content-Type: application/json" -XPOST localhost:9200/library2/book/1?pretty -d '{ + curl -s -H "Content-Type: application/json" -XPOST localhost:9200/library2/_doc/1?pretty -d '{ "title": "The Left Hand of Darkness" }' } @test "[UPGRADE] verify that the documents are there" { - curl -s localhost:9200/library/book/1?pretty | grep Elasticsearch - curl -s localhost:9200/library/book/2?pretty | grep World - curl -s localhost:9200/library2/book/1?pretty | grep Darkness + curl -s localhost:9200/library/_doc/1?pretty | grep Elasticsearch + curl -s localhost:9200/library/_doc/2?pretty | grep World + curl -s localhost:9200/library2/_doc/1?pretty | grep Darkness } @test "[UPGRADE] stop old version" { @@ -117,9 +117,9 @@ setup() { } @test "[UPGRADE] verify that the documents are there after restart" { - curl -s localhost:9200/library/book/1?pretty | grep Elasticsearch - curl -s localhost:9200/library/book/2?pretty | grep World - curl -s localhost:9200/library2/book/1?pretty | grep Darkness + curl -s localhost:9200/library/_doc/1?pretty | grep Elasticsearch + curl -s localhost:9200/library/_doc/2?pretty | grep World + curl -s localhost:9200/library2/_doc/1?pretty | grep Darkness } @test "[UPGRADE] cleanup version under test" { diff --git a/qa/os/bats/utils/utils.bash b/qa/os/bats/utils/utils.bash index ac03daaa70b49..3b9ba59536763 100644 --- a/qa/os/bats/utils/utils.bash +++ b/qa/os/bats/utils/utils.bash @@ -531,12 +531,12 @@ run_elasticsearch_tests() { [ "$status" -eq 0 ] echo "$output" | grep -w "green" - curl -s -H "Content-Type: application/json" -XPOST 'http://localhost:9200/library/book/1?refresh=true&pretty' -d '{ + curl -s -H "Content-Type: application/json" -XPOST 'http://localhost:9200/library/_doc/1?refresh=true&pretty' -d '{ "title": "Book #1", "pages": 123 }' - curl -s -H "Content-Type: application/json" -XPOST 'http://localhost:9200/library/book/2?refresh=true&pretty' -d '{ + curl -s -H "Content-Type: application/json" -XPOST 'http://localhost:9200/library/_doc/2?refresh=true&pretty' -d '{ "title": "Book #2", "pages": 456 }' From 75d3c8e40894c18311926156f32ab32a52aed052 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 8 Oct 2019 14:00:01 +0100 Subject: [PATCH 29/35] tests --- .../java/org/elasticsearch/client/CrudIT.java | 2 +- .../java/org/elasticsearch/client/TasksIT.java | 16 ++++++++-------- .../ingest/common/ForEachProcessorTests.java | 3 --- qa/os/bats/default/certgen.bash | 2 +- .../integration/IndexPrivilegeTests.java | 6 +++--- .../rest-api-spec/test/roles/11_idx_arrays.yml | 2 -- .../10_small_users_one_index.yml | 2 -- .../rest-api-spec/test/snapshot/10_basic.yml | 1 - 8 files changed, 13 insertions(+), 21 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java index 41d370c1837a9..8abb2fc5b5fcc 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java @@ -466,7 +466,7 @@ public void testUpdate() throws IOException { ElasticsearchStatusException exception = expectThrows(ElasticsearchStatusException.class, () -> execute(updateRequest, highLevelClient()::update, highLevelClient()::updateAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); - assertEquals("Elasticsearch exception [type=document_missing_exception, reason=[_doc][does_not_exist]: document missing]", + assertEquals("Elasticsearch exception [type=document_missing_exception, reason=[does_not_exist]: document missing]", exception.getMessage()); } { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java index 5dc168eadfe5e..f0515c0d9e2d1 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java @@ -71,7 +71,7 @@ public void testListTasks() throws IOException { } assertTrue("List tasks were not found", listTasksFound); } - + public void testGetValidTask() throws Exception { // Run a Reindex to create a task @@ -86,7 +86,7 @@ public void testGetValidTask() throws Exception { .add(new IndexRequest(sourceIndex).id("2").source(Collections.singletonMap("foo2", "bar2"), XContentType.JSON)) .setRefreshPolicy(RefreshPolicy.IMMEDIATE); assertEquals(RestStatus.OK, highLevelClient().bulk(bulkRequest, RequestOptions.DEFAULT).status()); - + // (need to use low level client because currently high level client // doesn't support async return of task id - needs // https://github.com/elastic/elasticsearch/pull/35202 ) @@ -105,24 +105,24 @@ public void testGetValidTask() throws Exception { gtr.setWaitForCompletion(randomBoolean()); Optional getTaskResponse = execute(gtr, highLevelClient().tasks()::get, highLevelClient().tasks()::getAsync); assertTrue(getTaskResponse.isPresent()); - GetTaskResponse taskResponse = getTaskResponse.get(); + GetTaskResponse taskResponse = getTaskResponse.get(); if (gtr.getWaitForCompletion()) { assertTrue(taskResponse.isCompleted()); } TaskInfo info = taskResponse.getTaskInfo(); assertTrue(info.isCancellable()); - assertEquals("reindex from [source1] to [dest][_doc]", info.getDescription()); + assertEquals("reindex from [source1] to [dest]", info.getDescription()); assertEquals("indices:data/write/reindex", info.getAction()); if (taskResponse.isCompleted() == false) { assertBusy(ReindexIT.checkCompletionStatus(client(), taskId.toString())); } - } - + } + public void testGetInvalidTask() throws IOException { // Check 404s are returned as empty Optionals - GetTaskRequest gtr = new GetTaskRequest("doesNotExistNodeName", 123); + GetTaskRequest gtr = new GetTaskRequest("doesNotExistNodeName", 123); Optional getTaskResponse = execute(gtr, highLevelClient().tasks()::get, highLevelClient().tasks()::getAsync); - assertFalse(getTaskResponse.isPresent()); + assertFalse(getTaskResponse.isPresent()); } public void testCancelTasks() throws IOException { diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java index 894cab1295bee..cda203f660093 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java @@ -107,7 +107,6 @@ public void testMetaDataAvailable() throws Exception { TestProcessor innerProcessor = new TestProcessor(id -> { id.setFieldValue("_ingest._value.index", id.getSourceAndMetadata().get("_index")); - id.setFieldValue("_ingest._value.type", id.getSourceAndMetadata().get("_type")); id.setFieldValue("_ingest._value.id", id.getSourceAndMetadata().get("_id")); }); ForEachProcessor processor = new ForEachProcessor("_tag", "values", innerProcessor, false); @@ -115,10 +114,8 @@ public void testMetaDataAvailable() throws Exception { assertThat(innerProcessor.getInvokedCounter(), equalTo(2)); assertThat(ingestDocument.getFieldValue("values.0.index", String.class), equalTo("_index")); - assertThat(ingestDocument.getFieldValue("values.0.type", String.class), equalTo("_type")); assertThat(ingestDocument.getFieldValue("values.0.id", String.class), equalTo("_id")); assertThat(ingestDocument.getFieldValue("values.1.index", String.class), equalTo("_index")); - assertThat(ingestDocument.getFieldValue("values.1.type", String.class), equalTo("_type")); assertThat(ingestDocument.getFieldValue("values.1.id", String.class), equalTo("_id")); } diff --git a/qa/os/bats/default/certgen.bash b/qa/os/bats/default/certgen.bash index bcefb9303c86d..0f637f7c34090 100644 --- a/qa/os/bats/default/certgen.bash +++ b/qa/os/bats/default/certgen.bash @@ -382,7 +382,7 @@ DATA_SETTINGS testIndex=$(sudo curl -u "elastic:changeme" \ -H "Content-Type: application/json" \ --cacert "$ESCONFIG/certs/ca/ca.crt" \ - -XPOST "https://127.0.0.1:9200/books/0?refresh" \ + -XPOST "https://127.0.0.1:9200/books/_doc/0?refresh" \ -d '{"title": "Elasticsearch The Definitive Guide"}') debug_collect_logs diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java index 8c0cd71e6d89d..f0d2b3ad14a67 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java @@ -141,7 +141,7 @@ protected String configUsersRoles() { public void insertBaseDocumentsAsAdmin() throws Exception { // indices: a,b,c,abc for (String index : new String[] {"a", "b", "c", "abc"}) { - Request request = new Request("PUT", "/" + index + "/foo/1"); + Request request = new Request("PUT", "/" + index + "/_doc/1"); request.setJsonEntity(jsonDoc); request.addParameter("refresh", "true"); assertAccessIsAllowed("admin", request); @@ -522,10 +522,10 @@ private void assertUserExecutes(String user, String action, String index, boolea case "index" : if (userIsAllowed) { assertAccessIsAllowed(user, "PUT", "/" + index + "/_doc/321", "{ \"foo\" : \"bar\" }"); - assertAccessIsAllowed(user, "POST", "/" + index + "/_doc/321/_update", "{ \"doc\" : { \"foo\" : \"baz\" } }"); + assertAccessIsAllowed(user, "POST", "/" + index + "/_update/321", "{ \"doc\" : { \"foo\" : \"baz\" } }"); } else { assertAccessIsDenied(user, "PUT", "/" + index + "/_doc/321", "{ \"foo\" : \"bar\" }"); - assertAccessIsDenied(user, "POST", "/" + index + "/_doc/321/_update", "{ \"doc\" : { \"foo\" : \"baz\" } }"); + assertAccessIsDenied(user, "POST", "/" + index + "/_update/321", "{ \"doc\" : { \"foo\" : \"baz\" } }"); } break; diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yml index 61b3070f9df4f..7b576d25037ed 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yml @@ -21,7 +21,6 @@ teardown: - do: delete: index: foo - type: doc id: 1 ignore: 404 @@ -56,7 +55,6 @@ teardown: - do: index: index: foo - type: doc id: 1 body: { foo: bar } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/set_security_user/10_small_users_one_index.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/set_security_user/10_small_users_one_index.yml index efa74c1d9b866..80a1ea12dec3d 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/set_security_user/10_small_users_one_index.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/set_security_user/10_small_users_one_index.yml @@ -97,7 +97,6 @@ teardown: Authorization: "Basic am9lOngtcGFjay10ZXN0LXBhc3N3b3Jk" index: index: shared_logs - type: type id: 1 pipeline: "my_pipeline" body: > @@ -109,7 +108,6 @@ teardown: Authorization: "Basic am9objp4LXBhY2stdGVzdC1wYXNzd29yZA==" index: index: shared_logs - type: type id: 2 pipeline: "my_pipeline" body: > diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/snapshot/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/snapshot/10_basic.yml index fd0aee19cfbe7..58ace059d04c1 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/snapshot/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/snapshot/10_basic.yml @@ -28,7 +28,6 @@ setup: - do: index: index: test_index - type: _doc id: 1 body: { foo: bar } - do: From 9e2d404697791948ad76ff2f74a834079de1d16a Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 8 Oct 2019 14:56:52 +0100 Subject: [PATCH 30/35] tests --- .../rest-api-spec/test/painless/15_update.yml | 4 ---- .../index/reindex/CancelTests.java | 10 ++++----- .../index/reindex/RestReindexActionTests.java | 22 ------------------- .../integration/BulkUpdateTests.java | 2 +- 4 files changed, 6 insertions(+), 32 deletions(-) diff --git a/modules/lang-painless/src/test/resources/rest-api-spec/test/painless/15_update.yml b/modules/lang-painless/src/test/resources/rest-api-spec/test/painless/15_update.yml index 15fcf54ce5a2a..15e93bf621c7e 100644 --- a/modules/lang-painless/src/test/resources/rest-api-spec/test/painless/15_update.yml +++ b/modules/lang-painless/src/test/resources/rest-api-spec/test/painless/15_update.yml @@ -20,7 +20,6 @@ params: { bar: 'xxx' } - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - match: { _version: 2 } @@ -42,7 +41,6 @@ source: "ctx._source.foo = 'yyy'" - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - match: { _version: 3 } @@ -64,7 +62,6 @@ source: "ctx._source.missing_length = ctx._source.missing?.length()" - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - match: { _version: 4 } @@ -88,7 +85,6 @@ source: "ctx._source.foo_length = ctx._source.foo?.length()" - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - match: { _version: 5 } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/CancelTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/CancelTests.java index 6e6ca81fdfc1d..001a055888860 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/CancelTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/CancelTests.java @@ -92,7 +92,7 @@ private void testCancel(String action, AbstractBulkByScrollRequestBuilder logger.debug("setting up [{}] docs", numDocs); indexRandom(true, false, true, IntStream.range(0, numDocs) - .mapToObj(i -> client().prepareIndex(INDEX, "_doc", String.valueOf(i)).setSource("n", i)) + .mapToObj(i -> client().prepareIndex().setIndex(INDEX).setId(String.valueOf(i)).setSource("n", i)) .collect(Collectors.toList())); // Checks that the all documents have been indexed and correctly counted @@ -208,12 +208,12 @@ public static TaskInfo findTaskToCancel(String actionName, int workerCount) { } public void testReindexCancel() throws Exception { - testCancel(ReindexAction.NAME, reindex().source(INDEX).destination("dest", "_doc"), (response, total, modified) -> { + testCancel(ReindexAction.NAME, reindex().source(INDEX).destination("dest"), (response, total, modified) -> { assertThat(response, matcher().created(modified).reasonCancelled(equalTo("by user request"))); refresh("dest"); assertHitCount(client().prepareSearch("dest").setSize(0).get(), modified); - }, equalTo("reindex from [" + INDEX + "] to [dest][_doc]")); + }, equalTo("reindex from [" + INDEX + "] to [dest]")); } public void testUpdateByQueryCancel() throws Exception { @@ -243,13 +243,13 @@ public void testDeleteByQueryCancel() throws Exception { public void testReindexCancelWithWorkers() throws Exception { testCancel(ReindexAction.NAME, - reindex().source(INDEX).filter(QueryBuilders.matchAllQuery()).destination("dest", "_doc").setSlices(5), + reindex().source(INDEX).filter(QueryBuilders.matchAllQuery()).destination("dest").setSlices(5), (response, total, modified) -> { assertThat(response, matcher().created(modified).reasonCancelled(equalTo("by user request")).slices(hasSize(5))); refresh("dest"); assertHitCount(client().prepareSearch("dest").setSize(0).get(), modified); }, - equalTo("reindex from [" + INDEX + "] to [dest][" + "_doc" + "]")); + equalTo("reindex from [" + INDEX + "] to [dest]")); } public void testUpdateByQueryCancelWithWorkers() throws Exception { diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RestReindexActionTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RestReindexActionTests.java index b7a3687f87231..ebfc117ec04ec 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RestReindexActionTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RestReindexActionTests.java @@ -24,7 +24,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.json.JsonXContent; -import org.elasticsearch.rest.RestRequest.Method; import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.test.rest.RestActionTestCase; import org.junit.Before; @@ -79,25 +78,4 @@ public void testSetScrollTimeout() throws IOException { assertEquals("10m", request.getScrollTime().toString()); } } - - /** - * test deprecation is logged if a type is used in the destination index request inside reindex - */ - public void testTypeInDestination() throws IOException { - FakeRestRequest.Builder requestBuilder = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(Method.POST) - .withPath("/_reindex"); - XContentBuilder b = JsonXContent.contentBuilder().startObject(); - { - b.startObject("dest"); - { - b.field("type", (randomBoolean() ? "_doc" : randomAlphaOfLength(4))); - } - b.endObject(); - } - b.endObject(); - requestBuilder.withContent(new BytesArray(BytesReference.bytes(b).toBytesRef()), XContentType.JSON); - dispatchRequest(requestBuilder.build()); - assertWarnings(ReindexRequest.TYPES_DEPRECATION_MESSAGE); - } } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index 644c1c4137e4a..605821812d650 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java @@ -91,7 +91,7 @@ public void testThatBulkUpdateDoesNotLoseFieldsHttp() throws IOException { } //update with new field - Request updateRequest = new Request("POST", path + "/_update"); + Request updateRequest = new Request("POST", "/index/_update/1"); updateRequest.setOptions(options); updateRequest.setJsonEntity("{\"doc\": {\"not test\": \"not test\"}}"); getRestClient().performRequest(updateRequest); From 3777f10119583c147289d32b38a1d79b59d47155 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 8 Oct 2019 16:19:57 +0100 Subject: [PATCH 31/35] tests --- .../resources/rest-api-spec/test/update_by_query/10_basic.yml | 2 -- .../java/org/elasticsearch/integration/BulkUpdateTests.java | 2 +- .../org/elasticsearch/integration/ClusterPrivilegeTests.java | 2 +- .../integration/CreateDocsIndexPrivilegeTests.java | 2 +- .../elasticsearch/integration/KibanaUserRoleIntegTests.java | 4 ++-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml index 1aaf664782101..ec2202dd2c20c 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml @@ -162,7 +162,6 @@ - do: index: index: test - type: _doc id: 1 body: { "text": "test" } - do: @@ -171,7 +170,6 @@ - do: index: index: test - type: _doc id: 1 body: { "text": "test2" } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index 605821812d650..edd2b96c0d6cf 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java @@ -91,7 +91,7 @@ public void testThatBulkUpdateDoesNotLoseFieldsHttp() throws IOException { } //update with new field - Request updateRequest = new Request("POST", "/index/_update/1"); + Request updateRequest = new Request("POST", "/index1/_update/1"); updateRequest.setOptions(options); updateRequest.setJsonEntity("{\"doc\": {\"not test\": \"not test\"}}"); getRestClient().performRequest(updateRequest); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java index 0d7db3cc1ad94..c434d3b182888 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java @@ -149,7 +149,7 @@ public void testThatSnapshotAndRestore() throws Exception { assertAccessIsDenied("user_d", "PUT", "/_snapshot/my-repo", repoJson); assertAccessIsAllowed("user_a", "PUT", "/_snapshot/my-repo", repoJson); - Request createBar = new Request("PUT", "/someindex/bar/1"); + Request createBar = new Request("PUT", "/someindex/_doc/1"); createBar.setJsonEntity("{ \"name\" : \"elasticsearch\" }"); createBar.addParameter("refresh", "true"); assertAccessIsDenied("user_a", createBar); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/CreateDocsIndexPrivilegeTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/CreateDocsIndexPrivilegeTests.java index edc9e7e4fd94b..ec2616e9389c5 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/CreateDocsIndexPrivilegeTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/CreateDocsIndexPrivilegeTests.java @@ -78,7 +78,7 @@ public void testCreateDocUserIsDeniedToIndexNewDocumentsWithExternalIdAndOpTypeI } public void testCreateDocUserIsDeniedToIndexUpdatesToExistingDocument() throws IOException { - assertAccessIsDenied(CREATE_DOC_USER, "POST", "/" + INDEX_NAME + "/_doc/1/_update", "{ \"doc\" : { \"foo\" : \"baz\" } }"); + assertAccessIsDenied(CREATE_DOC_USER, "POST", "/" + INDEX_NAME + "/_update/1", "{ \"doc\" : { \"foo\" : \"baz\" } }"); assertAccessIsDenied(CREATE_DOC_USER, "PUT", "/" + INDEX_NAME + "/_doc/1", "{ \"foo\" : \"baz\" }"); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java index 19533542686de..c3c398baa9992 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/KibanaUserRoleIntegTests.java @@ -61,7 +61,7 @@ public String configUsersRoles() { public void testFieldMappings() throws Exception { final String index = "logstash-20-12-2015"; - final String type = "event"; + final String type = "_doc"; final String field = "foo"; indexRandom(true, client().prepareIndex().setIndex(index).setType(type).setSource(field, "bar")); @@ -145,7 +145,7 @@ public void testGetIndex() throws Exception { public void testGetMappings() throws Exception { final String index = "logstash-20-12-2015"; - final String type = "event"; + final String type = "_doc"; final String field = "foo"; indexRandom(true, client().prepareIndex().setIndex(index).setType(type).setSource(field, "bar")); From e92fd44e0a3d529a7db5b13ad32f80791a8a01df Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 9 Oct 2019 09:30:30 +0100 Subject: [PATCH 32/35] more tests --- .../rest-api-spec/test/delete_by_query/10_basic.yml | 2 -- .../elasticsearch/packaging/util/ServerUtils.java | 4 ++-- .../rest-api-spec/test/rankeval/10_rankeval.yml | 2 -- .../resources/rest-api-spec/test/10_reindex.yml | 13 ------------- .../rest-api-spec/test/15_reindex_from_remote.yml | 11 ----------- .../rest-api-spec/test/20_update_by_query.yml | 8 -------- .../rest-api-spec/test/30_delete_by_query.yml | 8 -------- 7 files changed, 2 insertions(+), 46 deletions(-) diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml b/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml index d36511f3a1690..74276a11c3392 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml @@ -204,7 +204,6 @@ - do: index: index: test - type: _doc id: 1 body: { "text": "test" } - do: @@ -213,7 +212,6 @@ - do: index: index: test - type: _doc id: 1 body: { "text": "test2" } diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/util/ServerUtils.java b/qa/os/src/test/java/org/elasticsearch/packaging/util/ServerUtils.java index 9d91b2a15bdfb..d62fb73cfbf33 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/util/ServerUtils.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/util/ServerUtils.java @@ -97,11 +97,11 @@ public static void waitForElasticsearch(String status, String index, Installatio public static void runElasticsearchTests() throws IOException { makeRequest( - Request.Post("http://localhost:9200/library/book/1?refresh=true&pretty") + Request.Post("http://localhost:9200/library/_doc/1?refresh=true&pretty") .bodyString("{ \"title\": \"Book #1\", \"pages\": 123 }", ContentType.APPLICATION_JSON)); makeRequest( - Request.Post("http://localhost:9200/library/book/2?refresh=true&pretty") + Request.Post("http://localhost:9200/library/_doc/2?refresh=true&pretty") .bodyString("{ \"title\": \"Book #2\", \"pages\": 456 }", ContentType.APPLICATION_JSON)); String count = makeRequest(Request.Get("http://localhost:9200/_count?pretty")); diff --git a/x-pack/qa/core-rest-tests-with-security/src/test/resources/rest-api-spec/test/rankeval/10_rankeval.yml b/x-pack/qa/core-rest-tests-with-security/src/test/resources/rest-api-spec/test/rankeval/10_rankeval.yml index ed00c34874d21..520c247c0d25f 100644 --- a/x-pack/qa/core-rest-tests-with-security/src/test/resources/rest-api-spec/test/rankeval/10_rankeval.yml +++ b/x-pack/qa/core-rest-tests-with-security/src/test/resources/rest-api-spec/test/rankeval/10_rankeval.yml @@ -12,14 +12,12 @@ - do: index: index: foo - type: bar id: doc1 body: { "text": "berlin" } - do: index: index: foo - type: bar id: doc2 body: { "text": "amsterdam" } diff --git a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/10_reindex.yml b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/10_reindex.yml index 6173583a346cc..e63cdefa0bee4 100644 --- a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/10_reindex.yml +++ b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/10_reindex.yml @@ -7,7 +7,6 @@ setup: - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -28,7 +27,6 @@ setup: - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -61,7 +59,6 @@ setup: - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -94,7 +91,6 @@ setup: - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -116,7 +112,6 @@ setup: - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -137,13 +132,11 @@ setup: - do: index: index: source - type: tweet id: 1 body: { "user": "kimchy" } - do: index: index: source - type: tweet id: 2 body: { "user": "another" } - do: @@ -184,13 +177,11 @@ setup: - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: index: index: source - type: foo id: 2 body: { "text": "test", "hidden": true } - do: @@ -235,7 +226,6 @@ setup: - do: index: index: source - type: foo id: 1 body: { "text": "test", "foo": "z", "bar": "z" } - do: @@ -288,7 +278,6 @@ setup: - do: index: index: dest - type: foo id: 1 body: { "text": "test" } - do: @@ -309,7 +298,6 @@ setup: - do: index: index: dest - type: foo id: 1 body: { "text": "test" } - do: @@ -330,7 +318,6 @@ setup: - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: diff --git a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/15_reindex_from_remote.yml b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/15_reindex_from_remote.yml index e41fba0d7a55e..d37edf7b7272b 100644 --- a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/15_reindex_from_remote.yml +++ b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/15_reindex_from_remote.yml @@ -6,7 +6,6 @@ - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -42,7 +41,6 @@ - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -89,7 +87,6 @@ - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -135,7 +132,6 @@ - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -170,13 +166,11 @@ - do: index: index: source - type: tweet id: 1 body: { "user": "kimchy" } - do: index: index: source - type: tweet id: 2 body: { "user": "another" } - do: @@ -232,13 +226,11 @@ - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: index: index: source - type: foo id: 2 body: { "text": "test", "hidden": true } - do: @@ -297,7 +289,6 @@ - do: index: index: source - type: foo id: 1 body: { "text": "test", "foo": "z", "bar": "z" } - do: @@ -365,7 +356,6 @@ - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: @@ -401,7 +391,6 @@ - do: index: index: source - type: foo id: 1 body: { "text": "test" } - do: diff --git a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/20_update_by_query.yml b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/20_update_by_query.yml index 31202d1f20f63..8512e4e6308b1 100644 --- a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/20_update_by_query.yml +++ b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/20_update_by_query.yml @@ -7,7 +7,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -38,7 +37,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -70,7 +68,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -102,7 +99,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -120,7 +116,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -138,13 +133,11 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: index: index: source - type: _doc id: 2 body: { "text": "test", "hidden": true } - do: @@ -192,7 +185,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test", "foo": "z", "bar": "z" } - do: diff --git a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/30_delete_by_query.yml b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/30_delete_by_query.yml index 677a843ec53aa..827bd8364c073 100644 --- a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/30_delete_by_query.yml +++ b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/30_delete_by_query.yml @@ -7,7 +7,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -33,7 +32,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -60,7 +58,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -87,7 +84,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -114,7 +110,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test" } - do: @@ -141,13 +136,11 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test", "hidden": false } - do: index: index: source - type: _doc id: 2 body: { "text": "test", "hidden": true } - do: @@ -211,7 +204,6 @@ setup: - do: index: index: source - type: _doc id: 1 body: { "text": "test", "foo": "z", "bar": "z" } - do: From a99a0dec3275b2a14026ec91d63556881aac6545 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 9 Oct 2019 10:10:05 +0100 Subject: [PATCH 33/35] watcher tests --- .../test/resources/rest-api-spec/test/mustache/10_webhook.yml | 4 ++-- .../rest-api-spec/test/mustache/25_array_compare.yml | 4 ---- .../resources/rest-api-spec/test/mustache/30_search_input.yml | 4 ---- .../rest-api-spec/test/mustache/40_search_transform.yml | 4 ---- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/10_webhook.yml b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/10_webhook.yml index 6d03abd57293f..21119e75ca14e 100644 --- a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/10_webhook.yml +++ b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/10_webhook.yml @@ -21,7 +21,7 @@ pipeline: description: _description processors: [ grok: { field: host, patterns : ["%{IPORHOST:hostname}:%{NUMBER:port:int}"]} ] - docs: [ { _index: index, _type: type, _id: id, _source: { host: $host } } ] + docs: [ { _index: index, _id: id, _source: { host: $host } } ] - set: { docs.0.doc._source.hostname: hostname } - set: { docs.0.doc._source.port: port } @@ -43,7 +43,7 @@ method: PUT host: $hostname port: $port - path: "/my_index/my_type/{{ctx.watch_id}}" + path: "/my_index/_doc/{{ctx.watch_id}}" body: source: watch_id: "{{ctx.watch_id}}" diff --git a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/25_array_compare.yml b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/25_array_compare.yml index 9371040a0ff50..4cdf66d749aa7 100644 --- a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/25_array_compare.yml +++ b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/25_array_compare.yml @@ -8,28 +8,24 @@ - do: index: index: test_1 - type: test id: 1 body: { level: 0 } - do: index: index: test_1 - type: test id: 2 body: { level: 0 } - do: index: index: test_1 - type: test id: 3 body: { level: 0 } - do: index: index: test_1 - type: test id: 4 body: { level: 1 } - do: diff --git a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/30_search_input.yml b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/30_search_input.yml index 7866b54de7c77..807071411064a 100644 --- a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/30_search_input.yml +++ b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/30_search_input.yml @@ -7,7 +7,6 @@ setup: - do: index: index: idx - type: type id: 1 body: > { @@ -17,7 +16,6 @@ setup: - do: index: index: idx - type: type id: 2 body: > { @@ -27,7 +25,6 @@ setup: - do: index: index: idx - type: type id: 3 body: > { @@ -37,7 +34,6 @@ setup: - do: index: index: idx - type: type id: 4 body: > { diff --git a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/40_search_transform.yml b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/40_search_transform.yml index 08ff0fae5ba7b..068de0adb4649 100644 --- a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/40_search_transform.yml +++ b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/40_search_transform.yml @@ -7,7 +7,6 @@ setup: - do: index: index: idx - type: type id: 1 body: > { @@ -17,7 +16,6 @@ setup: - do: index: index: idx - type: type id: 2 body: > { @@ -27,7 +25,6 @@ setup: - do: index: index: idx - type: type id: 3 body: > { @@ -37,7 +34,6 @@ setup: - do: index: index: idx - type: type id: 4 body: > { From ed1f3fd0eca665dcf02fcf83593503a8fb41d41a Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 10 Oct 2019 09:43:33 +0100 Subject: [PATCH 34/35] Only need to check for 400 now --- .../java/org/elasticsearch/test/rest/ESRestTestCase.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index ad2c234765f75..1cf3c215420b5 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -684,8 +684,7 @@ private static void deleteAllILMPolicies() throws IOException { Response response = adminClient().performRequest(new Request("GET", "/_ilm/policy")); policies = entityAsMap(response); } catch (ResponseException e) { - if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode() || - RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { + if (RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { // If bad request returned, ILM is not enabled. return; } @@ -708,8 +707,7 @@ private static void deleteAllSLMPolicies() throws IOException { Response response = adminClient().performRequest(new Request("GET", "/_slm/policy")); policies = entityAsMap(response); } catch (ResponseException e) { - if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode() || - RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { + if (RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { // If bad request returned, SLM is not enabled. return; } From ffdfa0ec45e93214849ac707097f319069598f56 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 10 Oct 2019 09:56:48 +0100 Subject: [PATCH 35/35] Revert "Only need to check for 400 now" We still need to check for 405 errors during mixed-cluster BWC tests This reverts commit ed1f3fd0eca665dcf02fcf83593503a8fb41d41a. --- .../java/org/elasticsearch/test/rest/ESRestTestCase.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index 1cf3c215420b5..ad2c234765f75 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -684,7 +684,8 @@ private static void deleteAllILMPolicies() throws IOException { Response response = adminClient().performRequest(new Request("GET", "/_ilm/policy")); policies = entityAsMap(response); } catch (ResponseException e) { - if (RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { + if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode() || + RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { // If bad request returned, ILM is not enabled. return; } @@ -707,7 +708,8 @@ private static void deleteAllSLMPolicies() throws IOException { Response response = adminClient().performRequest(new Request("GET", "/_slm/policy")); policies = entityAsMap(response); } catch (ResponseException e) { - if (RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { + if (RestStatus.METHOD_NOT_ALLOWED.getStatus() == e.getResponse().getStatusLine().getStatusCode() || + RestStatus.BAD_REQUEST.getStatus() == e.getResponse().getStatusLine().getStatusCode()) { // If bad request returned, SLM is not enabled. return; }