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 8805af367a80e..17a755eda6860 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 @@ -52,8 +52,6 @@ public RestNoopBulkAction(Settings settings, RestController controller) { controller.registerHandler(PUT, "/_noop_bulk", this); controller.registerHandler(POST, "/{index}/_noop_bulk", this); controller.registerHandler(PUT, "/{index}/_noop_bulk", this); - controller.registerHandler(POST, "/{index}/{type}/_noop_bulk", this); - controller.registerHandler(PUT, "/{index}/{type}/_noop_bulk", this); } @Override @@ -65,7 +63,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"); String defaultRouting = request.param("routing"); String defaultPipeline = request.param("pipeline"); @@ -75,7 +72,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, null, defaultPipeline, true, request.getXContentType()); // short circuit the call to the transport layer 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 762e927551b8b..33fcb1abe5251 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 @@ -20,6 +20,7 @@ package org.elasticsearch.client; import com.carrotsearch.randomizedtesting.generators.RandomPicks; + import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkProcessor; import org.elasticsearch.action.bulk.BulkRequest; @@ -37,10 +38,7 @@ 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; @@ -51,16 +49,11 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.IntStream; 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; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.everyItem; @@ -77,12 +70,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); @@ -291,7 +278,6 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception assertMultiGetResponse(highLevelClient().mget(multiGetRequest, RequestOptions.DEFAULT), testDocs); } - @SuppressWarnings("unchecked") public void testGlobalParametersAndSingleRequest() throws Exception { createIndexWithMultipleShards("test"); @@ -302,7 +288,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()) { @@ -326,150 +311,29 @@ public void testGlobalParametersAndSingleRequest() throws Exception { assertThat(blogs, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ")))); } - @SuppressWarnings("unchecked") - 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) - //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, globalType); - - 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") - private Matcher[] expectedIds(int numDocs) { - return IntStream.rangeClosed(1, numDocs) - .boxed() - .map(n -> hasId(n.toString())) - .>toArray(Matcher[]::new); - } - - private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String localType, - String globalIndex, String globalType, String globalPipeline) throws Exception { + 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); - 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); - } + BytesArray data = bytesBulkRequest(localIndex, i); + processor.add(data, globalIndex, globalPipeline, XContentType.JSON); } multiGetRequest.add(localIndex, Integer.toString(i)); } 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(); @@ -483,7 +347,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, 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/BulkRequestWithGlobalParametersIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkRequestWithGlobalParametersIT.java index 3020eb0329b5c..5e497a5493162 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; @@ -44,7 +42,6 @@ public class BulkRequestWithGlobalParametersIT extends ESRestHighLevelClientTestCase { - @SuppressWarnings("unchecked") public void testGlobalPipelineOnBulkRequest() throws IOException { createFieldAddingPipleine("xyz", "fieldNameXYZ", "valueXYZ"); @@ -83,7 +80,6 @@ public void testPipelineOnRequestOverridesGlobalPipeline() throws IOException { assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldXYZ"), nullValue()))); } - @SuppressWarnings("unchecked") public void testMixPipelineOnRequestAndGlobal() throws IOException { createFieldAddingPipleine("globalId", "fieldXYZ", "valueXYZ"); createFieldAddingPipleine("perIndexId", "someNewField", "someValue"); @@ -110,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,9 +118,8 @@ public void testGlobalIndex() throws IOException { assertThat(hits, everyItem(hasIndex("global_index"))); } - @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 @@ -140,38 +135,20 @@ 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"))); - } - - @SuppressWarnings("unchecked") public void testTypeGlobalAndPerRequest() throws IOException { - BulkRequest request = new BulkRequest(null, "global_type"); - request.add(new IndexRequest("index1", "local_type", "1") + BulkRequest request = new BulkRequest(null); + request.add(new IndexRequest("index1").id("1") .source(XContentType.JSON, "field", "bulk1")); - request.add(new IndexRequest("index2").id("2") // will take global type + request.add(new IndexRequest("index2").id("2") .source(XContentType.JSON, "field", "bulk2")); - bulkWithTypes(request); + bulk(request); Iterable hits = searchAll("index1", "index2"); assertThat(hits, containsInAnyOrder( - both(hasId("1")) - .and(hasType("local_type")), - both(hasId("2")) - .and(hasType("global_type")))); + hasId("1"), hasId("2"))); } - @SuppressWarnings("unchecked") public void testGlobalRouting() throws IOException { createIndexWithMultipleShards("index"); BulkRequest request = new BulkRequest(null); @@ -189,7 +166,6 @@ public void testGlobalRouting() throws IOException { assertThat(hits, containsInAnyOrder(hasId("1"), hasId("2"))); } - @SuppressWarnings("unchecked") public void testMixLocalAndGlobalRouting() throws IOException { BulkRequest request = new BulkRequest(null); request.routing("globalRouting"); @@ -217,13 +193,6 @@ 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); 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 6c161444e2475..c6209957edda8 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,11 +54,9 @@ 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.RestGetAction; import org.elasticsearch.rest.action.document.RestIndexAction; -import org.elasticsearch.rest.action.document.RestMultiGetAction; import org.elasticsearch.rest.action.document.RestUpdateAction; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; @@ -426,36 +424,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", "type", "id2"); - - MultiGetResponse response = execute(multiGetRequest, - highLevelClient()::mget, - highLevelClient()::mgetAsync, - expectWarnings(RestMultiGetAction.TYPES_DEPRECATION_MESSAGE)); - assertEquals(2, response.getResponses().length); - - GetResponse firstResponse = response.getResponses()[0].getResponse(); - assertEquals("index", firstResponse.getIndex()); - assertEquals("type", firstResponse.getType()); - assertEquals("id1", firstResponse.getId()); - - GetResponse secondResponse = response.getResponses()[1].getResponse(); - assertEquals("index", secondResponse.getIndex()); - assertEquals("type", secondResponse.getType()); - assertEquals("id2", secondResponse.getId()); - } - 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/bulk/BulkProcessor.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java index b0ad87a8b744a..89fd66ed9acb5 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java @@ -90,7 +90,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; @@ -146,11 +145,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; @@ -186,7 +180,7 @@ public BulkProcessor build() { } private Supplier createBulkRequestWithGlobalDefaults() { - return () -> new BulkRequest(globalIndex, globalType) + return () -> new BulkRequest(globalIndex) .pipeline(globalPipeline) .routing(globalRouting); } @@ -324,18 +318,9 @@ private synchronized 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 synchronized BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, - @Nullable String defaultPipeline, - XContentType xContentType) throws Exception { - bulkRequest.add(data, defaultIndex, defaultType, null, null, defaultPipeline, true, xContentType); + public synchronized BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultPipeline, + XContentType xContentType) throws Exception { + bulkRequest.add(data, defaultIndex, null, null, defaultPipeline, true, xContentType); executeIfNeeded(); return this; } 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 2b935f0f0fc47..0ca802dd5c96f 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -74,7 +74,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques private String globalPipeline; private String globalRouting; private String globalIndex; - private String globalType; private long sizeInBytes = 0; @@ -85,15 +84,6 @@ 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; - } - /** * Adds a list of requests to be executed. Either index or delete requests. */ @@ -215,17 +205,7 @@ 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); - } - - /** - * 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, - XContentType xContentType) throws IOException { - return add(new BytesArray(data, from, length), defaultIndex, defaultType, xContentType); + return add(data, from, length, null, xContentType); } @@ -234,17 +214,7 @@ public BulkRequest add(byte[] data, int from, int length, @Nullable String defau */ public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, XContentType xContentType) throws IOException { - return add(new BytesArray(data, from, length), defaultIndex, MapperService.SINGLE_MAPPING_NAME, 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); + return add(new BytesArray(data, from, length), defaultIndex, xContentType); } /** @@ -252,17 +222,7 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null */ 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); + return add(data, defaultIndex, MapperService.SINGLE_MAPPING_NAME, null, null, true, xContentType); } /** @@ -270,28 +230,16 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null */ 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); + return add(data, defaultIndex, 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); - } - - /** - * @deprecated use {@link #add(BytesReference, String, String, FetchSourceContext, String, boolean, XContentType)} instead - */ - @Deprecated - public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, - @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().parse(data, defaultIndex, routing, defaultFetchSourceContext, pipeline, allowExplicitIndex, xContentType, this::internalAdd, this::internalAdd, this::add); return this; } @@ -420,9 +368,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..ce40951f67d9d 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,23 +108,12 @@ 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; } 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..459d27845a78c 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; @@ -35,7 +33,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; @@ -49,10 +46,7 @@ */ 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"); private static final ParseField ROUTING = new ParseField("routing"); private static final ParseField OP_TYPE = new ParseField("op_type"); @@ -64,14 +58,10 @@ 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; - /** * Create a new parser. - * @param warnOnTypeUsage whether it warns upon types being explicitly specified */ - public BulkRequestParser(boolean warnOnTypeUsage) { - this.warnOnTypeUsage = warnOnTypeUsage; + public BulkRequestParser() { } private static int findNextMarker(byte marker, int from, BytesReference data) { @@ -114,31 +104,10 @@ 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; byte marker = xContent.streamSeparator(); - boolean typesDeprecationLogged = false; while (true) { int nextMarker = findNextMarker(marker, from, data); if (nextMarker == -1) { @@ -172,7 +141,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 +167,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 +208,7 @@ public void parse( } if ("delete".equals(action)) { - deleteRequestConsumer.accept(new DeleteRequest(index, type, id).routing(routing) + deleteRequestConsumer.accept(new DeleteRequest(index, id).routing(routing) .version(version).versionType(versionType).setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm)); } else { nextMarker = findNextMarker(marker, from, data); @@ -259,19 +221,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 +242,7 @@ 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, 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/client/Client.java b/server/src/main/java/org/elasticsearch/client/Client.java index 07871709f5726..12dc51d828562 100644 --- a/server/src/main/java/org/elasticsearch/client/Client.java +++ b/server/src/main/java/org/elasticsearch/client/Client.java @@ -233,9 +233,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 e79f0567babe6..c2f5b72654f22 100644 --- a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -478,8 +478,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 08ddbb728c1ab..db12692717a2a 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; @@ -52,9 +48,6 @@ 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) { super(settings); @@ -63,10 +56,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); } @@ -79,12 +68,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"); @@ -94,7 +77,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 de8a2d9d67bbe..b39b2985bd662 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..28959212606b4 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; @@ -31,9 +30,9 @@ public class BulkRequestParserTests extends ESTestCase { public void testIndexRequest() throws IOException { BytesArray request = new BytesArray("{ \"index\":{ \"_id\": \"bar\" } }\n{}\n"); - BulkRequestParser parser = new BulkRequestParser(randomBoolean()); + BulkRequestParser parser = new BulkRequestParser(); 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()); @@ -46,9 +45,9 @@ public void testIndexRequest() throws IOException { public void testDeleteRequest() throws IOException { BytesArray request = new BytesArray("{ \"delete\":{ \"_id\": \"bar\" } }\n"); - BulkRequestParser parser = new BulkRequestParser(randomBoolean()); + BulkRequestParser parser = new BulkRequestParser(); 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()); @@ -61,9 +60,9 @@ public void testDeleteRequest() throws IOException { public void testUpdateRequest() throws IOException { BytesArray request = new BytesArray("{ \"update\":{ \"_id\": \"bar\" } }\n{}\n"); - BulkRequestParser parser = new BulkRequestParser(randomBoolean()); + BulkRequestParser parser = new BulkRequestParser(); 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()); @@ -77,38 +76,21 @@ public void testUpdateRequest() throws IOException { public void testBarfOnLackOfTrailingNewline() throws IOException { BytesArray request = new BytesArray("{ \"index\":{ \"_id\": \"bar\" } }\n{}"); - BulkRequestParser parser = new BulkRequestParser(randomBoolean()); + BulkRequestParser parser = new BulkRequestParser(); 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()); } public void testFailOnExplicitIndex() throws IOException { BytesArray request = new BytesArray("{ \"index\":{ \"_index\": \"foo\", \"_id\": \"bar\" } }\n{}\n"); - BulkRequestParser parser = new BulkRequestParser(randomBoolean()); + BulkRequestParser parser = new BulkRequestParser(); 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..b660d66876953 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,11 @@ 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); + // This test's JSON contains outdated references to types } 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 +74,7 @@ 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); + // This test's JSON contains outdated references to types } public void testSimpleBulk2() throws Exception { @@ -103,7 +100,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,29 +110,25 @@ 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() { 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)); @@ -150,8 +142,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 { @@ -160,9 +150,7 @@ public void testSimpleBulk7() throws Exception { IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> 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); + containsString("Malformed action/metadata line [5], expected a simple value for field [_unknown] but found [START_ARRAY]")); } public void testSimpleBulk8() throws Exception { @@ -171,8 +159,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 +175,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, @@ -233,19 +217,18 @@ 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)); + bulkRequest.add(new DeleteRequest("index", 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", "id")); + 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.")); @@ -254,8 +237,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())); @@ -280,7 +263,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 +278,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 +298,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 +312,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 +319,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 +334,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 89ccbefb00e59..951bafb659d49 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java @@ -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; @@ -201,8 +200,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 518f1bc572982..83d0b48bc41ab 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/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/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/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 12c4e0b7ee3cc..ab695cc272354 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 @@ -72,7 +72,7 @@ public MonitoringBulkRequest add(final MonitoredSystem system, final long intervalMillis) throws IOException { // MonitoringBulkRequest accepts a body request that has the same format as the BulkRequest - new BulkRequestParser(false).parse(content, null, null, null, null, true, xContentType, + new BulkRequestParser().parse(content, null, null, null, null, true, xContentType, indexRequest -> { // 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 diff --git a/x-pack/plugin/data-frame/qa/multi-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameIntegTestCase.java b/x-pack/plugin/data-frame/qa/multi-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameIntegTestCase.java index 3a6ab2e5b71d2..2e1b87b064b0f 100644 --- a/x-pack/plugin/data-frame/qa/multi-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameIntegTestCase.java +++ b/x-pack/plugin/data-frame/qa/multi-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameIntegTestCase.java @@ -238,7 +238,7 @@ protected void createReviewsIndex() throws Exception { } // create index - BulkRequestBuilder bulk = client().prepareBulk(REVIEWS_INDEX_NAME, "_doc"); + BulkRequestBuilder bulk = client().prepareBulk(REVIEWS_INDEX_NAME); int day = 10; for (int i = 0; i < numDocs; i++) { long user = i % 28; @@ -269,7 +269,7 @@ protected void createReviewsIndex() throws Exception { if (i % 50 == 0) { BulkResponse response = client().bulk(bulk.request()).get(); assertThat(response.buildFailureMessage(), response.hasFailures(), is(false)); - bulk = client().prepareBulk(REVIEWS_INDEX_NAME, "_doc"); + bulk = client().prepareBulk(REVIEWS_INDEX_NAME); day += 1; } } diff --git a/x-pack/plugin/data-frame/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameTransformProgressIT.java b/x-pack/plugin/data-frame/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameTransformProgressIT.java index 194d35e8ba636..7b8b02c938b2c 100644 --- a/x-pack/plugin/data-frame/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameTransformProgressIT.java +++ b/x-pack/plugin/data-frame/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameTransformProgressIT.java @@ -82,7 +82,7 @@ protected void createReviewsIndex() throws Exception { } // create index - BulkRequestBuilder bulk = client().prepareBulk(REVIEWS_INDEX_NAME, "_doc"); + BulkRequestBuilder bulk = client().prepareBulk(REVIEWS_INDEX_NAME); int day = 10; for (int i = 0; i < numDocs; i++) { long user = i % 28; @@ -113,7 +113,7 @@ protected void createReviewsIndex() throws Exception { if (i % 50 == 0) { BulkResponse response = client().bulk(bulk.request()).get(); assertThat(response.buildFailureMessage(), response.hasFailures(), is(false)); - bulk = client().prepareBulk(REVIEWS_INDEX_NAME, "_doc"); + bulk = client().prepareBulk(REVIEWS_INDEX_NAME); day += 1; } } 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 d4ea017ca8b3d..842b5a697ebfa 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 @@ -865,7 +865,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 b44ae0360d884..68ff2b16ea952 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); }