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 95b2fc0a43b..5989d9a9fe9 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 @@ -163,7 +163,7 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { for (BulkItemResponse bulkItemResponse : listener.bulkItems) { assertThat(bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false)); assertThat(bulkItemResponse.getIndex(), equalTo("test")); - assertThat(bulkItemResponse.getType(), equalTo("test")); + assertThat(bulkItemResponse.getType(), equalTo("_doc")); //with concurrent requests > 1 we can't rely on the order of the bulk requests assertThat(Integer.valueOf(bulkItemResponse.getId()), both(greaterThan(0)).and(lessThanOrEqualTo(numDocs))); //we do want to check that we don't get duplicate ids back @@ -240,12 +240,12 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { for (int i = 1; i <= numDocs; i++) { if (randomBoolean()) { testDocs++; - processor.add(new IndexRequest("test", "test", Integer.toString(testDocs)) + processor.add(new IndexRequest("test", "_doc", Integer.toString(testDocs)) .source(XContentType.JSON, "field", "value")); - multiGetRequest.add("test", "test", Integer.toString(testDocs)); + multiGetRequest.add("test", Integer.toString(testDocs)); } else { testReadOnlyDocs++; - processor.add(new IndexRequest("test-ro", "test", Integer.toString(testReadOnlyDocs)) + processor.add(new IndexRequest("test-ro", "_doc", Integer.toString(testReadOnlyDocs)) .source(XContentType.JSON, "field", "value")); } } @@ -262,7 +262,7 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { Set readOnlyIds = new HashSet<>(); for (BulkItemResponse bulkItemResponse : listener.bulkItems) { assertThat(bulkItemResponse.getIndex(), either(equalTo("test")).or(equalTo("test-ro"))); - assertThat(bulkItemResponse.getType(), equalTo("test")); + assertThat(bulkItemResponse.getType(), equalTo("_doc")); if (bulkItemResponse.getIndex().equals("test")) { assertThat(bulkItemResponse.isFailed(), equalTo(false)); //with concurrent requests > 1 we can't rely on the order of the bulk requests @@ -330,12 +330,12 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { .setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs) .setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)) .setGlobalIndex("test") - .setGlobalType("test") + .setGlobalType("_doc") .setGlobalRouting("routing") .setGlobalPipeline("pipeline_id") .build()) { - indexDocs(processor, numDocs, null, null, "test", "test", "pipeline_id"); + indexDocs(processor, numDocs, null, null, "test", "pipeline_id"); latch.await(); assertThat(listener.beforeCounts.get(), equalTo(1)); @@ -346,7 +346,7 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { Iterable hits = searchAll(new SearchRequest("test").routing("routing")); assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ")))); - assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType("test")))); + assertThat(hits, everyItem(Matchers.allOf(hasIndex("test"), hasType("_doc")))); assertThat(hits, containsInAnyOrder(expectedIds(numDocs))); } } @@ -359,18 +359,18 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { .>toArray(Matcher[]::new); } - private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String localType, + private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs, String localIndex, String globalIndex, String globalType, 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, "_doc", Integer.toString(i)) .source(XContentType.JSON, "field", randomRealisticUnicodeOfLengthBetween(1, 30))); } else { - BytesArray data = bytesBulkRequest(localIndex, localType, i); + BytesArray data = bytesBulkRequest(localIndex, "_doc", i); processor.add(data, globalIndex, globalType, globalPipeline, null, XContentType.JSON); } - multiGetRequest.add(localIndex, localType, Integer.toString(i)); + multiGetRequest.add(localIndex, Integer.toString(i)); } return multiGetRequest; } @@ -396,7 +396,7 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { } private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) throws Exception { - return indexDocs(processor, numDocs, "test", "test", null, null, null); + return indexDocs(processor, numDocs, "test", null, null, null); } private static void assertResponseItems(List bulkItemResponses, int numDocs) { @@ -404,7 +404,7 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { int i = 1; for (BulkItemResponse bulkItemResponse : bulkItemResponses) { assertThat(bulkItemResponse.getIndex(), equalTo("test")); - assertThat(bulkItemResponse.getType(), equalTo("test")); + assertThat(bulkItemResponse.getType(), equalTo("_doc")); assertThat(bulkItemResponse.getId(), equalTo(Integer.toString(i++))); assertThat("item " + i + " failed with cause: " + bulkItemResponse.getFailureMessage(), bulkItemResponse.isFailed(), equalTo(false)); @@ -416,7 +416,7 @@ public class BulkProcessorIT extends ESRestHighLevelClientTestCase { int i = 1; for (MultiGetItemResponse multiGetItemResponse : multiGetResponse) { assertThat(multiGetItemResponse.getIndex(), equalTo("test")); - assertThat(multiGetItemResponse.getType(), equalTo("test")); + assertThat(multiGetItemResponse.getType(), equalTo("_doc")); assertThat(multiGetItemResponse.getId(), equalTo(Integer.toString(i++))); } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java index 5fd9fcb661c..6262a5b9685 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorRetryIT.java @@ -45,7 +45,6 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo; public class BulkProcessorRetryIT extends ESRestHighLevelClientTestCase { private static final String INDEX_NAME = "index"; - private static final String TYPE_NAME = "type"; private static BulkProcessor.Builder initBulkProcessorBuilder(BulkProcessor.Listener listener) { return BulkProcessor.builder( @@ -144,9 +143,9 @@ public class BulkProcessorRetryIT extends ESRestHighLevelClientTestCase { private static MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) { MultiGetRequest multiGetRequest = new MultiGetRequest(); for (int i = 1; i <= numDocs; i++) { - processor.add(new IndexRequest(INDEX_NAME, TYPE_NAME, Integer.toString(i)) + processor.add(new IndexRequest(INDEX_NAME, "_doc", Integer.toString(i)) .source(XContentType.JSON, "field", randomRealisticUnicodeOfCodepointLengthBetween(1, 30))); - multiGetRequest.add(INDEX_NAME, TYPE_NAME, Integer.toString(i)); + multiGetRequest.add(INDEX_NAME, Integer.toString(i)); } return multiGetRequest; } 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 e78a7b4e512..c82988a98ad 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 @@ -175,7 +175,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { public void testExists() throws IOException { { - GetRequest getRequest = new GetRequest("index", "_doc", "id"); + GetRequest getRequest = new GetRequest("index", "id"); assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } IndexRequest index = new IndexRequest("index", "_doc", "id"); @@ -183,22 +183,22 @@ public class CrudIT extends ESRestHighLevelClientTestCase { index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); highLevelClient().index(index, RequestOptions.DEFAULT); { - GetRequest getRequest = new GetRequest("index", "_doc", "id"); + GetRequest getRequest = new GetRequest("index", "id"); assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } { - GetRequest getRequest = new GetRequest("index", "_doc", "does_not_exist"); + GetRequest getRequest = new GetRequest("index", "does_not_exist"); assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } { - GetRequest getRequest = new GetRequest("index", "_doc", "does_not_exist").version(1); + GetRequest getRequest = new GetRequest("index", "does_not_exist").version(1); assertFalse(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); } } public void testSourceExists() throws IOException { { - GetRequest getRequest = new GetRequest("index", "_doc", "id"); + GetRequest getRequest = new GetRequest("index", "id"); assertFalse(execute(getRequest, highLevelClient()::existsSource, highLevelClient()::existsSourceAsync)); } IndexRequest index = new IndexRequest("index", "_doc", "id"); @@ -206,15 +206,15 @@ public class CrudIT extends ESRestHighLevelClientTestCase { index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); highLevelClient().index(index, RequestOptions.DEFAULT); { - GetRequest getRequest = new GetRequest("index", "_doc", "id"); + GetRequest getRequest = new GetRequest("index", "id"); assertTrue(execute(getRequest, highLevelClient()::existsSource, highLevelClient()::existsSourceAsync)); } { - GetRequest getRequest = new GetRequest("index", "_doc", "does_not_exist"); + GetRequest getRequest = new GetRequest("index", "does_not_exist"); assertFalse(execute(getRequest, highLevelClient()::existsSource, highLevelClient()::existsSourceAsync)); } { - GetRequest getRequest = new GetRequest("index", "_doc", "does_not_exist").version(1); + GetRequest getRequest = new GetRequest("index", "does_not_exist").version(1); assertFalse(execute(getRequest, highLevelClient()::existsSource, highLevelClient()::existsSourceAsync)); } } @@ -245,7 +245,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { ); } { - GetRequest getRequest = new GetRequest(noSourceIndex, "_doc", "1"); + GetRequest getRequest = new GetRequest(noSourceIndex, "1"); assertTrue(execute(getRequest, highLevelClient()::exists, highLevelClient()::existsAsync)); assertFalse(execute(getRequest, highLevelClient()::existsSource, highLevelClient()::existsSourceAsync)); } @@ -253,7 +253,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { public void testGet() throws IOException { { - GetRequest getRequest = new GetRequest("index", "_doc", "id"); + GetRequest getRequest = new GetRequest("index", "id"); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync)); assertEquals(RestStatus.NOT_FOUND, exception.status()); @@ -266,7 +266,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { index.setRefreshPolicy(RefreshPolicy.IMMEDIATE); highLevelClient().index(index, RequestOptions.DEFAULT); { - GetRequest getRequest = new GetRequest("index", "_doc", "id").version(2); + GetRequest getRequest = new GetRequest("index", "id").version(2); ElasticsearchException exception = expectThrows(ElasticsearchException.class, () -> execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync)); assertEquals(RestStatus.CONFLICT, exception.status()); @@ -275,7 +275,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertEquals("index", exception.getMetadata("es.index").get(0)); } { - GetRequest getRequest = new GetRequest("index", "_doc", "id"); + GetRequest getRequest = new GetRequest("index", "id"); if (randomBoolean()) { getRequest.version(1L); } @@ -289,7 +289,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertEquals(document, getResponse.getSourceAsString()); } { - GetRequest getRequest = new GetRequest("index", "_doc", "does_not_exist"); + GetRequest getRequest = new GetRequest("index", "does_not_exist"); GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); assertEquals("_doc", getResponse.getType()); @@ -300,7 +300,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertNull(getResponse.getSourceAsString()); } { - GetRequest getRequest = new GetRequest("index", "_doc", "id"); + GetRequest getRequest = new GetRequest("index", "id"); getRequest.fetchSourceContext(new FetchSourceContext(false, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY)); GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); @@ -312,7 +312,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertNull(getResponse.getSourceAsString()); } { - GetRequest getRequest = new GetRequest("index", "_doc", "id"); + GetRequest getRequest = new GetRequest("index", "id"); if (randomBoolean()) { getRequest.fetchSourceContext(new FetchSourceContext(true, new String[]{"field1"}, Strings.EMPTY_ARRAY)); } else { @@ -334,15 +334,15 @@ public class CrudIT extends ESRestHighLevelClientTestCase { public void testMultiGet() throws IOException { { MultiGetRequest multiGetRequest = new MultiGetRequest(); - multiGetRequest.add("index", "_doc", "id1"); - multiGetRequest.add("index", "_doc", "id2"); + multiGetRequest.add("index", "id1"); + multiGetRequest.add("index", "id2"); MultiGetResponse response = execute(multiGetRequest, highLevelClient()::mget, highLevelClient()::mgetAsync); assertEquals(2, response.getResponses().length); assertTrue(response.getResponses()[0].isFailed()); assertNull(response.getResponses()[0].getResponse()); assertEquals("id1", response.getResponses()[0].getFailure().getId()); - assertEquals("_doc", response.getResponses()[0].getFailure().getType()); + assertNull(response.getResponses()[0].getFailure().getType()); assertEquals("index", response.getResponses()[0].getFailure().getIndex()); assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index [index]]", response.getResponses()[0].getFailure().getFailure().getMessage()); @@ -350,7 +350,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertTrue(response.getResponses()[1].isFailed()); assertNull(response.getResponses()[1].getResponse()); assertEquals("id2", response.getResponses()[1].getId()); - assertEquals("_doc", response.getResponses()[1].getType()); + assertNull(response.getResponses()[1].getType()); assertEquals("index", response.getResponses()[1].getIndex()); assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index [index]]", response.getResponses()[1].getFailure().getFailure().getMessage()); @@ -366,8 +366,8 @@ public class CrudIT extends ESRestHighLevelClientTestCase { highLevelClient().bulk(bulk, RequestOptions.DEFAULT); { MultiGetRequest multiGetRequest = new MultiGetRequest(); - multiGetRequest.add("index", "_doc", "id1"); - multiGetRequest.add("index", "_doc", "id2"); + multiGetRequest.add("index", "id1"); + multiGetRequest.add("index", "id2"); MultiGetResponse response = execute(multiGetRequest, highLevelClient()::mget, highLevelClient()::mgetAsync); assertEquals(2, response.getResponses().length); @@ -789,7 +789,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertEquals(0, bulkResponse.getSearchFailures().size()); assertEquals( 3, - (int) (highLevelClient().get(new GetRequest(sourceIndex, "_doc", "2"), RequestOptions.DEFAULT) + (int) (highLevelClient().get(new GetRequest(sourceIndex, "2"), RequestOptions.DEFAULT) .getSourceAsMap().get("foo")) ); } @@ -1059,7 +1059,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertEquals("id#1", indexResponse.getId()); } { - GetRequest getRequest = new GetRequest(indexPattern, "_doc", "id#1"); + GetRequest getRequest = new GetRequest(indexPattern, "id#1"); GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals(expectedIndex, getResponse.getIndex()); @@ -1077,7 +1077,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertEquals(docId, indexResponse.getId()); } { - GetRequest getRequest = new GetRequest("index", "_doc", docId); + GetRequest getRequest = new GetRequest("index", docId); GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals("index", getResponse.getIndex()); @@ -1101,7 +1101,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase { assertEquals("id", indexResponse.getId()); } { - GetRequest getRequest = new GetRequest("index", "_doc", "id").routing(routing); + GetRequest getRequest = new GetRequest("index", "id").routing(routing); GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals("index", getResponse.getIndex()); 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 73c146c954f..841b5399bfb 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 @@ -527,7 +527,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { // Set up the index and docs CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); - createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long"); + createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long"); highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); BulkRequest bulk = new BulkRequest(); bulk.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); @@ -538,7 +538,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { while(pastCopy < now) { IndexRequest doc = new IndexRequest(); doc.index(indexName); - doc.type("doc"); + doc.type("_doc"); doc.id("id" + i); doc.source("{\"total\":" +randomInt(1000) + ",\"timestamp\":"+ pastCopy +"}", XContentType.JSON); bulk.add(doc); @@ -558,7 +558,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId, jobId) .setIndices(indexName) .setQueryDelay(TimeValue.timeValueSeconds(1)) - .setTypes(Arrays.asList("doc")) + .setTypes(Arrays.asList("_doc")) .setFrequency(TimeValue.timeValueSeconds(1)).build(); machineLearningClient.putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); @@ -603,7 +603,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { // Set up the index CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); - createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long"); + createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long"); highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); // create the job and the datafeed @@ -667,7 +667,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { // Set up the index CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); - createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long"); + createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long"); highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); // create the job and the datafeed @@ -736,7 +736,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { // Set up the index and docs CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); - createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long"); + createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long"); highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); BulkRequest bulk = new BulkRequest(); bulk.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); @@ -748,7 +748,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { Integer total = randomInt(1000); IndexRequest doc = new IndexRequest(); doc.index(indexName); - doc.type("doc"); + doc.type("_doc"); doc.id("id" + i); doc.source("{\"total\":" + total + ",\"timestamp\":"+ thePast +"}", XContentType.JSON); bulk.add(doc); @@ -768,7 +768,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId, jobId) .setIndices(indexName) .setQueryDelay(TimeValue.timeValueSeconds(1)) - .setTypes(Collections.singletonList("doc")) + .setTypes(Collections.singletonList("_doc")) .setFrequency(TimeValue.timeValueSeconds(1)).build(); machineLearningClient.putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); @@ -795,7 +795,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { String indexId = jobId + "-data"; // Set up the index and docs CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexId); - createIndexRequest.mapping("doc", "timestamp", "type=date,format=epoch_millis", "total", "type=long"); + createIndexRequest.mapping("_doc", "timestamp", "type=date,format=epoch_millis", "total", "type=long"); highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); BulkRequest bulk = new BulkRequest(); bulk.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); @@ -809,7 +809,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { long timestamp = nowMillis - TimeValue.timeValueHours(totalBuckets - bucket).getMillis(); int bucketRate = bucket == anomalousBucket ? anomalousRate : normalRate; for (int point = 0; point < bucketRate; point++) { - IndexRequest indexRequest = new IndexRequest(indexId, "doc"); + IndexRequest indexRequest = new IndexRequest(indexId, "_doc"); indexRequest.source(XContentType.JSON, "timestamp", timestamp, "total", randomInt(1000)); bulk.add(indexRequest); } @@ -819,7 +819,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { { // Index a randomly named unused state document String docId = "non_existing_job_" + randomFrom("model_state_1234567#1", "quantiles", "categorizer_state#1"); - IndexRequest indexRequest = new IndexRequest(".ml-state", "doc", docId); + IndexRequest indexRequest = new IndexRequest(".ml-state", "_doc", docId); indexRequest.source(Collections.emptyMap(), XContentType.JSON); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); highLevelClient().index(indexRequest, RequestOptions.DEFAULT); @@ -1388,7 +1388,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { 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, "_doc", documentId); updateSnapshotRequest.doc(snapshotUpdate.getBytes(StandardCharsets.UTF_8), XContentType.JSON); highLevelClient().update(updateSnapshotRequest, RequestOptions.DEFAULT); @@ -1403,7 +1403,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId, jobId) .setIndices(indexName) .setQueryDelay(TimeValue.timeValueSeconds(1)) - .setTypes(Arrays.asList("doc")) + .setTypes(Arrays.asList("_doc")) .setFrequency(TimeValue.timeValueSeconds(1)).build(); highLevelClient().machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); return datafeedId; @@ -1414,7 +1414,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { 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", "_doc", 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\", " + @@ -1434,7 +1434,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase { 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", "_doc", 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/documentation/CRUDDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java index 4fc7fd21a39..ca15b20b163 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java @@ -1258,8 +1258,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { //tag::get-request GetRequest getRequest = new GetRequest( "posts", // <1> - "_doc", // <2> - "1"); // <3> + "1"); // <2> //end::get-request //tag::get-execute @@ -1282,7 +1281,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { //end::get-response } { - GetRequest request = new GetRequest("posts", "_doc", "1"); + GetRequest request = new GetRequest("posts", "1"); //tag::get-request-no-source request.fetchSourceContext(FetchSourceContext.DO_NOT_FETCH_SOURCE); // <1> //end::get-request-no-source @@ -1290,7 +1289,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { assertNull(getResponse.getSourceInternal()); } { - GetRequest request = new GetRequest("posts", "_doc", "1"); + GetRequest request = new GetRequest("posts", "1"); //tag::get-request-source-include String[] includes = new String[]{"message", "*Date"}; String[] excludes = Strings.EMPTY_ARRAY; @@ -1305,7 +1304,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { assertTrue(sourceAsMap.containsKey("postDate")); } { - GetRequest request = new GetRequest("posts", "_doc", "1"); + GetRequest request = new GetRequest("posts", "1"); //tag::get-request-source-exclude String[] includes = Strings.EMPTY_ARRAY; String[] excludes = new String[]{"message"}; @@ -1320,7 +1319,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { assertTrue(sourceAsMap.containsKey("postDate")); } { - GetRequest request = new GetRequest("posts", "_doc", "1"); + GetRequest request = new GetRequest("posts", "1"); //tag::get-request-stored request.storedFields("message"); // <1> GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); @@ -1331,7 +1330,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { assertNull(getResponse.getSourceInternal()); } { - GetRequest request = new GetRequest("posts", "_doc", "1"); + GetRequest request = new GetRequest("posts", "1"); //tag::get-request-routing request.routing("routing"); // <1> //end::get-request-routing @@ -1352,7 +1351,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { //end::get-request-version-type } { - GetRequest request = new GetRequest("posts", "_doc", "1"); + GetRequest request = new GetRequest("posts", "1"); // tag::get-execute-listener ActionListener listener = new ActionListener() { @@ -1380,7 +1379,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { } { //tag::get-indexnotfound - GetRequest request = new GetRequest("does_not_exist", "_doc", "1"); + GetRequest request = new GetRequest("does_not_exist", "1"); try { GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); } catch (ElasticsearchException e) { @@ -1393,7 +1392,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { { // tag::get-conflict try { - GetRequest request = new GetRequest("posts", "_doc", "1").version(2); + GetRequest request = new GetRequest("posts", "1").version(2); GetResponse getResponse = client.get(request, RequestOptions.DEFAULT); } catch (ElasticsearchException exception) { if (exception.status() == RestStatus.CONFLICT) { @@ -1409,10 +1408,9 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { // tag::exists-request GetRequest getRequest = new GetRequest( "posts", // <1> - "_doc", // <2> - "1"); // <3> - getRequest.fetchSourceContext(new FetchSourceContext(false)); // <4> - getRequest.storedFields("_none_"); // <5> + "1"); // <2> + getRequest.fetchSourceContext(new FetchSourceContext(false)); // <3> + getRequest.storedFields("_none_"); // <4> // end::exists-request { // tag::exists-execute @@ -1779,18 +1777,17 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { MultiGetRequest request = new MultiGetRequest(); request.add(new MultiGetRequest.Item( "index", // <1> - "_doc", // <2> - "example_id")); // <3> - request.add(new MultiGetRequest.Item("index", "_doc", "another_id")); // <4> + "example_id")); // <2> + request.add(new MultiGetRequest.Item("index", "another_id")); // <3> // end::multi-get-request // Add a missing index so we can test it. - request.add(new MultiGetRequest.Item("missing_index", "_doc", "id")); + request.add(new MultiGetRequest.Item("missing_index", "id")); // tag::multi-get-request-item-extras - request.add(new MultiGetRequest.Item("index", "_doc", "with_routing") + request.add(new MultiGetRequest.Item("index", "with_routing") .routing("some_routing")); // <1> - request.add(new MultiGetRequest.Item("index", "_doc", "with_version") + request.add(new MultiGetRequest.Item("index", "with_version") .versionType(VersionType.EXTERNAL) // <2> .version(10123L)); // <3> // end::multi-get-request-item-extras @@ -1809,7 +1806,6 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { assertNull(firstItem.getFailure()); // <1> GetResponse firstGet = firstItem.getResponse(); // <2> String index = firstItem.getIndex(); - String type = firstItem.getType(); String id = firstItem.getId(); if (firstGet.isExists()) { long version = firstGet.getVersion(); @@ -1863,7 +1859,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { { MultiGetRequest request = new MultiGetRequest(); // tag::multi-get-request-no-source - request.add(new MultiGetRequest.Item("index", "_doc", "example_id") + request.add(new MultiGetRequest.Item("index", "example_id") .fetchSourceContext(FetchSourceContext.DO_NOT_FETCH_SOURCE)); // <1> // end::multi-get-request-no-source MultiGetItemResponse item = unwrapAndAssertExample(client.mget(request, RequestOptions.DEFAULT)); @@ -1876,7 +1872,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { String[] excludes = Strings.EMPTY_ARRAY; FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); - request.add(new MultiGetRequest.Item("index", "_doc", "example_id") + request.add(new MultiGetRequest.Item("index", "example_id") .fetchSourceContext(fetchSourceContext)); // <1> // end::multi-get-request-source-include MultiGetItemResponse item = unwrapAndAssertExample(client.mget(request, RequestOptions.DEFAULT)); @@ -1891,7 +1887,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { String[] excludes = new String[] {"foo", "*r"}; FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); - request.add(new MultiGetRequest.Item("index", "_doc", "example_id") + request.add(new MultiGetRequest.Item("index", "example_id") .fetchSourceContext(fetchSourceContext)); // <1> // end::multi-get-request-source-exclude MultiGetItemResponse item = unwrapAndAssertExample(client.mget(request, RequestOptions.DEFAULT)); @@ -1902,7 +1898,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { { MultiGetRequest request = new MultiGetRequest(); // tag::multi-get-request-stored - request.add(new MultiGetRequest.Item("index", "_doc", "example_id") + request.add(new MultiGetRequest.Item("index", "example_id") .storedFields("foo")); // <1> MultiGetResponse response = client.mget(request, RequestOptions.DEFAULT); MultiGetItemResponse item = response.getResponses()[0]; @@ -1914,7 +1910,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase { { // tag::multi-get-conflict MultiGetRequest request = new MultiGetRequest(); - request.add(new MultiGetRequest.Item("index", "_doc", "example_id") + request.add(new MultiGetRequest.Item("index", "example_id") .version(1000L)); MultiGetResponse response = client.mget(request, RequestOptions.DEFAULT); MultiGetItemResponse item = response.getResponses()[0]; diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java index 6b9bf7a4c8b..d049e02f52e 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java @@ -106,7 +106,7 @@ public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase { } }); //end::migration-request-async-execution - assertBusy(() -> assertFalse(client.exists(new GetRequest("index", "_doc", "id"), RequestOptions.DEFAULT))); + assertBusy(() -> assertFalse(client.exists(new GetRequest("index", "id"), RequestOptions.DEFAULT))); } { //tag::migration-request-sync-execution 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 0ef6c8d6828..414e2553f84 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 @@ -764,7 +764,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // tag::get-datafeed-execute GetDatafeedResponse response = client.machineLearning().getDatafeed(request, RequestOptions.DEFAULT); // end::get-datafeed-execute - + // tag::get-datafeed-response long numberOfDatafeeds = response.count(); // <1> List datafeeds = response.datafeeds(); // <2> @@ -823,7 +823,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { AcknowledgedResponse deleteDatafeedResponse = client.machineLearning().deleteDatafeed( deleteDatafeedRequest, RequestOptions.DEFAULT); // end::delete-datafeed-execute - + // tag::delete-datafeed-response boolean isAcknowledged = deleteDatafeedResponse.isAcknowledged(); // <1> // end::delete-datafeed-response @@ -869,10 +869,10 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { String datafeedId = job.getId() + "-feed"; String indexName = "preview_data_2"; CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); - createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long"); + createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long"); highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId, job.getId()) - .setTypes(Arrays.asList("doc")) + .setTypes(Arrays.asList("_doc")) .setIndices(indexName) .build(); client.machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); @@ -929,10 +929,10 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { String datafeedId = job.getId() + "-feed"; String indexName = "start_data_2"; CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); - createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long"); + createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long"); highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId, job.getId()) - .setTypes(Arrays.asList("doc")) + .setTypes(Arrays.asList("_doc")) .setIndices(indexName) .build(); client.machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); @@ -1050,17 +1050,17 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { String datafeedId1 = job.getId() + "-feed"; String indexName = "datafeed_stats_data_2"; CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName); - createIndexRequest.mapping("doc", "timestamp", "type=date", "total", "type=long"); + createIndexRequest.mapping("_doc", "timestamp", "type=date", "total", "type=long"); highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT); DatafeedConfig datafeed = DatafeedConfig.builder(datafeedId1, job.getId()) - .setTypes(Arrays.asList("doc")) + .setTypes(Arrays.asList("_doc")) .setIndices(indexName) .build(); client.machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); String datafeedId2 = secondJob.getId() + "-feed"; DatafeedConfig secondDatafeed = DatafeedConfig.builder(datafeedId2, secondJob.getId()) - .setTypes(Arrays.asList("doc")) + .setTypes(Arrays.asList("_doc")) .setIndices(indexName) .build(); client.machineLearning().putDatafeed(new PutDatafeedRequest(secondDatafeed), RequestOptions.DEFAULT); @@ -1123,7 +1123,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { 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", "_doc"); 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); @@ -1277,7 +1277,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { assertTrue(latch.await(30L, TimeUnit.SECONDS)); } } - + public void testDeleteForecast() throws Exception { RestHighLevelClient client = highLevelClient(); @@ -1356,7 +1356,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { assertTrue(latch.await(30L, TimeUnit.SECONDS)); } } - + public void testGetJobStats() throws Exception { RestHighLevelClient client = highLevelClient(); @@ -1481,7 +1481,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { assertTrue(latch.await(30L, TimeUnit.SECONDS)); } } - + public void testGetOverallBuckets() throws IOException, InterruptedException { RestHighLevelClient client = highLevelClient(); @@ -1497,13 +1497,13 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); { - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "doc"); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc"); indexRequest.source("{\"job_id\":\"test-get-overall-buckets-1\", \"result_type\":\"bucket\", \"timestamp\": 1533081600000," + "\"bucket_span\": 600,\"is_interim\": false, \"anomaly_score\": 60.0}", XContentType.JSON); bulkRequest.add(indexRequest); } { - IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "doc"); + IndexRequest indexRequest = new IndexRequest(".ml-anomalies-shared", "_doc"); indexRequest.source("{\"job_id\":\"test-get-overall-buckets-2\", \"result_type\":\"bucket\", \"timestamp\": 1533081600000," + "\"bucket_span\": 3600,\"is_interim\": false, \"anomaly_score\": 100.0}", XContentType.JSON); bulkRequest.add(indexRequest); @@ -1591,7 +1591,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { 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", "_doc"); 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); @@ -1810,7 +1810,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { 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", "_doc"); 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\"," + @@ -1901,7 +1901,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { 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", "_doc"); 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); @@ -2022,7 +2022,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { 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", "_doc"); 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\", " + @@ -2088,7 +2088,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { 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", "_doc"); 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\", " + @@ -2186,7 +2186,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // 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", "_doc", 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\", " + @@ -2262,7 +2262,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { 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", "_doc", 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\", " + @@ -2475,7 +2475,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { assertTrue(latch.await(30L, TimeUnit.SECONDS)); } } - + public void testGetCalendar() throws IOException, InterruptedException { RestHighLevelClient client = highLevelClient(); @@ -2658,7 +2658,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { assertTrue(latch.await(30L, TimeUnit.SECONDS)); } } - + public void testPostCalendarEvent() throws IOException, InterruptedException { RestHighLevelClient client = highLevelClient(); diff --git a/distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/CreatedLocationHeaderIT.java b/distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/CreatedLocationHeaderIT.java index 71a41db80a2..5b0457d01b0 100644 --- a/distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/CreatedLocationHeaderIT.java +++ b/distribution/archives/integ-test-zip/src/test/java/org/elasticsearch/test/rest/CreatedLocationHeaderIT.java @@ -34,19 +34,19 @@ import static org.hamcrest.Matchers.startsWith; public class CreatedLocationHeaderIT extends ESRestTestCase { public void testCreate() throws IOException { - locationTestCase("PUT", "test/test/1"); + locationTestCase("PUT", "test/_doc/1"); } public void testIndexWithId() throws IOException { - locationTestCase("PUT", "test/test/1"); + locationTestCase("PUT", "test/_doc/1"); } public void testIndexWithoutId() throws IOException { - locationTestCase("POST", "test/test"); + locationTestCase("POST", "test/_doc"); } public void testUpsert() throws IOException { - Request request = new Request("POST", "test/test/1/_update"); + Request request = new Request("POST", "test/_doc/1/_update"); request.setJsonEntity("{" + "\"doc\": {\"test\": \"test\"}," + "\"doc_as_upsert\": true}"); @@ -69,7 +69,7 @@ public class CreatedLocationHeaderIT extends ESRestTestCase { private void locationTestCase(Response response) throws IOException { assertEquals(201, response.getStatusLine().getStatusCode()); String location = response.getHeader("Location"); - assertThat(location, startsWith("/test/test/")); + assertThat(location, startsWith("/test/_doc/")); Response getResponse = client().performRequest(new Request("GET", location)); assertEquals(singletonMap("test", "test"), entityAsMap(getResponse).get("_source")); } diff --git a/docs/java-rest/high-level/document/exists.asciidoc b/docs/java-rest/high-level/document/exists.asciidoc index 3a09203bab6..7ca3b82fb86 100644 --- a/docs/java-rest/high-level/document/exists.asciidoc +++ b/docs/java-rest/high-level/document/exists.asciidoc @@ -23,10 +23,9 @@ slightly lighter: include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Index -<2> Type -<3> Document id -<4> Disable fetching `_source`. -<5> Disable fetching stored fields. +<2> Document id +<3> Disable fetching `_source`. +<4> Disable fetching stored fields. include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/document/get.asciidoc b/docs/java-rest/high-level/document/get.asciidoc index f3ea9434f71..2916eb9335c 100644 --- a/docs/java-rest/high-level/document/get.asciidoc +++ b/docs/java-rest/high-level/document/get.asciidoc @@ -17,8 +17,7 @@ A +{request}+ requires the following arguments: include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Index -<2> Type -<3> Document id +<2> Document id [id="{upid}-{api}-request-optional-arguments"] ==== Optional arguments diff --git a/docs/java-rest/high-level/document/multi-get.asciidoc b/docs/java-rest/high-level/document/multi-get.asciidoc index 30b7d37313e..f63bf898922 100644 --- a/docs/java-rest/high-level/document/multi-get.asciidoc +++ b/docs/java-rest/high-level/document/multi-get.asciidoc @@ -21,9 +21,8 @@ what to fetch: include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Index -<2> Type -<3> Document id -<4> Add another item to fetch +<2> Document id +<3> Add another item to fetch ==== Optional arguments diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index d251995f6ca..b7202043bb9 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -93,7 +93,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { } { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("doc"); + mappingsAndSettings.startObject("_doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("string"); @@ -159,7 +159,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { } { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("doc"); + mappingsAndSettings.startObject("_doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -230,7 +230,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { } { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("doc"); + mappingsAndSettings.startObject("_doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("key"); @@ -333,7 +333,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { mappingsAndSettings.startObject(); { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("doc"); + mappingsAndSettings.startObject("_doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -401,7 +401,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { mappingsAndSettings.startObject(); { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("doc"); + mappingsAndSettings.startObject("_doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -489,7 +489,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { bulk.append("{\"index\":{}}\n"); bulk.append("{\"test\":\"test\"}\n"); } - Request bulkRequest = new Request("POST", "/" + index + "_write/doc/_bulk"); + Request bulkRequest = new Request("POST", "/" + index + "_write/_doc/_bulk"); bulkRequest.setJsonEntity(bulk.toString()); bulkRequest.addParameter("refresh", ""); assertThat(EntityUtils.toString(client().performRequest(bulkRequest).getEntity()), containsString("\"errors\":false")); @@ -619,11 +619,11 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { Map hit = (Map) ((List)(XContentMapValues.extractValue("hits.hits", searchResponse))).get(0); String docId = (String) hit.get("_id"); - Request updateRequest = new Request("POST", "/" + index + "/doc/" + docId + "/_update"); + Request updateRequest = new Request("POST", "/" + index + "/_doc/" + docId + "/_update"); updateRequest.setJsonEntity("{ \"doc\" : { \"foo\": \"bar\"}}"); client().performRequest(updateRequest); - Map getRsp = entityAsMap(client().performRequest(new Request("GET", "/" + index + "/doc/" + docId))); + Map getRsp = entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_doc/" + docId))); Map source = (Map) getRsp.get("_source"); assertTrue("doc does not contain 'foo' key: " + source, source.containsKey("foo")); @@ -676,7 +676,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { * Tests that a single document survives. Super basic smoke test. */ public void testSingleDoc() throws IOException { - String docLocation = "/" + index + "/doc/1"; + String docLocation = "/" + index + "/_doc/1"; String doc = "{\"test\": \"test\"}"; if (isRunningAgainstOldCluster()) { @@ -863,7 +863,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { } templateBuilder.endObject(); templateBuilder.startObject("mappings"); { - templateBuilder.startObject("doc"); { + templateBuilder.startObject("_doc"); { templateBuilder.startObject("_source"); { templateBuilder.field("enabled", true); } @@ -973,7 +973,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { int numDocs = between(10, 100); for (int i = 0; i < numDocs; i++) { String doc = Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v1").endObject()); - Request request = new Request("POST", "/" + index + "/doc/" + i); + Request request = new Request("POST", "/" + index + "/_doc/" + i); request.setJsonEntity(doc); client().performRequest(request); if (rarely()) { @@ -986,11 +986,11 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { for (int i = 0; i < numDocs; i++) { if (randomBoolean()) { String doc = Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v2").endObject()); - Request request = new Request("POST", "/" + index + "/doc/" + i); + Request request = new Request("POST", "/" + index + "/_doc/" + i); request.setJsonEntity(doc); client().performRequest(request); } else if (randomBoolean()) { - client().performRequest(new Request("DELETE", "/" + index + "/doc/" + i)); + client().performRequest(new Request("DELETE", "/" + index + "/_doc/" + i)); liveDocs--; } } @@ -1056,7 +1056,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { bulk.append("{\"index\":{\"_id\":\"").append(count + i).append("\"}}\n"); bulk.append("{\"test\":\"test\"}\n"); } - Request writeToRestoredRequest = new Request("POST", "/restored_" + index + "/doc/_bulk"); + Request writeToRestoredRequest = new Request("POST", "/restored_" + index + "/_doc/_bulk"); writeToRestoredRequest.addParameter("refresh", "true"); writeToRestoredRequest.setJsonEntity(bulk.toString()); assertThat(EntityUtils.toString(client().performRequest(writeToRestoredRequest).getEntity()), containsString("\"errors\":false")); @@ -1088,7 +1088,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { expectedTemplate.put("index_patterns", singletonList("evil_*")); } expectedTemplate.put("settings", singletonMap("index", singletonMap("number_of_shards", "1"))); - expectedTemplate.put("mappings", singletonMap("doc", singletonMap("_source", singletonMap("enabled", true)))); + expectedTemplate.put("mappings", singletonMap("_doc", singletonMap("_source", singletonMap("enabled", true)))); expectedTemplate.put("order", 0); Map aliases = new HashMap<>(); aliases.put("alias1", emptyMap()); @@ -1109,7 +1109,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { logger.info("Indexing {} random documents", count); for (int i = 0; i < count; i++) { logger.debug("Indexing document [{}]", i); - Request createDocument = new Request("POST", "/" + index + "/doc/" + i); + Request createDocument = new Request("POST", "/" + index + "/_doc/" + i); createDocument.setJsonEntity(Strings.toString(docSupplier.apply(i))); client().performRequest(createDocument); if (rarely()) { @@ -1134,14 +1134,14 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { infoDoc.field("value", value); infoDoc.endObject(); // Only create the first version so we know how many documents are created when the index is first created - Request request = new Request("PUT", "/info/doc/" + index + "_" + type); + Request request = new Request("PUT", "/info/_doc/" + index + "_" + type); request.addParameter("op_type", "create"); request.setJsonEntity(Strings.toString(infoDoc)); client().performRequest(request); } private String loadInfoDocument(String type) throws IOException { - Request request = new Request("GET", "/info/doc/" + index + "_" + type); + Request request = new Request("GET", "/info/_doc/" + index + "_" + type); request.addParameter("filter_path", "_source"); String doc = toStr(client().performRequest(request)); Matcher m = Pattern.compile("\"value\":\"(.+)\"").matcher(doc); 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 22a3fa65eec..380235b5476 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 @@ -45,7 +45,7 @@ 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 + "/test/" + id); + Request request = new Request("PUT", index + "/_doc/" + id); request.setJsonEntity("{\"test\": \"test_" + randomAlphaOfLength(2) + "\"}"); assertOK(client().performRequest(request)); } @@ -284,7 +284,7 @@ public class IndexingIT extends ESRestTestCase { } private void assertVersion(final String index, final int docId, final String preference, final int expectedVersion) throws IOException { - Request request = new Request("GET", index + "/test/" + docId); + Request request = new Request("GET", index + "/_doc/" + docId); request.addParameter("preference", preference); final Response response = client().performRequest(request); assertOK(response); diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/exists.json b/rest-api-spec/src/main/resources/rest-api-spec/api/exists.json index 2a7a1ffc728..1d3749a5d8c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/exists.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/exists.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html", "methods": ["HEAD"], "url": { - "path": "/{index}/{type}/{id}", - "paths": ["/{index}/{type}/{id}"], + "path": "/{index}/_doc/{id}", + "paths": ["/{index}/_doc/{id}", "/{index}/{type}/{id}"], "parts": { "id": { "type" : "string", @@ -18,7 +18,6 @@ }, "type": { "type" : "string", - "required" : true, "description" : "The type of the document (use `_all` to fetch the first document matching the ID across all types)" } }, diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/get.json b/rest-api-spec/src/main/resources/rest-api-spec/api/get.json index f97caede15a..ac3024c9c24 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/get.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/get.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html", "methods": ["GET"], "url": { - "path": "/{index}/{type}/{id}", - "paths": ["/{index}/{type}/{id}", "/{index}/_doc/{id}"], + "path": "/{index}/_doc/{id}", + "paths": ["/{index}/_doc/{id}", "/{index}/{type}/{id}"], "parts": { "id": { "type" : "string", diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/10_basic.yml index 7e4e26b6b1c..d98cbfca5b4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/10_basic.yml @@ -1,10 +1,12 @@ --- "Basic": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: exists: index: test_1 - type: test id: 1 - is_false: '' @@ -12,7 +14,7 @@ - do: index: index: test_1 - type: test + type: _doc id: 1 body: { "foo": "bar" } @@ -21,7 +23,6 @@ - do: exists: index: test_1 - type: test id: 1 - is_true: '' @@ -29,7 +30,6 @@ - do: exists: index: test_1 - type: test id: 1 version: 1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/11_basic_with_types.yml new file mode 100644 index 00000000000..7e4e26b6b1c --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/11_basic_with_types.yml @@ -0,0 +1,36 @@ +--- +"Basic": + + - do: + exists: + index: test_1 + type: test + id: 1 + + - is_false: '' + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + version: 1 + + - is_true: '' diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/40_routing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/40_routing.yml index 25315628d7e..a4ff0351729 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/40_routing.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/40_routing.yml @@ -1,5 +1,8 @@ --- "Routing": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: indices.create: @@ -18,7 +21,7 @@ - do: index: index: test_1 - type: test + type: _doc id: 1 routing: 5 body: { foo: bar } @@ -26,7 +29,6 @@ - do: exists: index: test_1 - type: test id: 1 routing: 5 @@ -35,7 +37,6 @@ - do: exists: index: test_1 - type: test id: 1 - is_false: '' diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/41_routing_with_types.yml new file mode 100644 index 00000000000..25315628d7e --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/41_routing_with_types.yml @@ -0,0 +1,41 @@ +--- +"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: + exists: + index: test_1 + type: test + id: 1 + routing: 5 + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + + - is_false: '' diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/60_realtime_refresh.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/60_realtime_refresh.yml index df8c697e4a1..23168319227 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/60_realtime_refresh.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/60_realtime_refresh.yml @@ -1,5 +1,8 @@ --- "Realtime Refresh": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: indices.create: @@ -17,14 +20,13 @@ - do: index: index: test_1 - type: test + type: _doc id: 1 body: { foo: bar } - do: exists: index: test_1 - type: test id: 1 realtime: false @@ -33,7 +35,6 @@ - do: exists: index: test_1 - type: test id: 1 realtime: true @@ -42,7 +43,6 @@ - do: exists: index: test_1 - type: test id: 1 realtime: false refresh: true diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/61_realtime_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/61_realtime_refresh_with_types.yml new file mode 100644 index 00000000000..df8c697e4a1 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/61_realtime_refresh_with_types.yml @@ -0,0 +1,50 @@ +--- +"Realtime Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + refresh_interval: -1 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + exists: + index: test_1 + type: test + id: 1 + realtime: false + + - is_false: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + realtime: true + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + realtime: false + refresh: true + + - is_true: '' diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/70_defaults.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/70_defaults.yml index 2db28f6634b..c1e11303767 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/70_defaults.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/70_defaults.yml @@ -1,17 +1,19 @@ --- "Client-side default type": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: index: index: test_1 - type: test + type: _doc id: 1 body: { "foo": "bar" } - do: exists: index: test_1 - type: _all id: 1 - is_true: '' diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/71_defaults_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/71_defaults_with_types.yml new file mode 100644 index 00000000000..2db28f6634b --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/71_defaults_with_types.yml @@ -0,0 +1,17 @@ +--- +"Client-side default type": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - do: + exists: + index: test_1 + type: _all + id: 1 + + - is_true: '' diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/10_basic.yml index 0850772ad42..64216f16654 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/10_basic.yml @@ -1,12 +1,16 @@ --- "Basic multi-get": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 + - do: indices.create: index: test_2 - do: index: index: test_1 - type: test + type: _doc id: 1 body: { foo: bar } @@ -17,29 +21,23 @@ mget: body: docs: - - { _index: test_2, _type: test, _id: 1} - - { _index: test_1, _type: none, _id: 1} - - { _index: test_1, _type: test, _id: 2} - - { _index: test_1, _type: test, _id: 1} + - { _index: test_2, _id: 1} + - { _index: test_1, _id: 2} + - { _index: test_1, _id: 1} - is_false: docs.0.found - match: { docs.0._index: test_2 } - - match: { docs.0._type: test } + - match: { docs.0._type: null } - match: { docs.0._id: "1" } - is_false: docs.1.found - match: { docs.1._index: test_1 } - - match: { docs.1._type: none } - - match: { docs.1._id: "1" } + - match: { docs.1._type: _doc } + - match: { docs.1._id: "2" } - - is_false: docs.2.found + - is_true: docs.2.found - match: { docs.2._index: test_1 } - - match: { docs.2._type: test } - - match: { docs.2._id: "2" } - - - is_true: docs.3.found - - match: { docs.3._index: test_1 } - - match: { docs.3._type: test } - - match: { docs.3._id: "1" } - - match: { docs.3._version: 1 } - - match: { docs.3._source: { foo: bar }} + - match: { docs.2._type: _doc } + - match: { docs.2._id: "1" } + - match: { docs.2._version: 1 } + - match: { docs.2._source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/12_non_existent_index.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/12_non_existent_index.yml index 06234642250..4e2bf0c5d61 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/12_non_existent_index.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/12_non_existent_index.yml @@ -1,9 +1,13 @@ --- "Non-existent index": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 + - do: index: index: test_1 - type: test + type: _doc id: 1 body: { foo: bar } @@ -11,20 +15,20 @@ mget: body: docs: - - { _index: test_2, _type: test, _id: 1} + - { _index: test_2, _id: 1} - is_false: docs.0.found - match: { docs.0._index: test_2 } - - match: { docs.0._type: test } + - match: { docs.0._type: null } - match: { docs.0._id: "1" } - do: mget: body: docs: - - { _index: test_1, _type: test, _id: 1} + - { _index: test_1, _id: 1} - is_true: docs.0.found - match: { docs.0._index: test_1 } - - match: { docs.0._type: test } + - match: { docs.0._type: _doc } - match: { docs.0._id: "1" } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/13_missing_metadata.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/13_missing_metadata.yml index d7af1797f7a..6138264d680 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/13_missing_metadata.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/13_missing_metadata.yml @@ -1,10 +1,13 @@ --- "Missing metadata": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: index: index: test_1 - type: test + type: _doc id: 1 body: { foo: bar } @@ -13,14 +16,14 @@ mget: body: docs: - - { _index: test_1, _type: test} + - { _index: test_1 } - do: catch: /action_request_validation_exception.+ index is missing/ mget: body: docs: - - { _type: test, _id: 1} + - { _id: 1 } - do: catch: /action_request_validation_exception.+ no documents to get/ @@ -41,7 +44,7 @@ - is_true: docs.0.found - match: { docs.0._index: test_1 } - - match: { docs.0._type: test } + - match: { docs.0._type: _doc } - match: { docs.0._id: "1" } - match: { docs.0._version: 1 } - match: { docs.0._source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/14_alias_to_multiple_indices.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/14_alias_to_multiple_indices.yml index 3a0fec04738..4ee56995639 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/14_alias_to_multiple_indices.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/14_alias_to_multiple_indices.yml @@ -1,15 +1,18 @@ --- "Multi Get with alias that resolves to multiple indices": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: bulk: refresh: true body: | - {"index": {"_index": "test_1", "_type": "test", "_id": 1}} + {"index": {"_index": "test_1", "_type": "_doc", "_id": 1}} { "foo": "bar" } - {"index": {"_index": "test_2", "_type": "test", "_id": 2}} + {"index": {"_index": "test_2", "_type": "_doc", "_id": 2}} { "foo": "bar" } - {"index": {"_index": "test_3", "_type": "test", "_id": 3}} + {"index": {"_index": "test_3", "_type": "_doc", "_id": 3}} { "foo": "bar" } - do: @@ -26,17 +29,17 @@ mget: body: docs: - - { _index: test_1, _type: test, _id: 1} - - { _index: test_two_and_three, _type: test, _id: 2} + - { _index: test_1, _id: 1} + - { _index: test_two_and_three, _id: 2} - is_true: docs.0.found - match: { docs.0._index: test_1 } - - match: { docs.0._type: test } + - match: { docs.0._type: _doc } - match: { docs.0._id: "1" } - is_false: docs.1.found - match: { docs.1._index: test_two_and_three } - - match: { docs.1._type: test } + - match: { docs.1._type: null } - match: { docs.1._id: "2" } - match: { docs.1.error.root_cause.0.type: "illegal_argument_exception" } - match: { docs.1.error.root_cause.0.reason: "/Alias.\\[test_two_and_three\\].has.more.than.one.indices.associated.with.it.\\[\\[test_[23]{1},.test_[23]{1}\\]\\],.can't.execute.a.single.index.op/" } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/15_ids.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/15_ids.yml index 6c233e4d92a..110b00c5f20 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/15_ids.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/15_ids.yml @@ -1,5 +1,9 @@ --- "IDs": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 + - do: indices.create: index: test_1 @@ -7,34 +11,33 @@ - do: index: index: test_1 - type: test + type: _doc id: 1 body: { foo: bar } - do: index: index: test_1 - type: test + type: _doc id: 2 body: { foo: baz } - do: mget: index: test_1 - type: test body: ids: [1, 3] - is_true: docs.0.found - match: { docs.0._index: test_1 } - - match: { docs.0._type: test } + - match: { docs.0._type: _doc } - match: { docs.0._id: "1" } - match: { docs.0._version: 1 } - match: { docs.0._source: { foo: bar }} - is_false: docs.1.found - match: { docs.1._index: test_1 } - - match: { docs.1._type: test } + - match: { docs.1._type: _doc } - match: { docs.1._id: "3" } - do: @@ -45,14 +48,14 @@ - is_true: docs.0.found - match: { docs.0._index: test_1 } - - match: { docs.0._type: test } + - match: { docs.0._type: _doc } - match: { docs.0._id: "1" } - match: { docs.0._version: 1 } - match: { docs.0._source: { foo: bar }} - is_true: docs.1.found - match: { docs.1._index: test_1 } - - match: { docs.1._type: test } + - match: { docs.1._type: _doc } - match: { docs.1._id: "2" } - match: { docs.1._version: 1 } - match: { docs.1._source: { foo: baz }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/16_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/16_basic_with_types.yml new file mode 100644 index 00000000000..0850772ad42 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/16_basic_with_types.yml @@ -0,0 +1,45 @@ +--- +"Basic multi-get": + - do: + indices.create: + index: test_2 + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + indices.refresh: {} + + - do: + mget: + body: + docs: + - { _index: test_2, _type: test, _id: 1} + - { _index: test_1, _type: none, _id: 1} + - { _index: test_1, _type: test, _id: 2} + - { _index: test_1, _type: test, _id: 1} + + - is_false: docs.0.found + - match: { docs.0._index: test_2 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + + - is_false: docs.1.found + - match: { docs.1._index: test_1 } + - match: { docs.1._type: none } + - match: { docs.1._id: "1" } + + - is_false: docs.2.found + - match: { docs.2._index: test_1 } + - match: { docs.2._type: test } + - match: { docs.2._id: "2" } + + - is_true: docs.3.found + - match: { docs.3._index: test_1 } + - match: { docs.3._type: test } + - match: { docs.3._id: "1" } + - match: { docs.3._version: 1 } + - match: { docs.3._source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/17_default_index.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/17_default_index.yml new file mode 100644 index 00000000000..8fb09c419b1 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/17_default_index.yml @@ -0,0 +1,41 @@ +--- +"Default index/type": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 + + - do: + indices.create: + index: test_2 + - do: + index: + index: test_1 + type: _doc + id: 1 + body: { foo: bar } + + - do: + mget: + index: test_1 + body: + docs: + - { _index: test_2, _id: 1} + - { _id: 2} + - { _id: 1} + + - is_false: docs.0.found + - match: { docs.0._index: test_2 } + - match: { docs.0._type: null } + - match: { docs.0._id: "1" } + + - is_false: docs.1.found + - match: { docs.1._index: test_1 } + - match: { docs.1._type: _doc } + - match: { docs.1._id: "2" } + + - is_true: docs.2.found + - match: { docs.2._index: test_1 } + - match: { docs.2._type: _doc } + - match: { docs.2._id: "1" } + - match: { docs.2._version: 1 } + - match: { docs.2._source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/18_non_existent_index_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/18_non_existent_index_with_types.yml new file mode 100644 index 00000000000..06234642250 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/18_non_existent_index_with_types.yml @@ -0,0 +1,30 @@ +--- +"Non-existent index": + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + mget: + body: + docs: + - { _index: test_2, _type: test, _id: 1} + + - is_false: docs.0.found + - match: { docs.0._index: test_2 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + + - do: + mget: + body: + docs: + - { _index: test_1, _type: test, _id: 1} + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/19_missing_metadata_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/19_missing_metadata_with_types.yml new file mode 100644 index 00000000000..d7af1797f7a --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/19_missing_metadata_with_types.yml @@ -0,0 +1,47 @@ +--- +"Missing metadata": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + catch: /action_request_validation_exception.+ id is missing/ + mget: + body: + docs: + - { _index: test_1, _type: test} + + - do: + catch: /action_request_validation_exception.+ index is missing/ + mget: + body: + docs: + - { _type: test, _id: 1} + + - do: + catch: /action_request_validation_exception.+ no documents to get/ + mget: + body: + docs: [] + + - do: + catch: /action_request_validation_exception.+ no documents to get/ + mget: + body: {} + + - do: + mget: + body: + docs: + - { _index: test_1, _id: 1} + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + - match: { docs.0._version: 1 } + - match: { docs.0._source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/20_stored_fields.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/20_stored_fields.yml index 33cab111a8b..0c8abee652f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/20_stored_fields.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/20_stored_fields.yml @@ -1,12 +1,15 @@ --- "Stored fields": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: indices.create: index: test_1 body: mappings: - test: + _doc: properties: foo: type: keyword @@ -18,14 +21,13 @@ - do: index: index: test_1 - type: test + type: _doc id: 1 body: { foo: bar } - do: mget: index: test_1 - type: test body: docs: - { _id: 1 } @@ -48,7 +50,6 @@ - do: mget: index: test_1 - type: test stored_fields: foo body: docs: @@ -72,7 +73,6 @@ - do: mget: index: test_1 - type: test stored_fields: [foo] body: docs: @@ -96,7 +96,6 @@ - do: mget: index: test_1 - type: test stored_fields: [foo, _source] body: docs: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/21_alias_to_multiple_indices_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/21_alias_to_multiple_indices_with_types.yml new file mode 100644 index 00000000000..3a0fec04738 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/21_alias_to_multiple_indices_with_types.yml @@ -0,0 +1,42 @@ +--- +"Multi Get with alias that resolves to multiple indices": + + - do: + bulk: + refresh: true + body: | + {"index": {"_index": "test_1", "_type": "test", "_id": 1}} + { "foo": "bar" } + {"index": {"_index": "test_2", "_type": "test", "_id": 2}} + { "foo": "bar" } + {"index": {"_index": "test_3", "_type": "test", "_id": 3}} + { "foo": "bar" } + + - do: + indices.put_alias: + index: test_2 + name: test_two_and_three + + - do: + indices.put_alias: + index: test_3 + name: test_two_and_three + + - do: + mget: + body: + docs: + - { _index: test_1, _type: test, _id: 1} + - { _index: test_two_and_three, _type: test, _id: 2} + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + + - is_false: docs.1.found + - match: { docs.1._index: test_two_and_three } + - match: { docs.1._type: test } + - match: { docs.1._id: "2" } + - match: { docs.1.error.root_cause.0.type: "illegal_argument_exception" } + - match: { docs.1.error.root_cause.0.reason: "/Alias.\\[test_two_and_three\\].has.more.than.one.indices.associated.with.it.\\[\\[test_[23]{1},.test_[23]{1}\\]\\],.can't.execute.a.single.index.op/" } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/22_ids_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/22_ids_with_types.yml new file mode 100644 index 00000000000..6c233e4d92a --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/22_ids_with_types.yml @@ -0,0 +1,72 @@ +--- +"IDs": + - do: + indices.create: + index: test_1 + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + index: + index: test_1 + type: test + id: 2 + body: { foo: baz } + + - do: + mget: + index: test_1 + type: test + body: + ids: [1, 3] + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + - match: { docs.0._version: 1 } + - match: { docs.0._source: { foo: bar }} + + - is_false: docs.1.found + - match: { docs.1._index: test_1 } + - match: { docs.1._type: test } + - match: { docs.1._id: "3" } + + - do: + mget: + index: test_1 + body: + ids: [1, 2] + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + - match: { docs.0._version: 1 } + - match: { docs.0._source: { foo: bar }} + + - is_true: docs.1.found + - match: { docs.1._index: test_1 } + - match: { docs.1._type: test } + - match: { docs.1._id: "2" } + - match: { docs.1._version: 1 } + - match: { docs.1._source: { foo: baz }} + + + - do: + catch: /action_request_validation_exception.+ no documents to get/ + mget: + index: test_1 + body: + ids: [] + + - do: + catch: /action_request_validation_exception.+ no documents to get/ + mget: + index: test_1 + body: {} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/23_stored_fields_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/23_stored_fields_with_types.yml new file mode 100644 index 00000000000..33cab111a8b --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/23_stored_fields_with_types.yml @@ -0,0 +1,119 @@ +--- +"Stored fields": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + properties: + foo: + type: keyword + store: true + count: + type: integer + store: true + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + mget: + index: test_1 + type: test + body: + docs: + - { _id: 1 } + - { _id: 1, stored_fields: foo } + - { _id: 1, stored_fields: [foo] } + - { _id: 1, stored_fields: [foo, _source] } + + - is_false: docs.0.fields + - match: { docs.0._source: { foo: bar }} + + - match: { docs.1.fields.foo: [bar] } + - is_false: docs.1._source + + - match: { docs.2.fields.foo: [bar] } + - is_false: docs.2._source + + - match: { docs.3.fields.foo: [bar] } + - match: { docs.3._source: { foo: bar }} + + - do: + mget: + index: test_1 + type: test + stored_fields: foo + body: + docs: + - { _id: 1 } + - { _id: 1, stored_fields: foo } + - { _id: 1, stored_fields: [foo] } + - { _id: 1, stored_fields: [foo, _source] } + + - match: { docs.0.fields.foo: [bar] } + - is_false: docs.0._source + + - match: { docs.1.fields.foo: [bar] } + - is_false: docs.1._source + + - match: { docs.2.fields.foo: [bar] } + - is_false: docs.2._source + + - match: { docs.3.fields.foo: [bar] } + - match: { docs.3._source: { foo: bar }} + + - do: + mget: + index: test_1 + type: test + stored_fields: [foo] + body: + docs: + - { _id: 1 } + - { _id: 1, stored_fields: foo } + - { _id: 1, stored_fields: [foo] } + - { _id: 1, stored_fields: [foo, _source] } + + - match: { docs.0.fields.foo: [bar] } + - is_false: docs.0._source + + - match: { docs.1.fields.foo: [bar] } + - is_false: docs.1._source + + - match: { docs.2.fields.foo: [bar] } + - is_false: docs.2._source + + - match: { docs.3.fields.foo: [bar] } + - match: { docs.3._source: { foo: bar }} + + - do: + mget: + index: test_1 + type: test + stored_fields: [foo, _source] + body: + docs: + - { _id: 1 } + - { _id: 1, stored_fields: foo } + - { _id: 1, stored_fields: [foo] } + - { _id: 1, stored_fields: [foo, _source] } + + - match: { docs.0.fields.foo: [bar] } + - match: { docs.0._source: { foo: bar }} + + - match: { docs.1.fields.foo: [bar] } + - is_false: docs.1._source + + - match: { docs.2.fields.foo: [bar] } + - is_false: docs.2._source + + - match: { docs.3.fields.foo: [bar] } + - match: { docs.3._source: { foo: bar }} + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/40_routing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/40_routing.yml index d550dd26657..7abe5e9df1f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/40_routing.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/40_routing.yml @@ -1,5 +1,8 @@ --- "Routing": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: indices.create: @@ -18,7 +21,7 @@ - do: index: index: test_1 - type: test + type: _doc id: 1 routing: 5 body: { foo: bar } @@ -26,7 +29,6 @@ - do: mget: index: test_1 - type: test stored_fields: [_routing] body: docs: @@ -39,6 +41,6 @@ - is_true: docs.2.found - match: { docs.2._index: test_1 } - - match: { docs.2._type: test } + - match: { docs.2._type: _doc } - match: { docs.2._id: "1" } - match: { docs.2._routing: "5" } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/41_routing_with_types.yml new file mode 100644 index 00000000000..d550dd26657 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/41_routing_with_types.yml @@ -0,0 +1,44 @@ +--- +"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: + mget: + index: test_1 + type: test + stored_fields: [_routing] + body: + docs: + - { _id: 1 } + - { _id: 1, routing: 4 } + - { _id: 1, routing: 5 } + + - is_false: docs.0.found + - is_false: docs.1.found + + - is_true: docs.2.found + - match: { docs.2._index: test_1 } + - match: { docs.2._type: test } + - match: { docs.2._id: "1" } + - match: { docs.2._routing: "5" } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/60_realtime_refresh.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/60_realtime_refresh.yml index 0cb7b71cf43..150f77ae4e8 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/60_realtime_refresh.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/60_realtime_refresh.yml @@ -1,5 +1,8 @@ --- "Realtime Refresh": + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 - do: indices.create: @@ -17,14 +20,13 @@ - do: index: index: test_1 - type: test + type: _doc id: 1 body: { foo: bar } - do: mget: index: test_1 - type: test realtime: false body: ids: [1] @@ -34,7 +36,6 @@ - do: mget: index: test_1 - type: test realtime: true body: ids: [1] @@ -44,7 +45,6 @@ - do: mget: index: test_1 - type: test realtime: false refresh: true body: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/61_realtime_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/61_realtime_refresh_with_types.yml new file mode 100644 index 00000000000..0cb7b71cf43 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/61_realtime_refresh_with_types.yml @@ -0,0 +1,53 @@ +--- +"Realtime Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + refresh_interval: -1 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + mget: + index: test_1 + type: test + realtime: false + body: + ids: [1] + + - is_false: docs.0.found + + - do: + mget: + index: test_1 + type: test + realtime: true + body: + ids: [1] + + - is_true: docs.0.found + + - do: + mget: + index: test_1 + type: test + realtime: false + refresh: true + body: + ids: [1] + + - is_true: docs.0.found diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/70_source_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/70_source_filtering.yml index 4581e060b41..35e3548ca42 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/70_source_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/70_source_filtering.yml @@ -1,14 +1,18 @@ setup: + - skip: + version: " - 6.99.99" + reason: types are required in requests before 7.0.0 + - do: index: index: test_1 - type: test + type: _doc id: 1 body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } - do: index: index: test_1 - type: test + type: _doc id: 2 body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } @@ -19,8 +23,8 @@ setup: mget: body: docs: - - { _index: "test_1", _type: "test", _id: "1", _source: false } - - { _index: "test_1", _type: "test", _id: "2", _source: true } + - { _index: "test_1", _id: "1", _source: false } + - { _index: "test_1", _id: "2", _source: true } - match: { docs.0._id: "1" } - is_false: docs.0._source @@ -34,8 +38,8 @@ setup: mget: body: docs: - - { _index: "test_1", _type: "test", _id: "1", _source: include.field1 } - - { _index: "test_1", _type: "test", _id: "2", _source: [ include.field1 ] } + - { _index: "test_1", _id: "1", _source: include.field1 } + - { _index: "test_1", _id: "2", _source: [ include.field1 ] } - match: { docs.0._source: { include: { field1: v1 }} } - match: { docs.1._source: { include: { field1: v1 }} } @@ -48,8 +52,8 @@ setup: mget: body: docs: - - { _index: "test_1", _type: "test", _id: "1", _source: { include: include.field1 } } - - { _index: "test_1", _type: "test", _id: "2", _source: { include: [ include.field1 ] } } + - { _index: "test_1", _id: "1", _source: { include: include.field1 } } + - { _index: "test_1", _id: "2", _source: { include: [ include.field1 ] } } - match: { docs.0._source: { include: { field1: v1 }} } - match: { docs.1._source: { include: { field1: v1 }} } @@ -61,7 +65,7 @@ setup: mget: body: docs: - - { _index: "test_1", _type: "test", _id: "1", _source: { include: [ include ], exclude: [ "*.field2" ] } } + - { _index: "test_1", _id: "1", _source: { include: [ include ], exclude: [ "*.field2" ] } } - match: { docs.0._source: { include: { field1: v1 }} } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/71_source_filtering_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/71_source_filtering_with_types.yml new file mode 100644 index 00000000000..4581e060b41 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/71_source_filtering_with_types.yml @@ -0,0 +1,119 @@ +setup: + - do: + index: + index: test_1 + type: test + id: 1 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + - do: + index: + index: test_1 + type: test + id: 2 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + +--- +"Source filtering - true/false": + + - do: + mget: + body: + docs: + - { _index: "test_1", _type: "test", _id: "1", _source: false } + - { _index: "test_1", _type: "test", _id: "2", _source: true } + + - match: { docs.0._id: "1" } + - is_false: docs.0._source + - match: { docs.1._id: "2" } + - is_true: docs.1._source + +--- +"Source filtering - include field": + + - do: + mget: + body: + docs: + - { _index: "test_1", _type: "test", _id: "1", _source: include.field1 } + - { _index: "test_1", _type: "test", _id: "2", _source: [ include.field1 ] } + + - match: { docs.0._source: { include: { field1: v1 }} } + - match: { docs.1._source: { include: { field1: v1 }} } + + +--- +"Source filtering - include nested field": + + - do: + mget: + body: + docs: + - { _index: "test_1", _type: "test", _id: "1", _source: { include: include.field1 } } + - { _index: "test_1", _type: "test", _id: "2", _source: { include: [ include.field1 ] } } + + - match: { docs.0._source: { include: { field1: v1 }} } + - match: { docs.1._source: { include: { field1: v1 }} } + +--- +"Source filtering - exclude field": + + - do: + mget: + body: + docs: + - { _index: "test_1", _type: "test", _id: "1", _source: { include: [ include ], exclude: [ "*.field2" ] } } + + - match: { docs.0._source: { include: { field1: v1 }} } + +--- +"Source filtering - ids and true/false": + + - do: + mget: + _source: false + index: test_1 + body: { ids: [ 1,2 ] } + - is_false: docs.0._source + - is_false: docs.1._source + + - do: + mget: + _source: true + index: test_1 + body: { ids: [ 1,2 ] } + - is_true: docs.0._source + - is_true: docs.1._source + +--- +"Source filtering - ids and include field": + + - do: + mget: + _source: include.field1 + index: test_1 + body: { ids: [ 1,2 ] } + - match: { docs.0._source: { include: { field1: v1 }} } + - match: { docs.1._source: { include: { field1: v1 }} } + +--- +"Source filtering - ids and include nested field": + + - do: + mget: + _source_includes: "include.field1,count" + index: test_1 + body: { ids: [ 1,2 ] } + - match: { docs.0._source: { include: { field1: v1 }, count: 1} } + - match: { docs.1._source: { include: { field1: v1 }, count: 1} } + +--- +"Source filtering - ids and exclude field": + + - do: + mget: + _source_includes: include + _source_excludes: "*.field2" + index: test_1 + body: { ids: [ 1,2 ] } + - match: { docs.0._source: { include: { field1: v1 } } } + - match: { docs.1._source: { include: { field1: v1 } } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated.yml index 5033f75c794..db42c00d416 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated.yml @@ -1,7 +1,6 @@ --- "Deprecated parameters should fail in Multi Get query": - - skip: version: " - 6.99.99" reason: _version, _routing are removed starting from 7.0, their equivalents without underscore are used instead @@ -10,14 +9,14 @@ - do: index: index: test_1 - type: test + type: _doc id: 1 body: { foo: bar } - do: index: index: test_1 - type: test + type: _doc id: 2 body: { foo: baz } @@ -26,13 +25,13 @@ mget: body: docs: - - { _index: test_1, _type: test, _id: 1, _routing : test1 } - - { _index: test_1, _type: test, _id: 2, _routing : test1 } + - { _index: test_1, _id: 1, _routing : test1 } + - { _index: test_1, _id: 2, _routing : test1 } - do: catch: bad_request mget: body: docs: - - { _index: test_1, _type: test, _id: 1, _version : 1 } - - { _index: test_1, _type: test, _id: 2, _version : 1 } + - { _index: test_1, _id: 1, _version : 1 } + - { _index: test_1, _id: 2, _version : 1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated_with_types.yml new file mode 100644 index 00000000000..5033f75c794 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated_with_types.yml @@ -0,0 +1,38 @@ + +--- +"Deprecated parameters should fail in Multi Get query": + + - skip: + version: " - 6.99.99" + reason: _version, _routing are removed starting from 7.0, their equivalents without underscore are used instead + features: "warnings" + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + index: + index: test_1 + type: test + id: 2 + body: { foo: baz } + + - do: + catch: bad_request + mget: + body: + docs: + - { _index: test_1, _type: test, _id: 1, _routing : test1 } + - { _index: test_1, _type: test, _id: 2, _routing : test1 } + + - do: + catch: bad_request + mget: + body: + docs: + - { _index: test_1, _type: test, _id: 1, _version : 1 } + - { _index: test_1, _type: test, _id: 2, _version : 1 } diff --git a/server/src/main/java/org/elasticsearch/action/get/GetRequest.java b/server/src/main/java/org/elasticsearch/action/get/GetRequest.java index 5162fd46eca..218925ff7a8 100644 --- a/server/src/main/java/org/elasticsearch/action/get/GetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/GetRequest.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.index.VersionType; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -66,16 +67,15 @@ public class GetRequest extends SingleShardRequest implements Realti private long version = Versions.MATCH_ANY; public GetRequest() { - type = "_all"; + type = MapperService.SINGLE_MAPPING_NAME; } /** - * Constructs a new get request against the specified index. The {@link #type(String)} and {@link #id(String)} - * must be set. + * Constructs a new get request against the specified index. The {@link #id(String)} must also be set. */ public GetRequest(String index) { super(index); - this.type = "_all"; + this.type = MapperService.SINGLE_MAPPING_NAME; } /** @@ -84,13 +84,28 @@ public class GetRequest extends SingleShardRequest implements Realti * @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 GetRequest(String, String)} instead. */ + @Deprecated public GetRequest(String index, String type, String id) { super(index); this.type = type; this.id = id; } + /** + * Constructs a new get request against the specified index and document ID. + * + * @param index The index to get the document from + * @param id The id of the document + */ + public GetRequest(String index, String id) { + super(index); + this.id = id; + this.type = MapperService.SINGLE_MAPPING_NAME; + } + @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validateNonNullIndex(); @@ -112,10 +127,13 @@ public class GetRequest extends SingleShardRequest implements Realti /** * Sets the type of the document to fetch. + * + * @deprecated Types are in the process of being removed. */ + @Deprecated public GetRequest type(@Nullable String type) { if (type == null) { - type = "_all"; + type = MapperService.SINGLE_MAPPING_NAME; } this.type = type; return this; @@ -148,6 +166,10 @@ public class GetRequest extends SingleShardRequest implements Realti return this; } + /** + * @deprecated Types are in the process of being removed. + */ + @Deprecated public String type() { return type; } diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java index 92004986796..9bd026e9187 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java @@ -89,13 +89,21 @@ public class MultiGetRequest extends ActionRequest * @param index The index name * @param type The type (can be null) * @param id The id + * + * @deprecated Types are in the process of being removed, use {@link Item(String, String) instead}. */ + @Deprecated public Item(String index, @Nullable String type, String id) { this.index = index; this.type = type; this.id = id; } + public Item(String index, String id) { + this.index = index; + this.id = id; + } + public String index() { return this.index; } @@ -119,11 +127,6 @@ public class MultiGetRequest extends ActionRequest return this.type; } - public Item type(String type) { - this.type = type; - return this; - } - public String id() { return this.id; } @@ -285,11 +288,21 @@ public class MultiGetRequest extends ActionRequest return this; } + /** + * @deprecated Types are in the process of being removed, use + * {@link MultiGetRequest#add(String, String)} instead. + */ + @Deprecated public MultiGetRequest add(String index, @Nullable String type, String id) { items.add(new Item(index, type, id)); return this; } + public MultiGetRequest add(String index, String id) { + items.add(new Item(index, id)); + return this; + } + @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java index 0a21188f545..bbf4d5b8601 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java @@ -19,12 +19,15 @@ package org.elasticsearch.rest.action.document; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; 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,6 +44,10 @@ import static org.elasticsearch.rest.RestStatus.NOT_FOUND; import static org.elasticsearch.rest.RestStatus.OK; public class RestGetAction extends BaseRestHandler { + private static final DeprecationLogger deprecationLogger = new DeprecationLogger( + LogManager.getLogger(RestGetAction.class)); + static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " + + "document get requests is deprecated, use the /{index}/_doc/{id} endpoint instead."; public RestGetAction(final Settings settings, final RestController controller) { super(settings); @@ -55,9 +62,12 @@ public class RestGetAction extends BaseRestHandler { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - final GetRequest getRequest = new GetRequest(request.param("index"), - request.param("type"), - request.param("id")); + String type = request.param("type"); + if (!type.equals(MapperService.SINGLE_MAPPING_NAME)) { + deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE); + } + + final GetRequest getRequest = new GetRequest(request.param("index"), type, request.param("id")); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); getRequest.routing(request.param("routing")); getRequest.preference(request.param("preference")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java index 923a466d8ec..2f630f95241 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java @@ -19,9 +19,11 @@ package org.elasticsearch.rest.action.document; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.rest.BaseRestHandler; @@ -36,6 +38,10 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestMultiGetAction extends BaseRestHandler { + private static final DeprecationLogger deprecationLogger = new DeprecationLogger( + LogManager.getLogger(RestMultiGetAction.class)); + static final String TYPES_DEPRECATION_MESSAGE = "[types removal]" + + " Specifying types in multi get requests is deprecated."; private final boolean allowExplicitIndex; @@ -58,6 +64,10 @@ public class RestMultiGetAction extends BaseRestHandler { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { + if (request.param("type") != null) { + deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE); + } + MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh())); multiGetRequest.preference(request.param("preference")); @@ -78,6 +88,13 @@ public class RestMultiGetAction extends BaseRestHandler { request.param("routing"), parser, allowExplicitIndex); } + for (MultiGetRequest.Item item : multiGetRequest.getItems()) { + if (item.type() != null) { + deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE); + break; + } + } + return channel -> client.multiGet(multiGetRequest, new RestToXContentListener<>(channel)); } } diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java new file mode 100644 index 00000000000..f68288fa261 --- /dev/null +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java @@ -0,0 +1,56 @@ +/* + * 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.common.settings.Settings; +import org.elasticsearch.rest.RestRequest.Method; +import org.elasticsearch.rest.action.RestActionTestCase; +import org.elasticsearch.test.rest.FakeRestRequest; +import org.junit.Before; + +public class RestGetActionTests extends RestActionTestCase { + + @Before + public void setUpAction() { + new RestGetAction(Settings.EMPTY, controller()); + } + + public void testTypeInPathWithGet() { + FakeRestRequest.Builder deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()) + .withPath("/some_index/some_type/some_id"); + dispatchRequest(deprecatedRequest.withMethod(Method.GET).build()); + assertWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE); + + FakeRestRequest.Builder validRequest = new FakeRestRequest.Builder(xContentRegistry()) + .withPath("/some_index/_doc/some_id"); + dispatchRequest(validRequest.withMethod(Method.GET).build()); + } + + public void testTypeInPathWithHead() { + FakeRestRequest.Builder deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()) + .withPath("/some_index/some_type/some_id"); + dispatchRequest(deprecatedRequest.withMethod(Method.HEAD).build()); + assertWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE); + + FakeRestRequest.Builder validRequest = new FakeRestRequest.Builder(xContentRegistry()) + .withPath("/some_index/_doc/some_id"); + dispatchRequest(validRequest.withMethod(Method.HEAD).build()); + } +} diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestMultiGetActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestMultiGetActionTests.java new file mode 100644 index 00000000000..db25a6b5739 --- /dev/null +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestMultiGetActionTests.java @@ -0,0 +1,77 @@ +/* + * 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.common.bytes.BytesReference; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.rest.RestRequest.Method; +import org.elasticsearch.rest.action.RestActionTestCase; +import org.elasticsearch.test.rest.FakeRestRequest; +import org.junit.Before; + +public class RestMultiGetActionTests extends RestActionTestCase { + + @Before + public void setUpAction() { + new RestMultiGetAction(Settings.EMPTY, controller()); + } + + public void testTypeInPath() { + RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry()) + .withMethod(Method.GET) + .withPath("some_index/some_type/_mget") + .build(); + dispatchRequest(deprecatedRequest); + assertWarnings(RestMultiGetAction.TYPES_DEPRECATION_MESSAGE); + + RestRequest validRequest = new FakeRestRequest.Builder(xContentRegistry()) + .withMethod(Method.GET) + .withPath("some_index/_mget") + .build(); + dispatchRequest(validRequest); + } + + public void testTypeInBody() throws Exception { + XContentBuilder content = XContentFactory.jsonBuilder().startObject() + .startArray("docs") + .startObject() + .field("_index", "some_index") + .field("_type", "_doc") + .field("_id", "2") + .endObject() + .startObject() + .field("_index", "test") + .field("_id", "2") + .endObject() + .endArray() + .endObject(); + + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) + .withPath("_mget") + .withContent(BytesReference.bytes(content), XContentType.JSON) + .build(); + dispatchRequest(request); + assertWarnings(RestMultiGetAction.TYPES_DEPRECATION_MESSAGE); + } +} diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 99f6a54d6bd..e9215602429 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -80,7 +80,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { * Tests that a single document survives. Super basic smoke test. */ public void testSingleDoc() throws IOException { - String docLocation = "/testsingledoc/doc/1"; + String docLocation = "/testsingledoc/_doc/1"; String doc = "{\"test\": \"test\"}"; if (isRunningAgainstOldCluster()) { @@ -252,7 +252,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { // index documents for the rollup job final StringBuilder bulk = new StringBuilder(); for (int i = 0; i < numDocs; i++) { - bulk.append("{\"index\":{\"_index\":\"rollup-docs\",\"_type\":\"doc\"}}\n"); + bulk.append("{\"index\":{\"_index\":\"rollup-docs\",\"_type\":\"_doc\"}}\n"); String date = String.format(Locale.ROOT, "%04d-01-01T00:%02d:00Z", year, i); bulk.append("{\"timestamp\":\"").append(date).append("\",\"value\":").append(i).append("}\n"); } diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java index 75625895944..8fd2135aac5 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java @@ -63,7 +63,7 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase { assertNotNull(token); assertTokenWorks(token); - Request indexRequest1 = new Request("PUT", "token_backwards_compatibility_it/doc/old_cluster_token1"); + Request indexRequest1 = new Request("PUT", "token_backwards_compatibility_it/_doc/old_cluster_token1"); indexRequest1.setJsonEntity( "{\n" + " \"token\": \"" + token + "\"\n" + @@ -77,7 +77,7 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase { token = (String) responseMap.get("access_token"); assertNotNull(token); assertTokenWorks(token); - Request indexRequest2 = new Request("PUT", "token_backwards_compatibility_it/doc/old_cluster_token2"); + Request indexRequest2 = new Request("PUT", "token_backwards_compatibility_it/_doc/old_cluster_token2"); indexRequest2.setJsonEntity( "{\n" + " \"token\": \"" + token + "\"\n" + @@ -88,7 +88,7 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase { public void testTokenWorksInMixedOrUpgradedCluster() throws Exception { assumeTrue("this test should only run against the mixed or upgraded cluster", CLUSTER_TYPE == ClusterType.MIXED || CLUSTER_TYPE == ClusterType.UPGRADED); - Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token1")); + Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token1")); assertOK(getResponse); Map source = (Map) entityAsMap(getResponse).get("_source"); assertTokenWorks((String) source.get("token")); @@ -97,7 +97,7 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase { public void testMixedCluster() throws Exception { assumeTrue("this test should only run against the mixed cluster", CLUSTER_TYPE == ClusterType.MIXED); assumeTrue("the master must be on the latest version before we can write", isMasterOnLatestVersion()); - Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token2")); + Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token2")); Map source = (Map) entityAsMap(getResponse).get("_source"); final String token = (String) source.get("token"); assertTokenWorks(token); @@ -146,7 +146,7 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase { public void testUpgradedCluster() throws Exception { assumeTrue("this test should only run against the mixed cluster", CLUSTER_TYPE == ClusterType.UPGRADED); - Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token2")); + Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token2")); assertOK(getResponse); Map source = (Map) entityAsMap(getResponse).get("_source"); final String token = (String) source.get("token"); @@ -159,7 +159,7 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase { assertOK(invalidationResponse); assertTokenDoesNotWork(token); - getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token1")); + getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token1")); source = (Map) entityAsMap(getResponse).get("_source"); final String workingToken = (String) source.get("token"); assertTokenWorks(workingToken); diff --git a/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java b/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java index 0a468cbf849..1b3b3f1bbeb 100644 --- a/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java +++ b/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java @@ -42,7 +42,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase { @Before public void startWatcher() throws Exception { - Request createAllowedDoc = new Request("PUT", "/my_test_index/doc/1"); + Request createAllowedDoc = new Request("PUT", "/my_test_index/_doc/1"); createAllowedDoc.setJsonEntity("{ \"value\" : \"15\" }"); createAllowedDoc.addParameter("refresh", "true"); adminClient().performRequest(createAllowedDoc); @@ -51,7 +51,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase { adminClient().performRequest(new Request("DELETE", ".watcher-history-*")); // create one document in this index, so we can test in the YAML tests, that the index cannot be accessed - Request createNotAllowedDoc = new Request("PUT", "/index_not_allowed_to_read/doc/1"); + Request createNotAllowedDoc = new Request("PUT", "/index_not_allowed_to_read/_doc/1"); createNotAllowedDoc.setJsonEntity("{\"foo\":\"bar\"}"); adminClient().performRequest(createNotAllowedDoc); @@ -211,7 +211,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase { boolean conditionMet = objectPath.evaluate("hits.hits.0._source.result.condition.met"); assertThat(conditionMet, is(true)); - ObjectPath getObjectPath = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/my_test_index/doc/my-id"))); + ObjectPath getObjectPath = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/my_test_index/_doc/my-id"))); String value = getObjectPath.evaluate("_source.hits.hits.0._source.value"); assertThat(value, is("15")); } @@ -239,7 +239,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase { getWatchHistoryEntry(watchId); - Response response = adminClient().performRequest(new Request("HEAD", "/my_test_index/doc/some-id")); + Response response = adminClient().performRequest(new Request("HEAD", "/my_test_index/_doc/some-id")); assertThat(response.getStatusLine().getStatusCode(), is(404)); } @@ -262,7 +262,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase { boolean conditionMet = objectPath.evaluate("hits.hits.0._source.result.condition.met"); assertThat(conditionMet, is(true)); - ObjectPath getObjectPath = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/my_test_index/doc/my-id"))); + ObjectPath getObjectPath = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/my_test_index/_doc/my-id"))); String spam = getObjectPath.evaluate("_source.spam"); assertThat(spam, is("eggs")); } @@ -286,7 +286,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase { boolean conditionMet = objectPath.evaluate("hits.hits.0._source.result.condition.met"); assertThat(conditionMet, is(true)); - Response response = adminClient().performRequest(new Request("HEAD", "/index_not_allowed_to_read/doc/my-id")); + Response response = adminClient().performRequest(new Request("HEAD", "/index_not_allowed_to_read/_doc/my-id")); assertThat(response.getStatusLine().getStatusCode(), is(404)); }