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 b095eab134b74..312b19fe1ec7a 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()); } @@ -309,11 +303,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); @@ -341,9 +333,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..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 @@ -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"); @@ -528,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()); } { @@ -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 43f774ded28fd..1c8e4b72fe8f6 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 @@ -2177,7 +2177,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); } @@ -2197,7 +2197,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\", " + @@ -2217,7 +2217,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/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/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 cd2d961f9b386..85ebc11e0a4bf 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/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/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..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/book?refresh +POST /library/_doc?refresh {"title": "Book #1", "rating": 200.1} -POST /library/book?refresh +POST /library/_doc?refresh {"title": "Book #2", "rating": 1.7} -POST /library/book?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 b1605e3014f92..1d5c95e013d44 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\/_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 4ed1408239247..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\/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/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 cbc0dfc081ee7..f40095be5420d 100644 --- a/docs/reference/indices/rollover-index.asciidoc +++ b/docs/reference/indices/rollover-index.asciidoc @@ -414,7 +414,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..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\/test\?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\/test\?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 a1d3f7f224dd4..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\/test\?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/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/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..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 @@ -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,12 +102,11 @@ 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 -> { 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")); } @@ -133,7 +130,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 +170,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 +189,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 +219,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 +250,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 +271,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/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/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/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 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/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/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/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java b/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java index 1f984a514d0e3..3acefce8e4e8b 100644 --- a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java +++ b/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java @@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.index.seqno.SeqNoStats; -import org.elasticsearch.rest.action.document.RestIndexAction; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.yaml.ObjectPath; @@ -46,9 +45,8 @@ public class IndexingIT extends ESRestTestCase { private int indexDocs(String index, final int idStart, final int numDocs) throws IOException { for (int i = 0; i < numDocs; i++) { final int id = idStart + i; - Request request = new Request("PUT", index + "/doc/" + id); + Request request = new Request("PUT", index + "/_doc/" + id); request.setJsonEntity("{\"test\": \"test_" + randomAlphaOfLength(2) + "\"}"); - request.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); assertOK(client().performRequest(request)); } return numDocs; 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/os/bats/default/certgen.bash b/qa/os/bats/default/certgen.bash index 8d6f085806d68..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/book/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/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 }' 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/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java index 15f110126f1c7..1d6978a8aae08 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java @@ -33,7 +33,6 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.seqno.RetentionLeaseUtils; -import org.elasticsearch.rest.action.document.RestIndexAction; import org.elasticsearch.test.rest.yaml.ObjectPath; import org.hamcrest.Matchers; @@ -49,7 +48,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; -import static com.carrotsearch.randomizedtesting.RandomizedTest.randomAsciiOfLength; +import static com.carrotsearch.randomizedtesting.RandomizedTest.randomAsciiLettersOfLength; import static org.elasticsearch.cluster.routing.UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING; import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING; import static org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY; @@ -104,9 +103,8 @@ public void testHistoryUUIDIsGenerated() throws Exception { private int indexDocs(String index, final int idStart, final int numDocs) throws IOException { for (int i = 0; i < numDocs; i++) { final int id = idStart + i; - Request indexDoc = new Request("PUT", index + "/test/" + id); - indexDoc.setJsonEntity("{\"test\": \"test_" + randomAsciiOfLength(2) + "\"}"); - indexDoc.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); + Request indexDoc = new Request("PUT", index + "/_doc/" + id); + indexDoc.setJsonEntity("{\"test\": \"test_" + randomAsciiLettersOfLength(2) + "\"}"); client().performRequest(indexDoc); } return numDocs; 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/java/org/elasticsearch/ingest/IngestDocumentMustacheIT.java b/qa/smoke-test-ingest-with-all-dependencies/src/test/java/org/elasticsearch/ingest/IngestDocumentMustacheIT.java index ec993262a4d59..2b21e3bf236ec 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/java/org/elasticsearch/ingest/IngestDocumentMustacheIT.java +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/java/org/elasticsearch/ingest/IngestDocumentMustacheIT.java @@ -33,7 +33,7 @@ public class IngestDocumentMustacheIT extends AbstractScriptTestCase { public void testAccessMetaDataViaTemplate() { Map 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/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..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}}"] } } ] @@ -30,7 +30,6 @@ - do: index: index: test - type: test id: 1 pipeline: "my_pipeline_1" body: {} @@ -40,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": @@ -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/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/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/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/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..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 @@ -16,7 +16,6 @@ - do: index: index: logs-1 - type: test id: "1" body: { "foo": "hello world" } # make this doc visible in index stats @@ -57,7 +56,6 @@ - do: index: index: logs-000002 - type: test id: "2" body: { "foo": "hello world" } 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/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java b/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java index fc8816460c96b..da7eb9868e331 100644 --- a/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java +++ b/server/src/main/java/org/elasticsearch/action/DocWriteRequest.java @@ -52,19 +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 df1ded8f1a561..d42adcbd62ca4 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -787,7 +787,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 ) ) @@ -796,8 +796,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 7d2718aef5a34..c4289edd58f7a 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. */ @@ -636,9 +579,9 @@ public void checkAutoIdWithOpTypeCreateSupportedByVersion(Version version) { public void writeTo(StreamOutput out) throws IOException { checkAutoIdWithOpTypeCreateSupportedByVersion(out.getVersion()); 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); @@ -674,7 +617,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/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/main/java/org/elasticsearch/action/update/TransportUpdateAction.java b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java index 7ba35b5e1a600..78584dc0390e2 100644 --- a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java @@ -182,7 +182,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 +206,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 +220,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(), 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 4f9838a105836..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 @@ -19,15 +19,12 @@ package org.elasticsearch.rest.action.document; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.Version; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.service.ClusterService; -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; @@ -41,11 +38,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})."; private final ClusterService clusterService; @@ -60,13 +52,6 @@ public RestIndexAction(RestController controller, ClusterService clusterService) 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}", autoIdHandler); // 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 @@ -119,15 +104,8 @@ public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient @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.id(request.param("id")); 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..bb1208bc3bba1 100644 --- a/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/DocWriteResponseTests.java @@ -41,42 +41,39 @@ public void testGetLocation() { final DocWriteResponse response = new DocWriteResponse( new ShardId("index", "uuid", 0), - "type", "id", SequenceNumbers.UNASSIGNED_SEQ_NO, 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() { final DocWriteResponse response = new DocWriteResponse( new ShardId("index", "uuid", 0), - "type", "ā¤", SequenceNumbers.UNASSIGNED_SEQ_NO, 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() { final DocWriteResponse response = new DocWriteResponse( new ShardId("index", "uuid", 0), - "type", "a b", SequenceNumbers.UNASSIGNED_SEQ_NO, 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")); } /** @@ -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 5116abaf02a59..0272a374dee76 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java @@ -81,7 +81,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"); } @@ -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/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 1bf3ea429e790..8d394c06245e2 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(); @@ -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(); @@ -595,9 +595,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 fe47eaf54546c..d3f52d3ee7ddc 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIndicesThatCannotBeCreatedTests.java @@ -60,7 +60,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 @@ -76,7 +76,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 56793f1c9d10c..9ae9f04eb8100 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionIngestTests.java @@ -220,7 +220,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 -> { @@ -231,7 +231,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); @@ -243,10 +243,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); @@ -286,7 +286,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); @@ -320,7 +320,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); @@ -365,7 +365,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); @@ -411,11 +411,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 { @@ -431,16 +431,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); @@ -485,7 +485,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); @@ -521,7 +521,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); @@ -557,7 +557,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..ebd7c9cc23ee0 100644 --- a/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/delete/DeleteResponseTests.java @@ -42,17 +42,17 @@ 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\"," + + assertEquals("{\"_index\":\"index\",\"_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); - 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); } } @@ -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..9d8518f23d750 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 + @@ -189,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 926f272ed8339..ba3ab85cd8c67 100644 --- a/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/index/IndexResponseTests.java @@ -43,17 +43,17 @@ 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," + + assertEquals("{\"_index\":\"index\",\"_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); - 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); } } @@ -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/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 37a1979fbd7b3..2d76256c91a85 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,14 +633,14 @@ 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], " + 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", "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]}")); + 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 7c33abe3ee6dc..dcc22c1d5411d 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\"," + + assertEquals("{\"_index\":\"index\",\"_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..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; @@ -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"); @@ -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/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 b17f36adb5ebd..a7c9c058d945e 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/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/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 52968a9d30436..1f9e7451da14a 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/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/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..de807a484c805 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() { @@ -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)); 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 71e30dcfa0c86..6fe27322fcd85 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 @@ -48,7 +48,7 @@ public class RestIndexActionTests extends RestActionTestCase { private RestIndexAction action; - private final AtomicReference clusterStateSupplier = new AtomicReference(); + private final AtomicReference clusterStateSupplier = new AtomicReference<>(); @Before public void setUpAction() { @@ -57,36 +57,6 @@ public void setUpAction() { action = new RestIndexAction(controller(), clusterService); } - 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() { 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/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/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..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,10 +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<>()); - types.add(builder.request().type()); + indices.add(builder.request().index()); } Set> bogusIds = new HashSet<>(); // (index, type, id) if (random.nextBoolean() && !builders.isEmpty() && dummyDocuments) { @@ -1303,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 { @@ -1362,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()); } 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..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; } @@ -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.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; } 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 838cd0d4514c1..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()); } @@ -502,7 +502,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/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/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/BulkUpdateTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index 644c1c4137e4a..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", path + "/_update"); + 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/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/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/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")); 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 d9c3d4d90e7c6..8778a7058647f 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/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: 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..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 @@ -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,16 +255,13 @@ 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")); } 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)); @@ -303,7 +299,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()); @@ -314,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)); @@ -358,7 +353,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/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)); } } 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()); 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: 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 } 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: > {