From 1882729686c40258205d7adf94eb1f6b86d1b370 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 10:18:24 +0100 Subject: [PATCH 01/13] Remove types from Get/MultiGet --- .../client/RequestConverters.java | 14 +- .../elasticsearch/client/BulkProcessorIT.java | 5 +- .../java/org/elasticsearch/client/CrudIT.java | 18 +- .../client/RequestConvertersTests.java | 17 +- .../documentation/CRUDDocumentationIT.java | 1 - .../ingest/common/IngestRestartIT.java | 12 +- .../percolator/PercolateQueryBuilder.java | 2 +- .../PercolateQueryBuilderTests.java | 5 +- .../index/reindex/ReindexVersioningTests.java | 6 +- .../reindex/UpdateByQueryBasicTests.java | 50 ++--- .../UpdateByQueryWhileModifyingTests.java | 4 +- .../index/mapper/size/SizeMappingIT.java | 2 +- .../tasks/get/TransportGetTaskAction.java | 3 +- .../explain/TransportExplainAction.java | 4 +- .../elasticsearch/action/get/GetRequest.java | 62 ++---- .../action/get/GetRequestBuilder.java | 9 - .../elasticsearch/action/get/GetResponse.java | 11 +- .../action/get/MultiGetItemResponse.java | 10 - .../action/get/MultiGetRequest.java | 64 ++---- .../action/get/MultiGetRequestBuilder.java | 13 +- .../action/get/MultiGetResponse.java | 31 ++- .../action/get/TransportGetAction.java | 4 +- .../action/get/TransportMultiGetAction.java | 12 +- .../get/TransportShardMultiGetAction.java | 8 +- .../action/update/UpdateHelper.java | 13 +- .../action/update/UpdateResponse.java | 2 +- .../java/org/elasticsearch/client/Client.java | 4 +- .../org/elasticsearch/client/Requests.java | 2 +- .../client/support/AbstractClient.java | 4 +- .../elasticsearch/index/engine/Engine.java | 11 +- .../elasticsearch/index/get/GetResult.java | 43 ++-- .../index/get/ShardGetService.java | 51 +++-- .../query/AbstractGeometryQueryBuilder.java | 10 +- .../index/query/TermsQueryBuilder.java | 4 +- .../elasticsearch/index/shard/IndexShard.java | 2 +- .../index/termvectors/TermVectorsService.java | 6 +- .../rest/action/document/RestGetAction.java | 2 +- .../action/document/RestGetSourceAction.java | 13 +- .../action/document/RestMultiGetAction.java | 9 +- .../action/IndicesRequestIT.java | 4 +- .../admin/indices/create/SplitIndexIT.java | 4 +- .../action/bulk/BulkIntegrationIT.java | 6 +- .../action/bulk/BulkProcessorIT.java | 1 - .../action/bulk/BulkWithUpdatesIT.java | 16 +- .../action/explain/ExplainResponseTests.java | 3 +- .../action/get/GetRequestTests.java | 8 +- .../action/get/GetResponseTests.java | 16 +- .../action/get/MultiGetRequestTests.java | 12 +- .../action/get/MultiGetResponseTests.java | 5 +- .../action/get/MultiGetShardRequestTests.java | 4 +- .../get/TransportMultiGetActionTests.java | 8 +- .../action/termvectors/GetTermVectorsIT.java | 8 +- .../action/update/UpdateRequestTests.java | 20 +- .../action/update/UpdateResponseTests.java | 11 +- .../client/AbstractClientHeadersTestCase.java | 4 +- .../elasticsearch/cluster/NoMasterNodeIT.java | 6 +- .../coordination/RareClusterStateIT.java | 4 +- .../UnsafeBootstrapAndDetachCommandIT.java | 4 +- .../discovery/ClusterDisruptionIT.java | 6 +- .../document/DocumentActionsIT.java | 20 +- .../env/NodeRepurposeCommandIT.java | 4 +- .../explain/ExplainActionIT.java | 1 - .../gateway/GatewayIndexStateIT.java | 4 +- .../org/elasticsearch/get/GetActionIT.java | 183 +++++++++--------- .../index/engine/InternalEngineTests.java | 30 +-- .../index/get/GetResultTests.java | 36 ++-- .../index/mapper/DynamicMappingIT.java | 2 +- .../query/GeoShapeQueryBuilderTests.java | 5 +- .../index/query/TermsQueryBuilderTests.java | 2 +- .../index/shard/IndexShardTests.java | 24 +-- .../index/shard/RefreshListenersTests.java | 2 +- .../index/shard/ShardGetServiceTests.java | 20 +- ...DateMathIndexExpressionsIntegrationIT.java | 6 +- .../indices/stats/IndexStatsIT.java | 4 +- .../elasticsearch/ingest/IngestClientIT.java | 8 +- .../org/elasticsearch/mget/SimpleMgetIT.java | 22 +-- .../recovery/RecoveryWhileUnderLoadIT.java | 8 +- .../recovery/SimpleRecoveryIT.java | 20 +- .../document/RestGetSourceActionTests.java | 47 +---- .../document/RestMultiGetActionTests.java | 77 -------- .../elasticsearch/routing/AliasRoutingIT.java | 46 ++--- .../routing/PartitionedRoutingIT.java | 2 +- .../routing/SimpleRoutingIT.java | 46 ++--- .../search/geo/GeoShapeQueryTests.java | 2 +- .../search/nested/SimpleNestedIT.java | 4 +- .../search/sort/GeoDistanceIT.java | 2 +- .../SharedClusterSnapshotRestoreIT.java | 23 +-- .../org/elasticsearch/update/UpdateIT.java | 30 +-- .../ConcurrentDocumentOperationIT.java | 4 +- .../versioning/SimpleVersioningIT.java | 16 +- .../index/engine/EngineTestCase.java | 2 +- .../hamcrest/ElasticsearchAssertions.java | 4 +- .../xpack/ccr/CcrRepositoryIT.java | 2 +- .../xpack/ccr/CcrRetentionLeaseIT.java | 2 +- .../xpack/ccr/IndexFollowingIT.java | 10 +- .../ml/job/results/ReservedFieldNames.java | 4 +- .../SourceOnlySnapshotShardTests.java | 4 +- .../ElasticsearchMappingsTests.java | 3 +- .../index/engine/FrozenIndexTests.java | 2 +- .../ml/job/persistence/MockClientBuilder.java | 4 +- .../job/results/ReservedFieldNamesTests.java | 1 - .../xpack/security/authc/ApiKeyService.java | 5 +- .../xpack/security/authc/TokenService.java | 14 +- .../authc/esnative/NativeUsersStore.java | 4 +- .../authz/store/NativePrivilegeStore.java | 2 +- .../authz/store/NativeRolesStore.java | 4 +- .../integration/BulkUpdateTests.java | 6 +- .../DateMathExpressionIntegTests.java | 2 +- .../DocumentLevelSecurityTests.java | 22 +-- .../integration/FieldLevelSecurityTests.java | 24 +-- ...onsWithAliasesWildcardsAndRegexsTests.java | 6 +- ...ansportOpenIdConnectLogoutActionTests.java | 5 +- .../saml/TransportSamlLogoutActionTests.java | 5 +- .../TransportCreateTokenActionTests.java | 5 +- .../authc/AuthenticationServiceTests.java | 13 +- .../security/authc/TokenServiceTests.java | 5 +- .../authc/esnative/NativeUsersStoreTests.java | 6 +- .../authz/AuthorizationServiceTests.java | 4 +- .../security/authz/ReadActionsTests.java | 8 +- .../authz/SnapshotUserRoleIntegTests.java | 4 +- .../store/NativePrivilegeStoreTests.java | 6 +- .../xpack/security/test/SecurityMocks.java | 7 +- .../index/query/ShapeQueryBuilderTests.java | 3 +- .../xpack/spatial/search/ShapeQueryTests.java | 2 +- .../execution/ExecutionServiceTests.java | 4 +- .../ack/TransportAckWatchActionTests.java | 3 +- .../ldap/AbstractAdLdapRealmTestCase.java | 2 +- 127 files changed, 629 insertions(+), 973 deletions(-) delete mode 100644 server/src/test/java/org/elasticsearch/rest/action/document/RestMultiGetActionTests.java diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java index 5f21ea6a2f1f2..d34a1d9f124c4 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java @@ -266,7 +266,7 @@ static Request get(GetRequest getRequest) { } private static Request getStyleRequest(String method, GetRequest getRequest) { - Request request = new Request(method, endpoint(getRequest.index(), getRequest.type(), getRequest.id())); + Request request = new Request(method, endpoint(getRequest.index(), getRequest.id())); Params parameters = new Params(); parameters.withPreference(getRequest.preference()); @@ -282,13 +282,7 @@ private static Request getStyleRequest(String method, GetRequest getRequest) { } static Request sourceExists(GetRequest getRequest) { - String optionalType = getRequest.type(); - String endpoint; - if (optionalType.equals(MapperService.SINGLE_MAPPING_NAME)) { - endpoint = endpoint(getRequest.index(), "_source", getRequest.id()); - } else { - endpoint = endpoint(getRequest.index(), optionalType, getRequest.id(), "_source"); - } + String endpoint = endpoint(getRequest.index(), "_source", getRequest.id()); Request request = new Request(HttpHead.METHOD_NAME, endpoint); Params parameters = new Params(); parameters.withPreference(getRequest.preference()); @@ -736,6 +730,10 @@ static String endpoint(String index, String type, String id) { return new EndpointBuilder().addPathPart(index, type, id).build(); } + static String endpoint(String index, String id) { + return new EndpointBuilder().addPathPart(index, id).build(); + } + @Deprecated static String endpoint(String index, String type, String id, String endpoint) { return new EndpointBuilder().addPathPart(index, type, id).addPathPartAsIs(endpoint).build(); 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 2aa9457bcd897..d30dbfc19cfa9 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 @@ -483,11 +483,11 @@ private static BytesArray bytesBulkRequest(String localIndex, String localType, private MultiGetRequest indexDocs(BulkProcessor processor, int numDocs) throws Exception { return indexDocs(processor, numDocs, "test", null, null, null, null); } - + private static void assertResponseItems(List bulkItemResponses, int numDocs) { assertResponseItems(bulkItemResponses, numDocs, MapperService.SINGLE_MAPPING_NAME); } - + private static void assertResponseItems(List bulkItemResponses, int numDocs, String expectedType) { assertThat(bulkItemResponses.size(), is(numDocs)); int i = 1; @@ -505,7 +505,6 @@ private static void assertMultiGetResponse(MultiGetResponse multiGetResponse, in int i = 1; for (MultiGetItemResponse multiGetItemResponse : multiGetResponse) { assertThat(multiGetItemResponse.getIndex(), 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/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java index c828a73e17d13..03cd3a8fe38f2 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 @@ -293,7 +293,6 @@ public void testGet() throws IOException { } GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); - assertEquals("_doc", getResponse.getType()); assertEquals("id", getResponse.getId()); assertTrue(getResponse.isExists()); assertFalse(getResponse.isSourceEmpty()); @@ -304,7 +303,6 @@ public void testGet() throws IOException { GetRequest getRequest = new GetRequest("index", "does_not_exist"); GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); - assertEquals("_doc", getResponse.getType()); assertEquals("does_not_exist", getResponse.getId()); assertFalse(getResponse.isExists()); assertEquals(-1, getResponse.getVersion()); @@ -316,7 +314,6 @@ public void testGet() throws IOException { getRequest.fetchSourceContext(new FetchSourceContext(false, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY)); GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); - assertEquals("_doc", getResponse.getType()); assertEquals("id", getResponse.getId()); assertTrue(getResponse.isExists()); assertTrue(getResponse.isSourceEmpty()); @@ -332,7 +329,6 @@ public void testGet() throws IOException { } GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync); assertEquals("index", getResponse.getIndex()); - assertEquals("_doc", getResponse.getType()); assertEquals("id", getResponse.getId()); assertTrue(getResponse.isExists()); assertFalse(getResponse.isSourceEmpty()); @@ -354,14 +350,13 @@ public void testGetWithTypes() throws IOException { expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE) ); - GetRequest getRequest = new GetRequest("index", "type", "id"); + GetRequest getRequest = new GetRequest("index", "id"); GetResponse getResponse = execute(getRequest, highLevelClient()::get, highLevelClient()::getAsync, expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); assertEquals("index", getResponse.getIndex()); - assertEquals("type", getResponse.getType()); assertEquals("id", getResponse.getId()); assertTrue(getResponse.isExists()); @@ -381,7 +376,6 @@ public void testMultiGet() throws IOException { assertTrue(response.getResponses()[0].isFailed()); assertNull(response.getResponses()[0].getResponse()); assertEquals("id1", response.getResponses()[0].getFailure().getId()); - 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()); @@ -389,7 +383,6 @@ public void testMultiGet() throws IOException { assertTrue(response.getResponses()[1].isFailed()); assertNull(response.getResponses()[1].getResponse()); assertEquals("id2", response.getResponses()[1].getId()); - 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()); @@ -413,14 +406,12 @@ public void testMultiGet() throws IOException { assertFalse(response.getResponses()[0].isFailed()); assertNull(response.getResponses()[0].getFailure()); assertEquals("id1", response.getResponses()[0].getId()); - assertEquals("_doc", response.getResponses()[0].getType()); assertEquals("index", response.getResponses()[0].getIndex()); assertEquals(Collections.singletonMap("field", "value1"), response.getResponses()[0].getResponse().getSource()); assertFalse(response.getResponses()[1].isFailed()); assertNull(response.getResponses()[1].getFailure()); assertEquals("id2", response.getResponses()[1].getId()); - assertEquals("_doc", response.getResponses()[1].getType()); assertEquals("index", response.getResponses()[1].getIndex()); assertEquals(Collections.singletonMap("field", "value2"), response.getResponses()[1].getResponse().getSource()); } @@ -437,7 +428,7 @@ public void testMultiGetWithTypes() throws IOException { highLevelClient().bulk(bulk, expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add("index", "id1"); - multiGetRequest.add("index", "type", "id2"); + multiGetRequest.add("index", "id2"); MultiGetResponse response = execute(multiGetRequest, highLevelClient()::mget, @@ -447,12 +438,10 @@ public void testMultiGetWithTypes() throws IOException { GetResponse firstResponse = response.getResponses()[0].getResponse(); assertEquals("index", firstResponse.getIndex()); - assertEquals("type", firstResponse.getType()); assertEquals("id1", firstResponse.getId()); GetResponse secondResponse = response.getResponses()[1].getResponse(); assertEquals("index", secondResponse.getIndex()); - assertEquals("type", secondResponse.getType()); assertEquals("id2", secondResponse.getId()); } @@ -972,7 +961,6 @@ public void testUrlEncode() throws IOException { GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals(expectedIndex, getResponse.getIndex()); - assertEquals("_doc", getResponse.getType()); assertEquals("id#1", getResponse.getId()); } @@ -990,7 +978,6 @@ public void testUrlEncode() throws IOException { GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals("index", getResponse.getIndex()); - assertEquals("_doc", getResponse.getType()); assertEquals(docId, getResponse.getId()); } @@ -1014,7 +1001,6 @@ public void testParamsEncode() throws IOException { GetResponse getResponse = highLevelClient().get(getRequest, RequestOptions.DEFAULT); assertTrue(getResponse.isExists()); assertEquals("index", getResponse.getIndex()); - assertEquals("_doc", getResponse.getType()); assertEquals("id", getResponse.getId()); assertEquals(routing, getResponse.getField("_routing").getValue()); } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java index 2291c24eeef7d..42636e7c684d2 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java @@ -162,7 +162,7 @@ public void testSourceExists() throws IOException { public void testSourceExistsWithType() throws IOException { String type = frequently() ? randomAlphaOfLengthBetween(3, 10) : MapperService.SINGLE_MAPPING_NAME; - doTestSourceExists((index, id) -> new GetRequest(index, type, id)); + doTestSourceExists((index, id) -> new GetRequest(index, id)); } private static void doTestSourceExists(BiFunction requestFunction) throws IOException { @@ -197,12 +197,7 @@ private static void doTestSourceExists(BiFunction re } Request request = RequestConverters.sourceExists(getRequest); assertEquals(HttpHead.METHOD_NAME, request.getMethod()); - String type = getRequest.type(); - if (type.equals(MapperService.SINGLE_MAPPING_NAME)) { - assertEquals("/" + index + "/_source/" + id, request.getEndpoint()); - } else { - assertEquals("/" + index + "/" + type + "/" + id + "/_source", request.getEndpoint()); - } + assertEquals("/" + index + "/_source/" + id, request.getEndpoint()); assertEquals(expectedParams, request.getParameters()); assertNull(request.getEntity()); @@ -260,7 +255,6 @@ public void testMultiGet() throws IOException { public void testMultiGetWithType() throws IOException { MultiGetRequest multiGetRequest = new MultiGetRequest(); MultiGetRequest.Item item = new MultiGetRequest.Item(randomAlphaOfLength(4), - randomAlphaOfLength(4), randomAlphaOfLength(4)); multiGetRequest.add(item); @@ -369,7 +363,7 @@ private static void getAndExistsTest(Function requestConver } } Request request = requestConverter.apply(getRequest); - assertEquals("/" + index + "/_doc/" + id, request.getEndpoint()); + assertEquals("/" + index + "/" + id, request.getEndpoint()); assertEquals(expectedParams, request.getParameters()); assertNull(request.getEntity()); assertEquals(method, request.getMethod()); @@ -377,12 +371,11 @@ private static void getAndExistsTest(Function requestConver private static void getAndExistsWithTypeTest(Function requestConverter, String method) { String index = randomAlphaOfLengthBetween(3, 10); - String type = randomAlphaOfLengthBetween(3, 10); String id = randomAlphaOfLengthBetween(3, 10); - GetRequest getRequest = new GetRequest(index, type, id); + GetRequest getRequest = new GetRequest(index, id); Request request = requestConverter.apply(getRequest); - assertEquals("/" + index + "/" + type + "/" + id, request.getEndpoint()); + assertEquals("/" + index + "/" + id, request.getEndpoint()); assertNull(request.getEntity()); assertEquals(method, request.getMethod()); } 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 062f90c0eb4db..9d88bb2ff222a 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 @@ -1943,7 +1943,6 @@ private MultiGetItemResponse unwrapAndAssertExample(MultiGetResponse response) { assertThat(response.getResponses(), arrayWithSize(1)); MultiGetItemResponse item = response.getResponses()[0]; assertEquals("index", item.getIndex()); - assertEquals("_doc", item.getType()); assertEquals("example_id", item.getId()); return item; } diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/IngestRestartIT.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/IngestRestartIT.java index 6c79c68df1df1..385e37bd11f69 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/IngestRestartIT.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/IngestRestartIT.java @@ -99,7 +99,7 @@ public Settings onNodeStopped(String nodeName) { } }); - + checkPipelineExists.accept(pipelineIdWithoutScript); checkPipelineExists.accept(pipelineIdWithScript); @@ -126,7 +126,7 @@ public Settings onNodeStopped(String nodeName) { "nested: IllegalArgumentException[cannot execute [inline] scripts];; java.lang.IllegalArgumentException: " + "cannot execute [inline] scripts]")); - Map source = client().prepareGet("index", "doc", "1").get().getSource(); + Map source = client().prepareGet("index", "1").get().getSource(); assertThat(source.get("x"), equalTo(0)); assertThat(source.get("y"), equalTo(0)); } @@ -153,7 +153,7 @@ public void testPipelineWithScriptProcessorThatHasStoredScript() throws Exceptio .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .get(); - Map source = client().prepareGet("index", "doc", "1").get().getSource(); + Map source = client().prepareGet("index", "1").get().getSource(); assertThat(source.get("x"), equalTo(0)); assertThat(source.get("y"), equalTo(0)); assertThat(source.get("z"), equalTo(0)); @@ -171,7 +171,7 @@ public void testPipelineWithScriptProcessorThatHasStoredScript() throws Exceptio .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .get(); - source = client().prepareGet("index", "doc", "2").get().getSource(); + source = client().prepareGet("index", "2").get().getSource(); assertThat(source.get("x"), equalTo(0)); assertThat(source.get("y"), equalTo(0)); assertThat(source.get("z"), equalTo(0)); @@ -197,7 +197,7 @@ public void testWithDedicatedIngestNode() throws Exception { .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .get(); - Map source = client().prepareGet("index", "doc", "1").get().getSource(); + Map source = client().prepareGet("index", "1").get().getSource(); assertThat(source.get("x"), equalTo(0)); assertThat(source.get("y"), equalTo(0)); @@ -210,7 +210,7 @@ public void testWithDedicatedIngestNode() throws Exception { .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) .get(); - source = client(ingestNode).prepareGet("index", "doc", "2").get().getSource(); + source = client(ingestNode).prepareGet("index", "2").get().getSource(); assertThat(source.get("x"), equalTo(0)); assertThat(source.get("y"), equalTo(0)); } diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java index 151dd8b9e61ba..1a89752fe1d0d 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java @@ -502,7 +502,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) { GetRequest getRequest; if (indexedDocumentType != null) { deprecationLogger.deprecatedAndMaybeLog("percolate_with_type", TYPE_DEPRECATION_MESSAGE); - getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentType, indexedDocumentId); + getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId); } else { getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId); } diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java index a86f93ce40549..ce2c12e5a2622 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java @@ -146,19 +146,18 @@ protected String[] shuffleProtectedFields() { @Override protected GetResponse executeGet(GetRequest getRequest) { assertThat(getRequest.index(), Matchers.equalTo(indexedDocumentIndex)); - assertThat(getRequest.type(), Matchers.equalTo(MapperService.SINGLE_MAPPING_NAME)); assertThat(getRequest.id(), Matchers.equalTo(indexedDocumentId)); assertThat(getRequest.routing(), Matchers.equalTo(indexedDocumentRouting)); assertThat(getRequest.preference(), Matchers.equalTo(indexedDocumentPreference)); assertThat(getRequest.version(), Matchers.equalTo(indexedDocumentVersion)); if (indexedDocumentExists) { return new GetResponse( - new GetResult(indexedDocumentIndex, MapperService.SINGLE_MAPPING_NAME, indexedDocumentId, 0, 1, 0L, true, + new GetResult(indexedDocumentIndex, indexedDocumentId, 0, 1, 0L, true, documentSource.iterator().next(), Collections.emptyMap(), Collections.emptyMap()) ); } else { return new GetResponse( - new GetResult(indexedDocumentIndex, MapperService.SINGLE_MAPPING_NAME, indexedDocumentId, UNASSIGNED_SEQ_NO, 0, -1, + new GetResult(indexedDocumentIndex, indexedDocumentId, UNASSIGNED_SEQ_NO, 0, -1, false, null, Collections.emptyMap(), Collections.emptyMap()) ); } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexVersioningTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexVersioningTests.java index 627238e5380be..2831980022dad 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexVersioningTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexVersioningTests.java @@ -116,7 +116,7 @@ private void setupSourceAbsent() throws Exception { indexRandom(true, client().prepareIndex("source", "_doc", "test").setVersionType(EXTERNAL) .setVersion(SOURCE_VERSION).setSource("foo", "source")); - assertEquals(SOURCE_VERSION, client().prepareGet("source", "_doc", "test").get().getVersion()); + assertEquals(SOURCE_VERSION, client().prepareGet("source", "test").get().getVersion()); } private void setupDest(int version) throws Exception { @@ -124,7 +124,7 @@ private void setupDest(int version) throws Exception { indexRandom(true, client().prepareIndex("dest", "_doc", "test").setVersionType(EXTERNAL) .setVersion(version).setSource("foo", "dest")); - assertEquals(version, client().prepareGet("dest", "_doc", "test").get().getVersion()); + assertEquals(version, client().prepareGet("dest", "test").get().getVersion()); } private void setupDestOlder() throws Exception { @@ -136,7 +136,7 @@ private void setupDestNewer() throws Exception { } private void assertDest(String fooValue, int version) { - GetResponse get = client().prepareGet("dest", "_doc", "test").get(); + GetResponse get = client().prepareGet("dest", "test").get(); assertEquals(fooValue, get.getSource().get("foo")); assertEquals(version, get.getVersion()); } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryBasicTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryBasicTests.java index f55ee1e802e6b..2f71b2969a513 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryBasicTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryBasicTests.java @@ -40,35 +40,35 @@ public void testBasics() throws Exception { client().prepareIndex("test", "test", "3").setSource("foo", "b"), client().prepareIndex("test", "test", "4").setSource("foo", "c")); assertHitCount(client().prepareSearch("test").setSize(0).get(), 4); - assertEquals(1, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(1, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(1, client().prepareGet("test", "1").get().getVersion()); + assertEquals(1, client().prepareGet("test", "4").get().getVersion()); // Reindex all the docs assertThat(updateByQuery().source("test").refresh(true).get(), matcher().updated(4)); - assertEquals(2, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(2, client().prepareGet("test", "1").get().getVersion()); + assertEquals(2, client().prepareGet("test", "4").get().getVersion()); // Now none of them assertThat(updateByQuery().source("test").filter(termQuery("foo", "no_match")).refresh(true).get(), matcher().updated(0)); - assertEquals(2, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(2, client().prepareGet("test", "1").get().getVersion()); + assertEquals(2, client().prepareGet("test", "4").get().getVersion()); // Now half of them assertThat(updateByQuery().source("test").filter(termQuery("foo", "a")).refresh(true).get(), matcher().updated(2)); - assertEquals(3, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(3, client().prepareGet("test", "test", "2").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "3").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(3, client().prepareGet("test", "1").get().getVersion()); + assertEquals(3, client().prepareGet("test", "2").get().getVersion()); + assertEquals(2, client().prepareGet("test", "3").get().getVersion()); + assertEquals(2, client().prepareGet("test", "4").get().getVersion()); // Limit with size UpdateByQueryRequestBuilder request = updateByQuery().source("test").size(3).refresh(true); request.source().addSort("foo.keyword", SortOrder.ASC); assertThat(request.get(), matcher().updated(3)); // Only the first three documents are updated because of sort - assertEquals(4, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(4, client().prepareGet("test", "test", "2").get().getVersion()); - assertEquals(3, client().prepareGet("test", "test", "3").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(4, client().prepareGet("test", "1").get().getVersion()); + assertEquals(4, client().prepareGet("test", "2").get().getVersion()); + assertEquals(3, client().prepareGet("test", "3").get().getVersion()); + assertEquals(2, client().prepareGet("test", "4").get().getVersion()); } public void testSlices() throws Exception { @@ -78,8 +78,8 @@ public void testSlices() throws Exception { client().prepareIndex("test", "test", "3").setSource("foo", "b"), client().prepareIndex("test", "test", "4").setSource("foo", "c")); assertHitCount(client().prepareSearch("test").setSize(0).get(), 4); - assertEquals(1, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(1, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(1, client().prepareGet("test", "1").get().getVersion()); + assertEquals(1, client().prepareGet("test", "4").get().getVersion()); int slices = randomSlices(2, 10); int expectedSlices = expectedSliceStatuses(slices, "test"); @@ -93,8 +93,8 @@ public void testSlices() throws Exception { matcher() .updated(4) .slices(hasSize(expectedSlices))); - assertEquals(2, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(2, client().prepareGet("test", "1").get().getVersion()); + assertEquals(2, client().prepareGet("test", "4").get().getVersion()); // Now none of them assertThat( @@ -106,8 +106,8 @@ public void testSlices() throws Exception { matcher() .updated(0) .slices(hasSize(expectedSlices))); - assertEquals(2, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(2, client().prepareGet("test", "1").get().getVersion()); + assertEquals(2, client().prepareGet("test", "4").get().getVersion()); // Now half of them assertThat( @@ -119,10 +119,10 @@ public void testSlices() throws Exception { matcher() .updated(2) .slices(hasSize(expectedSlices))); - assertEquals(3, client().prepareGet("test", "test", "1").get().getVersion()); - assertEquals(3, client().prepareGet("test", "test", "2").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "3").get().getVersion()); - assertEquals(2, client().prepareGet("test", "test", "4").get().getVersion()); + assertEquals(3, client().prepareGet("test", "1").get().getVersion()); + assertEquals(3, client().prepareGet("test", "2").get().getVersion()); + assertEquals(2, client().prepareGet("test", "3").get().getVersion()); + assertEquals(2, client().prepareGet("test", "4").get().getVersion()); } public void testMultipleSources() throws Exception { @@ -155,7 +155,7 @@ public void testMultipleSources() throws Exception { String index = entry.getKey(); List indexDocs = entry.getValue(); int randomDoc = between(0, indexDocs.size() - 1); - assertEquals(2, client().prepareGet(index, "test", Integer.toString(randomDoc)).get().getVersion()); + assertEquals(2, client().prepareGet(index, Integer.toString(randomDoc)).get().getVersion()); } } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryWhileModifyingTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryWhileModifyingTests.java index 1c3456fe20c5f..ecee755a24071 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryWhileModifyingTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryWhileModifyingTests.java @@ -61,7 +61,7 @@ public void testUpdateWhileReindexing() throws Exception { try { for (int i = 0; i < MAX_MUTATIONS; i++) { - GetResponse get = client().prepareGet("test", "test", "test").get(); + GetResponse get = client().prepareGet("test", "test").get(); assertEquals(value.get(), get.getSource().get("test")); value.set(randomSimpleString(random())); IndexRequestBuilder index = client().prepareIndex("test", "test", "test").setSource("test", value.get()) @@ -84,7 +84,7 @@ public void testUpdateWhileReindexing() throws Exception { } logger.info("Caught expected version conflict trying to perform mutation number [{}] with version [{}] " + "on attempt [{}]. Retrying.", i, get.getVersion(), attempts); - get = client().prepareGet("test", "test", "test").get(); + get = client().prepareGet("test", "test").get(); } } } diff --git a/plugins/mapper-size/src/test/java/org/elasticsearch/index/mapper/size/SizeMappingIT.java b/plugins/mapper-size/src/test/java/org/elasticsearch/index/mapper/size/SizeMappingIT.java index d74baee3d56e3..cbf89567b9a59 100644 --- a/plugins/mapper-size/src/test/java/org/elasticsearch/index/mapper/size/SizeMappingIT.java +++ b/plugins/mapper-size/src/test/java/org/elasticsearch/index/mapper/size/SizeMappingIT.java @@ -109,7 +109,7 @@ public void testBasic() throws Exception { final String source = "{\"f\":10}"; indexRandom(true, client().prepareIndex("test", "type", "1").setSource(source, XContentType.JSON)); - GetResponse getResponse = client().prepareGet("test", "type", "1").setStoredFields("_size").get(); + GetResponse getResponse = client().prepareGet("test", "1").setStoredFields("_size").get(); assertNotNull(getResponse.getField("_size")); assertEquals(source.length(), (int) getResponse.getField("_size").getValue()); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java index 0de2725803c85..d5d60fa7d71c0 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java @@ -175,8 +175,7 @@ void waitedForCompletion(Task thisTask, GetTaskRequest request, TaskInfo snapsho * coordinating node if the node is no longer part of the cluster. */ void getFinishedTaskFromIndex(Task thisTask, GetTaskRequest request, ActionListener listener) { - GetRequest get = new GetRequest(TaskResultsService.TASK_INDEX, TaskResultsService.TASK_TYPE, - request.getTaskId().toString()); + GetRequest get = new GetRequest(TaskResultsService.TASK_INDEX, request.getTaskId().toString()); get.setParentTask(clusterService.localNode().getId(), thisTask.getId()); client.get(get, ActionListener.wrap(r -> onGetFinishedTaskFromIndex(r, listener), e -> { diff --git a/server/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java b/server/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java index e6a2ef5be9d04..bcafaff3c404c 100644 --- a/server/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java +++ b/server/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java @@ -115,7 +115,7 @@ protected ExplainResponse shardOperation(ExplainRequest request, ShardId shardId try { // No need to check the type, IndexShard#get does it for us Term uidTerm = new Term(IdFieldMapper.NAME, Uid.encodeId(request.id())); - result = context.indexShard().get(new Engine.Get(false, false, request.type(), request.id(), uidTerm)); + result = context.indexShard().get(new Engine.Get(false, false, request.id(), uidTerm)); if (!result.exists()) { return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), false); } @@ -131,7 +131,7 @@ protected ExplainResponse shardOperation(ExplainRequest request, ShardId shardId // Advantage is that we're not opening a second searcher to retrieve the _source. Also // because we are working in the same searcher in engineGetResult we can be sure that a // doc isn't deleted between the initial get and this call. - GetResult getResult = context.indexShard().getService().get(result, request.id(), request.type(), request.storedFields(), + GetResult getResult = context.indexShard().getService().get(result, request.id(), request.storedFields(), request.fetchSourceContext()); return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), true, explanation, getResult); } else { 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 932602b3a2d22..1233a5b7e4c50 100644 --- a/server/src/main/java/org/elasticsearch/action/get/GetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/GetRequest.java @@ -19,11 +19,11 @@ package org.elasticsearch.action.get; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.RealtimeRequest; import org.elasticsearch.action.ValidateActions; import org.elasticsearch.action.support.single.shard.SingleShardRequest; -import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -40,7 +40,7 @@ * A request to get a document (its source) from an index based on its id. Best created using * {@link org.elasticsearch.client.Requests#getRequest(String)}. *

- * The operation requires the {@link #index()}, {@link #type(String)} and {@link #id(String)} + * The operation requires the {@link #index()} and {@link #id(String)} * to be set. * * @see org.elasticsearch.action.get.GetResponse @@ -49,7 +49,6 @@ */ public class GetRequest extends SingleShardRequest implements RealtimeRequest { - private String type; private String id; private String routing; private String preference; @@ -65,13 +64,11 @@ public class GetRequest extends SingleShardRequest implements Realti private VersionType versionType = VersionType.INTERNAL; private long version = Versions.MATCH_ANY; - public GetRequest() { - type = MapperService.SINGLE_MAPPING_NAME; - } - GetRequest(StreamInput in) throws IOException { super(in); - type = in.readString(); + if (in.getVersion().before(Version.V_8_0_0)) { + in.readString(); + } id = in.readString(); routing = in.readOptionalString(); preference = in.readOptionalString(); @@ -84,27 +81,13 @@ public GetRequest() { fetchSourceContext = in.readOptionalWriteable(FetchSourceContext::new); } + public GetRequest() {} + /** * 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 = MapperService.SINGLE_MAPPING_NAME; - } - - /** - * Constructs a new get request against the specified index with the type and id. - * - * @param index The index to get the document from - * @param type The type of the document - * @param id The id of the document - * @deprecated Types are in the process of being removed, use {@link GetRequest(String, String)} instead. - */ - @Deprecated - public GetRequest(String index, String type, String id) { - super(index); - this.type = type; - this.id = id; } /** @@ -116,15 +99,11 @@ public GetRequest(String index, String type, String id) { 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(); - if (Strings.isEmpty(type)) { - validationException = addValidationError("type is missing", validationException); - } if (Strings.isEmpty(id)) { validationException = addValidationError("id is missing", validationException); } @@ -138,19 +117,6 @@ public ActionRequestValidationException validate() { return validationException; } - /** - * 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 = MapperService.SINGLE_MAPPING_NAME; - } - this.type = type; - return this; - } - /** * Sets the id of the document to fetch. */ @@ -178,14 +144,6 @@ public GetRequest preference(String preference) { return this; } - /** - * @deprecated Types are in the process of being removed. - */ - @Deprecated - public String type() { - return type; - } - public String id() { return id; } @@ -279,7 +237,9 @@ public VersionType versionType() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeString(type); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); out.writeOptionalString(routing); out.writeOptionalString(preference); @@ -294,7 +254,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public String toString() { - return "get [" + index + "][" + type + "][" + id + "]: routing [" + routing + "]"; + return "get [" + index + "][" + id + "]: routing [" + routing + "]"; } } diff --git a/server/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java index 37b9dbe79dfe4..29a8ca8f44586 100644 --- a/server/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java @@ -39,15 +39,6 @@ public GetRequestBuilder(ElasticsearchClient client, GetAction action, @Nullable super(client, action, new GetRequest(index)); } - /** - * Sets the type of the document to fetch. If set to {@code null}, will use just the id to fetch the - * first document matching it. - */ - public GetRequestBuilder setType(@Nullable String type) { - request.type(type); - return this; - } - /** * Sets the id of the document to fetch. */ diff --git a/server/src/main/java/org/elasticsearch/action/get/GetResponse.java b/server/src/main/java/org/elasticsearch/action/get/GetResponse.java index c3362f7fc650c..71a7fcf665d28 100644 --- a/server/src/main/java/org/elasticsearch/action/get/GetResponse.java +++ b/server/src/main/java/org/elasticsearch/action/get/GetResponse.java @@ -71,13 +71,6 @@ public String getIndex() { return getResult.getIndex(); } - /** - * The type of the document. - */ - public String getType() { - return getResult.getType(); - } - /** * The id of the document. */ @@ -196,9 +189,9 @@ public static GetResponse fromXContent(XContentParser parser) throws IOException // At this stage we ensure that we parsed enough information to return // a valid GetResponse instance. If it's not the case, we throw an // exception so that callers know it and can handle it correctly. - if (getResult.getIndex() == null && getResult.getType() == null && getResult.getId() == null) { + if (getResult.getIndex() == null && getResult.getId() == null) { throw new ParsingException(parser.getTokenLocation(), - String.format(Locale.ROOT, "Missing required fields [%s,%s,%s]", GetResult._INDEX, GetResult._TYPE, GetResult._ID)); + String.format(Locale.ROOT, "Missing required fields [%s,%s]", GetResult._INDEX, GetResult._ID)); } return new GetResponse(getResult); } diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java index d2ae4be9f98df..da221cef80470 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java @@ -58,16 +58,6 @@ public String getIndex() { return response.getIndex(); } - /** - * The type of the document. - */ - public String getType() { - if (failure != null) { - return failure.getType(); - } - return response.getType(); - } - /** * The id of the document. */ 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 a9a6878998935..f9e2da1535b80 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.get; import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; @@ -40,6 +41,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.index.VersionType; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -55,7 +57,6 @@ public class MultiGetRequest extends ActionRequest private static final ParseField DOCS = new ParseField("docs"); private static final ParseField INDEX = new ParseField("_index"); - private static final ParseField TYPE = new ParseField("_type"); private static final ParseField ID = new ParseField("_id"); private static final ParseField ROUTING = new ParseField("routing"); private static final ParseField VERSION = new ParseField("version"); @@ -70,7 +71,6 @@ public class MultiGetRequest extends ActionRequest public static class Item implements Writeable, IndicesRequest, ToXContentObject { private String index; - private String type; private String id; private String routing; private String[] storedFields; @@ -84,7 +84,9 @@ public Item() { public Item(StreamInput in) throws IOException { index = in.readString(); - type = in.readOptionalString(); + if (in.getVersion().before(Version.V_8_0_0)) { + in.readOptionalString(); + } id = in.readString(); routing = in.readOptionalString(); storedFields = in.readOptionalStringArray(); @@ -94,22 +96,6 @@ public Item(StreamInput in) throws IOException { fetchSourceContext = in.readOptionalWriteable(FetchSourceContext::new); } - /** - * Constructs a single get item. - * - * @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; @@ -134,10 +120,6 @@ public Item index(String index) { return this; } - public String type() { - return this.type; - } - public String id() { return this.id; } @@ -196,7 +178,9 @@ public Item fetchSourceContext(FetchSourceContext fetchSourceContext) { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(index); - out.writeOptionalString(type); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); out.writeOptionalString(routing); out.writeOptionalStringArray(storedFields); @@ -210,7 +194,6 @@ public void writeTo(StreamOutput out) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(INDEX.getPreferredName(), index); - builder.field(TYPE.getPreferredName(), type); builder.field(ID.getPreferredName(), id); builder.field(ROUTING.getPreferredName(), routing); builder.field(STORED_FIELDS.getPreferredName(), storedFields); @@ -235,7 +218,6 @@ public boolean equals(Object o) { if (!id.equals(item.id)) return false; if (!index.equals(item.index)) return false; if (routing != null ? !routing.equals(item.routing) : item.routing != null) return false; - if (type != null ? !type.equals(item.type) : item.type != null) return false; if (versionType != item.versionType) return false; return true; @@ -244,7 +226,6 @@ public boolean equals(Object o) { @Override public int hashCode() { int result = index.hashCode(); - result = 31 * result + (type != null ? type.hashCode() : 0); result = 31 * result + id.hashCode(); result = 31 * result + (routing != null ? routing.hashCode() : 0); result = 31 * result + (storedFields != null ? Arrays.hashCode(storedFields) : 0); @@ -289,16 +270,6 @@ public MultiGetRequest add(Item item) { 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; @@ -356,7 +327,7 @@ public MultiGetRequest refresh(boolean refresh) { return this; } - public MultiGetRequest add(@Nullable String defaultIndex, @Nullable String defaultType, @Nullable String[] defaultFields, + public MultiGetRequest add(@Nullable String defaultIndex, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource, @Nullable String defaultRouting, XContentParser parser, boolean allowExplicitIndex) throws IOException { Token token; @@ -374,10 +345,10 @@ public MultiGetRequest add(@Nullable String defaultIndex, @Nullable String defau currentFieldName = parser.currentName(); } else if (token == Token.START_ARRAY) { if ("docs".equals(currentFieldName)) { - parseDocuments(parser, this.items, defaultIndex, defaultType, defaultFields, defaultFetchSource, defaultRouting, + parseDocuments(parser, this.items, defaultIndex, defaultFields, defaultFetchSource, defaultRouting, allowExplicitIndex); } else if ("ids".equals(currentFieldName)) { - parseIds(parser, this.items, defaultIndex, defaultType, defaultFields, defaultFetchSource, defaultRouting); + parseIds(parser, this.items, defaultIndex, defaultFields, defaultFetchSource, defaultRouting); } else { final String message = String.format( Locale.ROOT, @@ -399,7 +370,7 @@ public MultiGetRequest add(@Nullable String defaultIndex, @Nullable String defau return this; } - private static void parseDocuments(XContentParser parser, List items, @Nullable String defaultIndex, @Nullable String defaultType, + private static void parseDocuments(XContentParser parser, List items, @Nullable String defaultIndex, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource, @Nullable String defaultRouting, boolean allowExplicitIndex) throws IOException { String currentFieldName = null; @@ -409,7 +380,6 @@ private static void parseDocuments(XContentParser parser, List items, @Nul throw new IllegalArgumentException("docs array element should include an object"); } String index = defaultIndex; - String type = defaultType; String id = null; String routing = defaultRouting; List storedFields = null; @@ -427,8 +397,6 @@ private static void parseDocuments(XContentParser parser, List items, @Nul throw new IllegalArgumentException("explicit index in multi get is not allowed"); } index = parser.text(); - } else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) { - type = parser.text(); } else if (ID.match(currentFieldName, parser.getDeprecationHandler())) { id = parser.text(); } else if (ROUTING.match(currentFieldName, parser.getDeprecationHandler())) { @@ -511,12 +479,12 @@ private static void parseDocuments(XContentParser parser, List items, @Nul } else { aFields = defaultFields; } - items.add(new Item(index, type, id).routing(routing).storedFields(aFields).version(version).versionType(versionType) + items.add(new Item(index, id).routing(routing).storedFields(aFields).version(version).versionType(versionType) .fetchSourceContext(fetchSourceContext == FetchSourceContext.FETCH_SOURCE ? defaultFetchSource : fetchSourceContext)); } } - public static void parseIds(XContentParser parser, List items, @Nullable String defaultIndex, @Nullable String defaultType, + public static void parseIds(XContentParser parser, List items, @Nullable String defaultIndex, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource, @Nullable String defaultRouting) throws IOException { Token token; @@ -524,13 +492,13 @@ public static void parseIds(XContentParser parser, List items, @Nullable S if (!token.isValue()) { throw new IllegalArgumentException("ids array element should only contain ids"); } - items.add(new Item(defaultIndex, defaultType, parser.text()).storedFields(defaultFields).fetchSourceContext(defaultFetchSource) + items.add(new Item(defaultIndex, parser.text()).storedFields(defaultFields).fetchSourceContext(defaultFetchSource) .routing(defaultRouting)); } } public static void parseIds(XContentParser parser, List items) throws IOException { - parseIds(parser, items, null, null, null, null, null); + parseIds(parser, items, null, null, null, null); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java index 4385447846b83..f4e6a73d453ac 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java @@ -21,7 +21,6 @@ import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.client.ElasticsearchClient; -import org.elasticsearch.common.Nullable; /** * A multi get document action request builder. @@ -32,21 +31,21 @@ public MultiGetRequestBuilder(ElasticsearchClient client, MultiGetAction action) super(client, action, new MultiGetRequest()); } - public MultiGetRequestBuilder add(String index, @Nullable String type, String id) { - request.add(index, type, id); + public MultiGetRequestBuilder add(String index, String id) { + request.add(index, id); return this; } - public MultiGetRequestBuilder add(String index, @Nullable String type, Iterable ids) { + public MultiGetRequestBuilder add(String index, Iterable ids) { for (String id : ids) { - request.add(index, type, id); + request.add(index, id); } return this; } - public MultiGetRequestBuilder add(String index, @Nullable String type, String... ids) { + public MultiGetRequestBuilder add(String index, String... ids) { for (String id : ids) { - request.add(index, type, id); + request.add(index, id); } return this; } diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java index 78e7e92fa7af3..3934b9db81efe 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.get; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; @@ -30,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.index.get.GetResult; +import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; import java.util.ArrayList; @@ -40,7 +42,6 @@ public class MultiGetResponse extends ActionResponse implements Iterable, ToXContentObject { private static final ParseField INDEX = new ParseField("_index"); - private static final ParseField TYPE = new ParseField("_type"); private static final ParseField ID = new ParseField("_id"); private static final ParseField ERROR = new ParseField("error"); private static final ParseField DOCS = new ParseField("docs"); @@ -51,20 +52,20 @@ public class MultiGetResponse extends ActionResponse implements Iterable new ParameterizedMessage("{} failed to execute multi_get for [{}]/[{}]", shardId, - item.type(), item.id()), e); - response.add(request.locations.get(i), new MultiGetResponse.Failure(request.index(), item.type(), item.id(), e)); + logger.debug(() -> new ParameterizedMessage("{} failed to execute multi_get for [{}]", shardId, + item.id()), e); + response.add(request.locations.get(i), new MultiGetResponse.Failure(request.index(), item.id(), e)); } } } diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateHelper.java b/server/src/main/java/org/elasticsearch/action/update/UpdateHelper.java index 7e0ff56f80442..92e320fe5c5f4 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateHelper.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateHelper.java @@ -38,6 +38,7 @@ import org.elasticsearch.index.engine.DocumentMissingException; import org.elasticsearch.index.engine.DocumentSourceMissingException; import org.elasticsearch.index.get.GetResult; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.RoutingFieldMapper; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.ShardId; @@ -70,7 +71,7 @@ public UpdateHelper(ScriptService scriptService) { */ public Result prepare(UpdateRequest request, IndexShard indexShard, LongSupplier nowInMillis) { final GetResult getResult = indexShard.getService().getForUpdate( - request.type(), request.id(), request.ifSeqNo(), request.ifPrimaryTerm()); + request.id(), request.ifSeqNo(), request.ifPrimaryTerm()); return prepare(indexShard.shardId(), request, getResult, nowInMillis); } @@ -139,7 +140,7 @@ Result prepareUpsert(ShardId shardId, UpdateRequest request, final GetResult get indexRequest.source(upsertResult.v2()); break; case NONE: - UpdateResponse update = new UpdateResponse(shardId, getResult.getType(), getResult.getId(), + UpdateResponse update = new UpdateResponse(shardId, MapperService.SINGLE_MAPPING_NAME, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), DocWriteResponse.Result.NOOP); update.setGetResult(getResult); return new Result(update, DocWriteResponse.Result.NOOP, upsertResult.v2(), XContentType.JSON); @@ -193,7 +194,7 @@ Result prepareUpdateIndexRequest(ShardId shardId, UpdateRequest request, GetResu // We can only actually turn the update into a noop if detectNoop is true to preserve backwards compatibility and to handle cases // where users repopulating multi-fields or adding synonyms, etc. if (detectNoop && noop) { - UpdateResponse update = new UpdateResponse(shardId, getResult.getType(), getResult.getId(), + UpdateResponse update = new UpdateResponse(shardId, MapperService.SINGLE_MAPPING_NAME, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), DocWriteResponse.Result.NOOP); update.setGetResult(extractGetResult(request, request.index(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), updatedSourceAsMap, updateSourceContentType, getResult.internalSourceRef())); @@ -224,7 +225,7 @@ Result prepareUpdateScriptRequest(ShardId shardId, UpdateRequest request, GetRes Map ctx = new HashMap<>(16); ctx.put(ContextFields.OP, UpdateOpType.INDEX.toString()); // The default operation is "index" ctx.put(ContextFields.INDEX, getResult.getIndex()); - ctx.put(ContextFields.TYPE, getResult.getType()); + ctx.put(ContextFields.TYPE, MapperService.SINGLE_MAPPING_NAME); ctx.put(ContextFields.ID, getResult.getId()); ctx.put(ContextFields.VERSION, getResult.getVersion()); ctx.put(ContextFields.ROUTING, routing); @@ -256,7 +257,7 @@ Result prepareUpdateScriptRequest(ShardId shardId, UpdateRequest request, GetRes return new Result(deleteRequest, DocWriteResponse.Result.DELETED, updatedSourceAsMap, updateSourceContentType); default: // If it was neither an INDEX or DELETE operation, treat it as a noop - UpdateResponse update = new UpdateResponse(shardId, getResult.getType(), getResult.getId(), + UpdateResponse update = new UpdateResponse(shardId, MapperService.SINGLE_MAPPING_NAME, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), DocWriteResponse.Result.NOOP); update.setGetResult(extractGetResult(request, request.index(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), updatedSourceAsMap, updateSourceContentType, getResult.internalSourceRef())); @@ -305,7 +306,7 @@ public static GetResult extractGetResult(final UpdateRequest request, String con } // TODO when using delete/none, we can still return the source as bytes by generating it (using the sourceContentType) - return new GetResult(concreteIndex, request.type(), request.id(), seqNo, primaryTerm, version, true, sourceFilteredAsBytes, + return new GetResult(concreteIndex, request.id(), seqNo, primaryTerm, version, true, sourceFilteredAsBytes, Collections.emptyMap(), Collections.emptyMap()); } diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateResponse.java b/server/src/main/java/org/elasticsearch/action/update/UpdateResponse.java index 05aaf53ed400b..e27581480b732 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateResponse.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateResponse.java @@ -157,7 +157,7 @@ public UpdateResponse build() { update = new UpdateResponse(shardId, type, id, seqNo, primaryTerm, version, result); } if (getResult != null) { - update.setGetResult(new GetResult(update.getIndex(), update.getType(), update.getId(), + update.setGetResult(new GetResult(update.getIndex(), update.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), update.getVersion(), getResult.isExists(), getResult.internalSourceRef(), getResult.getDocumentFields(), getResult.getMetadataFields())); diff --git a/server/src/main/java/org/elasticsearch/client/Client.java b/server/src/main/java/org/elasticsearch/client/Client.java index 3ea28ad074be0..b2f01d92e6c74 100644 --- a/server/src/main/java/org/elasticsearch/client/Client.java +++ b/server/src/main/java/org/elasticsearch/client/Client.java @@ -259,9 +259,9 @@ public interface Client extends ElasticsearchClient, Releasable { GetRequestBuilder prepareGet(); /** - * Gets the document that was indexed from an index with a type (optional) and id. + * Gets the document that was indexed from an index with an id. */ - GetRequestBuilder prepareGet(String index, @Nullable String type, String id); + GetRequestBuilder prepareGet(String index, String id); /** * Multi get documents. diff --git a/server/src/main/java/org/elasticsearch/client/Requests.java b/server/src/main/java/org/elasticsearch/client/Requests.java index fa7bc73c8b9fc..24f52b69f9f3c 100644 --- a/server/src/main/java/org/elasticsearch/client/Requests.java +++ b/server/src/main/java/org/elasticsearch/client/Requests.java @@ -116,7 +116,7 @@ public static BulkRequest bulkRequest() { /** * Creates a get request to get the JSON source from an index based on a type and id. Note, the - * {@link GetRequest#type(String)} and {@link GetRequest#id(String)} must be set. + * {@link GetRequest#id(String)} must be set. * * @param index The index to get the JSON source from * @return The get request diff --git a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java index 283b8dc0a2843..1c9b6e593f8e1 100644 --- a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -485,8 +485,8 @@ public GetRequestBuilder prepareGet() { } @Override - public GetRequestBuilder prepareGet(String index, String type, String id) { - return prepareGet().setIndex(index).setType(type).setId(id); + public GetRequestBuilder prepareGet(String index, String id) { + return prepareGet().setIndex(index).setId(id); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/engine/Engine.java b/server/src/main/java/org/elasticsearch/index/engine/Engine.java index f26e5b8ad1ffe..8aadc64806c5f 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/Engine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/Engine.java @@ -1561,16 +1561,15 @@ public int estimatedSizeInBytes() { public static class Get { private final boolean realtime; private final Term uid; - private final String type, id; + private final String id; private final boolean readFromTranslog; private long version = Versions.MATCH_ANY; private VersionType versionType = VersionType.INTERNAL; private long ifSeqNo = UNASSIGNED_SEQ_NO; private long ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM; - public Get(boolean realtime, boolean readFromTranslog, String type, String id, Term uid) { + public Get(boolean realtime, boolean readFromTranslog, String id, Term uid) { this.realtime = realtime; - this.type = type; this.id = id; this.uid = uid; this.readFromTranslog = readFromTranslog; @@ -1580,10 +1579,6 @@ public boolean realtime() { return this.realtime; } - public String type() { - return type; - } - public String id() { return id; } @@ -1628,7 +1623,7 @@ public Get setIfPrimaryTerm(long primaryTerm) { this.ifPrimaryTerm = primaryTerm; return this; } - + public long getIfPrimaryTerm() { return ifPrimaryTerm; } diff --git a/server/src/main/java/org/elasticsearch/index/get/GetResult.java b/server/src/main/java/org/elasticsearch/index/get/GetResult.java index f2fd252d7644e..f64aa03b9c487 100644 --- a/server/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/server/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.IgnoredFieldMapper; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.SourceFieldMapper; import org.elasticsearch.search.lookup.SourceLookup; @@ -51,7 +52,6 @@ public class GetResult implements Writeable, Iterable, ToXContentObject { public static final String _INDEX = "_index"; - public static final String _TYPE = "_type"; public static final String _ID = "_id"; private static final String _VERSION = "_version"; private static final String _SEQ_NO = "_seq_no"; @@ -60,7 +60,6 @@ public class GetResult implements Writeable, Iterable, ToXContent private static final String FIELDS = "fields"; private String index; - private String type; private String id; private long version; private long seqNo; @@ -74,7 +73,9 @@ public class GetResult implements Writeable, Iterable, ToXContent public GetResult(StreamInput in) throws IOException { index = in.readString(); - type = in.readOptionalString(); + if (in.getVersion().before(Version.V_8_0_0)) { + in.readOptionalString(); + } id = in.readString(); seqNo = in.readZLong(); primaryTerm = in.readVLong(); @@ -97,10 +98,9 @@ public GetResult(StreamInput in) throws IOException { } } - public GetResult(String index, String type, String id, long seqNo, long primaryTerm, long version, boolean exists, + public GetResult(String index, String id, long seqNo, long primaryTerm, long version, boolean exists, BytesReference source, Map documentFields, Map metaFields) { this.index = index; - this.type = type; this.id = id; this.seqNo = seqNo; this.primaryTerm = primaryTerm; @@ -135,13 +135,6 @@ public String getIndex() { return index; } - /** - * The type of the document. - */ - public String getType() { - return type; - } - /** * The id of the document. */ @@ -310,7 +303,6 @@ public XContentBuilder toXContentEmbedded(XContentBuilder builder, Params params public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(_INDEX, index); - builder.field(_TYPE, type); builder.field(_ID, id); if (isExists()) { if (version != -1) { @@ -327,10 +319,10 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws public static GetResult fromXContentEmbedded(XContentParser parser) throws IOException { XContentParser.Token token = parser.nextToken(); ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser::getTokenLocation); - return fromXContentEmbedded(parser, null, null, null); + return fromXContentEmbedded(parser, null, null); } - public static GetResult fromXContentEmbedded(XContentParser parser, String index, String type, String id) throws IOException { + public static GetResult fromXContentEmbedded(XContentParser parser, String index, String id) throws IOException { XContentParser.Token token = parser.currentToken(); ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser::getTokenLocation); @@ -348,8 +340,6 @@ public static GetResult fromXContentEmbedded(XContentParser parser, String index } else if (token.isValue()) { if (_INDEX.equals(currentFieldName)) { index = parser.text(); - } else if (_TYPE.equals(currentFieldName)) { - type = parser.text(); } else if (_ID.equals(currentFieldName)) { id = parser.text(); } else if (_VERSION.equals(currentFieldName)) { @@ -361,7 +351,7 @@ public static GetResult fromXContentEmbedded(XContentParser parser, String index } else if (FOUND.equals(currentFieldName)) { found = parser.booleanValue(); } else { - metaFields.put(currentFieldName, new DocumentField(currentFieldName, + metaFields.put(currentFieldName, new DocumentField(currentFieldName, Collections.singletonList(parser.objectText()))); } } else if (token == XContentParser.Token.START_OBJECT) { @@ -388,7 +378,7 @@ public static GetResult fromXContentEmbedded(XContentParser parser, String index } } } - return new GetResult(index, type, id, seqNo, primaryTerm, version, found, source, documentFields, metaFields); + return new GetResult(index, id, seqNo, primaryTerm, version, found, source, documentFields, metaFields); } public static GetResult fromXContent(XContentParser parser) throws IOException { @@ -412,7 +402,7 @@ private Map readFields(StreamInput in) throws IOException } return fields; } - + static void splitFieldsByMetadata(Map fields, Map outOther, Map outMetadata) { if (fields == null) { @@ -422,7 +412,7 @@ static void splitFieldsByMetadata(Map fields, Map fields, Map fields) throws IOException { if (fields == null) { out.writeVInt(0); @@ -472,7 +464,6 @@ public boolean equals(Object o) { primaryTerm == getResult.primaryTerm && exists == getResult.exists && Objects.equals(index, getResult.index) && - Objects.equals(type, getResult.type) && Objects.equals(id, getResult.id) && Objects.equals(documentFields, getResult.documentFields) && Objects.equals(metaFields, getResult.metaFields) && @@ -481,7 +472,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(version, seqNo, primaryTerm, exists, index, type, id, documentFields, metaFields, sourceAsMap()); + return Objects.hash(version, seqNo, primaryTerm, exists, index, id, documentFields, metaFields, sourceAsMap()); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/get/ShardGetService.java b/server/src/main/java/org/elasticsearch/index/get/ShardGetService.java index f77fc072c7062..d547c1603fc74 100644 --- a/server/src/main/java/org/elasticsearch/index/get/ShardGetService.java +++ b/server/src/main/java/org/elasticsearch/index/get/ShardGetService.java @@ -78,19 +78,19 @@ public GetStats stats() { missingMetric.count(), TimeUnit.NANOSECONDS.toMillis(missingMetric.sum()), currentMetric.count()); } - public GetResult get(String type, String id, String[] gFields, boolean realtime, long version, + public GetResult get(String id, String[] gFields, boolean realtime, long version, VersionType versionType, FetchSourceContext fetchSourceContext) { return - get(type, id, gFields, realtime, version, versionType, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, fetchSourceContext, false); + get(id, gFields, realtime, version, versionType, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, fetchSourceContext, false); } - private GetResult get(String type, String id, String[] gFields, boolean realtime, long version, VersionType versionType, + private GetResult get(String id, String[] gFields, boolean realtime, long version, VersionType versionType, long ifSeqNo, long ifPrimaryTerm, FetchSourceContext fetchSourceContext, boolean readFromTranslog) { currentMetric.inc(); try { long now = System.nanoTime(); GetResult getResult = - innerGet(type, id, gFields, realtime, version, versionType, ifSeqNo, ifPrimaryTerm, fetchSourceContext, readFromTranslog); + innerGet(id, gFields, realtime, version, versionType, ifSeqNo, ifPrimaryTerm, fetchSourceContext, readFromTranslog); if (getResult.isExists()) { existsMetric.inc(System.nanoTime() - now); @@ -103,8 +103,8 @@ private GetResult get(String type, String id, String[] gFields, boolean realtime } } - public GetResult getForUpdate(String type, String id, long ifSeqNo, long ifPrimaryTerm) { - return get(type, id, new String[]{RoutingFieldMapper.NAME}, true, + public GetResult getForUpdate(String id, long ifSeqNo, long ifPrimaryTerm) { + return get(id, new String[]{RoutingFieldMapper.NAME}, true, Versions.MATCH_ANY, VersionType.INTERNAL, ifSeqNo, ifPrimaryTerm, FetchSourceContext.FETCH_SOURCE, true); } @@ -115,17 +115,17 @@ public GetResult getForUpdate(String type, String id, long ifSeqNo, long ifPrima *

* Note: Call must release engine searcher associated with engineGetResult! */ - public GetResult get(Engine.GetResult engineGetResult, String id, String type, + public GetResult get(Engine.GetResult engineGetResult, String id, String[] fields, FetchSourceContext fetchSourceContext) { if (!engineGetResult.exists()) { - return new GetResult(shardId.getIndexName(), type, id, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, -1, false, null, null, null); + return new GetResult(shardId.getIndexName(), id, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, -1, false, null, null, null); } currentMetric.inc(); try { long now = System.nanoTime(); fetchSourceContext = normalizeFetchSourceContent(fetchSourceContext, fields); - GetResult getResult = innerGetLoadFromStoredFields(type, id, fields, fetchSourceContext, engineGetResult, mapperService); + GetResult getResult = innerGetLoadFromStoredFields(id, fields, fetchSourceContext, engineGetResult, mapperService); if (getResult.isExists()) { existsMetric.inc(System.nanoTime() - now); } else { @@ -155,37 +155,30 @@ private FetchSourceContext normalizeFetchSourceContent(@Nullable FetchSourceCont return FetchSourceContext.DO_NOT_FETCH_SOURCE; } - private GetResult innerGet(String type, String id, String[] gFields, boolean realtime, long version, VersionType versionType, + private GetResult innerGet(String id, String[] gFields, boolean realtime, long version, VersionType versionType, long ifSeqNo, long ifPrimaryTerm, FetchSourceContext fetchSourceContext, boolean readFromTranslog) { fetchSourceContext = normalizeFetchSourceContent(fetchSourceContext, gFields); - if (type == null || type.equals("_all")) { - DocumentMapper mapper = mapperService.documentMapper(); - type = mapper == null ? null : mapper.type(); - } - Engine.GetResult get = null; - if (type != null) { - Term uidTerm = new Term(IdFieldMapper.NAME, Uid.encodeId(id)); - get = indexShard.get(new Engine.Get(realtime, readFromTranslog, type, id, uidTerm) - .version(version).versionType(versionType).setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm)); - if (get.exists() == false) { - get.close(); - } + Term uidTerm = new Term(IdFieldMapper.NAME, Uid.encodeId(id)); + Engine.GetResult get = indexShard.get(new Engine.Get(realtime, readFromTranslog, id, uidTerm) + .version(version).versionType(versionType).setIfSeqNo(ifSeqNo).setIfPrimaryTerm(ifPrimaryTerm)); + if (get.exists() == false) { + get.close(); } if (get == null || get.exists() == false) { - return new GetResult(shardId.getIndexName(), type, id, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, -1, false, null, null, null); + return new GetResult(shardId.getIndexName(), id, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, -1, false, null, null, null); } try { // break between having loaded it from translog (so we only have _source), and having a document to load - return innerGetLoadFromStoredFields(type, id, gFields, fetchSourceContext, get, mapperService); + return innerGetLoadFromStoredFields(id, gFields, fetchSourceContext, get, mapperService); } finally { get.close(); } } - private GetResult innerGetLoadFromStoredFields(String type, String id, String[] gFields, FetchSourceContext fetchSourceContext, + private GetResult innerGetLoadFromStoredFields(String id, String[] gFields, FetchSourceContext fetchSourceContext, Engine.GetResult get, MapperService mapperService) { Map documentFields = null; Map metaDataFields = null; @@ -196,7 +189,7 @@ private GetResult innerGetLoadFromStoredFields(String type, String id, String[] try { docIdAndVersion.reader.document(docIdAndVersion.docId, fieldVisitor); } catch (IOException e) { - throw new ElasticsearchException("Failed to get type [" + type + "] and id [" + id + "]", e); + throw new ElasticsearchException("Failed to get id [" + id + "]", e); } source = fieldVisitor.source(); @@ -206,7 +199,7 @@ private GetResult innerGetLoadFromStoredFields(String type, String id, String[] metaDataFields = new HashMap<>(); for (Map.Entry> entry : fieldVisitor.fields().entrySet()) { if (MapperService.isMetadataField(entry.getKey())) { - metaDataFields.put(entry.getKey(), new DocumentField(entry.getKey(), entry.getValue())); + metaDataFields.put(entry.getKey(), new DocumentField(entry.getKey(), entry.getValue())); } else { documentFields.put(entry.getKey(), new DocumentField(entry.getKey(), entry.getValue())); } @@ -241,11 +234,11 @@ private GetResult innerGetLoadFromStoredFields(String type, String id, String[] try { source = BytesReference.bytes(XContentFactory.contentBuilder(sourceContentType).map(sourceAsMap)); } catch (IOException e) { - throw new ElasticsearchException("Failed to get type [" + type + "] and id [" + id + "] with includes/excludes set", e); + throw new ElasticsearchException("Failed to get id [" + id + "] with includes/excludes set", e); } } - return new GetResult(shardId.getIndexName(), type, id, get.docIdAndVersion().seqNo, get.docIdAndVersion().primaryTerm, + return new GetResult(shardId.getIndexName(), id, get.docIdAndVersion().seqNo, get.docIdAndVersion().primaryTerm, get.version(), get.exists(), source, documentFields, metaDataFields); } diff --git a/server/src/main/java/org/elasticsearch/index/query/AbstractGeometryQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/AbstractGeometryQueryBuilder.java index 4b59323994f7c..6de7caa211fbf 100644 --- a/server/src/main/java/org/elasticsearch/index/query/AbstractGeometryQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/AbstractGeometryQueryBuilder.java @@ -409,18 +409,16 @@ protected Query doToQuery(QueryShardContext context) { */ private void fetch(Client client, GetRequest getRequest, String path, ActionListener listener) { getRequest.preference("_local"); - client.get(getRequest, new ActionListener(){ + client.get(getRequest, new ActionListener<>(){ @Override public void onResponse(GetResponse response) { try { if (!response.isExists()) { - throw new IllegalArgumentException("Shape with ID [" + getRequest.id() + "] in type [" + getRequest.type() - + "] not found"); + throw new IllegalArgumentException("Shape with ID [" + getRequest.id() + "] not found"); } if (response.isSourceEmpty()) { - throw new IllegalArgumentException("Shape with ID [" + getRequest.id() + "] in type [" + getRequest.type() + - "] source disabled"); + throw new IllegalArgumentException("Shape with ID [" + getRequest.id() + "] source disabled"); } String[] pathElements = path.split("\\."); @@ -530,7 +528,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws if (indexedShapeType == null) { getRequest = new GetRequest(indexedShapeIndex, indexedShapeId); } else { - getRequest = new GetRequest(indexedShapeIndex, indexedShapeType, indexedShapeId); + getRequest = new GetRequest(indexedShapeIndex, indexedShapeId); } getRequest.routing(indexedShapeRouting); fetch(client, getRequest, indexedShapePath, ActionListener.wrap(builder-> { diff --git a/server/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java index 2f4f934727dc7..0d11f6012daf3 100644 --- a/server/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/TermsQueryBuilder.java @@ -459,9 +459,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException { } private void fetch(TermsLookup termsLookup, Client client, ActionListener> actionListener) { - GetRequest getRequest = termsLookup.type() == null - ? new GetRequest(termsLookup.index(), termsLookup.id()) - : new GetRequest(termsLookup.index(), termsLookup.type(), termsLookup.id()); + GetRequest getRequest = new GetRequest(termsLookup.index(), termsLookup.id()); getRequest.preference("_local").routing(termsLookup.routing()); client.get(getRequest, ActionListener.delegateFailure(actionListener, (delegatedListener, getResponse) -> { List terms = new ArrayList<>(); diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 784bfd273c227..13f9092a3ae28 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -922,7 +922,7 @@ private Engine.DeleteResult delete(Engine engine, Engine.Delete delete) throws I public Engine.GetResult get(Engine.Get get) { readAllowed(); DocumentMapper mapper = mapperService.documentMapper(); - if (mapper == null || mapper.type().equals(mapperService.resolveDocumentType(get.type())) == false) { + if (mapper == null) { return GetResult.NOT_EXISTS; } return getEngine().get(get, this::acquireSearcher); diff --git a/server/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java b/server/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java index ae0af3166b504..052f9251bdc10 100644 --- a/server/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java +++ b/server/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java @@ -92,8 +92,7 @@ static TermVectorsResponse getTermVectors(IndexShard indexShard, TermVectorsRequ handleFieldWildcards(indexShard, request); } - try (Engine.GetResult get = indexShard.get(new Engine.Get(request.realtime(), false, MapperService.SINGLE_MAPPING_NAME, - request.id(), uidTerm) + try (Engine.GetResult get = indexShard.get(new Engine.Get(request.realtime(), false, request.id(), uidTerm) .version(request.version()).versionType(request.versionType())); Engine.Searcher searcher = indexShard.acquireSearcher("term_vector")) { Fields topLevelFields = fields(get.searcher() != null ? get.searcher().getIndexReader() : searcher.getIndexReader()); @@ -213,8 +212,7 @@ private static Fields addGeneratedTermVectors(IndexShard indexShard, Engine.GetR /* generate term vectors from fetched document fields */ String[] getFields = validFields.toArray(new String[validFields.size() + 1]); getFields[getFields.length - 1] = SourceFieldMapper.NAME; - GetResult getResult = indexShard.getService().get( - get, request.id(), MapperService.SINGLE_MAPPING_NAME, getFields, null); + GetResult getResult = indexShard.getService().get(get, request.id(), getFields, null); Fields generatedTermVectors = generateTermVectors(indexShard, getResult.sourceAsMap(), getResult.getFields().values(), request.offsets(), request.perFieldAnalyzer(), validFields); 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 100d4cc653118..6452e9e9124b3 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 @@ -66,7 +66,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC GetRequest getRequest; if (request.hasParam("type")) { deprecationLogger.deprecatedAndMaybeLog("get_with_types", TYPES_DEPRECATION_MESSAGE); - getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); + getRequest = new GetRequest(request.param("index"), request.param("id")); } else { getRequest = new GetRequest(request.param("index"), request.param("id")); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java index a45c30d0ad1bb..14fb060396099 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java @@ -68,13 +68,7 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - final GetRequest getRequest; - if (request.hasParam("type")) { - deprecationLogger.deprecatedAndMaybeLog("get_source_with_types", TYPES_DEPRECATION_MESSAGE); - getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); - } else { - getRequest = new GetRequest(request.param("index"), request.param("id")); - } + final GetRequest getRequest = new GetRequest(request.param("index"), request.param("id")); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); getRequest.routing(request.param("routing")); getRequest.preference(request.param("preference")); @@ -121,13 +115,12 @@ public RestResponse buildResponse(final GetResponse response) throws Exception { */ private void checkResource(final GetResponse response) { final String index = response.getIndex(); - final String type = response.getType(); final String id = response.getId(); if (response.isExists() == false) { - throw new ResourceNotFoundException("Document not found [" + index + "]/[" + type + "]/[" + id + "]"); + throw new ResourceNotFoundException("Document not found [" + index + "]/[" + id + "]"); } else if (response.isSourceEmpty()) { - throw new ResourceNotFoundException("Source not found [" + index + "]/[" + type + "]/[" + id + "]"); + throw new ResourceNotFoundException("Source not found [" + index + "]/[" + id + "]"); } } } 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 a7ef8e60fb0c3..067e4029e3b76 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 @@ -85,17 +85,10 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC FetchSourceContext defaultFetchSource = FetchSourceContext.parseFromRestRequest(request); try (XContentParser parser = request.contentOrSourceParamParser()) { - multiGetRequest.add(request.param("index"), request.param("type"), sFields, defaultFetchSource, + multiGetRequest.add(request.param("index"), sFields, defaultFetchSource, 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/action/IndicesRequestIT.java b/server/src/test/java/org/elasticsearch/action/IndicesRequestIT.java index 24e2e68ed4fc6..9d23ca48e81f2 100644 --- a/server/src/test/java/org/elasticsearch/action/IndicesRequestIT.java +++ b/server/src/test/java/org/elasticsearch/action/IndicesRequestIT.java @@ -318,7 +318,7 @@ public void testGet() { String getShardAction = GetAction.NAME + "[s]"; interceptTransportActions(getShardAction); - GetRequest getRequest = new GetRequest(randomIndexOrAlias(), "type", "id"); + GetRequest getRequest = new GetRequest(randomIndexOrAlias(), "id"); internalCluster().coordOnlyNodeClient().get(getRequest).actionGet(); clearInterceptedActions(); @@ -374,7 +374,7 @@ public void testMultiGet() { int numDocs = iterations(1, 30); for (int i = 0; i < numDocs; i++) { String indexOrAlias = randomIndexOrAlias(); - multiGetRequest.add(indexOrAlias, "type", Integer.toString(i)); + multiGetRequest.add(indexOrAlias, Integer.toString(i)); indices.add(indexOrAlias); } internalCluster().coordOnlyNodeClient().multiGet(multiGetRequest).actionGet(); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java b/server/src/test/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java index 0fecff449f9b5..1a8d234ebc403 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java @@ -211,7 +211,7 @@ private void splitToN(int sourceShards, int firstSplitShards, int secondSplitSha assertHitCount(client().prepareSearch("first_split").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), numDocs); assertHitCount(client().prepareSearch("source").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), numDocs); for (int i = 0; i < numDocs; i++) { - GetResponse getResponse = client().prepareGet("first_split", "t1", Integer.toString(i)).setRouting(routingValue[i]).get(); + GetResponse getResponse = client().prepareGet("first_split", Integer.toString(i)).setRouting(routingValue[i]).get(); assertTrue(getResponse.isExists()); } @@ -245,7 +245,7 @@ private void splitToN(int sourceShards, int firstSplitShards, int secondSplitSha } flushAndRefresh(); for (int i = 0; i < numDocs; i++) { - GetResponse getResponse = client().prepareGet("second_split", "t1", Integer.toString(i)).setRouting(routingValue[i]).get(); + GetResponse getResponse = client().prepareGet("second_split", Integer.toString(i)).setRouting(routingValue[i]).get(); assertTrue(getResponse.isExists()); } assertHitCount(client().prepareSearch("second_split").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), numDocs); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java index de8a2d9d67bbe..5109f89d0dfee 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkIntegrationIT.java @@ -90,14 +90,14 @@ public void testBulkWithWriteIndexAndRouting() { assertThat(bulkResponse.getItems()[0].getResponse().getShardId().getId(), equalTo(0)); assertThat(bulkResponse.getItems()[0].getResponse().getVersion(), equalTo(1L)); assertThat(bulkResponse.getItems()[0].getResponse().status(), equalTo(RestStatus.CREATED)); - assertThat(client().prepareGet("index3", "type", "id").setRouting("1").get().getSource().get("foo"), equalTo("baz")); + assertThat(client().prepareGet("index3", "id").setRouting("1").get().getSource().get("foo"), equalTo("baz")); bulkResponse = client().prepareBulk().add(client().prepareUpdate("alias1", "type", "id").setDoc("foo", "updated")).get(); assertFalse(bulkResponse.buildFailureMessage(), bulkResponse.hasFailures()); - assertThat(client().prepareGet("index3", "type", "id").setRouting("1").get().getSource().get("foo"), equalTo("updated")); + assertThat(client().prepareGet("index3", "id").setRouting("1").get().getSource().get("foo"), equalTo("updated")); bulkResponse = client().prepareBulk().add(client().prepareDelete("alias1", "type", "id")).get(); assertFalse(bulkResponse.buildFailureMessage(), bulkResponse.hasFailures()); - assertFalse(client().prepareGet("index3", "type", "id").setRouting("1").get().isExists()); + assertFalse(client().prepareGet("index3", "id").setRouting("1").get().isExists()); } public void testBulkWithGlobalDefaults() throws Exception { diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java index f7869a4935a6f..79e1438956e52 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java @@ -290,7 +290,6 @@ private static void assertMultiGetResponse(MultiGetResponse multiGetResponse, in int i = 1; for (MultiGetItemResponse multiGetItemResponse : multiGetResponse) { assertThat(multiGetItemResponse.getIndex(), equalTo("test")); - assertThat(multiGetItemResponse.getType(), equalTo("test")); assertThat(multiGetItemResponse.getId(), equalTo(Integer.toString(i++))); } } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java index 8d52fbad097fd..96f132e4de031 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java @@ -149,18 +149,18 @@ public void testBulkUpdateSimple() throws Exception { assertThat(bulkResponse.getItems()[2].getResponse().getId(), equalTo("3")); assertThat(bulkResponse.getItems()[2].getResponse().getVersion(), equalTo(2L)); - GetResponse getResponse = client().prepareGet().setIndex("test").setType("type1").setId("1").execute() + GetResponse getResponse = client().prepareGet().setIndex("test").setId("1").execute() .actionGet(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getVersion(), equalTo(2L)); assertThat(((Number) getResponse.getSource().get("field")).longValue(), equalTo(2L)); - getResponse = client().prepareGet().setIndex("test").setType("type1").setId("2").execute().actionGet(); + getResponse = client().prepareGet().setIndex("test").setId("2").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getVersion(), equalTo(2L)); assertThat(((Number) getResponse.getSource().get("field")).longValue(), equalTo(3L)); - getResponse = client().prepareGet().setIndex("test").setType("type1").setId("3").execute().actionGet(); + getResponse = client().prepareGet().setIndex("test").setId("3").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getVersion(), equalTo(2L)); assertThat(getResponse.getSource().get("field1").toString(), equalTo("test")); @@ -185,15 +185,15 @@ public void testBulkUpdateSimple() throws Exception { assertThat(bulkResponse.getItems()[2].getResponse().getIndex(), equalTo("test")); assertThat(bulkResponse.getItems()[2].getResponse().getVersion(), equalTo(3L)); - getResponse = client().prepareGet().setIndex("test").setType("type1").setId("6").execute().actionGet(); + getResponse = client().prepareGet().setIndex("test").setId("6").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getVersion(), equalTo(1L)); assertThat(((Number) getResponse.getSource().get("field")).longValue(), equalTo(0L)); - getResponse = client().prepareGet().setIndex("test").setType("type1").setId("7").execute().actionGet(); + getResponse = client().prepareGet().setIndex("test").setId("7").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(false)); - getResponse = client().prepareGet().setIndex("test").setType("type1").setId("2").execute().actionGet(); + getResponse = client().prepareGet().setIndex("test").setId("2").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getVersion(), equalTo(3L)); assertThat(((Number) getResponse.getSource().get("field")).longValue(), equalTo(4L)); @@ -328,7 +328,7 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(((UpdateResponse) response.getItems()[i].getResponse()).getGetResult().sourceAsMap().get("counter"), equalTo(1)); for (int j = 0; j < 5; j++) { - GetResponse getResponse = client().prepareGet("test", "type1", Integer.toString(i)).execute() + GetResponse getResponse = client().prepareGet("test", Integer.toString(i)).execute() .actionGet(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getVersion(), equalTo(1L)); @@ -422,7 +422,7 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(itemResponse.getType(), equalTo("type1")); assertThat(itemResponse.getOpType(), equalTo(OpType.UPDATE)); for (int j = 0; j < 5; j++) { - GetResponse getResponse = client().prepareGet("test", "type1", Integer.toString(i)).get(); + GetResponse getResponse = client().prepareGet("test", Integer.toString(i)).get(); assertThat(getResponse.isExists(), equalTo(false)); } } diff --git a/server/src/test/java/org/elasticsearch/action/explain/ExplainResponseTests.java b/server/src/test/java/org/elasticsearch/action/explain/ExplainResponseTests.java index 1b3b9a8afa9f4..4f62c1375899c 100644 --- a/server/src/test/java/org/elasticsearch/action/explain/ExplainResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/explain/ExplainResponseTests.java @@ -65,7 +65,6 @@ protected ExplainResponse createTestInstance() { String fieldName = randomAlphaOfLength(10); List values = Arrays.asList(randomAlphaOfLengthBetween(3, 10), randomInt(), randomLong(), randomDouble(), randomBoolean()); GetResult getResult = new GetResult(randomAlphaOfLengthBetween(3, 10), - randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10), 0, 1, randomNonNegativeLong(), true, @@ -85,7 +84,7 @@ public void testToXContent() throws IOException { String id = "1"; boolean exist = true; Explanation explanation = Explanation.match(1.0f, "description", Collections.emptySet()); - GetResult getResult = new GetResult(null, null, null, 0, 1, -1, true, new BytesArray("{ \"field1\" : " + + GetResult getResult = new GetResult(null, null, 0, 1, -1, true, new BytesArray("{ \"field1\" : " + "\"value1\", \"field2\":\"value2\"}"), singletonMap("field1", new DocumentField("field1", singletonList("value1"))), null); ExplainResponse response = new ExplainResponse(index, type, id, exist, explanation, getResult); diff --git a/server/src/test/java/org/elasticsearch/action/get/GetRequestTests.java b/server/src/test/java/org/elasticsearch/action/get/GetRequestTests.java index 499932ccdf026..984be6ef3ab3b 100644 --- a/server/src/test/java/org/elasticsearch/action/get/GetRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/get/GetRequestTests.java @@ -29,19 +29,19 @@ public class GetRequestTests extends ESTestCase { public void testValidation() { { - final GetRequest request = new GetRequest("index4", "_doc", "0"); + final GetRequest request = new GetRequest("index4", "0"); final ActionRequestValidationException validate = request.validate(); assertThat(validate, nullValue()); } { - final GetRequest request = new GetRequest("index4", randomBoolean() ? "" : null, randomBoolean() ? "" : null); + final GetRequest request = new GetRequest("index4", randomBoolean() ? "" : null); final ActionRequestValidationException validate = request.validate(); assertThat(validate, not(nullValue())); - assertEquals(2, validate.validationErrors().size()); - assertThat(validate.validationErrors(), hasItems("type is missing", "id is missing")); + assertEquals(1, validate.validationErrors().size()); + assertThat(validate.validationErrors(), hasItems("id is missing")); } } } diff --git a/server/src/test/java/org/elasticsearch/action/get/GetResponseTests.java b/server/src/test/java/org/elasticsearch/action/get/GetResponseTests.java index 359a394b33806..a81ccfc20c3fb 100644 --- a/server/src/test/java/org/elasticsearch/action/get/GetResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/get/GetResponseTests.java @@ -92,27 +92,27 @@ private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws public void testToXContent() { { - GetResponse getResponse = new GetResponse(new GetResult("index", "type", "id", 0, 1, 1, true, new BytesArray("{ \"field1\" : " + + GetResponse getResponse = new GetResponse(new GetResult("index", "id", 0, 1, 1, true, new BytesArray("{ \"field1\" : " + "\"value1\", \"field2\":\"value2\"}"), Collections.singletonMap("field1", new DocumentField("field1", Collections.singletonList("value1"))), null)); String output = Strings.toString(getResponse); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "\"found\":true,\"_source\":{ \"field1\" : \"value1\", \"field2\":\"value2\"},\"fields\":{\"field1\":[\"value1\"]}}", output); } { - GetResponse getResponse = new GetResponse(new GetResult("index", "type", "id", UNASSIGNED_SEQ_NO, + GetResponse getResponse = new GetResponse(new GetResult("index", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null)); String output = Strings.toString(getResponse); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"found\":false}", output); + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"found\":false}", output); } } public void testToString() { - GetResponse getResponse = new GetResponse(new GetResult("index", "type", "id", 0, 1, 1, true, + GetResponse getResponse = new GetResponse(new GetResult("index", "id", 0, 1, 1, true, new BytesArray("{ \"field1\" : " + "\"value1\", \"field2\":\"value2\"}"), Collections.singletonMap("field1", new DocumentField("field1", Collections.singletonList("value1"))), null)); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "\"found\":true,\"_source\":{ \"field1\" : \"value1\", \"field2\":\"value2\"},\"fields\":{\"field1\":[\"value1\"]}}", getResponse.toString()); } @@ -124,7 +124,7 @@ public void testEqualsAndHashcode() { public void testFromXContentThrowsParsingException() throws IOException { GetResponse getResponse = - new GetResponse(new GetResult(null, null, null, UNASSIGNED_SEQ_NO, 0, randomIntBetween(1, 5), + new GetResponse(new GetResult(null, null, UNASSIGNED_SEQ_NO, 0, randomIntBetween(1, 5), randomBoolean(), null, null, null)); XContentType xContentType = randomFrom(XContentType.values()); @@ -132,7 +132,7 @@ public void testFromXContentThrowsParsingException() throws IOException { try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) { ParsingException exception = expectThrows(ParsingException.class, () -> GetResponse.fromXContent(parser)); - assertEquals("Missing required fields [_index,_type,_id]", exception.getMessage()); + assertEquals("Missing required fields [_index,_id]", exception.getMessage()); } } diff --git a/server/src/test/java/org/elasticsearch/action/get/MultiGetRequestTests.java b/server/src/test/java/org/elasticsearch/action/get/MultiGetRequestTests.java index fd2a1e5dca8e4..b5f0a0946c067 100644 --- a/server/src/test/java/org/elasticsearch/action/get/MultiGetRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/get/MultiGetRequestTests.java @@ -60,9 +60,8 @@ public void testAddWithInvalidKey() throws IOException { ParsingException.class, () -> { final String defaultIndex = randomAlphaOfLength(5); - final String defaultType = randomAlphaOfLength(3); final FetchSourceContext fetchSource = FetchSourceContext.FETCH_SOURCE; - mgr.add(defaultIndex, defaultType, null, fetchSource, null, parser, true); + mgr.add(defaultIndex, null, fetchSource, null, parser, true); }); assertThat( e.toString(), @@ -88,9 +87,8 @@ public void testUnexpectedField() throws IOException { ParsingException.class, () -> { final String defaultIndex = randomAlphaOfLength(5); - final String defaultType = randomAlphaOfLength(3); final FetchSourceContext fetchSource = FetchSourceContext.FETCH_SOURCE; - mgr.add(defaultIndex, defaultType, null, fetchSource, null, parser, true); + mgr.add(defaultIndex, null, fetchSource, null, parser, true); }); assertThat( e.toString(), @@ -114,7 +112,7 @@ public void testAddWithValidSourceValueIsAccepted() throws Exception { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add( - randomAlphaOfLength(5), randomAlphaOfLength(3), null, FetchSourceContext.FETCH_SOURCE, null, parser, true); + randomAlphaOfLength(5), null, FetchSourceContext.FETCH_SOURCE, null, parser, true); assertEquals(2, multiGetRequest.getItems().size()); } @@ -126,7 +124,7 @@ public void testXContentSerialization() throws IOException { BytesReference shuffled = toShuffledXContent(expected, xContentType, ToXContent.EMPTY_PARAMS, false); try (XContentParser parser = createParser(XContentFactory.xContent(xContentType), shuffled)) { MultiGetRequest actual = new MultiGetRequest(); - actual.add(null, null, null, null, null, parser, true); + actual.add(null, null, null, null, parser, true); assertThat(parser.nextToken(), nullValue()); assertThat(actual.items.size(), equalTo(expected.items.size())); @@ -143,7 +141,7 @@ private MultiGetRequest createTestInstance() { int numItems = randomIntBetween(0, 128); MultiGetRequest request = new MultiGetRequest(); for (int i = 0; i < numItems; i++) { - MultiGetRequest.Item item = new MultiGetRequest.Item(randomAlphaOfLength(4), randomAlphaOfLength(4), randomAlphaOfLength(4)); + MultiGetRequest.Item item = new MultiGetRequest.Item(randomAlphaOfLength(4), randomAlphaOfLength(4)); if (randomBoolean()) { item.version(randomNonNegativeLong()); } diff --git a/server/src/test/java/org/elasticsearch/action/get/MultiGetResponseTests.java b/server/src/test/java/org/elasticsearch/action/get/MultiGetResponseTests.java index 8182e49049052..1a52158fc8592 100644 --- a/server/src/test/java/org/elasticsearch/action/get/MultiGetResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/get/MultiGetResponseTests.java @@ -51,7 +51,6 @@ public void testFromXContent() throws IOException { MultiGetItemResponse expectedItem = expected.getResponses()[i]; MultiGetItemResponse actualItem = parsed.getResponses()[i]; assertThat(actualItem.getIndex(), equalTo(expectedItem.getIndex())); - assertThat(actualItem.getType(), equalTo(expectedItem.getType())); assertThat(actualItem.getId(), equalTo(expectedItem.getId())); if (expectedItem.isFailed()) { assertThat(actualItem.isFailed(), is(true)); @@ -70,12 +69,12 @@ private static MultiGetResponse createTestInstance() { for (int i = 0; i < items.length; i++) { if (randomBoolean()) { items[i] = new MultiGetItemResponse(new GetResponse(new GetResult( - randomAlphaOfLength(4), randomAlphaOfLength(4), randomAlphaOfLength(4), 0, 1, randomNonNegativeLong(), + randomAlphaOfLength(4), randomAlphaOfLength(4), 0, 1, randomNonNegativeLong(), true, null, null, null )), null); } else { items[i] = new MultiGetItemResponse(null, new MultiGetResponse.Failure(randomAlphaOfLength(4), - randomAlphaOfLength(4), randomAlphaOfLength(4), new RuntimeException(randomAlphaOfLength(4)))); + randomAlphaOfLength(4), new RuntimeException(randomAlphaOfLength(4)))); } } return new MultiGetResponse(items); diff --git a/server/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java b/server/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java index 4d43454e8dd25..67c0e9e620441 100644 --- a/server/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/get/MultiGetShardRequestTests.java @@ -45,8 +45,7 @@ public void testSerialization() throws IOException { MultiGetShardRequest multiGetShardRequest = new MultiGetShardRequest(multiGetRequest, "index", 0); int numItems = iterations(10, 30); for (int i = 0; i < numItems; i++) { - MultiGetRequest.Item item = new MultiGetRequest.Item("alias-" + randomAlphaOfLength(randomIntBetween(1, 10)), - "type", "id-" + i); + MultiGetRequest.Item item = new MultiGetRequest.Item("alias-" + randomAlphaOfLength(randomIntBetween(1, 10)), "id-" + i); if (randomBoolean()) { int numFields = randomIntBetween(1, 5); String[] fields = new String[numFields]; @@ -81,7 +80,6 @@ public void testSerialization() throws IOException { MultiGetRequest.Item item = multiGetShardRequest.items.get(i); MultiGetRequest.Item item2 = multiGetShardRequest2.items.get(i); assertThat(item2.index(), equalTo(item.index())); - assertThat(item2.type(), equalTo(item.type())); assertThat(item2.id(), equalTo(item.id())); assertThat(item2.storedFields(), equalTo(item.storedFields())); assertThat(item2.version(), equalTo(item.version())); diff --git a/server/src/test/java/org/elasticsearch/action/get/TransportMultiGetActionTests.java b/server/src/test/java/org/elasticsearch/action/get/TransportMultiGetActionTests.java index 324880fa1bf39..576766df044bb 100644 --- a/server/src/test/java/org/elasticsearch/action/get/TransportMultiGetActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/get/TransportMultiGetActionTests.java @@ -167,8 +167,8 @@ public void testTransportMultiGetAction() { final Task task = createTask(); final NodeClient client = new NodeClient(Settings.EMPTY, threadPool); final MultiGetRequestBuilder request = new MultiGetRequestBuilder(client, MultiGetAction.INSTANCE); - request.add(new MultiGetRequest.Item("index1", "_doc", "1")); - request.add(new MultiGetRequest.Item("index1", "_doc", "2")); + request.add(new MultiGetRequest.Item("index1", "1")); + request.add(new MultiGetRequest.Item("index1", "2")); final AtomicBoolean shardActionInvoked = new AtomicBoolean(false); transportAction = new TransportMultiGetAction(transportService, clusterService, client, @@ -192,8 +192,8 @@ public void testTransportMultiGetAction_withMissingRouting() { final Task task = createTask(); final NodeClient client = new NodeClient(Settings.EMPTY, threadPool); final MultiGetRequestBuilder request = new MultiGetRequestBuilder(client, MultiGetAction.INSTANCE); - request.add(new MultiGetRequest.Item("index2", "_doc", "1").routing("1")); - request.add(new MultiGetRequest.Item("index2", "_doc", "2")); + request.add(new MultiGetRequest.Item("index2", "1").routing("1")); + request.add(new MultiGetRequest.Item("index2", "2")); final AtomicBoolean shardActionInvoked = new AtomicBoolean(false); transportAction = new TransportMultiGetAction(transportService, clusterService, client, diff --git a/server/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java b/server/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java index 934f2563574d0..b4c132d922e7f 100644 --- a/server/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java @@ -802,7 +802,7 @@ public void testTermVectorsWithVersion() { assertThat(response.getVersion(), equalTo(1L)); try { - client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).get(); + client().prepareGet(indexOrAlias(), "1").setVersion(2).get(); fail(); } catch (VersionConflictEngineException e) { //all good @@ -825,7 +825,7 @@ public void testTermVectorsWithVersion() { assertThat(response.getVersion(), equalTo(1L)); try { - client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).setRealtime(false).get(); + client().prepareGet(indexOrAlias(), "1").setVersion(2).setRealtime(false).get(); fail(); } catch (VersionConflictEngineException e) { //all good @@ -844,7 +844,7 @@ public void testTermVectorsWithVersion() { assertThat(response.getVersion(), equalTo(2L)); try { - client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get(); + client().prepareGet(indexOrAlias(), "1").setVersion(1).get(); fail(); } catch (VersionConflictEngineException e) { //all good @@ -867,7 +867,7 @@ public void testTermVectorsWithVersion() { assertThat(response.getVersion(), equalTo(2L)); try { - client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get(); + client().prepareGet(indexOrAlias(), "1").setVersion(1).setRealtime(false).get(); fail(); } catch (VersionConflictEngineException e) { //all good diff --git a/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java b/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java index 8d1e785c4f43b..37a1979fbd7b3 100644 --- a/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/update/UpdateRequestTests.java @@ -359,7 +359,7 @@ public void testNowInScript() throws IOException { .scriptedUpsert(true); long nowInMillis = randomNonNegativeLong(); // We simulate that the document is not existing yet - GetResult getResult = new GetResult("test", "type1", "2", UNASSIGNED_SEQ_NO, 0, 0, false, null, null, null); + GetResult getResult = new GetResult("test", "2", UNASSIGNED_SEQ_NO, 0, 0, false, null, null, null); UpdateHelper.Result result = updateHelper.prepare(new ShardId("test", "_na_", 0), updateRequest, getResult, () -> nowInMillis); Writeable action = result.action(); assertThat(action, instanceOf(IndexRequest.class)); @@ -372,7 +372,7 @@ public void testNowInScript() throws IOException { .script(mockInlineScript("ctx._timestamp = ctx._now")) .scriptedUpsert(true); // We simulate that the document is not existing yet - GetResult getResult = new GetResult("test", "type1", "2", 0, 1, 0, true, new BytesArray("{}"), null, null); + GetResult getResult = new GetResult("test", "2", 0, 1, 0, true, new BytesArray("{}"), null, null); UpdateHelper.Result result = updateHelper.prepare(new ShardId("test", "_na_", 0), updateRequest, getResult, () -> 42L); Writeable action = result.action(); assertThat(action, instanceOf(IndexRequest.class)); @@ -381,7 +381,7 @@ public void testNowInScript() throws IOException { public void testIndexTimeout() { final GetResult getResult = - new GetResult("test", "type", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); + new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); final UpdateRequest updateRequest = new UpdateRequest("test", "type", "1") .script(mockInlineScript("return")) @@ -391,7 +391,7 @@ public void testIndexTimeout() { public void testDeleteTimeout() { final GetResult getResult = - new GetResult("test", "type", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); + new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); final UpdateRequest updateRequest = new UpdateRequest("test", "type", "1") .script(mockInlineScript("ctx.op = delete")) @@ -402,7 +402,7 @@ public void testDeleteTimeout() { public void testUpsertTimeout() throws IOException { final boolean exists = randomBoolean(); final BytesReference source = exists ? new BytesArray("{\"f\":\"v\"}") : null; - final GetResult getResult = new GetResult("test", "type", "1", UNASSIGNED_SEQ_NO, 0, 0, exists, source, null, null); + final GetResult getResult = new GetResult("test", "1", UNASSIGNED_SEQ_NO, 0, 0, exists, source, null, null); final XContentBuilder sourceBuilder = jsonBuilder(); sourceBuilder.startObject(); { @@ -546,7 +546,7 @@ public void testValidate() { } public void testRoutingExtraction() throws Exception { - GetResult getResult = new GetResult("test", "type", "1", UNASSIGNED_SEQ_NO, 0, 0, false, null, null, null); + GetResult getResult = new GetResult("test", "1", UNASSIGNED_SEQ_NO, 0, 0, false, null, null, null); IndexRequest indexRequest = new IndexRequest("test", "type", "1"); // There is no routing and parent because the document doesn't exist @@ -556,7 +556,7 @@ public void testRoutingExtraction() throws Exception { assertNull(UpdateHelper.calculateRouting(getResult, indexRequest)); // Doc exists but has no source or fields - getResult = new GetResult("test", "type", "1", 0, 1, 0, true, null, null, null); + getResult = new GetResult("test", "1", 0, 1, 0, true, null, null, null); // There is no routing and parent on either request assertNull(UpdateHelper.calculateRouting(getResult, indexRequest)); @@ -565,7 +565,7 @@ public void testRoutingExtraction() throws Exception { fields.put("_routing", new DocumentField("_routing", Collections.singletonList("routing1"))); // Doc exists and has the parent and routing fields - getResult = new GetResult("test", "type", "1", 0, 1, 0, true, null, fields, null); + getResult = new GetResult("test", "1", 0, 1, 0, true, null, fields, null); // Use the get result parent and routing assertThat(UpdateHelper.calculateRouting(getResult, indexRequest), equalTo("routing1")); @@ -573,7 +573,7 @@ public void testRoutingExtraction() throws Exception { public void testNoopDetection() throws Exception { ShardId shardId = new ShardId("test", "", 0); - GetResult getResult = new GetResult("test", "type", "1", 0, 1, 0, true, + GetResult getResult = new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"body\": \"foo\"}"), null, null); @@ -604,7 +604,7 @@ public void testNoopDetection() throws Exception { public void testUpdateScript() throws Exception { ShardId shardId = new ShardId("test", "", 0); - GetResult getResult = new GetResult("test", "type", "1", 0, 1, 0, true, + GetResult getResult = new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"body\": \"bar\"}"), null, null); diff --git a/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java b/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java index f904024e83f05..7c33abe3ee6dc 100644 --- a/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/update/UpdateResponseTests.java @@ -75,7 +75,7 @@ public void testToXContent() throws IOException { UpdateResponse updateResponse = new UpdateResponse(new ReplicationResponse.ShardInfo(3, 2), new ShardId("books", "books_uuid", 2), "book", "1", 7, 17, 2, UPDATED); - updateResponse.setGetResult(new GetResult("books", "book", "1",0, 1, 2, true, source, fields, null)); + updateResponse.setGetResult(new GetResult("books", "1",0, 1, 2, true, source, fields, null)); String output = Strings.toString(updateResponse); assertEquals("{\"_index\":\"books\",\"_type\":\"book\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\"," + @@ -154,7 +154,6 @@ public static Tuple randomUpdateResponse(XConten GetResult expectedGetResult = getResults.v2(); String index = actualGetResult.getIndex(); - String type = actualGetResult.getType(); String id = actualGetResult.getId(); long version = actualGetResult.getVersion(); DocWriteResponse.Result result = actualGetResult.isExists() ? DocWriteResponse.Result.UPDATED : DocWriteResponse.Result.NOT_FOUND; @@ -173,11 +172,11 @@ public static Tuple randomUpdateResponse(XConten if (seqNo != SequenceNumbers.UNASSIGNED_SEQ_NO) { Tuple shardInfos = RandomObjects.randomShardInfo(random()); - actual = new UpdateResponse(shardInfos.v1(), actualShardId, type, id, seqNo, primaryTerm, version, result); - expected = new UpdateResponse(shardInfos.v2(), expectedShardId, type, id, seqNo, primaryTerm, version, result); + actual = new UpdateResponse(shardInfos.v1(), actualShardId, "_doc", id, seqNo, primaryTerm, version, result); + expected = new UpdateResponse(shardInfos.v2(), expectedShardId, "_doc", id, seqNo, primaryTerm, version, result); } else { - actual = new UpdateResponse(actualShardId, type, id, seqNo, primaryTerm, version, result); - expected = new UpdateResponse(expectedShardId, type, id, seqNo, primaryTerm, version, result); + actual = new UpdateResponse(actualShardId, "_doc", id, seqNo, primaryTerm, version, result); + expected = new UpdateResponse(expectedShardId, "_doc", id, seqNo, primaryTerm, version, result); } if (actualGetResult.isExists()) { diff --git a/server/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java b/server/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java index ce65ed063bc08..f6533dce36014 100644 --- a/server/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java +++ b/server/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java @@ -103,7 +103,7 @@ public void testActions() { // validation in the settings??? - ugly and conceptually wrong) // choosing arbitrary top level actions to test - client.prepareGet("idx", "type", "id").execute(new AssertingActionListener<>(GetAction.NAME, client.threadPool())); + client.prepareGet("idx", "id").execute(new AssertingActionListener<>(GetAction.NAME, client.threadPool())); client.prepareSearch().execute(new AssertingActionListener<>(SearchAction.NAME, client.threadPool())); client.prepareDelete("idx", "type", "id").execute(new AssertingActionListener<>(DeleteAction.NAME, client.threadPool())); client.admin().cluster().prepareDeleteStoredScript("id") @@ -131,7 +131,7 @@ public void testOverrideHeader() throws Exception { expected.put("key1", key1Val); expected.put("key2", "val 2"); client.threadPool().getThreadContext().putHeader("key1", key1Val); - client.prepareGet("idx", "type", "id") + client.prepareGet("idx", "id") .execute(new AssertingActionListener<>(GetAction.NAME, expected, client.threadPool())); client.admin().cluster().prepareClusterStats() diff --git a/server/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java b/server/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java index 1555e9fd4cfd2..8cac97fd06284 100644 --- a/server/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java @@ -96,11 +96,11 @@ public void testNoMasterActions() throws Exception { assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID)); }); - assertThrows(clientToMasterlessNode.prepareGet("test", "type1", "1"), + assertThrows(clientToMasterlessNode.prepareGet("test", "1"), ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); - assertThrows(clientToMasterlessNode.prepareGet("no_index", "type1", "1"), + assertThrows(clientToMasterlessNode.prepareGet("no_index", "1"), ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); @@ -225,7 +225,7 @@ public void testNoMasterActionsWriteMasterBlock() throws Exception { } )); - GetResponse getResponse = clientToMasterlessNode.prepareGet("test1", "type1", "1").get(); + GetResponse getResponse = clientToMasterlessNode.prepareGet("test1", "1").get(); assertExists(getResponse); SearchResponse countResponse = clientToMasterlessNode.prepareSearch("test1").setAllowPartialSearchResults(true).setSize(0).get(); diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java b/server/src/test/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java index 9658900f4ebe9..a709748d8ea7c 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java @@ -341,7 +341,7 @@ public void testDelayedMappingPropagationOnReplica() throws Exception { final ActionFuture docIndexResponse = client().prepareIndex("index", "type", "1").setSource("field", 42).execute(); - assertBusy(() -> assertTrue(client().prepareGet("index", "type", "1").get().isExists())); + assertBusy(() -> assertTrue(client().prepareGet("index", "1").get().isExists())); // index another document, this time using dynamic mappings. // The ack timeout of 0 on dynamic mapping updates makes it possible for the document to be indexed on the primary, even @@ -362,7 +362,7 @@ public void testDelayedMappingPropagationOnReplica() throws Exception { assertNotNull(mapper.mappers().getMapper("field2")); }); - assertBusy(() -> assertTrue(client().prepareGet("index", "type", "2").get().isExists())); + assertBusy(() -> assertTrue(client().prepareGet("index", "2").get().isExists())); // The mappings have not been propagated to the replica yet as a consequence the document count not be indexed // We wait on purpose to make sure that the document is not indexed because the shard operation is stalled diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java b/server/src/test/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java index 6f6dde9f4f3f7..7a7738798cea7 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java @@ -379,7 +379,7 @@ public void testAllMasterEligibleNodesFailedDanglingIndexImport() throws Excepti logger.info("--> verify 1 doc in the index"); assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L); - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(true)); logger.info("--> stop data-only node and detach it from the old cluster"); Settings dataNodeDataPathSettings = internalCluster().dataPathSettings(dataNode); @@ -407,7 +407,7 @@ public boolean clearData(String nodeName) { ensureGreen("test"); logger.info("--> verify the doc is there"); - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(true)); } public void testNoInitialBootstrapAfterDetach() throws Exception { diff --git a/server/src/test/java/org/elasticsearch/discovery/ClusterDisruptionIT.java b/server/src/test/java/org/elasticsearch/discovery/ClusterDisruptionIT.java index 749e0d96929c2..25b5cd2ed38fc 100644 --- a/server/src/test/java/org/elasticsearch/discovery/ClusterDisruptionIT.java +++ b/server/src/test/java/org/elasticsearch/discovery/ClusterDisruptionIT.java @@ -239,7 +239,7 @@ public void testAckedIndexing() throws Exception { logger.debug("validating through node [{}] ([{}] acked docs)", node, ackedDocs.size()); for (String id : ackedDocs.keySet()) { assertTrue("doc [" + id + "] indexed via node [" + ackedDocs.get(id) + "] not found", - client(node).prepareGet("test", "type", id).setPreference("_local").get().isExists()); + client(node).prepareGet("test", id).setPreference("_local").get().isExists()); } } catch (AssertionError | NoShardAvailableActionException e) { throw new AssertionError(e.getMessage() + " (checked via node [" + node + "]", e); @@ -298,7 +298,7 @@ public void testRejoinDocumentExistsInAllShardCopies() throws Exception { assertThat(indexResponse.getVersion(), equalTo(1L)); logger.info("Verifying if document exists via node[{}]", notIsolatedNode); - GetResponse getResponse = internalCluster().client(notIsolatedNode).prepareGet("test", "type", indexResponse.getId()) + GetResponse getResponse = internalCluster().client(notIsolatedNode).prepareGet("test", indexResponse.getId()) .setPreference("_local") .get(); assertThat(getResponse.isExists(), is(true)); @@ -312,7 +312,7 @@ public void testRejoinDocumentExistsInAllShardCopies() throws Exception { for (String node : nodes) { logger.info("Verifying if document exists after isolating node[{}] via node[{}]", isolatedNode, node); - getResponse = internalCluster().client(node).prepareGet("test", "type", indexResponse.getId()) + getResponse = internalCluster().client(node).prepareGet("test", indexResponse.getId()) .setPreference("_local") .get(); assertThat(getResponse.isExists(), is(true)); diff --git a/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java b/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java index c2cff5a326c3c..6b431ea42090a 100644 --- a/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java +++ b/server/src/test/java/org/elasticsearch/document/DocumentActionsIT.java @@ -96,18 +96,18 @@ public void testIndexActions() throws Exception { logger.info("Get [type1/1]"); for (int i = 0; i < 5; i++) { - getResult = client().prepareGet("test", "type1", "1").execute().actionGet(); + getResult = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResult.getIndex(), equalTo(getConcreteIndexName())); assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test")))); assertThat("cycle(map) #" + i, (String) getResult.getSourceAsMap().get("name"), equalTo("test")); - getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test")))); assertThat(getResult.getIndex(), equalTo(getConcreteIndexName())); } logger.info("Get [type1/1] with script"); for (int i = 0; i < 5; i++) { - getResult = client().prepareGet("test", "type1", "1").setStoredFields("name").execute().actionGet(); + getResult = client().prepareGet("test", "1").setStoredFields("name").execute().actionGet(); assertThat(getResult.getIndex(), equalTo(getConcreteIndexName())); assertThat(getResult.isExists(), equalTo(true)); assertThat(getResult.getSourceAsBytes(), nullValue()); @@ -116,7 +116,7 @@ public void testIndexActions() throws Exception { logger.info("Get [type1/2] (should be empty)"); for (int i = 0; i < 5; i++) { - getResult = client().get(getRequest("test").type("type1").id("2")).actionGet(); + getResult = client().get(getRequest("test").id("2")).actionGet(); assertThat(getResult.isExists(), equalTo(false)); } @@ -130,7 +130,7 @@ public void testIndexActions() throws Exception { logger.info("Get [type1/1] (should be empty)"); for (int i = 0; i < 5; i++) { - getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat(getResult.isExists(), equalTo(false)); } @@ -148,10 +148,10 @@ public void testIndexActions() throws Exception { logger.info("Get [type1/1] and [type1/2]"); for (int i = 0; i < 5; i++) { - getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat(getResult.getIndex(), equalTo(getConcreteIndexName())); assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test")))); - getResult = client().get(getRequest("test").type("type1").id("2")).actionGet(); + getResult = client().get(getRequest("test").id("2")).actionGet(); String ste1 = getResult.getSourceAsString(); String ste2 = Strings.toString(source("2", "test2")); assertThat("cycle #" + i, ste1, equalTo(ste2)); @@ -232,15 +232,15 @@ public void testBulk() throws Exception { for (int i = 0; i < 5; i++) { - GetResponse getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + GetResponse getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat(getResult.getIndex(), equalTo(getConcreteIndexName())); assertThat("cycle #" + i, getResult.isExists(), equalTo(false)); - getResult = client().get(getRequest("test").type("type1").id("2")).actionGet(); + getResult = client().get(getRequest("test").id("2")).actionGet(); assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("2", "test")))); assertThat(getResult.getIndex(), equalTo(getConcreteIndexName())); - getResult = client().get(getRequest("test").type("type1").id(generatedId3)).actionGet(); + getResult = client().get(getRequest("test").id(generatedId3)).actionGet(); assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("3", "test")))); assertThat(getResult.getIndex(), equalTo(getConcreteIndexName())); } diff --git a/server/src/test/java/org/elasticsearch/env/NodeRepurposeCommandIT.java b/server/src/test/java/org/elasticsearch/env/NodeRepurposeCommandIT.java index a6229b16c3055..b56d6c154fc1e 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeRepurposeCommandIT.java +++ b/server/src/test/java/org/elasticsearch/env/NodeRepurposeCommandIT.java @@ -52,7 +52,7 @@ public void testRepurpose() throws Exception { ensureGreen(); - assertTrue(client().prepareGet(indexName, "type1", "1").get().isExists()); + assertTrue(client().prepareGet(indexName, "1").get().isExists()); final Settings masterNodeDataPathSettings = internalCluster().dataPathSettings(masterNode); final Settings dataNodeDataPathSettings = internalCluster().dataPathSettings(dataNode); @@ -94,7 +94,7 @@ public void testRepurpose() throws Exception { internalCluster().startCoordinatingOnlyNode(dataNodeDataPathSettings); assertTrue(indexExists(indexName)); - expectThrows(NoShardAvailableActionException.class, () -> client().prepareGet(indexName, "type1", "1").get()); + expectThrows(NoShardAvailableActionException.class, () -> client().prepareGet(indexName, "1").get()); logger.info("--> Restarting and repurposing other node"); diff --git a/server/src/test/java/org/elasticsearch/explain/ExplainActionIT.java b/server/src/test/java/org/elasticsearch/explain/ExplainActionIT.java index 6616f93ded24b..1f57c7a89bb68 100644 --- a/server/src/test/java/org/elasticsearch/explain/ExplainActionIT.java +++ b/server/src/test/java/org/elasticsearch/explain/ExplainActionIT.java @@ -240,7 +240,6 @@ public void testExplainWithFilteredAliasFetchSource() throws Exception { assertThat(response.getId(), equalTo("1")); assertThat(response.getGetResult(), notNullValue()); assertThat(response.getGetResult().getIndex(), equalTo("test")); - assertThat(response.getGetResult().getType(), equalTo("test")); assertThat(response.getGetResult().getId(), equalTo("1")); assertThat(response.getGetResult().getSource(), notNullValue()); assertThat((String)response.getGetResult().getSource().get("field1"), equalTo("value1")); diff --git a/server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java b/server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java index c850b9d61da5b..0cbf25c7cee6e 100644 --- a/server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java +++ b/server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java @@ -165,7 +165,7 @@ public void testSimpleOpenClose() throws Exception { equalTo(test.totalNumShards)); logger.info("--> trying to get the indexed document on the first index"); - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); logger.info("--> closing test index..."); @@ -204,7 +204,7 @@ public void testSimpleOpenClose() throws Exception { equalTo(test.totalNumShards)); logger.info("--> trying to get the indexed document on the first round (before close and shutdown)"); - getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); logger.info("--> indexing a simple document"); diff --git a/server/src/test/java/org/elasticsearch/get/GetActionIT.java b/server/src/test/java/org/elasticsearch/get/GetActionIT.java index 8be9a991d17e9..e63f37e94a34a 100644 --- a/server/src/test/java/org/elasticsearch/get/GetActionIT.java +++ b/server/src/test/java/org/elasticsearch/get/GetActionIT.java @@ -75,25 +75,25 @@ public void testSimpleGet() { .addAlias(new Alias("alias").writeIndex(randomFrom(true, false, null)))); ensureGreen(); - GetResponse response = client().prepareGet(indexOrAlias(), "type1", "1").get(); + GetResponse response = client().prepareGet(indexOrAlias(), "1").get(); assertThat(response.isExists(), equalTo(false)); logger.info("--> index doc 1"); client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2").get(); logger.info("--> non realtime get 1"); - response = client().prepareGet(indexOrAlias(), "type1", "1").setRealtime(false).get(); + response = client().prepareGet(indexOrAlias(), "1").setRealtime(false).get(); assertThat(response.isExists(), equalTo(false)); logger.info("--> realtime get 1"); - response = client().prepareGet(indexOrAlias(), "type1", "1").get(); + response = client().prepareGet(indexOrAlias(), "1").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1")); assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2")); logger.info("--> realtime get 1 (no source, implicit)"); - response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields(Strings.EMPTY_ARRAY).get(); + response = client().prepareGet(indexOrAlias(), "1").setStoredFields(Strings.EMPTY_ARRAY).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); Set fields = new HashSet<>(response.getFields().keySet()); @@ -101,7 +101,7 @@ public void testSimpleGet() { assertThat(response.getSourceAsBytes(), nullValue()); logger.info("--> realtime get 1 (no source, explicit)"); - response = client().prepareGet(indexOrAlias(), "type1", "1").setFetchSource(false).get(); + response = client().prepareGet(indexOrAlias(), "1").setFetchSource(false).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); fields = new HashSet<>(response.getFields().keySet()); @@ -109,14 +109,14 @@ public void testSimpleGet() { assertThat(response.getSourceAsBytes(), nullValue()); logger.info("--> realtime get 1 (no type)"); - response = client().prepareGet(indexOrAlias(), null, "1").get(); + response = client().prepareGet(indexOrAlias(), "1").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1")); assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2")); logger.info("--> realtime fetch of field"); - response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields("field1").get(); + response = client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsBytes(), nullValue()); @@ -124,7 +124,7 @@ public void testSimpleGet() { assertThat(response.getField("field2"), nullValue()); logger.info("--> realtime fetch of field & source"); - response = client().prepareGet(indexOrAlias(), "type1", "1") + response = client().prepareGet(indexOrAlias(), "1") .setStoredFields("field1").setFetchSource("field1", null).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); @@ -135,7 +135,7 @@ public void testSimpleGet() { logger.info("--> realtime get 1"); - response = client().prepareGet(indexOrAlias(), "type1", "1").get(); + response = client().prepareGet(indexOrAlias(), "1").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1")); @@ -145,14 +145,14 @@ public void testSimpleGet() { refresh(); logger.info("--> non realtime get 1 (loaded from index)"); - response = client().prepareGet(indexOrAlias(), "type1", "1").setRealtime(false).get(); + response = client().prepareGet(indexOrAlias(), "1").setRealtime(false).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1")); assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2")); logger.info("--> realtime fetch of field (loaded from index)"); - response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields("field1").get(); + response = client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsBytes(), nullValue()); @@ -160,7 +160,7 @@ public void testSimpleGet() { assertThat(response.getField("field2"), nullValue()); logger.info("--> realtime fetch of field & source (loaded from index)"); - response = client().prepareGet(indexOrAlias(), "type1", "1") + response = client().prepareGet(indexOrAlias(), "1") .setStoredFields("field1").setFetchSource(true).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); @@ -172,7 +172,7 @@ public void testSimpleGet() { client().prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").get(); logger.info("--> realtime get 1"); - response = client().prepareGet(indexOrAlias(), "type1", "1").get(); + response = client().prepareGet(indexOrAlias(), "1").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1_1")); @@ -181,7 +181,7 @@ public void testSimpleGet() { logger.info("--> update doc 1 again"); client().prepareIndex("test", "type1", "1").setSource("field1", "value1_2", "field2", "value2_2").get(); - response = client().prepareGet(indexOrAlias(), "type1", "1").get(); + response = client().prepareGet(indexOrAlias(), "1").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsMap().get("field1").toString(), equalTo("value1_2")); @@ -190,7 +190,7 @@ public void testSimpleGet() { DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "1").get(); assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); - response = client().prepareGet(indexOrAlias(), "type1", "1").get(); + response = client().prepareGet(indexOrAlias(), "1").get(); assertThat(response.isExists(), equalTo(false)); } @@ -209,7 +209,7 @@ public void testGetWithAliasPointingToMultipleIndices() { assertThat(indexResponse.status().getStatus(), equalTo(RestStatus.CREATED.getStatus())); IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> - client().prepareGet("alias1", "type", "_alias_id").get()); + client().prepareGet("alias1", "_alias_id").get()); assertThat(exception.getMessage(), endsWith("can't execute a single index op")); } @@ -261,8 +261,8 @@ public void testSimpleMultiGet() throws Exception { // multi get with specific field response = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").storedFields("field")) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "3").storedFields("field")) + .add(new MultiGetRequest.Item(indexOrAlias(), "1").storedFields("field")) + .add(new MultiGetRequest.Item(indexOrAlias(), "3").storedFields("field")) .get(); assertThat(response.getResponses().length, equalTo(2)); @@ -280,17 +280,16 @@ public void testGetDocWithMultivaluedFields() throws Exception { .addMapping("type1", mapping1, XContentType.JSON)); ensureGreen(); - GetResponse response = client().prepareGet("test", "type1", "1").get(); + GetResponse response = client().prepareGet("test", "1").get(); assertThat(response.isExists(), equalTo(false)); assertThat(response.isExists(), equalTo(false)); client().prepareIndex("test", "type1", "1") .setSource(jsonBuilder().startObject().array("field", "1", "2").endObject()).get(); - response = client().prepareGet("test", "type1", "1").setStoredFields("field").get(); + response = client().prepareGet("test", "1").setStoredFields("field").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); - assertThat(response.getType(), equalTo("type1")); Set fields = new HashSet<>(response.getFields().keySet()); assertThat(fields, equalTo(singleton("field"))); assertThat(response.getFields().get("field").getValues().size(), equalTo(2)); @@ -299,7 +298,7 @@ public void testGetDocWithMultivaluedFields() throws Exception { // Now test values being fetched from stored fields. refresh(); - response = client().prepareGet("test", "type1", "1").setStoredFields("field").get(); + response = client().prepareGet("test", "1").setStoredFields("field").get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); fields = new HashSet<>(response.getFields().keySet()); @@ -314,7 +313,7 @@ public void testGetWithVersion() { .setSettings(Settings.builder().put("index.refresh_interval", -1))); ensureGreen(); - GetResponse response = client().prepareGet("test", "type1", "1").get(); + GetResponse response = client().prepareGet("test", "1").get(); assertThat(response.isExists(), equalTo(false)); logger.info("--> index doc 1"); @@ -322,18 +321,18 @@ public void testGetWithVersion() { // From translog: - response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).get(); + response = client().prepareGet(indexOrAlias(), "1").setVersion(Versions.MATCH_ANY).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getVersion(), equalTo(1L)); - response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get(); + response = client().prepareGet(indexOrAlias(), "1").setVersion(1).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getVersion(), equalTo(1L)); try { - client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).get(); + client().prepareGet(indexOrAlias(), "1").setVersion(2).get(); fail(); } catch (VersionConflictEngineException e) { //all good @@ -342,20 +341,20 @@ public void testGetWithVersion() { // From Lucene index: refresh(); - response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).setRealtime(false).get(); + response = client().prepareGet(indexOrAlias(), "1").setVersion(Versions.MATCH_ANY).setRealtime(false).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getVersion(), equalTo(1L)); - response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get(); + response = client().prepareGet(indexOrAlias(), "1").setVersion(1).setRealtime(false).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getVersion(), equalTo(1L)); try { - client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).setRealtime(false).get(); + client().prepareGet(indexOrAlias(), "1").setVersion(2).setRealtime(false).get(); fail(); } catch (VersionConflictEngineException e) { //all good @@ -366,20 +365,20 @@ public void testGetWithVersion() { // From translog: - response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).get(); + response = client().prepareGet(indexOrAlias(), "1").setVersion(Versions.MATCH_ANY).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getVersion(), equalTo(2L)); try { - client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get(); + client().prepareGet(indexOrAlias(), "1").setVersion(1).get(); fail(); } catch (VersionConflictEngineException e) { //all good } - response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).get(); + response = client().prepareGet(indexOrAlias(), "1").setVersion(2).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); @@ -388,20 +387,20 @@ public void testGetWithVersion() { // From Lucene index: refresh(); - response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).setRealtime(false).get(); + response = client().prepareGet(indexOrAlias(), "1").setVersion(Versions.MATCH_ANY).setRealtime(false).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getVersion(), equalTo(2L)); try { - client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get(); + client().prepareGet(indexOrAlias(), "1").setVersion(1).setRealtime(false).get(); fail(); } catch (VersionConflictEngineException e) { //all good } - response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).setRealtime(false).get(); + response = client().prepareGet(indexOrAlias(), "1").setVersion(2).setRealtime(false).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); @@ -423,9 +422,9 @@ public void testMultiGetWithVersion() throws Exception { // Version from translog response = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(Versions.MATCH_ANY)) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(1)) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(2)) + .add(new MultiGetRequest.Item(indexOrAlias(), "1").version(Versions.MATCH_ANY)) + .add(new MultiGetRequest.Item(indexOrAlias(), "1").version(1)) + .add(new MultiGetRequest.Item(indexOrAlias(), "1").version(2)) .get(); assertThat(response.getResponses().length, equalTo(3)); // [0] version doesn't matter, which is the default @@ -447,9 +446,9 @@ public void testMultiGetWithVersion() throws Exception { //Version from Lucene index refresh(); response = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(Versions.MATCH_ANY)) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(1)) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").version(2)) + .add(new MultiGetRequest.Item(indexOrAlias(), "1").version(Versions.MATCH_ANY)) + .add(new MultiGetRequest.Item(indexOrAlias(), "1").version(1)) + .add(new MultiGetRequest.Item(indexOrAlias(), "1").version(2)) .setRealtime(false) .get(); assertThat(response.getResponses().length, equalTo(3)); @@ -475,9 +474,9 @@ public void testMultiGetWithVersion() throws Exception { // Version from translog response = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(Versions.MATCH_ANY)) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(1)) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(2)) + .add(new MultiGetRequest.Item(indexOrAlias(), "2").version(Versions.MATCH_ANY)) + .add(new MultiGetRequest.Item(indexOrAlias(), "2").version(1)) + .add(new MultiGetRequest.Item(indexOrAlias(), "2").version(2)) .get(); assertThat(response.getResponses().length, equalTo(3)); // [0] version doesn't matter, which is the default @@ -500,9 +499,9 @@ public void testMultiGetWithVersion() throws Exception { //Version from Lucene index refresh(); response = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(Versions.MATCH_ANY)) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(1)) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").version(2)) + .add(new MultiGetRequest.Item(indexOrAlias(), "2").version(Versions.MATCH_ANY)) + .add(new MultiGetRequest.Item(indexOrAlias(), "2").version(1)) + .add(new MultiGetRequest.Item(indexOrAlias(), "2").version(2)) .setRealtime(false) .get(); assertThat(response.getResponses().length, equalTo(3)); @@ -539,14 +538,14 @@ public void testGetFieldsNonLeafField() throws Exception { IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, - () -> client().prepareGet(indexOrAlias(), "my-type1", "1").setStoredFields("field1").get()); + () -> client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get()); assertThat(exc.getMessage(), equalTo("field [field1] isn't a leaf field")); flush(); exc = expectThrows(IllegalArgumentException.class, - () -> client().prepareGet(indexOrAlias(), "my-type1", "1").setStoredFields("field1").get()); + () -> client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get()); assertThat(exc.getMessage(), equalTo("field [field1] isn't a leaf field")); } @@ -594,14 +593,14 @@ public void testGetFieldsComplexField() throws Exception { logger.info("checking real time retrieval"); String field = "field1.field2.field3.field4"; - GetResponse getResponse = client().prepareGet("my-index", "my-type", "1").setStoredFields(field).get(); + GetResponse getResponse = client().prepareGet("my-index", "1").setStoredFields(field).get(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getField(field).isMetadataField(), equalTo(false)); assertThat(getResponse.getField(field).getValues().size(), equalTo(2)); assertThat(getResponse.getField(field).getValues().get(0).toString(), equalTo("value1")); assertThat(getResponse.getField(field).getValues().get(1).toString(), equalTo("value2")); - getResponse = client().prepareGet("my-index", "my-type", "1").setStoredFields(field).get(); + getResponse = client().prepareGet("my-index", "1").setStoredFields(field).get(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getField(field).isMetadataField(), equalTo(false)); assertThat(getResponse.getField(field).getValues().size(), equalTo(2)); @@ -629,7 +628,7 @@ public void testGetFieldsComplexField() throws Exception { logger.info("checking post-flush retrieval"); - getResponse = client().prepareGet("my-index", "my-type", "1").setStoredFields(field).get(); + getResponse = client().prepareGet("my-index", "1").setStoredFields(field).get(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getField(field).isMetadataField(), equalTo(false)); assertThat(getResponse.getField(field).getValues().size(), equalTo(2)); @@ -667,13 +666,13 @@ public void testUngeneratedFieldsThatAreNeverStored() throws IOException { index("test", "_doc", "1", doc); String[] fieldsList = {"suggest"}; // before refresh - document is only in translog - assertGetFieldsAlwaysNull(indexOrAlias(), "_doc", "1", fieldsList); + assertGetFieldsAlwaysNull(indexOrAlias(), "1", fieldsList); refresh(); //after refresh - document is in translog and also indexed - assertGetFieldsAlwaysNull(indexOrAlias(), "_doc", "1", fieldsList); + assertGetFieldsAlwaysNull(indexOrAlias(), "1", fieldsList); flush(); //after flush - document is in not anymore translog - only indexed - assertGetFieldsAlwaysNull(indexOrAlias(), "_doc", "1", fieldsList); + assertGetFieldsAlwaysNull(indexOrAlias(), "1", fieldsList); } public void testUngeneratedFieldsThatAreAlwaysStored() throws IOException { @@ -691,13 +690,13 @@ public void testUngeneratedFieldsThatAreAlwaysStored() throws IOException { String[] fieldsList = {"_routing"}; // before refresh - document is only in translog - assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList, "routingValue"); + assertGetFieldsAlwaysWorks(indexOrAlias(), "1", fieldsList, "routingValue"); refresh(); //after refresh - document is in translog and also indexed - assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList, "routingValue"); + assertGetFieldsAlwaysWorks(indexOrAlias(), "1", fieldsList, "routingValue"); flush(); //after flush - document is in not anymore translog - only indexed - assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList, "routingValue"); + assertGetFieldsAlwaysWorks(indexOrAlias(), "1", fieldsList, "routingValue"); } public void testUngeneratedFieldsNotPartOfSourceStored() throws IOException { @@ -716,38 +715,38 @@ public void testUngeneratedFieldsNotPartOfSourceStored() throws IOException { client().prepareIndex("test", "_doc").setId("1").setSource(doc, XContentType.JSON).setRouting("1").get(); String[] fieldsList = {"_routing"}; // before refresh - document is only in translog - assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList, "1"); + assertGetFieldsAlwaysWorks(indexOrAlias(), "1", fieldsList, "1"); refresh(); //after refresh - document is in translog and also indexed - assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList, "1"); + assertGetFieldsAlwaysWorks(indexOrAlias(), "1", fieldsList, "1"); flush(); //after flush - document is in not anymore translog - only indexed - assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList, "1"); + assertGetFieldsAlwaysWorks(indexOrAlias(), "1", fieldsList, "1"); } public void testGeneratedStringFieldsUnstored() throws IOException { indexSingleDocumentWithStringFieldsGeneratedFromText(false, randomBoolean()); String[] fieldsList = {"_field_names"}; // before refresh - document is only in translog - assertGetFieldsAlwaysNull(indexOrAlias(), "_doc", "1", fieldsList); + assertGetFieldsAlwaysNull(indexOrAlias(), "1", fieldsList); refresh(); //after refresh - document is in translog and also indexed - assertGetFieldsAlwaysNull(indexOrAlias(), "_doc", "1", fieldsList); + assertGetFieldsAlwaysNull(indexOrAlias(), "1", fieldsList); flush(); //after flush - document is in not anymore translog - only indexed - assertGetFieldsAlwaysNull(indexOrAlias(), "_doc", "1", fieldsList); + assertGetFieldsAlwaysNull(indexOrAlias(), "1", fieldsList); } public void testGeneratedStringFieldsStored() throws IOException { indexSingleDocumentWithStringFieldsGeneratedFromText(true, randomBoolean()); String[] fieldsList = {"text1", "text2"}; String[] alwaysNotStoredFieldsList = {"_field_names"}; - assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList); - assertGetFieldsNull(indexOrAlias(), "_doc", "1", alwaysNotStoredFieldsList); + assertGetFieldsAlwaysWorks(indexOrAlias(), "1", fieldsList); + assertGetFieldsNull(indexOrAlias(), "1", alwaysNotStoredFieldsList); flush(); //after flush - document is in not anymore translog - only indexed - assertGetFieldsAlwaysWorks(indexOrAlias(), "_doc", "1", fieldsList); - assertGetFieldsNull(indexOrAlias(), "_doc", "1", alwaysNotStoredFieldsList); + assertGetFieldsAlwaysWorks(indexOrAlias(), "1", fieldsList); + assertGetFieldsNull(indexOrAlias(), "1", alwaysNotStoredFieldsList); } void indexSingleDocumentWithStringFieldsGeneratedFromText(boolean stored, boolean sourceEnabled) { @@ -784,64 +783,64 @@ void indexSingleDocumentWithStringFieldsGeneratedFromText(boolean stored, boolea index("test", "_doc", "1", doc); } - private void assertGetFieldsAlwaysWorks(String index, String type, String docId, String[] fields) { - assertGetFieldsAlwaysWorks(index, type, docId, fields, null); + private void assertGetFieldsAlwaysWorks(String index, String docId, String[] fields) { + assertGetFieldsAlwaysWorks(index, docId, fields, null); } - private void assertGetFieldsAlwaysWorks(String index, String type, String docId, String[] fields, @Nullable String routing) { + private void assertGetFieldsAlwaysWorks(String index, String docId, String[] fields, @Nullable String routing) { for (String field : fields) { - assertGetFieldWorks(index, type, docId, field, routing); - assertGetFieldWorks(index, type, docId, field, routing); + assertGetFieldWorks(index, docId, field, routing); + assertGetFieldWorks(index, docId, field, routing); } } - private void assertGetFieldWorks(String index, String type, String docId, String field, @Nullable String routing) { - GetResponse response = getDocument(index, type, docId, field, routing); + private void assertGetFieldWorks(String index, String docId, String field, @Nullable String routing) { + GetResponse response = getDocument(index, docId, field, routing); assertThat(response.getId(), equalTo(docId)); assertTrue(response.isExists()); assertNotNull(response.getField(field)); - response = multiGetDocument(index, type, docId, field, routing); + response = multiGetDocument(index, docId, field, routing); assertThat(response.getId(), equalTo(docId)); assertTrue(response.isExists()); assertNotNull(response.getField(field)); } - protected void assertGetFieldsNull(String index, String type, String docId, String[] fields) { - assertGetFieldsNull(index, type, docId, fields, null); + protected void assertGetFieldsNull(String index, String docId, String[] fields) { + assertGetFieldsNull(index, docId, fields, null); } - protected void assertGetFieldsNull(String index, String type, String docId, String[] fields, @Nullable String routing) { + protected void assertGetFieldsNull(String index, String docId, String[] fields, @Nullable String routing) { for (String field : fields) { - assertGetFieldNull(index, type, docId, field, routing); + assertGetFieldNull(index, docId, field, routing); } } - protected void assertGetFieldsAlwaysNull(String index, String type, String docId, String[] fields) { - assertGetFieldsAlwaysNull(index, type, docId, fields, null); + protected void assertGetFieldsAlwaysNull(String index, String docId, String[] fields) { + assertGetFieldsAlwaysNull(index, docId, fields, null); } - protected void assertGetFieldsAlwaysNull(String index, String type, String docId, String[] fields, @Nullable String routing) { + protected void assertGetFieldsAlwaysNull(String index, String docId, String[] fields, @Nullable String routing) { for (String field : fields) { - assertGetFieldNull(index, type, docId, field, routing); - assertGetFieldNull(index, type, docId, field, routing); + assertGetFieldNull(index, docId, field, routing); + assertGetFieldNull(index, docId, field, routing); } } - protected void assertGetFieldNull(String index, String type, String docId, String field, @Nullable String routing) { + protected void assertGetFieldNull(String index, String docId, String field, @Nullable String routing) { //for get - GetResponse response = getDocument(index, type, docId, field, routing); + GetResponse response = getDocument(index, docId, field, routing); assertTrue(response.isExists()); assertNull(response.getField(field)); assertThat(response.getId(), equalTo(docId)); //same for multi get - response = multiGetDocument(index, type, docId, field, routing); + response = multiGetDocument(index, docId, field, routing); assertNull(response.getField(field)); assertThat(response.getId(), equalTo(docId)); assertTrue(response.isExists()); } - private GetResponse multiGetDocument(String index, String type, String docId, String field, @Nullable String routing) { - MultiGetRequest.Item getItem = new MultiGetRequest.Item(index, type, docId).storedFields(field); + private GetResponse multiGetDocument(String index, String docId, String field, @Nullable String routing) { + MultiGetRequest.Item getItem = new MultiGetRequest.Item(index, docId).storedFields(field); if (routing != null) { getItem.routing(routing); } @@ -851,8 +850,8 @@ private GetResponse multiGetDocument(String index, String type, String docId, St return multiGetResponse.getResponses()[0].getResponse(); } - private GetResponse getDocument(String index, String type, String docId, String field, @Nullable String routing) { - GetRequestBuilder getRequestBuilder = client().prepareGet().setIndex(index).setType(type).setId(docId).setStoredFields(field); + private GetResponse getDocument(String index, String docId, String field, @Nullable String routing) { + GetRequestBuilder getRequestBuilder = client().prepareGet().setIndex(index).setId(docId).setStoredFields(field); if (routing != null) { getRequestBuilder.setRouting(routing); } diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 8704bd8be3490..0c2133b598099 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -1382,7 +1382,7 @@ public void testVersionedUpdate() throws IOException { Engine.Index create = new Engine.Index(newUid(doc), primaryTerm.get(), doc, Versions.MATCH_DELETED); Engine.IndexResult indexResult = engine.index(create); assertThat(indexResult.getVersion(), equalTo(1L)); - try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.type(), doc.id(), create.uid()), + try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.id(), create.uid()), searcherFactory)) { assertEquals(1, get.version()); } @@ -1391,7 +1391,7 @@ public void testVersionedUpdate() throws IOException { Engine.IndexResult update_1_result = engine.index(update_1); assertThat(update_1_result.getVersion(), equalTo(2L)); - try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.type(), doc.id(), create.uid()), + try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.id(), create.uid()), searcherFactory)) { assertEquals(2, get.version()); } @@ -1400,7 +1400,7 @@ public void testVersionedUpdate() throws IOException { Engine.IndexResult update_2_result = engine.index(update_2); assertThat(update_2_result.getVersion(), equalTo(3L)); - try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.type(), doc.id(), create.uid()), + try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.id(), create.uid()), searcherFactory)) { assertEquals(3, get.version()); } @@ -1420,21 +1420,21 @@ public void testGetIfSeqNoIfPrimaryTerm() throws IOException { engine.flush(); } try (Engine.GetResult get = engine.get( - new Engine.Get(true, true, doc.type(), doc.id(), create.uid()) + new Engine.Get(true, true, doc.id(), create.uid()) .setIfSeqNo(indexResult.getSeqNo()).setIfPrimaryTerm(primaryTerm.get()), searcherFactory)) { assertEquals(indexResult.getSeqNo(), get.docIdAndVersion().seqNo); } - expectThrows(VersionConflictEngineException.class, () -> engine.get(new Engine.Get(true, false, doc.type(), doc.id(), create.uid()) + expectThrows(VersionConflictEngineException.class, () -> engine.get(new Engine.Get(true, false, doc.id(), create.uid()) .setIfSeqNo(indexResult.getSeqNo() + 1).setIfPrimaryTerm(primaryTerm.get()), searcherFactory)); - expectThrows(VersionConflictEngineException.class, () -> engine.get(new Engine.Get(true, false, doc.type(), doc.id(), create.uid()) + expectThrows(VersionConflictEngineException.class, () -> engine.get(new Engine.Get(true, false, doc.id(), create.uid()) .setIfSeqNo(indexResult.getSeqNo()).setIfPrimaryTerm(primaryTerm.get() + 1), searcherFactory)); - expectThrows(VersionConflictEngineException.class, () -> engine.get(new Engine.Get(true, false, doc.type(), doc.id(), create.uid()) + expectThrows(VersionConflictEngineException.class, () -> engine.get(new Engine.Get(true, false, doc.id(), create.uid()) .setIfSeqNo(indexResult.getSeqNo() + 1).setIfPrimaryTerm(primaryTerm.get() + 1), searcherFactory)); } @@ -2167,7 +2167,7 @@ public void testVersioningPromotedReplica() throws IOException { assertOpsOnReplica(replicaOps, replicaEngine, true, logger); final int opsOnPrimary = assertOpsOnPrimary(primaryOps, finalReplicaVersion, deletedOnReplica, replicaEngine); final long currentSeqNo = getSequenceID(replicaEngine, - new Engine.Get(false, false, "type", lastReplicaOp.uid().text(), lastReplicaOp.uid())).v1(); + new Engine.Get(false, false, lastReplicaOp.uid().text(), lastReplicaOp.uid())).v1(); try (Engine.Searcher searcher = engine.acquireSearcher("test")) { final TotalHitCountCollector collector = new TotalHitCountCollector(); searcher.search(new MatchAllDocsQuery(), collector); @@ -2234,7 +2234,7 @@ class OpAndVersion { } for (int op = 0; op < opsPerThread; op++) { try (Engine.GetResult get = engine.get(new Engine.Get(true, false, - doc.type(), doc.id(), uidTerm), searcherFactory)) { + doc.id(), uidTerm), searcherFactory)) { FieldsVisitor visitor = new FieldsVisitor(true); get.docIdAndVersion().reader.document(get.docIdAndVersion().docId, visitor); List values = new ArrayList<>(Strings.commaDelimitedListToSet(visitor.source().utf8ToString())); @@ -2277,7 +2277,7 @@ class OpAndVersion { } try (Engine.GetResult get = engine.get(new Engine.Get(true, false, - doc.type(), doc.id(), uidTerm), searcherFactory)) { + doc.id(), uidTerm), searcherFactory)) { FieldsVisitor visitor = new FieldsVisitor(true); get.docIdAndVersion().reader.document(get.docIdAndVersion().docId, visitor); List values = Arrays.asList(Strings.commaDelimitedListToStringArray(visitor.source().utf8ToString())); @@ -2704,7 +2704,7 @@ public void testEnableGcDeletes() throws Exception { 10, VersionType.EXTERNAL, Engine.Operation.Origin.PRIMARY, System.nanoTime(), UNASSIGNED_SEQ_NO, 0)); // Get should not find the document (we never indexed uid=2): - getResult = engine.get(new Engine.Get(true, false, "type", "2", newUid("2")), + getResult = engine.get(new Engine.Get(true, false, "2", newUid("2")), searcherFactory); assertThat(getResult.exists(), equalTo(false)); @@ -3967,7 +3967,7 @@ public void afterRefresh(boolean didRefresh) throws IOException { public void testSequenceIDs() throws Exception { Tuple seqID = getSequenceID(engine, new Engine.Get(false, false, - "type", "2", newUid("1"))); + "2", newUid("1"))); // Non-existent doc returns no seqnum and no primary term assertThat(seqID.v1(), equalTo(UNASSIGNED_SEQ_NO)); assertThat(seqID.v2(), equalTo(0L)); @@ -4268,7 +4268,7 @@ public void testOutOfOrderSequenceNumbersWithVersionConflict() throws IOExceptio assertThat(engine.getProcessedLocalCheckpoint(), equalTo(expectedLocalCheckpoint)); try (Engine.GetResult result = engine.get(new Engine.Get(true, false, - "type", "2", uid), searcherFactory)) { + "2", uid), searcherFactory)) { assertThat(result.exists(), equalTo(exists)); } } @@ -5158,7 +5158,7 @@ public void testStressUpdateSameDocWhileGettingIt() throws IOException, Interrup CountDownLatch awaitStarted = new CountDownLatch(1); Thread thread = new Thread(() -> { awaitStarted.countDown(); - try (Engine.GetResult getResult = engine.get(new Engine.Get(true, false, doc3.type(), + try (Engine.GetResult getResult = engine.get(new Engine.Get(true, false, doc3.id(), doc3.uid()), engine::acquireSearcher)) { assertTrue(getResult.exists()); @@ -5166,7 +5166,7 @@ public void testStressUpdateSameDocWhileGettingIt() throws IOException, Interrup }); thread.start(); awaitStarted.await(); - try (Engine.GetResult getResult = engine.get(new Engine.Get(true, false, doc.type(), + try (Engine.GetResult getResult = engine.get(new Engine.Get(true, false, doc.id(), doc.uid()), engine::acquireSearcher)) { assertFalse(getResult.exists()); diff --git a/server/src/test/java/org/elasticsearch/index/get/GetResultTests.java b/server/src/test/java/org/elasticsearch/index/get/GetResultTests.java index 5758fb5bcb971..92cf49ac6f487 100644 --- a/server/src/test/java/org/elasticsearch/index/get/GetResultTests.java +++ b/server/src/test/java/org/elasticsearch/index/get/GetResultTests.java @@ -74,19 +74,19 @@ public void testToAndFromXContent() throws Exception { public void testToXContent() throws IOException { { - GetResult getResult = new GetResult("index", "type", "id", 0, 1, 1, true, new BytesArray("{ \"field1\" : " + + GetResult getResult = new GetResult("index", "id", 0, 1, 1, true, new BytesArray("{ \"field1\" : " + "\"value1\", \"field2\":\"value2\"}"), singletonMap("field1", new DocumentField("field1", singletonList("value1"))), singletonMap("field1", new DocumentField("metafield", singletonList("metavalue")))); String output = Strings.toString(getResult); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "\"metafield\":\"metavalue\",\"found\":true,\"_source\":{ \"field1\" : \"value1\", \"field2\":\"value2\"}," + "\"fields\":{\"field1\":[\"value1\"]}}", output); } { - GetResult getResult = new GetResult("index", "type", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null); + GetResult getResult = new GetResult("index", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null); String output = Strings.toString(getResult); - assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"found\":false}", output); + assertEquals("{\"_index\":\"index\",\"_id\":\"id\",\"found\":false}", output); } } @@ -96,7 +96,7 @@ public void testToAndFromXContentEmbedded() throws Exception { GetResult getResult = tuple.v1(); // We don't expect to retrieve the index/type/id of the GetResult because they are not rendered // by the toXContentEmbedded method. - GetResult expectedGetResult = new GetResult(null, null, null, tuple.v2().getSeqNo(), tuple.v2().getPrimaryTerm(), -1, + GetResult expectedGetResult = new GetResult(null, null, tuple.v2().getSeqNo(), tuple.v2().getPrimaryTerm(), -1, tuple.v2().isExists(), tuple.v2().sourceRef(), tuple.v2().getDocumentFields(), tuple.v2().getMetadataFields()); @@ -123,7 +123,7 @@ public void testToXContentEmbedded() throws IOException { fields.put("foo", new DocumentField("foo", singletonList("bar"))); fields.put("baz", new DocumentField("baz", Arrays.asList("baz_0", "baz_1"))); - GetResult getResult = new GetResult("index", "type", "id", 0, 1, 2, true, + GetResult getResult = new GetResult("index", "id", 0, 1, 2, true, new BytesArray("{\"foo\":\"bar\",\"baz\":[\"baz_0\",\"baz_1\"]}"), fields, null); BytesReference originalBytes = toXContentEmbedded(getResult, XContentType.JSON, false); @@ -132,7 +132,7 @@ public void testToXContentEmbedded() throws IOException { } public void testToXContentEmbeddedNotFound() throws IOException { - GetResult getResult = new GetResult("index", "type", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null); + GetResult getResult = new GetResult("index", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null); BytesReference originalBytes = toXContentEmbedded(getResult, XContentType.JSON, false); assertEquals("{\"found\":false}", originalBytes.utf8ToString()); @@ -154,33 +154,30 @@ public void testEqualsAndHashcode() { } public static GetResult copyGetResult(GetResult getResult) { - return new GetResult(getResult.getIndex(), getResult.getType(), getResult.getId(), + return new GetResult(getResult.getIndex(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), getResult.isExists(), getResult.internalSourceRef(), getResult.getDocumentFields(), getResult.getMetadataFields()); } public static GetResult mutateGetResult(GetResult getResult) { List> mutations = new ArrayList<>(); - mutations.add(() -> new GetResult(randomUnicodeOfLength(15), getResult.getType(), getResult.getId(), + mutations.add(() -> new GetResult(randomUnicodeOfLength(15), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), getResult.isExists(), getResult.internalSourceRef(), getResult.getFields(), null)); - mutations.add(() -> new GetResult(getResult.getIndex(), randomUnicodeOfLength(15), getResult.getId(), + mutations.add(() -> new GetResult(getResult.getIndex(), randomUnicodeOfLength(15), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), getResult.isExists(), getResult.internalSourceRef(), getResult.getFields(), null)); - mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getType(), randomUnicodeOfLength(15), - getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), - getResult.isExists(), getResult.internalSourceRef(), getResult.getFields(), null)); - mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getType(), getResult.getId(), + mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), randomNonNegativeLong(), getResult.isExists(), getResult.internalSourceRef(), getResult.getFields(), null)); - mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getType(), getResult.getId(), + mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getId(), getResult.isExists() ? UNASSIGNED_SEQ_NO : getResult.getSeqNo(), getResult.isExists() ? 0 : getResult.getPrimaryTerm(), getResult.getVersion(), getResult.isExists() == false, getResult.internalSourceRef(), getResult.getFields(), null)); - mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getType(), getResult.getId(), + mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), getResult.isExists(), RandomObjects.randomSource(random()), getResult.getFields(), null)); - mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getType(), getResult.getId(), + mutations.add(() -> new GetResult(getResult.getIndex(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), getResult.getVersion(), getResult.isExists(), getResult.internalSourceRef(), randomDocumentFields(XContentType.JSON).v1(), null)); return randomFrom(mutations).get(); @@ -188,7 +185,6 @@ public static GetResult mutateGetResult(GetResult getResult) { public static Tuple randomGetResult(XContentType xContentType) { final String index = randomAlphaOfLengthBetween(3, 10); - final String type = randomAlphaOfLengthBetween(3, 10); final String id = randomAlphaOfLengthBetween(3, 10); final long version; final long seqNo; @@ -223,8 +219,8 @@ public static Tuple randomGetResult(XContentType xContentT version = -1; exists = false; } - GetResult getResult = new GetResult(index, type, id, seqNo, primaryTerm, version, exists, source, fields, metaFields); - GetResult expectedGetResult = new GetResult(index, type, id, seqNo, primaryTerm, version, exists, source, + GetResult getResult = new GetResult(index, id, seqNo, primaryTerm, version, exists, source, fields, metaFields); + GetResult expectedGetResult = new GetResult(index, id, seqNo, primaryTerm, version, exists, source, expectedFields, expectedMetaFields); return Tuple.tuple(getResult, expectedGetResult); } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIT.java b/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIT.java index e1f235c19c662..f51363cf8df34 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIT.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIT.java @@ -116,7 +116,7 @@ public void run() { assertMappingsHaveField(mappings, "index", "type", "field" + i); } for (int i = 0; i < indexThreads.length; ++i) { - assertTrue(client().prepareGet("index", "type", Integer.toString(i)).get().isExists()); + assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists()); } } } diff --git a/server/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java index ca84a19cf6190..f196714619d8d 100644 --- a/server/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/GeoShapeQueryBuilderTests.java @@ -39,7 +39,6 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.index.get.GetResult; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.AbstractQueryTestCase; import org.elasticsearch.test.VersionUtils; @@ -128,12 +127,10 @@ protected GeoShapeQueryBuilder doCreateTestQueryBuilder(boolean indexedShape) { @Override protected GetResponse executeGet(GetRequest getRequest) { - String indexedType = indexedShapeType != null ? indexedShapeType : MapperService.SINGLE_MAPPING_NAME; assertThat(indexedShapeToReturn, notNullValue()); assertThat(indexedShapeId, notNullValue()); assertThat(getRequest.id(), equalTo(indexedShapeId)); - assertThat(getRequest.type(), equalTo(indexedType)); assertThat(getRequest.routing(), equalTo(indexedShapeRouting)); String expectedShapeIndex = indexedShapeIndex == null ? GeoShapeQueryBuilder.DEFAULT_SHAPE_INDEX_NAME : indexedShapeIndex; assertThat(getRequest.index(), equalTo(expectedShapeIndex)); @@ -150,7 +147,7 @@ protected GetResponse executeGet(GetRequest getRequest) { } catch (IOException ex) { throw new ElasticsearchException("boom", ex); } - return new GetResponse(new GetResult(indexedShapeIndex, indexedType, indexedShapeId, 0, 1, 0, true, new BytesArray(json), + return new GetResponse(new GetResult(indexedShapeIndex, indexedShapeId, 0, 1, 0, true, new BytesArray(json), null, null)); } diff --git a/server/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java index f782c45c03127..ec4879a1b6bf0 100644 --- a/server/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java @@ -209,7 +209,7 @@ public GetResponse executeGet(GetRequest getRequest) { } catch (IOException ex) { throw new ElasticsearchException("boom", ex); } - return new GetResponse(new GetResult(getRequest.index(), getRequest.type(), getRequest.id(), 0, 1, 0, true, + return new GetResponse(new GetResult(getRequest.index(), getRequest.id(), 0, 1, 0, true, new BytesArray(json), null, null)); } diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index 0d92bc3802f63..811e27ee8848a 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -1575,7 +1575,7 @@ public void testRefreshMetric() throws IOException { } long refreshCount = shard.refreshStats().getTotal(); indexDoc(shard, "_doc", "test"); - try (Engine.GetResult ignored = shard.get(new Engine.Get(true, false, "_doc", "test", + try (Engine.GetResult ignored = shard.get(new Engine.Get(true, false, "test", new Term(IdFieldMapper.NAME, Uid.encodeId("test"))))) { assertThat(shard.refreshStats().getTotal(), equalTo(refreshCount+1)); } @@ -1600,7 +1600,7 @@ public void testExternalRefreshMetric() throws IOException { final long externalRefreshCount = shard.refreshStats().getExternalTotal(); final long extraInternalRefreshes = shard.routingEntry().primary() || shard.indexSettings().isSoftDeleteEnabled() == false ? 0 : 1; indexDoc(shard, "_doc", "test"); - try (Engine.GetResult ignored = shard.get(new Engine.Get(true, false, "_doc", "test", + try (Engine.GetResult ignored = shard.get(new Engine.Get(true, false, "test", new Term(IdFieldMapper.NAME, Uid.encodeId("test"))))) { assertThat(shard.refreshStats().getExternalTotal(), equalTo(externalRefreshCount)); assertThat(shard.refreshStats().getExternalTotal(), equalTo(shard.refreshStats().getTotal() - 1 - extraInternalRefreshes)); @@ -2379,7 +2379,7 @@ public void testReaderWrapperIsUsed() throws IOException { shard.refresh("test"); try (Engine.GetResult getResult = shard - .get(new Engine.Get(false, false, "_doc", "1", + .get(new Engine.Get(false, false, "1", new Term(IdFieldMapper.NAME, Uid.encodeId("1"))))) { assertTrue(getResult.exists()); assertNotNull(getResult.searcher()); @@ -2412,7 +2412,7 @@ public void testReaderWrapperIsUsed() throws IOException { assertEquals(search.totalHits.value, 1); } try (Engine.GetResult getResult = newShard - .get(new Engine.Get(false, false, "_doc", "1", + .get(new Engine.Get(false, false, "1", new Term(IdFieldMapper.NAME, Uid.encodeId("1"))))) { assertTrue(getResult.exists()); assertNotNull(getResult.searcher()); // make sure get uses the wrapped reader @@ -4055,24 +4055,16 @@ public void testTypelessGet() throws IOException { .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .build(); IndexMetaData metaData = IndexMetaData.builder("index") - .putMapping("some_type", "{ \"properties\": { \"foo\": { \"type\": \"text\"}}}") + .putMapping("_doc", "{ \"properties\": { \"foo\": { \"type\": \"text\"}}}") .settings(settings) .primaryTerm(0, 1).build(); IndexShard shard = newShard(new ShardId(metaData.getIndex(), 0), true, "n1", metaData, null); recoverShardFromStore(shard); - Engine.IndexResult indexResult = indexDoc(shard, "some_type", "0", "{\"foo\" : \"bar\"}"); + Engine.IndexResult indexResult = indexDoc(shard, "_doc", "0", "{\"foo\" : \"bar\"}"); assertTrue(indexResult.isCreated()); - org.elasticsearch.index.engine.Engine.GetResult getResult = shard.get( - new Engine.Get(true, true, "some_type", "0", new Term("_id", Uid.encodeId("0")))); - assertTrue(getResult.exists()); - getResult.close(); - - getResult = shard.get(new Engine.Get(true, true, "some_other_type", "0", new Term("_id", Uid.encodeId("0")))); - assertFalse(getResult.exists()); - getResult.close(); - - getResult = shard.get(new Engine.Get(true, true, "_doc", "0", new Term("_id", Uid.encodeId("0")))); + org.elasticsearch.index.engine.Engine.GetResult getResult + = shard.get(new Engine.Get(true, true, "0", new Term("_id", Uid.encodeId("0")))); assertTrue(getResult.exists()); getResult.close(); diff --git a/server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java b/server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java index e264d33ffed61..df1f4b21a3a00 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java @@ -344,7 +344,7 @@ public void testLotsOfThreads() throws Exception { } listener.assertNoError(); - Engine.Get get = new Engine.Get(false, false, "test", threadId, new Term(IdFieldMapper.NAME, threadId)); + Engine.Get get = new Engine.Get(false, false, threadId, new Term(IdFieldMapper.NAME, threadId)); try (Engine.GetResult getResult = engine.get(get, engine::acquireSearcher)) { assertTrue("document not found", getResult.exists()); assertEquals(iteration, getResult.version()); diff --git a/server/src/test/java/org/elasticsearch/index/shard/ShardGetServiceTests.java b/server/src/test/java/org/elasticsearch/index/shard/ShardGetServiceTests.java index 86c2ac836226a..d7e4fca1180aa 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/ShardGetServiceTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/ShardGetServiceTests.java @@ -49,7 +49,7 @@ public void testGetForUpdate() throws IOException { recoverShardFromStore(primary); Engine.IndexResult test = indexDoc(primary, "test", "0", "{\"foo\" : \"bar\"}"); assertTrue(primary.getEngine().refreshNeeded()); - GetResult testGet = primary.getService().getForUpdate("test", "0", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); + GetResult testGet = primary.getService().getForUpdate("0", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); assertFalse(testGet.getFields().containsKey(RoutingFieldMapper.NAME)); assertEquals(new String(testGet.source(), StandardCharsets.UTF_8), "{\"foo\" : \"bar\"}"); try (Engine.Searcher searcher = primary.getEngine().acquireSearcher("test", Engine.SearcherScope.INTERNAL)) { @@ -58,7 +58,7 @@ public void testGetForUpdate() throws IOException { Engine.IndexResult test1 = indexDoc(primary, "test", "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar"); assertTrue(primary.getEngine().refreshNeeded()); - GetResult testGet1 = primary.getService().getForUpdate("test", "1", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); + GetResult testGet1 = primary.getService().getForUpdate("1", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); assertEquals(new String(testGet1.source(), StandardCharsets.UTF_8), "{\"foo\" : \"baz\"}"); assertTrue(testGet1.getFields().containsKey(RoutingFieldMapper.NAME)); assertEquals("foobar", testGet1.getFields().get(RoutingFieldMapper.NAME).getValue()); @@ -73,19 +73,19 @@ public void testGetForUpdate() throws IOException { // now again from the reader Engine.IndexResult test2 = indexDoc(primary, "test", "1", "{\"foo\" : \"baz\"}", XContentType.JSON, "foobar"); assertTrue(primary.getEngine().refreshNeeded()); - testGet1 = primary.getService().getForUpdate("test", "1", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); + testGet1 = primary.getService().getForUpdate("1", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); assertEquals(new String(testGet1.source(), StandardCharsets.UTF_8), "{\"foo\" : \"baz\"}"); assertTrue(testGet1.getFields().containsKey(RoutingFieldMapper.NAME)); assertEquals("foobar", testGet1.getFields().get(RoutingFieldMapper.NAME).getValue()); final long primaryTerm = primary.getOperationPrimaryTerm(); - testGet1 = primary.getService().getForUpdate("test", "1", test2.getSeqNo(), primaryTerm); + testGet1 = primary.getService().getForUpdate("1", test2.getSeqNo(), primaryTerm); assertEquals(new String(testGet1.source(), StandardCharsets.UTF_8), "{\"foo\" : \"baz\"}"); expectThrows(VersionConflictEngineException.class, () -> - primary.getService().getForUpdate("test", "1", test2.getSeqNo() + 1, primaryTerm)); + primary.getService().getForUpdate("1", test2.getSeqNo() + 1, primaryTerm)); expectThrows(VersionConflictEngineException.class, () -> - primary.getService().getForUpdate("test", "1", test2.getSeqNo(), primaryTerm + 1)); + primary.getService().getForUpdate("1", test2.getSeqNo(), primaryTerm + 1)); closeShards(primary); } @@ -103,13 +103,7 @@ public void testTypelessGetForUpdate() throws IOException { Engine.IndexResult indexResult = indexDoc(shard, "some_type", "0", "{\"foo\" : \"bar\"}"); assertTrue(indexResult.isCreated()); - GetResult getResult = shard.getService().getForUpdate("some_type", "0", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); - assertTrue(getResult.isExists()); - - getResult = shard.getService().getForUpdate("some_other_type", "0", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); - assertFalse(getResult.isExists()); - - getResult = shard.getService().getForUpdate("_doc", "0", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); + GetResult getResult = shard.getService().getForUpdate( "0", UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM); assertTrue(getResult.isExists()); closeShards(shard); diff --git a/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java b/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java index ffe25b4a372e3..23c4904024e66 100644 --- a/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java @@ -101,15 +101,15 @@ public void testIndexNameDateMathExpressions() { assertHitCount(searchResponse, 3); assertSearchHits(searchResponse, "1", "2", "3"); - GetResponse getResponse = dateSensitiveGet(client().prepareGet(dateMathExp1, "type", "1")); + GetResponse getResponse = dateSensitiveGet(client().prepareGet(dateMathExp1, "1")); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("1")); - getResponse = dateSensitiveGet(client().prepareGet(dateMathExp2, "type", "2")); + getResponse = dateSensitiveGet(client().prepareGet(dateMathExp2, "2")); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("2")); - getResponse = dateSensitiveGet(client().prepareGet(dateMathExp3, "type", "3")); + getResponse = dateSensitiveGet(client().prepareGet(dateMathExp3, "3")); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("3")); diff --git a/server/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java b/server/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java index eb0e564e92d33..78ddd3a9326c9 100644 --- a/server/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java +++ b/server/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java @@ -500,7 +500,7 @@ public void testSimpleStats() throws Exception { assertThat(stats.getTotal().getRefresh(), notNullValue()); // check get - GetResponse getResponse = client().prepareGet("test2", "type", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test2", "1").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); stats = client().admin().indices().prepareStats().execute().actionGet(); @@ -509,7 +509,7 @@ public void testSimpleStats() throws Exception { assertThat(stats.getTotal().getGet().getMissingCount(), equalTo(0L)); // missing get - getResponse = client().prepareGet("test2", "type", "2").execute().actionGet(); + getResponse = client().prepareGet("test2", "2").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(false)); stats = client().admin().indices().prepareStats().execute().actionGet(); diff --git a/server/src/test/java/org/elasticsearch/ingest/IngestClientIT.java b/server/src/test/java/org/elasticsearch/ingest/IngestClientIT.java index 6e5d862372ac6..5e35ee4f83ec8 100644 --- a/server/src/test/java/org/elasticsearch/ingest/IngestClientIT.java +++ b/server/src/test/java/org/elasticsearch/ingest/IngestClientIT.java @@ -202,11 +202,11 @@ public void testBulkWithUpsert() throws Exception { BulkResponse response = client().bulk(bulkRequest).actionGet(); assertThat(response.getItems().length, equalTo(bulkRequest.requests().size())); - Map inserted = client().prepareGet("index", "type", "1") + Map inserted = client().prepareGet("index", "1") .get().getSourceAsMap(); assertThat(inserted.get("field1"), equalTo("val1")); assertThat(inserted.get("processed"), equalTo(true)); - Map upserted = client().prepareGet("index", "type", "2") + Map upserted = client().prepareGet("index", "2") .get().getSourceAsMap(); assertThat(upserted.get("field1"), equalTo("upserted_val")); assertThat(upserted.get("processed"), equalTo(true)); @@ -233,14 +233,14 @@ public void test() throws Exception { client().prepareIndex("test", "type", "1").setPipeline("_id").setSource("field", "value", "fail", false).get(); - Map doc = client().prepareGet("test", "type", "1") + Map doc = client().prepareGet("test", "1") .get().getSourceAsMap(); assertThat(doc.get("field"), equalTo("value")); assertThat(doc.get("processed"), equalTo(true)); client().prepareBulk().add( client().prepareIndex("test", "type", "2").setSource("field", "value2", "fail", false).setPipeline("_id")).get(); - doc = client().prepareGet("test", "type", "2").get().getSourceAsMap(); + doc = client().prepareGet("test", "2").get().getSourceAsMap(); assertThat(doc.get("field"), equalTo("value2")); assertThat(doc.get("processed"), equalTo(true)); diff --git a/server/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java b/server/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java index c7f27dc81a7c4..9fba0a4da2d6a 100644 --- a/server/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java +++ b/server/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java @@ -52,8 +52,8 @@ public void testThatMgetShouldWorkWithOneIndexMissing() throws IOException { .setRefreshPolicy(IMMEDIATE).get(); MultiGetResponse mgetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item("test", "test", "1")) - .add(new MultiGetRequest.Item("nonExistingIndex", "test", "1")) + .add(new MultiGetRequest.Item("test", "1")) + .add(new MultiGetRequest.Item("nonExistingIndex", "1")) .get(); assertThat(mgetResponse.getResponses().length, is(2)); @@ -67,7 +67,7 @@ public void testThatMgetShouldWorkWithOneIndexMissing() throws IOException { is("nonExistingIndex")); mgetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item("nonExistingIndex", "test", "1")) + .add(new MultiGetRequest.Item("nonExistingIndex", "1")) .get(); assertThat(mgetResponse.getResponses().length, is(1)); assertThat(mgetResponse.getResponses()[0].getIndex(), is("nonExistingIndex")); @@ -85,8 +85,8 @@ public void testThatMgetShouldWorkWithMultiIndexAlias() throws IOException { .setRefreshPolicy(IMMEDIATE).get(); MultiGetResponse mgetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item("test", "test", "1")) - .add(new MultiGetRequest.Item("multiIndexAlias", "test", "1")) + .add(new MultiGetRequest.Item("test", "1")) + .add(new MultiGetRequest.Item("multiIndexAlias", "1")) .get(); assertThat(mgetResponse.getResponses().length, is(2)); @@ -98,7 +98,7 @@ public void testThatMgetShouldWorkWithMultiIndexAlias() throws IOException { assertThat(mgetResponse.getResponses()[1].getFailure().getMessage(), containsString("more than one indices")); mgetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item("multiIndexAlias", "test", "1")) + .add(new MultiGetRequest.Item("multiIndexAlias", "1")) .get(); assertThat(mgetResponse.getResponses().length, is(1)); assertThat(mgetResponse.getResponses()[0].getIndex(), is("multiIndexAlias")); @@ -115,7 +115,7 @@ public void testThatMgetShouldWorkWithAliasRouting() throws IOException { .setRefreshPolicy(IMMEDIATE).get(); MultiGetResponse mgetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item("alias1", "test", "1")) + .add(new MultiGetRequest.Item("alias1", "1")) .get(); assertEquals(1, mgetResponse.getResponses().length); @@ -138,10 +138,10 @@ public void testThatSourceFilteringIsSupported() throws Exception { MultiGetRequestBuilder request = client().prepareMultiGet(); for (int i = 0; i < 100; i++) { if (i % 2 == 0) { - request.add(new MultiGetRequest.Item(indexOrAlias(), "type", Integer.toString(i)) + request.add(new MultiGetRequest.Item(indexOrAlias(), Integer.toString(i)) .fetchSourceContext(new FetchSourceContext(true, new String[] {"included"}, new String[] {"*.hidden_field"}))); } else { - request.add(new MultiGetRequest.Item(indexOrAlias(), "type", Integer.toString(i)) + request.add(new MultiGetRequest.Item(indexOrAlias(), Integer.toString(i)) .fetchSourceContext(new FetchSourceContext(false))); } } @@ -178,8 +178,8 @@ public void testThatRoutingPerDocumentIsSupported() throws Exception { .get(); MultiGetResponse mgetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "test", id).routing(routingOtherShard)) - .add(new MultiGetRequest.Item(indexOrAlias(), "test", id)) + .add(new MultiGetRequest.Item(indexOrAlias(), id).routing(routingOtherShard)) + .add(new MultiGetRequest.Item(indexOrAlias(), id)) .get(); assertThat(mgetResponse.getResponses().length, is(2)); diff --git a/server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java b/server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java index 9e5a170b6b334..88e88ee173886 100644 --- a/server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java +++ b/server/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java @@ -339,7 +339,7 @@ private void iterateAssertCount(final int numberOfShards, final int iterations, IndicesStatsResponse indicesStatsResponse = client().admin().indices().prepareStats().get(); for (ShardStats shardStats : indicesStatsResponse.getShards()) { DocsStats docsStats = shardStats.getStats().docs; - logger.info("shard [{}] - count {}, primary {}", shardStats.getShardRouting().id(), docsStats.getCount(), + logger.info("shard [{}] - count {}, primary {}", shardStats.getShardRouting().id(), docsStats.getCount(), shardStats.getShardRouting().primary()); } @@ -350,7 +350,7 @@ private void iterateAssertCount(final int numberOfShards, final int iterations, ShardId docShard = clusterService.operationRouting().shardId(state, "test", id, null); if (docShard.id() == shard) { for (ShardRouting shardRouting : state.routingTable().shardRoutingTable("test", shard)) { - GetResponse response = client().prepareGet("test", "type", id) + GetResponse response = client().prepareGet("test", id) .setPreference("_only_nodes:" + shardRouting.currentNodeId()).get(); if (response.isExists()) { logger.info("missing id [{}] on shard {}", id, shardRouting); @@ -390,13 +390,13 @@ private void iterateAssertCount(final int numberOfShards, final int iterations, } private void logSearchResponse(int numberOfShards, long numberOfDocs, int iteration, SearchResponse searchResponse) { - logger.info("iteration [{}] - successful shards: {} (expected {})", iteration, + logger.info("iteration [{}] - successful shards: {} (expected {})", iteration, searchResponse.getSuccessfulShards(), numberOfShards); logger.info("iteration [{}] - failed shards: {} (expected 0)", iteration, searchResponse.getFailedShards()); if (searchResponse.getShardFailures() != null && searchResponse.getShardFailures().length > 0) { logger.info("iteration [{}] - shard failures: {}", iteration, Arrays.toString(searchResponse.getShardFailures())); } - logger.info("iteration [{}] - returned documents: {} (expected {})", iteration, + logger.info("iteration [{}] - returned documents: {} (expected {})", iteration, searchResponse.getHits().getTotalHits().value, numberOfDocs); } diff --git a/server/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java b/server/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java index 3096c7b9e4f13..4fab90cf4e3ed 100644 --- a/server/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java +++ b/server/src/test/java/org/elasticsearch/recovery/SimpleRecoveryIT.java @@ -72,13 +72,13 @@ public void testSimpleRecovery() throws Exception { GetResponse getResult; for (int i = 0; i < 5; i++) { - getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("1", "test"))); - getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("1", "test"))); - getResult = client().get(getRequest("test").type("type1").id("2")).actionGet(); + getResult = client().get(getRequest("test").id("2")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("2", "test"))); - getResult = client().get(getRequest("test").type("type1").id("2")).actionGet(); + getResult = client().get(getRequest("test").id("2")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("2", "test"))); } @@ -89,17 +89,17 @@ public void testSimpleRecovery() throws Exception { ensureGreen(); for (int i = 0; i < 5; i++) { - getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("1", "test"))); - getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("1", "test"))); - getResult = client().get(getRequest("test").type("type1").id("1")).actionGet(); + getResult = client().get(getRequest("test").id("1")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("1", "test"))); - getResult = client().get(getRequest("test").type("type1").id("2")).actionGet(); + getResult = client().get(getRequest("test").id("2")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("2", "test"))); - getResult = client().get(getRequest("test").type("type1").id("2")).actionGet(); + getResult = client().get(getRequest("test").id("2")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("2", "test"))); - getResult = client().get(getRequest("test").type("type1").id("2")).actionGet(); + getResult = client().get(getRequest("test").id("2")).actionGet(); assertThat(getResult.getSourceAsString(), equalTo(source("2", "test"))); } } diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetSourceActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetSourceActionTests.java index a42cfce31b5c9..924ead60c3315 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetSourceActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestGetSourceActionTests.java @@ -25,7 +25,6 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.index.get.GetResult; import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestRequest.Method; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.action.document.RestGetSourceAction.RestGetSourceResponseListener; import org.elasticsearch.test.rest.FakeRestChannel; @@ -34,10 +33,6 @@ import org.junit.AfterClass; import org.junit.Before; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - import static java.util.Collections.emptyMap; import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; import static org.elasticsearch.rest.RestStatus.OK; @@ -60,42 +55,10 @@ public static void cleanupReferences() { channel = null; listener = null; } - - /** - * test deprecation is logged if type is used in path - */ - public void testTypeInPath() { - for (Method method : Arrays.asList(Method.GET, Method.HEAD)) { - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(method) - .withPath("/some_index/some_type/id/_source") - .build(); - dispatchRequest(request); - assertWarnings(RestGetSourceAction.TYPES_DEPRECATION_MESSAGE); - } - } - - /** - * test deprecation is logged if type is used as parameter - */ - public void testTypeParameter() { - Map params = new HashMap<>(); - params.put("type", "some_type"); - for (Method method : Arrays.asList(Method.GET, Method.HEAD)) { - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(method) - .withPath("/some_index/_source/id") - .withParams(params) - .build(); - dispatchRequest(request); - assertWarnings(RestGetSourceAction.TYPES_DEPRECATION_MESSAGE); - } - } - public void testRestGetSourceAction() throws Exception { final BytesReference source = new BytesArray("{\"foo\": \"bar\"}"); final GetResponse response = - new GetResponse(new GetResult("index1", "_doc", "1", UNASSIGNED_SEQ_NO, 0, -1, true, source, emptyMap(), null)); + new GetResponse(new GetResult("index1", "1", UNASSIGNED_SEQ_NO, 0, -1, true, source, emptyMap(), null)); final RestResponse restResponse = listener.buildResponse(response); @@ -106,19 +69,19 @@ public void testRestGetSourceAction() throws Exception { public void testRestGetSourceActionWithMissingDocument() { final GetResponse response = - new GetResponse(new GetResult("index1", "_doc", "1", UNASSIGNED_SEQ_NO, 0, -1, false, null, emptyMap(), null)); + new GetResponse(new GetResult("index1", "1", UNASSIGNED_SEQ_NO, 0, -1, false, null, emptyMap(), null)); final ResourceNotFoundException exception = expectThrows(ResourceNotFoundException.class, () -> listener.buildResponse(response)); - assertThat(exception.getMessage(), equalTo("Document not found [index1]/[_doc]/[1]")); + assertThat(exception.getMessage(), equalTo("Document not found [index1]/[1]")); } public void testRestGetSourceActionWithMissingDocumentSource() { final GetResponse response = - new GetResponse(new GetResult("index1", "_doc", "1", UNASSIGNED_SEQ_NO, 0, -1, true, null, emptyMap(), null)); + new GetResponse(new GetResult("index1", "1", UNASSIGNED_SEQ_NO, 0, -1, true, null, emptyMap(), null)); final ResourceNotFoundException exception = expectThrows(ResourceNotFoundException.class, () -> listener.buildResponse(response)); - assertThat(exception.getMessage(), equalTo("Source not found [index1]/[_doc]/[1]")); + assertThat(exception.getMessage(), equalTo("Source not found [index1]/[1]")); } } 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 deleted file mode 100644 index da5c7e1fdfd6d..0000000000000 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestMultiGetActionTests.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.rest.action.document; - -import org.elasticsearch.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.test.rest.FakeRestRequest; -import org.elasticsearch.test.rest.RestActionTestCase; -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/server/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java index 1919b7e6a9ae4..8269d3ce0e0f1 100644 --- a/server/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java @@ -52,16 +52,16 @@ public void testAliasCrudRouting() throws Exception { client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true)); } logger.info("--> verifying get with routing alias, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true)); } logger.info("--> updating with id [1] and routing through alias"); @@ -70,8 +70,8 @@ public void testAliasCrudRouting() throws Exception { .setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2") .execute().actionGet(); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareGet("alias0", "type1", "1") + assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("alias0", "1") .execute() .actionGet() .getSourceAsMap() @@ -83,29 +83,29 @@ public void testAliasCrudRouting() throws Exception { logger.info("--> deleting with no routing, should not delete anything"); client().prepareDelete("test", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); - assertThat(client().prepareGet("test", "type1", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true)); } logger.info("--> deleting with routing alias, should delete"); client().prepareDelete("alias0", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); - assertThat(client().prepareGet("test", "type1", "1").setRouting("0").execute().actionGet().isExists(), equalTo(false)); - assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> indexing with id [1], and routing [0] using alias"); client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").setRouting("0").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true)); } } @@ -122,11 +122,11 @@ public void testAliasSearchRouting() throws Exception { client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("alias0", "1").execute().actionGet().isExists(), equalTo(true)); } logger.info("--> search with no routing, should fine one"); @@ -399,22 +399,22 @@ public void testAliasSearchRoutingWithTwoIndices() throws Exception { client().prepareIndex("alias-a0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test-a", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test-a", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("alias-a0", "type1", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("alias-a0", "1").execute().actionGet().isExists(), equalTo(true)); } logger.info("--> indexing with id [0], and routing [1] using alias to test-b"); client().prepareIndex("alias-b1", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test-a", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test-a", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("alias-b1", "type1", "1").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("alias-b1", "1").execute().actionGet().isExists(), equalTo(true)); } @@ -544,7 +544,7 @@ public void testIndexingAliasesOverTime() throws Exception { logger.info("--> verifying get and search with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true)); assertThat(client().prepareSearch("alias") .setQuery(QueryBuilders.matchAllQuery()) .execute() @@ -591,8 +591,8 @@ public void testIndexingAliasesOverTime() throws Exception { logger.info("--> verifying get and search with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareGet("test", "type1", "1").setRouting("4").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").setRouting("4").execute().actionGet().isExists(), equalTo(true)); assertThat(client().prepareSearch("alias") .setQuery(QueryBuilders.matchAllQuery()) .execute() diff --git a/server/src/test/java/org/elasticsearch/routing/PartitionedRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/PartitionedRoutingIT.java index 248ced106b311..39f330be8ab80 100644 --- a/server/src/test/java/org/elasticsearch/routing/PartitionedRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/PartitionedRoutingIT.java @@ -172,7 +172,7 @@ private void verifyGets(String index, Map> routingToDocument String routing = routingEntry.getKey(); for (String id : routingEntry.getValue()) { - assertTrue(client().prepareGet(index, "type", id).setRouting(routing).execute().actionGet().isExists()); + assertTrue(client().prepareGet(index, id).setRouting(routing).execute().actionGet().isExists()); } } } diff --git a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java index 38ed0b819d4ab..fd7882cf7774e 100644 --- a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -85,11 +85,11 @@ public void testSimpleCrudRouting() throws Exception { .get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1") + assertThat(client().prepareGet("test", "1") .setRouting(routingValue) .execute() .actionGet() @@ -99,8 +99,8 @@ public void testSimpleCrudRouting() throws Exception { logger.info("--> deleting with no routing, should not delete anything"); client().prepareDelete("test", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); - assertThat(client().prepareGet("test", "type1", "1") + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1") .setRouting(routingValue) .execute() .actionGet() @@ -110,8 +110,8 @@ public void testSimpleCrudRouting() throws Exception { logger.info("--> deleting with routing, should delete"); client().prepareDelete("test", "type1", "1").setRouting(routingValue).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); - assertThat(client().prepareGet("test", "type1", "1") + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1") .setRouting(routingValue) .execute() .actionGet() @@ -126,11 +126,11 @@ public void testSimpleCrudRouting() throws Exception { .get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1") + assertThat(client().prepareGet("test", "1") .setRouting(routingValue) .execute() .actionGet() @@ -151,11 +151,11 @@ public void testSimpleSearchRouting() { .get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1") + assertThat(client().prepareGet("test", "1") .setRouting(routingValue) .execute() .actionGet() @@ -361,7 +361,7 @@ public void testRequiredRoutingCrudApis() throws Exception { logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { assertThat(client() - .prepareGet(indexOrAlias(), "type1", "1") + .prepareGet(indexOrAlias(), "1") .setRouting(routingValue) .execute() .actionGet() @@ -378,14 +378,14 @@ public void testRequiredRoutingCrudApis() throws Exception { for (int i = 0; i < 5; i++) { try { - client().prepareGet(indexOrAlias(), "type1", "1").execute().actionGet().isExists(); + client().prepareGet(indexOrAlias(), "1").execute().actionGet().isExists(); fail("get with missing routing when routing is required should fail"); } catch (RoutingMissingException e) { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); } assertThat(client() - .prepareGet(indexOrAlias(), "type1", "1") + .prepareGet(indexOrAlias(), "1") .setRouting(routingValue) .execute() .actionGet() @@ -410,13 +410,13 @@ public void testRequiredRoutingCrudApis() throws Exception { for (int i = 0; i < 5; i++) { try { - client().prepareGet(indexOrAlias(), "type1", "1").execute().actionGet().isExists(); + client().prepareGet(indexOrAlias(), "1").execute().actionGet().isExists(); fail(); } catch (RoutingMissingException e) { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); } - GetResponse getResponse = client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet(); + GetResponse getResponse = client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getSourceAsMap().get("field"), equalTo("value2")); } @@ -425,14 +425,14 @@ public void testRequiredRoutingCrudApis() throws Exception { for (int i = 0; i < 5; i++) { try { - client().prepareGet(indexOrAlias(), "type1", "1").execute().actionGet().isExists(); + client().prepareGet(indexOrAlias(), "1").execute().actionGet().isExists(); fail(); } catch (RoutingMissingException e) { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); } assertThat(client() - .prepareGet(indexOrAlias(), "type1", "1") + .prepareGet(indexOrAlias(), "1") .setRouting(routingValue) .execute() .actionGet() @@ -553,7 +553,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { .setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); logger.info("--> verifying get with id [1] with routing [0], should succeed"); - assertThat(client().prepareGet(indexOrAlias(), "type1", "1") + assertThat(client().prepareGet(indexOrAlias(), "1") .setRouting(routingValue) .execute() .actionGet() @@ -561,7 +561,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { logger.info("--> verifying get with id [1], with no routing, should fail"); try { - client().prepareGet(indexOrAlias(), "type1", "1").get(); + client().prepareGet(indexOrAlias(), "1").get(); fail(); } catch (RoutingMissingException e) { assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); @@ -611,8 +611,8 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { logger.info("--> verifying mget with ids [1,2], with routing [0], should succeed"); MultiGetResponse multiGetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").routing("0")) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").routing("0")).get(); + .add(new MultiGetRequest.Item(indexOrAlias(), "1").routing("0")) + .add(new MultiGetRequest.Item(indexOrAlias(), "2").routing("0")).get(); assertThat(multiGetResponse.getResponses().length, equalTo(2)); assertThat(multiGetResponse.getResponses()[0].isFailed(), equalTo(false)); assertThat(multiGetResponse.getResponses()[0].getResponse().getId(), equalTo("1")); @@ -621,8 +621,8 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { logger.info("--> verifying mget with ids [1,2], with no routing, should fail"); multiGetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1")) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2")).get(); + .add(new MultiGetRequest.Item(indexOrAlias(), "1")) + .add(new MultiGetRequest.Item(indexOrAlias(), "2")).get(); assertThat(multiGetResponse.getResponses().length, equalTo(2)); assertThat(multiGetResponse.getResponses()[0].isFailed(), equalTo(true)); assertThat(multiGetResponse.getResponses()[0].getFailure().getId(), equalTo("1")); diff --git a/server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java b/server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java index f9f2d8525fb4c..1fe6d42bef0f6 100644 --- a/server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java +++ b/server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java @@ -96,7 +96,7 @@ public void testNullShape() throws Exception { client().prepareIndex("test", "type1", "aNullshape").setSource("{\"location\": null}", XContentType.JSON) .setRefreshPolicy(IMMEDIATE).get(); - GetResponse result = client().prepareGet("test", "type1", "aNullshape").get(); + GetResponse result = client().prepareGet("test", "aNullshape").get(); assertThat(result.getField("location"), nullValue()); } diff --git a/server/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java b/server/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java index d1d4f26f46f90..7cd9899ba0ac0 100644 --- a/server/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java +++ b/server/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java @@ -84,7 +84,7 @@ public void testSimpleNested() throws Exception { .endObject()).get(); waitForRelocation(ClusterHealthStatus.GREEN); - GetResponse getResponse = client().prepareGet("test", "type1", "1").get(); + GetResponse getResponse = client().prepareGet("test", "1").get(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getSourceAsBytes(), notNullValue()); refresh(); @@ -185,7 +185,7 @@ public void testMultiNested() throws Exception { .endArray() .endObject()).get(); - GetResponse getResponse = client().prepareGet("test", "type1", "1").get(); + GetResponse getResponse = client().prepareGet("test", "1").get(); assertThat(getResponse.isExists(), equalTo(true)); waitForRelocation(ClusterHealthStatus.GREEN); refresh(); diff --git a/server/src/test/java/org/elasticsearch/search/sort/GeoDistanceIT.java b/server/src/test/java/org/elasticsearch/search/sort/GeoDistanceIT.java index 4d750c4d43828..c621f778bc4b6 100644 --- a/server/src/test/java/org/elasticsearch/search/sort/GeoDistanceIT.java +++ b/server/src/test/java/org/elasticsearch/search/sort/GeoDistanceIT.java @@ -393,7 +393,7 @@ public void testGeoDistanceFilter() throws IOException { assertAcked(prepareCreate("locations").setSettings(settings).addMapping("location", mapping)); client().prepareIndex("locations", "location", "1").setCreate(true).setSource(source).get(); refresh(); - client().prepareGet("locations", "location", "1").get(); + client().prepareGet("locations", "1").get(); SearchResponse result = client().prepareSearch("locations").setQuery(QueryBuilders.matchAllQuery()) .setPostFilter(QueryBuilders.geoDistanceQuery("pin").geoDistance(GeoDistance.ARC).point(lat, lon).distance("1m")).get(); diff --git a/server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java index b11cf9107e30b..709bd6c8061f2 100644 --- a/server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java +++ b/server/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java @@ -331,13 +331,12 @@ public void testSingleGetAfterRestore() throws Exception { String absolutePath = randomRepoPath().toAbsolutePath().toString(); logger.info("Path [{}]", absolutePath); String restoredIndexName = indexName + "-restored"; - String typeName = "actions"; String expectedValue = "expected"; Client client = client(); // Write a document String docId = Integer.toString(randomInt()); - index(indexName, typeName, docId, "value", expectedValue); + index(indexName, "_doc", docId, "value", expectedValue); logger.info("--> creating repository"); assertAcked(client.admin().cluster().preparePutRepository(repoName) @@ -362,7 +361,7 @@ public void testSingleGetAfterRestore() throws Exception { .get(); assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0)); - assertThat(client.prepareGet(restoredIndexName, typeName, docId).get().isExists(), equalTo(true)); + assertThat(client.prepareGet(restoredIndexName, docId).get().isExists(), equalTo(true)); } public void testFreshIndexUUID() throws InterruptedException { @@ -3700,16 +3699,15 @@ public void testParallelRestoreOperations() { logger.info("Path [{}]", absolutePath); String restoredIndexName1 = indexName1 + "-restored"; String restoredIndexName2 = indexName2 + "-restored"; - String typeName = "actions"; String expectedValue = "expected"; Client client = client(); // Write a document String docId = Integer.toString(randomInt()); - index(indexName1, typeName, docId, "value", expectedValue); + index(indexName1, "_doc", docId, "value", expectedValue); String docId2 = Integer.toString(randomInt()); - index(indexName2, typeName, docId2, "value", expectedValue); + index(indexName2, "_doc", docId2, "value", expectedValue); logger.info("--> creating repository"); assertAcked(client.admin().cluster().preparePutRepository(repoName) @@ -3749,8 +3747,8 @@ public void testParallelRestoreOperations() { assertThat(restoreSnapshotResponse1.status(), equalTo(RestStatus.ACCEPTED)); assertThat(restoreSnapshotResponse2.status(), equalTo(RestStatus.ACCEPTED)); ensureGreen(restoredIndexName1, restoredIndexName2); - assertThat(client.prepareGet(restoredIndexName1, typeName, docId).get().isExists(), equalTo(true)); - assertThat(client.prepareGet(restoredIndexName2, typeName, docId2).get().isExists(), equalTo(true)); + assertThat(client.prepareGet(restoredIndexName1, docId).get().isExists(), equalTo(true)); + assertThat(client.prepareGet(restoredIndexName2, docId2).get().isExists(), equalTo(true)); } public void testParallelRestoreOperationsFromSingleSnapshot() throws Exception { @@ -3762,16 +3760,15 @@ public void testParallelRestoreOperationsFromSingleSnapshot() throws Exception { logger.info("Path [{}]", absolutePath); String restoredIndexName1 = indexName1 + "-restored"; String restoredIndexName2 = indexName2 + "-restored"; - String typeName = "actions"; String expectedValue = "expected"; Client client = client(); // Write a document String docId = Integer.toString(randomInt()); - index(indexName1, typeName, docId, "value", expectedValue); + index(indexName1, "_doc", docId, "value", expectedValue); String docId2 = Integer.toString(randomInt()); - index(indexName2, typeName, docId2, "value", expectedValue); + index(indexName2, "_doc", docId2, "value", expectedValue); logger.info("--> creating repository"); assertAcked(client.admin().cluster().preparePutRepository(repoName) @@ -3807,8 +3804,8 @@ public void testParallelRestoreOperationsFromSingleSnapshot() throws Exception { assertThat(restoreSnapshotResponse1.get().status(), equalTo(RestStatus.ACCEPTED)); assertThat(restoreSnapshotResponse2.get().status(), equalTo(RestStatus.ACCEPTED)); ensureGreen(restoredIndexName1, restoredIndexName2); - assertThat(client.prepareGet(restoredIndexName1, typeName, docId).get().isExists(), equalTo(true)); - assertThat(client.prepareGet(restoredIndexName2, typeName, sameSourceIndex ? docId : docId2).get().isExists(), equalTo(true)); + assertThat(client.prepareGet(restoredIndexName1, docId).get().isExists(), equalTo(true)); + assertThat(client.prepareGet(restoredIndexName2, sameSourceIndex ? docId : docId2).get().isExists(), equalTo(true)); } public void testRestoreIncreasesPrimaryTerms() { diff --git a/server/src/test/java/org/elasticsearch/update/UpdateIT.java b/server/src/test/java/org/elasticsearch/update/UpdateIT.java index 0bd5851e35b45..5d213cb27bbfb 100644 --- a/server/src/test/java/org/elasticsearch/update/UpdateIT.java +++ b/server/src/test/java/org/elasticsearch/update/UpdateIT.java @@ -161,7 +161,7 @@ public void testUpsert() throws Exception { assertThat(updateResponse.getIndex(), equalTo("test")); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("1")); } @@ -173,7 +173,7 @@ public void testUpsert() throws Exception { assertThat(updateResponse.getIndex(), equalTo("test")); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("2")); } } @@ -202,7 +202,7 @@ public void testScriptedUpsert() throws Exception { assertThat(updateResponse.getIndex(), equalTo("test")); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("balance").toString(), equalTo("9")); } @@ -216,7 +216,7 @@ public void testScriptedUpsert() throws Exception { assertThat(updateResponse.getIndex(), equalTo("test")); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("balance").toString(), equalTo("7")); } } @@ -310,7 +310,7 @@ public void testUpdate() throws Exception { assertThat(updateResponse.getIndex(), equalTo("test")); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("2")); } @@ -324,7 +324,7 @@ public void testUpdate() throws Exception { assertThat(updateResponse.getIndex(), equalTo("test")); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("5")); } @@ -337,7 +337,7 @@ public void testUpdate() throws Exception { assertThat(updateResponse.getIndex(), equalTo("test")); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("5")); } @@ -350,7 +350,7 @@ public void testUpdate() throws Exception { assertThat(updateResponse.getIndex(), equalTo("test")); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(false)); } @@ -374,7 +374,7 @@ public void testUpdate() throws Exception { client().prepareUpdate(indexOrAlias(), "type1", "1") .setDoc(XContentFactory.jsonBuilder().startObject().field("field2", 2).endObject()).execute().actionGet(); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("1")); assertThat(getResponse.getSourceAsMap().get("field2").toString(), equalTo("2")); } @@ -383,7 +383,7 @@ public void testUpdate() throws Exception { client().prepareUpdate(indexOrAlias(), "type1", "1") .setDoc(XContentFactory.jsonBuilder().startObject().field("field", 3).endObject()).execute().actionGet(); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); assertThat(getResponse.getSourceAsMap().get("field").toString(), equalTo("3")); assertThat(getResponse.getSourceAsMap().get("field2").toString(), equalTo("2")); } @@ -402,7 +402,7 @@ public void testUpdate() throws Exception { client().prepareUpdate(indexOrAlias(), "type1", "1") .setDoc(XContentFactory.jsonBuilder().startObject().field("map", testMap3).endObject()).execute().actionGet(); for (int i = 0; i < 5; i++) { - GetResponse getResponse = client().prepareGet("test", "type1", "1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "1").execute().actionGet(); Map map1 = (Map) getResponse.getSourceAsMap().get("map"); assertThat(map1.size(), equalTo(3)); assertThat(map1.containsKey("map1"), equalTo(true)); @@ -521,7 +521,7 @@ public void testContextVariables() throws Exception { assertEquals(2, updateResponse.getVersion()); - GetResponse getResponse = client().prepareGet("test", "type1", "id1").setRouting("routing1").execute().actionGet(); + GetResponse getResponse = client().prepareGet("test", "id1").setRouting("routing1").execute().actionGet(); Map updateContext = (Map) getResponse.getSourceAsMap().get("update_context"); assertEquals("test", updateContext.get("_index")); assertEquals("type1", updateContext.get("_type")); @@ -536,7 +536,7 @@ public void testContextVariables() throws Exception { assertEquals(2, updateResponse.getVersion()); - getResponse = client().prepareGet("test", "type1", "id2").execute().actionGet(); + getResponse = client().prepareGet("test", "id2").execute().actionGet(); updateContext = (Map) getResponse.getSourceAsMap().get("update_context"); assertEquals("test", updateContext.get("_index")); assertEquals("type1", updateContext.get("_type")); @@ -610,7 +610,7 @@ public void run() { } assertThat(failures.size(), equalTo(0)); for (int i = 0; i < numberOfUpdatesPerThread; i++) { - GetResponse response = client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet(); + GetResponse response = client().prepareGet("test", Integer.toString(i)).execute().actionGet(); assertThat(response.getId(), equalTo(Integer.toString(i))); assertThat(response.isExists(), equalTo(true)); assertThat(response.getVersion(), equalTo((long) numberOfThreads)); @@ -821,7 +821,7 @@ private void waitForOutstandingRequests(TimeValue timeOut, Semaphore requestsOut for (int i = 0; i < numberOfIdsPerThread; ++i) { int totalFailures = 0; - GetResponse response = client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet(); + GetResponse response = client().prepareGet("test", Integer.toString(i)).execute().actionGet(); if (response.isExists()) { assertThat(response.getId(), equalTo(Integer.toString(i))); int expectedVersion = (numberOfThreads * numberOfUpdatesPerId * 2) + 1; diff --git a/server/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java b/server/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java index 8edcbd45a8cdc..a51436b269e79 100644 --- a/server/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java +++ b/server/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java @@ -65,9 +65,9 @@ public void onFailure(Exception e) { client().admin().indices().prepareRefresh().execute().actionGet(); logger.info("done indexing, check all have the same field value"); - Map masterSource = client().prepareGet("test", "type1", "1").execute().actionGet().getSourceAsMap(); + Map masterSource = client().prepareGet("test", "1").execute().actionGet().getSourceAsMap(); for (int i = 0; i < (cluster().size() * 5); i++) { - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().getSourceAsMap(), equalTo(masterSource)); + assertThat(client().prepareGet("test", "1").execute().actionGet().getSourceAsMap(), equalTo(masterSource)); } } } diff --git a/server/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java b/server/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java index f42857216f8ca..4f653300f4892 100644 --- a/server/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java +++ b/server/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java @@ -98,7 +98,7 @@ public void testExternalGTE() throws Exception { refresh(); } for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(14L)); + assertThat(client().prepareGet("test", "1").get().getVersion(), equalTo(14L)); } // deleting with a lower version fails. @@ -146,7 +146,7 @@ public void testExternalVersioning() throws Exception { refresh(); } for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(14L)); + assertThat(client().prepareGet("test", "1").execute().actionGet().getVersion(), equalTo(14L)); } // deleting with a lower version fails. @@ -256,7 +256,7 @@ public void testCompareAndSet() { client().admin().indices().prepareRefresh().execute().actionGet(); for (int i = 0; i < 10; i++) { - final GetResponse response = client().prepareGet("test", "type", "1").get(); + final GetResponse response = client().prepareGet("test", "1").get(); assertThat(response.getSeqNo(), equalTo(1L)); assertThat(response.getPrimaryTerm(), equalTo(1L)); } @@ -313,7 +313,7 @@ public void testSimpleVersioningWithFlush() throws Exception { assertThrows(client().prepareDelete("test", "type", "1").setIfSeqNo(0).setIfPrimaryTerm(1), VersionConflictEngineException.class); for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(2L)); + assertThat(client().prepareGet("test", "1").execute().actionGet().getVersion(), equalTo(2L)); } client().admin().indices().prepareRefresh().execute().actionGet(); @@ -667,7 +667,7 @@ public void run() { } else { expected = -1; } - long actualVersion = client().prepareGet("test", "type", id).execute().actionGet().getVersion(); + long actualVersion = client().prepareGet("test", id).execute().actionGet().getVersion(); if (actualVersion != expected) { logger.error("--> FAILED: idVersion={} actualVersion= {}", idVersion, actualVersion); failed = true; @@ -735,7 +735,7 @@ public void testDeleteNotLost() throws Exception { // Real-time get should reflect delete: assertThat("doc should have been deleted", client() - .prepareGet("test", "type", "id") + .prepareGet("test", "id") .execute() .actionGet() .getVersion(), @@ -756,7 +756,7 @@ public void testDeleteNotLost() throws Exception { // Real-time get should still reflect delete: assertThat("doc should have been deleted", client() - .prepareGet("test", "type", "id") + .prepareGet("test", "id") .execute() .actionGet() .getVersion(), @@ -804,7 +804,7 @@ public void testGCDeletesZero() throws Exception { // Real-time get should reflect delete even though index.gc_deletes is 0: assertThat("doc should have been deleted", client() - .prepareGet("test", "type", "id") + .prepareGet("test", "id") .execute() .actionGet() .getVersion(), diff --git a/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java index b67108a16c19b..4535a87962271 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java @@ -750,7 +750,7 @@ public static Term newUid(ParsedDocument doc) { } protected Engine.Get newGet(boolean realtime, ParsedDocument doc) { - return new Engine.Get(realtime, false, doc.type(), doc.id(), newUid(doc)); + return new Engine.Get(realtime, false, doc.id(), newUid(doc)); } protected Engine.Index indexForDoc(ParsedDocument doc) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java index a06696169de45..96872c6710d97 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java +++ b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java @@ -257,8 +257,8 @@ public static void assertHitCount(SearchResponse countResponse, long expectedHit } public static void assertExists(GetResponse response) { - String message = String.format(Locale.ROOT, "Expected %s/%s/%s to exist, but does not", - response.getIndex(), response.getType(), response.getId()); + String message = String.format(Locale.ROOT, "Expected %s/%s to exist, but does not", + response.getIndex(), response.getId()); assertThat(message, response.isExists(), is(true)); } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java index 14385bf4d6812..76e9751626bd9 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java @@ -445,7 +445,7 @@ public void testFollowerMappingIsUpdated() throws IOException { } private void assertExpectedDocument(String followerIndex, final int value) { - final GetResponse getResponse = followerClient().prepareGet(followerIndex, "doc", Integer.toString(value)).get(); + final GetResponse getResponse = followerClient().prepareGet(followerIndex, Integer.toString(value)).get(); assertTrue("Doc with id [" + value + "] is missing", getResponse.isExists()); assertTrue((getResponse.getSource().containsKey("f"))); assertThat(getResponse.getSource().get("f"), equalTo(value)); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java index 2f6af23f7ad92..7676fb5f7da0f 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java @@ -1067,7 +1067,7 @@ private String getRetentionLeaseId(String followerIndex, String followerUUID, St } private void assertExpectedDocument(final String followerIndex, final int value) { - final GetResponse getResponse = followerClient().prepareGet(followerIndex, "doc", Integer.toString(value)).get(); + final GetResponse getResponse = followerClient().prepareGet(followerIndex, Integer.toString(value)).get(); assertTrue("doc with id [" + value + "] is missing", getResponse.isExists()); assertTrue((getResponse.getSource().containsKey("f"))); assertThat(getResponse.getSource().get("f"), equalTo(value)); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java index 0c421cef21975..4a6c00505ca09 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java @@ -202,7 +202,7 @@ public void testFollowIndex() throws Exception { for (String docId : indexer.getIds()) { assertBusy(() -> { - final GetResponse getResponse = followerClient().prepareGet("index2", "_doc", docId).get(); + final GetResponse getResponse = followerClient().prepareGet("index2", docId).get(); assertTrue("Doc with id [" + docId + "] is missing", getResponse.isExists()); }); } @@ -229,7 +229,7 @@ public void testFollowIndex() throws Exception { for (String docId : indexer.getIds()) { assertBusy(() -> { - final GetResponse getResponse = followerClient().prepareGet("index2", "_doc", docId).get(); + final GetResponse getResponse = followerClient().prepareGet("index2", docId).get(); assertTrue("Doc with id [" + docId + "] is missing", getResponse.isExists()); }); } @@ -561,7 +561,7 @@ public void testFollowIndexWithNestedField() throws Exception { for (int i = 0; i < numDocs; i++) { int value = i; assertBusy(() -> { - final GetResponse getResponse = followerClient().prepareGet("index2", "doc", Integer.toString(value)).get(); + final GetResponse getResponse = followerClient().prepareGet("index2", Integer.toString(value)).get(); assertTrue(getResponse.isExists()); assertTrue((getResponse.getSource().containsKey("field"))); assertThat(XContentMapValues.extractValue("objects.field", getResponse.getSource()), @@ -1315,7 +1315,7 @@ public void testUpdateRemoteConfigsDuringFollowing() throws Exception { for (String docId : indexer.getIds()) { assertBusy(() -> { - final GetResponse getResponse = followerClient().prepareGet("index2", "_doc", docId).get(); + final GetResponse getResponse = followerClient().prepareGet("index2", docId).get(); assertTrue("Doc with id [" + docId + "] is missing", getResponse.isExists()); }); } @@ -1453,7 +1453,7 @@ private CheckedRunnable assertExpectedDocumentRunnable(final int valu private CheckedRunnable assertExpectedDocumentRunnable(final int key, final int value) { return () -> { - final GetResponse getResponse = followerClient().prepareGet("index2", "doc", Integer.toString(key)).get(); + final GetResponse getResponse = followerClient().prepareGet("index2", Integer.toString(key)).get(); assertTrue("Doc with id [" + key + "] is missing", getResponse.isExists()); assertTrue((getResponse.getSource().containsKey("f"))); assertThat(getResponse.getSource().get("f"), equalTo(value)); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java index cba7a7f634d2e..97f1fce796351 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java @@ -199,8 +199,7 @@ public final class ReservedFieldNames { ExponentialAverageCalculationContext.PREVIOUS_EXPONENTIAL_AVERAGE_MS.getPreferredName(), GetResult._ID, - GetResult._INDEX, - GetResult._TYPE + GetResult._INDEX }; /** @@ -315,7 +314,6 @@ public final class ReservedFieldNames { GetResult._ID, GetResult._INDEX, - GetResult._TYPE }; /** diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/SourceOnlySnapshotShardTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/SourceOnlySnapshotShardTests.java index 34acf179c3fbf..65b85df36af00 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/SourceOnlySnapshotShardTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/SourceOnlySnapshotShardTests.java @@ -233,7 +233,7 @@ public void testRestoreMinmal() throws IOException { restoredShard.refresh("test"); assertEquals(restoredShard.docStats().getCount(), shard.docStats().getCount()); EngineException engineException = expectThrows(EngineException.class, () -> restoredShard.get( - new Engine.Get(false, false, "_doc", Integer.toString(0), new Term("_id", Uid.encodeId(Integer.toString(0)))))); + new Engine.Get(false, false, Integer.toString(0), new Term("_id", Uid.encodeId(Integer.toString(0)))))); assertEquals(engineException.getCause().getMessage(), "_source only indices can't be searched or filtered"); SeqNoStats seqNoStats = restoredShard.seqNoStats(); assertEquals(seqNoStats.getMaxSeqNo(), seqNoStats.getLocalCheckpoint()); @@ -259,7 +259,7 @@ public void testRestoreMinmal() throws IOException { } for (int i = 0; i < numInitialDocs; i++) { - Engine.Get get = new Engine.Get(false, false, "_doc", Integer.toString(i), new Term("_id", Uid.encodeId(Integer.toString(i)))); + Engine.Get get = new Engine.Get(false, false, Integer.toString(i), new Term("_id", Uid.encodeId(Integer.toString(i)))); Engine.GetResult original = shard.get(get); Engine.GetResult restored = targetShard.get(get); assertEquals(original.exists(), restored.exists()); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappingsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappingsTests.java index 13ce6f2ab610d..421e04d814f8e 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappingsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappingsTests.java @@ -85,8 +85,7 @@ public class ElasticsearchMappingsTests extends ESTestCase { private static List INTERNAL_FIELDS = Arrays.asList( GetResult._ID, - GetResult._INDEX, - GetResult._TYPE + GetResult._INDEX ); public void testResultsMapppingReservedFields() throws Exception { diff --git a/x-pack/plugin/frozen-indices/src/test/java/org/elasticsearch/index/engine/FrozenIndexTests.java b/x-pack/plugin/frozen-indices/src/test/java/org/elasticsearch/index/engine/FrozenIndexTests.java index 4453830f30566..a6cd886bf812e 100644 --- a/x-pack/plugin/frozen-indices/src/test/java/org/elasticsearch/index/engine/FrozenIndexTests.java +++ b/x-pack/plugin/frozen-indices/src/test/java/org/elasticsearch/index/engine/FrozenIndexTests.java @@ -123,7 +123,7 @@ public void testSearchAndGetAPIsAreThrottled() throws InterruptedException, IOEx numRefreshes++; switch (randomIntBetween(0, 3)) { case 0: - client().prepareGet("index", "_doc", "" + randomIntBetween(0, 9)).execute(ActionListener.wrap(latch::countDown)); + client().prepareGet("index", "" + randomIntBetween(0, 9)).execute(ActionListener.wrap(latch::countDown)); break; case 1: client().prepareSearch("index").setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED) diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java index b325d3b33ca61..27cab34b7237a 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/MockClientBuilder.java @@ -143,11 +143,11 @@ public MockClientBuilder addIndicesDeleteResponse(String index, boolean exists, return this; } - public MockClientBuilder prepareGet(String index, String type, String id, GetResponse response) { + public MockClientBuilder prepareGet(String index, String id, GetResponse response) { GetRequestBuilder getRequestBuilder = mock(GetRequestBuilder.class); when(getRequestBuilder.get()).thenReturn(response); when(getRequestBuilder.setFetchSource(false)).thenReturn(getRequestBuilder); - when(client.prepareGet(index, type, id)).thenReturn(getRequestBuilder); + when(client.prepareGet(index, id)).thenReturn(getRequestBuilder); return this; } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java index d594404e9c284..b936d7902e78d 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java @@ -18,7 +18,6 @@ public void testIsValidFieldName() { assertFalse(ReservedFieldNames.isValidFieldName("actual.host")); assertFalse(ReservedFieldNames.isValidFieldName(AnomalyRecord.BUCKET_SPAN.getPreferredName())); assertFalse(ReservedFieldNames.isValidFieldName(GetResult._INDEX)); - assertFalse(ReservedFieldNames.isValidFieldName(GetResult._TYPE)); assertFalse(ReservedFieldNames.isValidFieldName(GetResult._ID)); } } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java index 72b5217692a3a..096f75ab04331 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java @@ -71,6 +71,7 @@ import org.elasticsearch.xpack.core.security.user.User; import org.elasticsearch.xpack.security.support.SecurityIndexManager; +import javax.crypto.SecretKeyFactory; import java.io.Closeable; import java.io.IOException; import java.io.UncheckedIOException; @@ -94,8 +95,6 @@ import java.util.function.Function; import java.util.stream.Collectors; -import javax.crypto.SecretKeyFactory; - import static org.elasticsearch.index.mapper.MapperService.SINGLE_MAPPING_NAME; import static org.elasticsearch.search.SearchService.DEFAULT_KEEPALIVE_SETTING; import static org.elasticsearch.xpack.core.ClientHelper.SECURITY_ORIGIN; @@ -332,7 +331,7 @@ void authenticateWithApiKeyIfPresent(ThreadContext ctx, ActionListenerwrap(response -> { diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java index 6472220482966..a2082e3bd09c0 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java @@ -141,9 +141,9 @@ import static org.elasticsearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK; import static org.elasticsearch.index.mapper.MapperService.SINGLE_MAPPING_NAME; import static org.elasticsearch.search.SearchService.DEFAULT_KEEPALIVE_SETTING; +import static org.elasticsearch.threadpool.ThreadPool.Names.GENERIC; import static org.elasticsearch.xpack.core.ClientHelper.SECURITY_ORIGIN; import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin; -import static org.elasticsearch.threadpool.ThreadPool.Names.GENERIC; /** * Service responsible for the creation, validation, and other management of {@link UserToken} @@ -418,7 +418,7 @@ private void getUserTokenFromId(String userTokenId, Version tokenVersion, Action logger.warn("failed to get access token [{}] because index [{}] is not available", userTokenId, tokensIndex.aliasName()); listener.onResponse(null); } else { - final GetRequest getRequest = client.prepareGet(tokensIndex.aliasName(), SINGLE_MAPPING_NAME, + final GetRequest getRequest = client.prepareGet(tokensIndex.aliasName(), getTokenDocumentId(userTokenId)).request(); final Consumer onFailure = ex -> listener.onFailure(traceLog("decode token", userTokenId, ex)); tokensIndex.checkIndexVersionThenExecute( @@ -653,7 +653,7 @@ private void invalidateAllTokens(Collection userTokens, ActionListene } /** - * Invalidates access and/or refresh tokens associated to a user token (coexisting in the same token document) + * Invalidates access and/or refresh tokens associated to a user token (coexisting in the same token document) */ private void indexInvalidation(Collection userTokens, Iterator backoff, String srcPrefix, @Nullable TokensInvalidationResult previousResult, ActionListener listener) { @@ -1087,7 +1087,7 @@ String encryptSupersedingTokens(String supersedingAccessToken, String supersedin } private void getTokenDocAsync(String tokenDocId, SecurityIndexManager tokensIndex, ActionListener listener) { - final GetRequest getRequest = client.prepareGet(tokensIndex.aliasName(), SINGLE_MAPPING_NAME, tokenDocId).request(); + final GetRequest getRequest = client.prepareGet(tokensIndex.aliasName(), tokenDocId).request(); tokensIndex.checkIndexVersionThenExecute( ex -> listener.onFailure(traceLog("prepare tokens index [" + tokensIndex.aliasName() + "]", tokenDocId, ex)), () -> executeAsyncWithOrigin(client.threadPool().getThreadContext(), SECURITY_ORIGIN, getRequest, listener, client::get)); @@ -1184,7 +1184,7 @@ private static Map getUserTokenSourceMap(Map sou /** * Checks if the token can be refreshed once more. If a token has previously been refreshed, it can only by refreshed again inside a * short span of time (30 s). - * + * * @return An {@code Optional} containing the exception in case this refresh token cannot be reused, or an empty Optional if * refreshing is allowed. */ @@ -1325,7 +1325,7 @@ private void sourceIndicesWithTokensAndRun(ActionListener> listener } final SecurityIndexManager frozenMainIndex = securityMainIndex.freeze(); if (frozenMainIndex.indexExists()) { - // main security index _might_ contain tokens if the tokens index has been created recently + // main security index _might_ contain tokens if the tokens index has been created recently if (false == frozenTokensIndex.indexExists() || frozenTokensIndex.getCreationTime() .isAfter(clock.instant().minus(ExpiredTokenRemover.MAXIMUM_TOKEN_LIFETIME_HOURS, ChronoUnit.HOURS))) { if (false == frozenMainIndex.isAvailable()) { @@ -1479,7 +1479,7 @@ private void checkIfTokenIsValid(UserToken userToken, ActionListener listener.onResponse(null); } else { final GetRequest getRequest = client - .prepareGet(tokensIndex.aliasName(), SINGLE_MAPPING_NAME, getTokenDocumentId(userToken)).request(); + .prepareGet(tokensIndex.aliasName(), getTokenDocumentId(userToken)).request(); Consumer onFailure = ex -> listener.onFailure(traceLog("check token state", userToken.getId(), ex)); tokensIndex.checkIndexVersionThenExecute(listener::onFailure, () -> { executeAsyncWithOrigin(client.threadPool().getThreadContext(), SECURITY_ORIGIN, getRequest, diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java index b8495e20b10bd..3b3741cca02e3 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java @@ -205,7 +205,7 @@ private void getUserAndPassword(final String user, final ActionListener executeAsyncWithOrigin(client.threadPool().getThreadContext(), SECURITY_ORIGIN, - client.prepareGet(SECURITY_MAIN_ALIAS, SINGLE_MAPPING_NAME, getIdForUser(USER_DOC_TYPE, user)).request(), + client.prepareGet(SECURITY_MAIN_ALIAS, getIdForUser(USER_DOC_TYPE, user)).request(), new ActionListener() { @Override public void onResponse(GetResponse response) { @@ -526,7 +526,7 @@ void getReservedUserInfo(String username, ActionListener liste } else { securityIndex.checkIndexVersionThenExecute(listener::onFailure, () -> executeAsyncWithOrigin(client.threadPool().getThreadContext(), SECURITY_ORIGIN, - client.prepareGet(SECURITY_MAIN_ALIAS, SINGLE_MAPPING_NAME, getIdForUser(RESERVED_USER_TYPE, username)) + client.prepareGet(SECURITY_MAIN_ALIAS, getIdForUser(RESERVED_USER_TYPE, username)) .request(), new ActionListener() { @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStore.java index 64c9df8e7005a..8aea63dc34b36 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStore.java @@ -199,7 +199,7 @@ void getPrivilege(String application, String name, ActionListener executeAsyncWithOrigin(client.threadPool().getThreadContext(), SECURITY_ORIGIN, - client.prepareGet(SECURITY_MAIN_ALIAS, SINGLE_MAPPING_NAME, toDocId(application, name)) + client.prepareGet(SECURITY_MAIN_ALIAS, toDocId(application, name)) .request(), new ActionListener() { @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java index b962e853cc629..e6ba43f6fbaf9 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java @@ -131,7 +131,7 @@ public void getRoleDescriptors(Set names, final ActionListener { final String[] roleIds = names.stream().map(NativeRolesStore::getIdForRole).toArray(String[]::new); - MultiGetRequest multiGetRequest = client.prepareMultiGet().add(SECURITY_MAIN_ALIAS, SINGLE_MAPPING_NAME, roleIds).request(); + MultiGetRequest multiGetRequest = client.prepareMultiGet().add(SECURITY_MAIN_ALIAS, roleIds).request(); executeAsyncWithOrigin(client.threadPool().getThreadContext(), SECURITY_ORIGIN, multiGetRequest, ActionListener.wrap(mGetResponse -> { final MultiGetItemResponse[] responses = mGetResponse.getResponses(); @@ -329,7 +329,7 @@ public void onFailure(Exception e) { private void executeGetRoleRequest(String role, ActionListener listener) { securityIndex.checkIndexVersionThenExecute(listener::onFailure, () -> executeAsyncWithOrigin(client.threadPool().getThreadContext(), SECURITY_ORIGIN, - client.prepareGet(SECURITY_MAIN_ALIAS, SINGLE_MAPPING_NAME, getIdForRole(role)).request(), + client.prepareGet(SECURITY_MAIN_ALIAS, getIdForRole(role)).request(), listener, client::get)); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index db5a22c5e6e9d..c9ed889ffed27 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java @@ -42,7 +42,7 @@ public Settings nodeSettings(int nodeOrdinal) { public void testThatBulkUpdateDoesNotLoseFields() { assertEquals(DocWriteResponse.Result.CREATED, client().prepareIndex("index1", "type").setSource("{\"test\": \"test\"}", XContentType.JSON).setId("1").get().getResult()); - GetResponse getResponse = client().prepareGet("index1", "type", "1").get(); + GetResponse getResponse = client().prepareGet("index1", "1").get(); assertEquals("test", getResponse.getSource().get("test")); if (randomBoolean()) { @@ -52,7 +52,7 @@ public void testThatBulkUpdateDoesNotLoseFields() { // update with a new field assertEquals(DocWriteResponse.Result.UPDATED, client().prepareUpdate("index1", "type", "1") .setDoc("{\"not test\": \"not test\"}", XContentType.JSON).get().getResult()); - getResponse = client().prepareGet("index1", "type", "1").get(); + getResponse = client().prepareGet("index1", "1").get(); assertEquals("test", getResponse.getSource().get("test")); assertEquals("not test", getResponse.getSource().get("not test")); @@ -64,7 +64,7 @@ public void testThatBulkUpdateDoesNotLoseFields() { BulkResponse response = client().prepareBulk().add(client().prepareUpdate("index1", "type", "1") .setDoc("{\"bulk updated\": \"bulk updated\"}", XContentType.JSON)).get(); assertEquals(DocWriteResponse.Result.UPDATED, response.getItems()[0].getResponse().getResult()); - getResponse = client().prepareGet("index1", "type", "1").get(); + getResponse = client().prepareGet("index1", "1").get(); assertEquals("test", getResponse.getSource().get("test")); assertEquals("not test", getResponse.getSource().get("not test")); assertEquals("bulk updated", getResponse.getSource().get("bulk updated")); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java index dbdb16b798374..033cb418a031c 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java @@ -95,7 +95,7 @@ public void testDateMathExpressionsCanBeAuthorized() throws Exception { if (refeshOnOperation == false) { client.admin().indices().prepareRefresh(expression).get(); } - GetResponse getResponse = client.prepareGet(expression, "type", response.getId()).setFetchSource(true).get(); + GetResponse getResponse = client.prepareGet(expression, response.getId()).setFetchSource(true).get(); assertThat(getResponse.isExists(), is(true)); assertEquals(expectedIndexName, getResponse.getIndex()); assertThat(getResponse.getSourceAsMap().get("foo").toString(), is("bar")); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java index 59a6c4b31fe15..84595c72fa1b0 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java @@ -201,7 +201,7 @@ public void testGetApi() throws Exception { boolean realtime = randomBoolean(); GetResponse response = client() .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -209,7 +209,7 @@ public void testGetApi() throws Exception { assertThat(response.getId(), equalTo("1")); response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) - .prepareGet("test", "type1", "2") + .prepareGet("test", "2") .setRealtime(realtime) .setRefresh(true) .get(); @@ -217,7 +217,7 @@ public void testGetApi() throws Exception { assertThat(response.getId(), equalTo("2")); response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test","1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -225,7 +225,7 @@ public void testGetApi() throws Exception { assertThat(response.getId(), equalTo("1")); response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) - .prepareGet("test", "type1", "2") + .prepareGet("test", "2") .setRealtime(realtime) .setRefresh(true) .get(); @@ -234,19 +234,19 @@ public void testGetApi() throws Exception { // test documents user cannot see response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); assertThat(response.isExists(), is(false)); response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) - .prepareGet("test", "type1", "2") + .prepareGet("test", "2") .setRealtime(realtime) .setRefresh(true) .get(); assertThat(response.isExists(), is(false)); response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) - .prepareGet("test", "type1", "3") + .prepareGet("test", "3") .setRealtime(realtime) .setRefresh(true) .get(); @@ -815,12 +815,12 @@ public void testUpdateApiIsBlocked() throws Exception { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(e.getMessage(), equalTo("Can't execute an update request if field or document level security is enabled")); } - assertThat(client().prepareGet("test", "type", "1").get().getSource().get("field1").toString(), equalTo("value1")); + assertThat(client().prepareGet("test", "1").get().getSource().get("field1").toString(), equalTo("value1")); // With no document level security enabled the update is allowed: client().prepareUpdate("test", "type", "1").setDoc(Requests.INDEX_CONTENT_TYPE, "field1", "value2") .get(); - assertThat(client().prepareGet("test", "type", "1").get().getSource().get("field1").toString(), equalTo("value2")); + assertThat(client().prepareGet("test", "1").get().getSource().get("field1").toString(), equalTo("value2")); // With document level security enabled the update in bulk is not allowed: BulkResponse bulkResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue @@ -837,12 +837,12 @@ public void testUpdateApiIsBlocked() throws Exception { assertThat(securityException.getMessage(), equalTo("Can't execute a bulk item request with update requests embedded if field or document level security is enabled")); - assertThat(client().prepareGet("test", "type", "1").get().getSource().get("field1").toString(), equalTo("value2")); + assertThat(client().prepareGet("test", "1").get().getSource().get("field1").toString(), equalTo("value2")); client().prepareBulk() .add(new UpdateRequest("test", "type", "1").doc(Requests.INDEX_CONTENT_TYPE, "field1", "value3")) .get(); - assertThat(client().prepareGet("test", "type", "1").get().getSource().get("field1").toString(), equalTo("value3")); + assertThat(client().prepareGet("test", "1").get().getSource().get("field1").toString(), equalTo("value3")); } public void testNestedInnerHits() throws Exception { diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java index 6b87b5d41faf2..04b8deed639ee 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java @@ -323,7 +323,7 @@ public void testGetApi() throws Exception { // user1 is granted access to field1 only: GetResponse response = client() .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -333,7 +333,7 @@ public void testGetApi() throws Exception { // user2 is granted access to field2 only: response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -343,7 +343,7 @@ public void testGetApi() throws Exception { // user3 is granted access to field1 and field2: response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -354,7 +354,7 @@ public void testGetApi() throws Exception { // user4 is granted access to no fields, so the get response does say the doc exist, but no fields are returned: response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -363,7 +363,7 @@ public void testGetApi() throws Exception { // user5 has no field level security configured, so all fields are returned: response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user5", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -375,7 +375,7 @@ public void testGetApi() throws Exception { // user6 has access to field* response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user6", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -387,7 +387,7 @@ public void testGetApi() throws Exception { // user7 has roles with field level security and without field level security response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user7", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -399,7 +399,7 @@ public void testGetApi() throws Exception { // user8 has roles with field level security with access to field1 and field2 response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user8", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -1420,12 +1420,12 @@ public void testUpdateApiIsBlocked() throws Exception { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(e.getMessage(), equalTo("Can't execute an update request if field or document level security is enabled")); } - assertThat(client().prepareGet("test", "type", "1").get().getSource().get("field2").toString(), equalTo("value1")); + assertThat(client().prepareGet("test", "1").get().getSource().get("field2").toString(), equalTo("value1")); // With no field level security enabled the update is allowed: client().prepareUpdate("test", "type", "1").setDoc(Requests.INDEX_CONTENT_TYPE, "field2", "value2") .get(); - assertThat(client().prepareGet("test", "type", "1").get().getSource().get("field2").toString(), equalTo("value2")); + assertThat(client().prepareGet("test", "1").get().getSource().get("field2").toString(), equalTo("value2")); // With field level security enabled the update in bulk is not allowed: BulkResponse bulkResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue @@ -1442,12 +1442,12 @@ public void testUpdateApiIsBlocked() throws Exception { assertThat(securityException.getMessage(), equalTo("Can't execute a bulk item request with update requests embedded if field or document level security is enabled")); - assertThat(client().prepareGet("test", "type", "1").get().getSource().get("field2").toString(), equalTo("value2")); + assertThat(client().prepareGet("test", "1").get().getSource().get("field2").toString(), equalTo("value2")); client().prepareBulk() .add(new UpdateRequest("test", "type", "1").doc(Requests.INDEX_CONTENT_TYPE, "field2", "value3")) .get(); - assertThat(client().prepareGet("test", "type", "1").get().getSource().get("field2").toString(), equalTo("value3")); + assertThat(client().prepareGet("test", "1").get().getSource().get("field2").toString(), equalTo("value3")); } public void testQuery_withRoleWithFieldWildcards() { diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java index b20c1adb9b997..bb38a3c40f849 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndicesPermissionsWithAliasesWildcardsAndRegexsTests.java @@ -77,21 +77,21 @@ public void testResolveWildcardsRegexs() throws Exception { GetResponse getResponse = client() .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) - .prepareGet("test", "type1", "1") + .prepareGet("test", "1") .get(); assertThat(getResponse.getSource().size(), equalTo(1)); assertThat((String) getResponse.getSource().get("field1"), equalTo("value1")); getResponse = client() .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) - .prepareGet("my_alias", "type1", "1") + .prepareGet("my_alias", "1") .get(); assertThat(getResponse.getSource().size(), equalTo(1)); assertThat((String) getResponse.getSource().get("field2"), equalTo("value2")); getResponse = client() .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) - .prepareGet("an_alias", "type1", "1") + .prepareGet("an_alias", "1") .get(); assertThat(getResponse.getSource().size(), equalTo(1)); assertThat((String) getResponse.getSource().get("field3"), equalTo("value3")); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java index ba6da8e31eefb..7e6b7435bce29 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java @@ -107,10 +107,9 @@ public void setup() throws Exception { doAnswer(invocationOnMock -> { GetRequestBuilder builder = new GetRequestBuilder(client, GetAction.INSTANCE); builder.setIndex((String) invocationOnMock.getArguments()[0]) - .setType((String) invocationOnMock.getArguments()[1]) - .setId((String) invocationOnMock.getArguments()[2]); + .setId((String) invocationOnMock.getArguments()[1]); return builder; - }).when(client).prepareGet(anyString(), anyString(), anyString()); + }).when(client).prepareGet(anyString(), anyString()); doAnswer(invocationOnMock -> { IndexRequestBuilder builder = new IndexRequestBuilder(client, IndexAction.INSTANCE); builder.setIndex((String) invocationOnMock.getArguments()[0]) diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java index 9b9dc79a29cd4..24062f4aa92cb 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java @@ -126,10 +126,9 @@ public void setup() throws Exception { doAnswer(invocationOnMock -> { GetRequestBuilder builder = new GetRequestBuilder(client, GetAction.INSTANCE); builder.setIndex((String) invocationOnMock.getArguments()[0]) - .setType((String) invocationOnMock.getArguments()[1]) - .setId((String) invocationOnMock.getArguments()[2]); + .setId((String) invocationOnMock.getArguments()[1]); return builder; - }).when(client).prepareGet(anyString(), anyString(), anyString()); + }).when(client).prepareGet(anyString(), anyString()); doAnswer(invocationOnMock -> { IndexRequestBuilder builder = new IndexRequestBuilder(client, IndexAction.INSTANCE); builder.setIndex((String) invocationOnMock.getArguments()[0]) diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java index b32ceee1a87d9..34e18542cc7f6 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java @@ -93,10 +93,9 @@ public void setupClient() { doAnswer(invocationOnMock -> { GetRequestBuilder builder = new GetRequestBuilder(client, GetAction.INSTANCE); builder.setIndex((String) invocationOnMock.getArguments()[0]) - .setType((String) invocationOnMock.getArguments()[1]) - .setId((String) invocationOnMock.getArguments()[2]); + .setId((String) invocationOnMock.getArguments()[1]); return builder; - }).when(client).prepareGet(anyString(), anyString(), anyString()); + }).when(client).prepareGet(anyString(), anyString()); when(client.prepareMultiGet()).thenReturn(new MultiGetRequestBuilder(client, MultiGetAction.INSTANCE)); doAnswer(invocationOnMock -> { ActionListener listener = (ActionListener) invocationOnMock.getArguments()[1]; diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java index d9e1e5e10fbe6..d04d6781f5a10 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java @@ -207,10 +207,9 @@ licenseState, threadContext, mock(ReservedRealm.class), Arrays.asList(firstRealm doAnswer(invocationOnMock -> { GetRequestBuilder builder = new GetRequestBuilder(client, GetAction.INSTANCE); builder.setIndex((String) invocationOnMock.getArguments()[0]) - .setType((String) invocationOnMock.getArguments()[1]) - .setId((String) invocationOnMock.getArguments()[2]); + .setId((String) invocationOnMock.getArguments()[1]); return builder; - }).when(client).prepareGet(anyString(), anyString(), anyString()); + }).when(client).prepareGet(anyString(), anyString()); securityIndex = mock(SecurityIndexManager.class); doAnswer(invocationOnMock -> { Runnable runnable = (Runnable) invocationOnMock.getArguments()[1]; @@ -1250,11 +1249,11 @@ public void testApiKeyAuth() { creatorMap.put("metadata", Collections.emptyMap()); creatorMap.put("realm", "auth realm"); source.put("creator", creatorMap); - GetResponse getResponse = new GetResponse(new GetResult(request.index(), request.type(), request.id(), 0, 1, 1L, true, + GetResponse getResponse = new GetResponse(new GetResult(request.index(), request.id(), 0, 1, 1L, true, BytesReference.bytes(JsonXContent.contentBuilder().map(source)), Collections.emptyMap(), Collections.emptyMap())); listener.onResponse(getResponse); } else { - listener.onResponse(new GetResponse(new GetResult(request.index(), request.type(), request.id(), + listener.onResponse(new GetResponse(new GetResult(request.index(), request.id(), SequenceNumbers.UNASSIGNED_SEQ_NO, 1, -1L, false, null, Collections.emptyMap(), Collections.emptyMap()))); } @@ -1290,11 +1289,11 @@ public void testExpiredApiKey() { creatorMap.put("metadata", Collections.emptyMap()); creatorMap.put("realm", "auth realm"); source.put("creator", creatorMap); - GetResponse getResponse = new GetResponse(new GetResult(request.index(), request.type(), request.id(), 0, 1, 1L, true, + GetResponse getResponse = new GetResponse(new GetResult(request.index(), request.id(), 0, 1, 1L, true, BytesReference.bytes(JsonXContent.contentBuilder().map(source)), Collections.emptyMap(), Collections.emptyMap())); listener.onResponse(getResponse); } else { - listener.onResponse(new GetResponse(new GetResult(request.index(), request.type(), request.id(), + listener.onResponse(new GetResponse(new GetResult(request.index(), request.id(), SequenceNumbers.UNASSIGNED_SEQ_NO, 1, -1L, false, null, Collections.emptyMap(), Collections.emptyMap()))); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java index 2a4cfb4882966..a68a5647c3a08 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java @@ -112,10 +112,9 @@ public void setupClient() { doAnswer(invocationOnMock -> { GetRequestBuilder builder = new GetRequestBuilder(client, GetAction.INSTANCE); builder.setIndex((String) invocationOnMock.getArguments()[0]) - .setType((String) invocationOnMock.getArguments()[1]) - .setId((String) invocationOnMock.getArguments()[2]); + .setId((String) invocationOnMock.getArguments()[1]); return builder; - }).when(client).prepareGet(anyString(), anyString(), anyString()); + }).when(client).prepareGet(anyString(), anyString()); when(client.prepareIndex(any(String.class), any(String.class), any(String.class))) .thenReturn(new IndexRequestBuilder(client, IndexAction.INSTANCE)); when(client.prepareUpdate(any(String.class), any(String.class), any(String.class))) diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java index db591f98b6b90..b8b68db6c0881 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStoreTests.java @@ -5,10 +5,10 @@ */ package org.elasticsearch.xpack.security.authc.esnative; -import org.elasticsearch.action.ActionType; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.support.PlainActionFuture; @@ -22,7 +22,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.index.get.GetResult; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.core.security.authc.AuthenticationResult; @@ -113,7 +112,6 @@ public void testBlankPasswordInIndexImpliesDefaultPassword() throws Exception { final GetResult result = new GetResult( RestrictedIndicesNames.SECURITY_MAIN_ALIAS, - MapperService.SINGLE_MAPPING_NAME, NativeUsersStore.getIdForUser(NativeUsersStore.RESERVED_USER_TYPE, randomAlphaOfLength(12)), 0, 1, 1L, true, @@ -183,7 +181,6 @@ public void testVerifyNonExistentUser() throws Exception { final GetResult getResult = new GetResult( RestrictedIndicesNames.SECURITY_MAIN_ALIAS, - MapperService.SINGLE_MAPPING_NAME, NativeUsersStore.getIdForUser(NativeUsersStore.USER_DOC_TYPE, username), UNASSIGNED_SEQ_NO, 0, 1L, false, @@ -226,7 +223,6 @@ private void respondToGetUserRequest(String username, SecureString password, Str final BytesReference source = BytesReference.bytes(jsonBuilder().map(values)); final GetResult getResult = new GetResult( RestrictedIndicesNames.SECURITY_MAIN_ALIAS, - MapperService.SINGLE_MAPPING_NAME, NativeUsersStore.getIdForUser(NativeUsersStore.USER_DOC_TYPE, username), 0, 1, 1L, true, diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 600cc6531fa4e..89fcc394a2c5b 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -1018,7 +1018,7 @@ public void testSuperusersCanExecuteOperationAgainstSecurityIndex() throws IOExc requests.add(new Tuple<>(TermVectorsAction.NAME, new TermVectorsRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id"))); requests.add( - new Tuple<>(GetAction.NAME, new GetRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "type", "id"))); + new Tuple<>(GetAction.NAME, new GetRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id"))); requests.add(new Tuple<>(TermVectorsAction.NAME, new TermVectorsRequest(randomFrom(SECURITY_MAIN_ALIAS, INTERNAL_SECURITY_MAIN_INDEX_7), "id"))); requests.add(new Tuple<>(IndicesAliasesAction.NAME, new IndicesAliasesRequest() @@ -1249,7 +1249,7 @@ private BulkShardRequest createBulkShardRequest(String indexName, TriFunction randomCompositeRequest() { switch (randomIntBetween(0, 7)) { case 0: - return Tuple.tuple(MultiGetAction.NAME, new MultiGetRequest().add("index", "type", "id")); + return Tuple.tuple(MultiGetAction.NAME, new MultiGetRequest().add("index", "id")); case 1: return Tuple.tuple(MultiSearchAction.NAME, new MultiSearchRequest().add(new SearchRequest())); case 2: diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java index 18bfe191e196e..cf783478a3223 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java @@ -320,13 +320,13 @@ public void testMultiSearchWildcard() { public void testGet() { createIndicesWithRandomAliases("test1", "index1"); - client().prepareGet("test1", "type", "id").get(); + client().prepareGet("test1", "id").get(); - assertThrowsAuthorizationExceptionDefaultUsers(client().prepareGet("index1", "type", "id")::get, GetAction.NAME); + assertThrowsAuthorizationExceptionDefaultUsers(client().prepareGet("index1", "id")::get, GetAction.NAME); - assertThrowsAuthorizationExceptionDefaultUsers(client().prepareGet("missing", "type", "id")::get, GetAction.NAME); + assertThrowsAuthorizationExceptionDefaultUsers(client().prepareGet("missing", "id")::get, GetAction.NAME); - expectThrows(IndexNotFoundException.class, () -> client().prepareGet("test5", "type", "id").get()); + expectThrows(IndexNotFoundException.class, () -> client().prepareGet("test5", "id").get()); } public void testMultiGet() { diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java index 1994e5b702061..9ac278ab40770 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java @@ -131,7 +131,7 @@ public void testSnapshotUserRoleUnathorizedForDestructiveActions() { // try destructive/revealing actions on all indices for (final String indexToTest : Arrays.asList(INTERNAL_SECURITY_MAIN_INDEX_7, SECURITY_MAIN_ALIAS, ordinaryIndex)) { assertThrowsAuthorizationException(() -> client.prepareSearch(indexToTest).get(), "indices:data/read/search", "snapshot_user"); - assertThrowsAuthorizationException(() -> client.prepareGet(indexToTest, "doc", "1").get(), "indices:data/read/get", + assertThrowsAuthorizationException(() -> client.prepareGet(indexToTest, "1").get(), "indices:data/read/get", "snapshot_user"); assertThrowsAuthorizationException(() -> client.prepareIndex(indexToTest, "doc").setSource("term", "val").get(), "indices:data/write/index", "snapshot_user"); @@ -144,5 +144,5 @@ public void testSnapshotUserRoleUnathorizedForDestructiveActions() { "snapshot_user"); } } - + } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStoreTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStoreTests.java index 486b561a5cbe0..657a1f47e42d9 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStoreTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStoreTests.java @@ -125,12 +125,11 @@ public void testGetSinglePrivilegeByName() throws Exception { assertThat(requests.get(0), instanceOf(GetRequest.class)); GetRequest request = (GetRequest) requests.get(0); assertThat(request.index(), equalTo(RestrictedIndicesNames.SECURITY_MAIN_ALIAS)); - assertThat(request.type(), equalTo(MapperService.SINGLE_MAPPING_NAME)); assertThat(request.id(), equalTo("application-privilege_myapp:admin")); final String docSource = Strings.toString(sourcePrivilege); listener.get().onResponse(new GetResponse( - new GetResult(request.index(), request.type(), request.id(), 0, 1, 1L, true, + new GetResult(request.index(), request.id(), 0, 1, 1L, true, new BytesArray(docSource), emptyMap(), emptyMap()) )); final ApplicationPrivilegeDescriptor getPrivilege = future.get(1, TimeUnit.SECONDS); @@ -144,11 +143,10 @@ public void testGetMissingPrivilege() throws Exception { assertThat(requests.get(0), instanceOf(GetRequest.class)); GetRequest request = (GetRequest) requests.get(0); assertThat(request.index(), equalTo(RestrictedIndicesNames.SECURITY_MAIN_ALIAS)); - assertThat(request.type(), equalTo(MapperService.SINGLE_MAPPING_NAME)); assertThat(request.id(), equalTo("application-privilege_myapp:admin")); listener.get().onResponse(new GetResponse( - new GetResult(request.index(), request.type(), request.id(), UNASSIGNED_SEQ_NO, 0, -1, + new GetResult(request.index(), request.id(), UNASSIGNED_SEQ_NO, 0, -1, false, null, emptyMap(), emptyMap()) )); final ApplicationPrivilegeDescriptor getPrivilege = future.get(1, TimeUnit.SECONDS); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityMocks.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityMocks.java index 20108b0114933..97df77e19bb54 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityMocks.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/test/SecurityMocks.java @@ -20,7 +20,6 @@ import java.util.function.Consumer; import static java.util.Collections.emptyMap; -import static org.elasticsearch.index.mapper.MapperService.SINGLE_MAPPING_NAME; import static org.elasticsearch.xpack.core.security.index.RestrictedIndicesNames.SECURITY_MAIN_ALIAS; import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.equalTo; @@ -65,7 +64,7 @@ public static SecurityIndexManager mockSecurityIndexManager(boolean exists, bool } public static void mockGetRequest(Client client, String documentId, BytesReference source) { - GetResult result = new GetResult(SECURITY_MAIN_ALIAS, SINGLE_MAPPING_NAME, documentId, 0, 1, 1, true, source, + GetResult result = new GetResult(SECURITY_MAIN_ALIAS, documentId, 0, 1, 1, true, source, emptyMap(), emptyMap()); mockGetRequest(client, documentId, result); } @@ -73,9 +72,8 @@ public static void mockGetRequest(Client client, String documentId, BytesReferen public static void mockGetRequest(Client client, String documentId, GetResult result) { final GetRequestBuilder requestBuilder = new GetRequestBuilder(client, GetAction.INSTANCE); requestBuilder.setIndex(SECURITY_MAIN_ALIAS); - requestBuilder.setType(SINGLE_MAPPING_NAME); requestBuilder.setId(documentId); - when(client.prepareGet(SECURITY_MAIN_ALIAS, SINGLE_MAPPING_NAME, documentId)).thenReturn(requestBuilder); + when(client.prepareGet(SECURITY_MAIN_ALIAS, documentId)).thenReturn(requestBuilder); doAnswer(inv -> { Assert.assertThat(inv.getArguments(), arrayWithSize(2)); @@ -83,7 +81,6 @@ public static void mockGetRequest(Client client, String documentId, GetResult re final GetRequest request = (GetRequest) inv.getArguments()[0]; Assert.assertThat(request.id(), equalTo(documentId)); Assert.assertThat(request.index(), equalTo(SECURITY_MAIN_ALIAS)); - Assert.assertThat(request.type(), equalTo(SINGLE_MAPPING_NAME)); Assert.assertThat(inv.getArguments()[1], instanceOf(ActionListener.class)); ActionListener listener = (ActionListener) inv.getArguments()[1]; diff --git a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java index fdf6d625b1f2d..3e671d588254e 100644 --- a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java +++ b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java @@ -263,7 +263,6 @@ protected GetResponse executeGet(GetRequest getRequest) { assertThat(indexedShapeToReturn, notNullValue()); assertThat(indexedShapeId, notNullValue()); assertThat(getRequest.id(), equalTo(indexedShapeId)); - assertThat(getRequest.type(), equalTo(indexedType)); assertThat(getRequest.routing(), equalTo(indexedShapeRouting)); String expectedShapeIndex = indexedShapeIndex == null ? ShapeQueryBuilder.DEFAULT_SHAPE_INDEX_NAME : indexedShapeIndex; assertThat(getRequest.index(), equalTo(expectedShapeIndex)); @@ -285,7 +284,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } catch (IOException ex) { throw new ElasticsearchException("boom", ex); } - return new GetResponse(new GetResult(indexedShapeIndex, indexedType, indexedShapeId, 0, 1, 0, true, new BytesArray(json), + return new GetResponse(new GetResult(indexedShapeIndex, indexedShapeId, 0, 1, 0, true, new BytesArray(json), null, null)); } } diff --git a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java index 937790b56abe7..bd01e684f6303 100644 --- a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java +++ b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java @@ -222,7 +222,7 @@ public void testNullShape() { .setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex(IGNORE_MALFORMED_INDEX, FIELD_TYPE, "aNullshape").setSource("{\"" + FIELD + "\": null}", XContentType.JSON).setRefreshPolicy(IMMEDIATE).get(); - GetResponse result = client().prepareGet(INDEX, FIELD_TYPE, "aNullshape").get(); + GetResponse result = client().prepareGet(INDEX, "aNullshape").get(); assertThat(result.getField(FIELD), nullValue()); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java index d42ddfeb2fe2c..825e62e408553 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/execution/ExecutionServiceTests.java @@ -1216,7 +1216,7 @@ private void mockGetWatchResponse(Client client, String id, GetResponse response listener.onResponse(response); } else { GetResult notFoundResult = - new GetResult(request.index(), request.type(), request.id(), UNASSIGNED_SEQ_NO, 0, + new GetResult(request.index(), request.id(), UNASSIGNED_SEQ_NO, 0, -1, false, null, null, null); listener.onResponse(new GetResponse(notFoundResult)); } @@ -1232,7 +1232,7 @@ private void mockGetWatchException(Client client, String id, Exception e) { listener.onFailure(e); } else { GetResult notFoundResult = - new GetResult(request.index(), request.type(), request.id(), UNASSIGNED_SEQ_NO, 0, -1, + new GetResult(request.index(), request.id(), UNASSIGNED_SEQ_NO, 0, -1, false, null, null, null); listener.onResponse(new GetResponse(notFoundResult)); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/ack/TransportAckWatchActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/ack/TransportAckWatchActionTests.java index bfaed67f6de23..0d7f3733f24de 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/ack/TransportAckWatchActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/actions/ack/TransportAckWatchActionTests.java @@ -19,7 +19,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.index.get.GetResult; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.ESTestCase; @@ -72,7 +71,7 @@ public void testWatchNotFound() { String watchId = "my_watch_id"; doAnswer(invocation -> { ActionListener listener = (ActionListener) invocation.getArguments()[1]; - listener.onResponse(new GetResponse(new GetResult(Watch.INDEX, MapperService.SINGLE_MAPPING_NAME, watchId, UNASSIGNED_SEQ_NO, + listener.onResponse(new GetResponse(new GetResult(Watch.INDEX, watchId, UNASSIGNED_SEQ_NO, 0, -1, false, BytesArray.EMPTY, Collections.emptyMap(), Collections.emptyMap()))); return null; }).when(client).get(anyObject(), anyObject()); diff --git a/x-pack/qa/third-party/active-directory/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractAdLdapRealmTestCase.java b/x-pack/qa/third-party/active-directory/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractAdLdapRealmTestCase.java index 94c23b77d3ab0..943b1fbc143c7 100644 --- a/x-pack/qa/third-party/active-directory/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractAdLdapRealmTestCase.java +++ b/x-pack/qa/third-party/active-directory/src/test/java/org/elasticsearch/xpack/security/authc/ldap/AbstractAdLdapRealmTestCase.java @@ -259,7 +259,7 @@ protected void assertAccessAllowed(String user, String index) throws IOException refresh(); - GetResponse getResponse = client.prepareGet(index, "type", indexResponse.getId()) + GetResponse getResponse = client.prepareGet(index, indexResponse.getId()) .get(); assertThat("user " + user + " should have read access to index " + index, getResponse.getId(), equalTo(indexResponse.getId())); From 6e65e2e3297cfc72d77ad2ad5cd1c5869a0d703c Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 11:35:32 +0100 Subject: [PATCH 02/13] YAML tests --- docs/plugins/ingest-attachment.asciidoc | 4 - .../docs/concurrency-control.asciidoc | 3 +- docs/reference/docs/get.asciidoc | 6 - docs/reference/docs/multi-get.asciidoc | 36 +----- docs/reference/docs/reindex.asciidoc | 1 - docs/reference/getting-started.asciidoc | 3 +- docs/reference/ingest/ingest-node.asciidoc | 5 +- .../ingest/processors/circle.asciidoc | 1 - .../ingest/processors/geoip.asciidoc | 3 - .../ingest/processors/user-agent.asciidoc | 1 - .../mapping/removal_of_types.asciidoc | 1 - .../test/ingest/200_dissect_processor.yml | 1 - .../rest-api-spec/test/ingest/80_foreach.yml | 2 - .../rest-api-spec/test/ingest/90_simulate.yml | 18 +-- .../main/resources/rest-api-spec/api/get.json | 27 +--- .../resources/rest-api-spec/api/mget.json | 36 +----- .../test/get/100_mix_typeless_typeful.yml | 44 ------- .../rest-api-spec/test/get/10_basic.yml | 1 - .../test/get/11_basic_with_types.yml | 31 ----- .../test/get/15_default_values.yml | 1 - .../test/get/16_default_values_with_types.yml | 21 --- .../test/get/20_stored_fields.yml | 1 - .../test/get/21_stored_fields_with_types.yml | 60 --------- .../test/get/41_routing_with_types.yml | 43 ------- .../test/get/50_with_headers.yml | 1 - .../test/get/51_with_headers_with_types.yml | 26 ---- .../get/61_realtime_refresh_with_types.yml | 49 ------- .../test/get/70_source_filtering.yml | 2 - .../get/71_source_filtering_with_types.yml | 69 ---------- .../test/get/81_missing_with_types.yml | 19 --- .../test/get/91_versions_with_types.yml | 89 ------------- .../rest-api-spec/test/mget/10_basic.yml | 3 - .../test/mget/11_default_index_type.yml | 44 ------- .../test/mget/12_non_existent_index.yml | 2 - .../test/mget/13_missing_metadata.yml | 1 - .../mget/14_alias_to_multiple_indices.yml | 2 - .../rest-api-spec/test/mget/15_ids.yml | 4 - .../test/mget/16_basic_with_types.yml | 45 ------- .../test/mget/17_default_index.yml | 3 - .../mget/18_non_existent_index_with_types.yml | 30 ----- .../mget/19_missing_metadata_with_types.yml | 47 ------- ...1_alias_to_multiple_indices_with_types.yml | 42 ------ .../test/mget/22_ids_with_types.yml | 72 ----------- .../test/mget/23_stored_fields_with_types.yml | 120 ------------------ .../rest-api-spec/test/mget/40_routing.yml | 1 - .../test/mget/41_routing_with_types.yml | 44 ------- .../mget/61_realtime_refresh_with_types.yml | 53 -------- .../mget/71_source_filtering_with_types.yml | 119 ----------------- .../test/mget/80_deprecated_with_types.yml | 36 ------ .../rest/action/document/RestGetAction.java | 18 +-- .../action/document/RestMultiGetAction.java | 13 -- 51 files changed, 17 insertions(+), 1287 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/100_mix_typeless_typeful.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/11_basic_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/16_default_values_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/21_stored_fields_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/41_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/51_with_headers_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/61_realtime_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/71_source_filtering_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/81_missing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get/91_versions_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/11_default_index_type.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/16_basic_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/18_non_existent_index_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/19_missing_metadata_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/21_alias_to_multiple_indices_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/22_ids_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/23_stored_fields_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/41_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/61_realtime_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/71_source_filtering_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated_with_types.yml diff --git a/docs/plugins/ingest-attachment.asciidoc b/docs/plugins/ingest-attachment.asciidoc index e2498a3b873d2..1c57e75a3fe46 100644 --- a/docs/plugins/ingest-attachment.asciidoc +++ b/docs/plugins/ingest-attachment.asciidoc @@ -59,7 +59,6 @@ Returns this: { "found": true, "_index": "my_index", - "_type": "_doc", "_id": "my_id", "_version": 1, "_seq_no": 22, @@ -142,7 +141,6 @@ Returns this: { "found": true, "_index": "my_index", - "_type": "_doc", "_id": "my_id", "_version": 1, "_seq_no": 35, @@ -191,7 +189,6 @@ Returns this: { "found": true, "_index": "my_index", - "_type": "_doc", "_id": "my_id_2", "_version": 1, "_seq_no": 40, @@ -284,7 +281,6 @@ Returns this: -------------------------------------------------- { "_index" : "my_index", - "_type" : "_doc", "_id" : "my_id", "_version" : 1, "_seq_no" : 50, diff --git a/docs/reference/docs/concurrency-control.asciidoc b/docs/reference/docs/concurrency-control.asciidoc index facd68532c3b0..8e29c0d6054e2 100644 --- a/docs/reference/docs/concurrency-control.asciidoc +++ b/docs/reference/docs/concurrency-control.asciidoc @@ -41,8 +41,8 @@ You can see the assigned sequence number and primary term in the "successful" : 1 }, "_index" : "products", - "_type" : "_doc", "_id" : "1567", + "_type" : "_doc", "_version" : 1, "_seq_no" : 362, "_primary_term" : 2, @@ -69,7 +69,6 @@ returns: -------------------------------------------------- { "_index" : "products", - "_type" : "_doc", "_id" : "1567", "_version" : 1, "_seq_no" : 362, diff --git a/docs/reference/docs/get.asciidoc b/docs/reference/docs/get.asciidoc index bf1cd8d8179de..561729226dbb6 100644 --- a/docs/reference/docs/get.asciidoc +++ b/docs/reference/docs/get.asciidoc @@ -189,9 +189,6 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=version_type] `_index`:: The name of the index the document belongs to. -`_type`:: -The document type. {es} indices now support a single document type, `_doc`. - `_id`:: The unique identifier for the document. @@ -239,7 +236,6 @@ The API returns the following result: -------------------------------------------------- { "_index" : "twitter", - "_type" : "_doc", "_id" : "0", "_version" : 1, "_seq_no" : 10, @@ -351,7 +347,6 @@ The API returns the following result: -------------------------------------------------- { "_index": "twitter", - "_type": "_doc", "_id": "1", "_version": 1, "_seq_no" : 22, @@ -393,7 +388,6 @@ The API returns the following result: -------------------------------------------------- { "_index": "twitter", - "_type": "_doc", "_id": "2", "_version": 1, "_seq_no" : 13, diff --git a/docs/reference/docs/multi-get.asciidoc b/docs/reference/docs/multi-get.asciidoc index ccf91e172e441..834a77458274f 100644 --- a/docs/reference/docs/multi-get.asciidoc +++ b/docs/reference/docs/multi-get.asciidoc @@ -1,8 +1,8 @@ [[docs-multi-get]] === Multi Get API -The Multi get API returns multiple documents based on an index, type, -(optional) and id (and possibly routing). The response includes a `docs` array +The Multi get API returns multiple documents based on an index and id +(and possibly routing). The response includes a `docs` array with all the fetched documents in order corresponding to the original multi-get request (if there was a failure for a specific get, an object containing this error is included in place in the response instead). The structure of a @@ -18,12 +18,10 @@ GET /_mget "docs" : [ { "_index" : "test", - "_type" : "_doc", "_id" : "1" }, { "_index" : "test", - "_type" : "_doc", "_id" : "2" } ] @@ -36,25 +34,6 @@ is not required in the body): [source,console] -------------------------------------------------- GET /test/_mget -{ - "docs" : [ - { - "_type" : "_doc", - "_id" : "1" - }, - { - "_type" : "_doc", - "_id" : "2" - } - ] -} --------------------------------------------------- - -And type: - -[source,console] --------------------------------------------------- -GET /test/_doc/_mget { "docs" : [ { @@ -73,7 +52,7 @@ request: [source,console] -------------------------------------------------- -GET /test/_doc/_mget +GET /test/_mget { "ids" : ["1", "2"] } @@ -98,19 +77,16 @@ GET /_mget "docs" : [ { "_index" : "test", - "_type" : "_doc", "_id" : "1", "_source" : false }, { "_index" : "test", - "_type" : "_doc", "_id" : "2", "_source" : ["field3", "field4"] }, { "_index" : "test", - "_type" : "_doc", "_id" : "3", "_source" : { "include": ["user"], @@ -136,13 +112,11 @@ GET /_mget "docs" : [ { "_index" : "test", - "_type" : "_doc", "_id" : "1", "stored_fields" : ["field1", "field2"] }, { "_index" : "test", - "_type" : "_doc", "_id" : "2", "stored_fields" : ["field3", "field4"] } @@ -155,7 +129,7 @@ as a default to be applied to all documents. [source,console] -------------------------------------------------- -GET /test/_doc/_mget?stored_fields=field1,field2 +GET /test/_mget?stored_fields=field1,field2 { "docs" : [ { @@ -184,13 +158,11 @@ GET /_mget?routing=key1 "docs" : [ { "_index" : "test", - "_type" : "_doc", "_id" : "1", "routing" : "key2" }, { "_index" : "test", - "_type" : "_doc", "_id" : "2" } ] diff --git a/docs/reference/docs/reindex.asciidoc b/docs/reference/docs/reindex.asciidoc index ef7a6fab46635..2f6d1561e67c1 100644 --- a/docs/reference/docs/reindex.asciidoc +++ b/docs/reference/docs/reindex.asciidoc @@ -937,7 +937,6 @@ which will return: "found": true, "_id": "1", "_index": "test2", - "_type": "_doc", "_version": 1, "_seq_no": 44, "_primary_term": 1, diff --git a/docs/reference/getting-started.asciidoc b/docs/reference/getting-started.asciidoc index 499522d1ecdb5..0723e91b6b5f7 100755 --- a/docs/reference/getting-started.asciidoc +++ b/docs/reference/getting-started.asciidoc @@ -229,8 +229,8 @@ operation was that version 1 of the document was created: -------------------------------------------------- { "_index" : "customer", - "_type" : "_doc", "_id" : "1", + "_type" : "_doc", "_version" : 1, "result" : "created", "_shards" : { @@ -263,7 +263,6 @@ and shows the original source fields that were indexed. -------------------------------------------------- { "_index" : "customer", - "_type" : "_doc", "_id" : "1", "_version" : 1, "_seq_no" : 26, diff --git a/docs/reference/ingest/ingest-node.asciidoc b/docs/reference/ingest/ingest-node.asciidoc index e9813f44f5385..15a750da43159 100644 --- a/docs/reference/ingest/ingest-node.asciidoc +++ b/docs/reference/ingest/ingest-node.asciidoc @@ -76,7 +76,7 @@ The following example sets the `_id` metadata field of a document to `1`: -------------------------------------------------- // NOTCONSOLE -The following metadata fields are accessible by a processor: `_index`, `_type`, `_id`, `_routing`. +The following metadata fields are accessible by a processor: `_index`, `_id`, `_routing`. [float] [[accessing-ingest-metadata]] @@ -276,7 +276,6 @@ GET test/_doc/2 -------------------------------------------------- { "_index": "test", - "_type": "_doc", "_id": "2", "_version": 1, "_seq_no": 22, @@ -465,7 +464,6 @@ GET test/_doc/2 -------------------------------------------------- { "_index": "test", - "_type": "_doc", "_id": "2", "_version": 1, "_seq_no": 34, @@ -586,7 +584,6 @@ GET test/_doc/1 -------------------------------------------------- { "_index": "test", - "_type": "_doc", "_id": "1", "_version": 1, "_seq_no": 60, diff --git a/docs/reference/ingest/processors/circle.asciidoc b/docs/reference/ingest/processors/circle.asciidoc index 5669c69414782..a20c1f3cc82f7 100644 --- a/docs/reference/ingest/processors/circle.asciidoc +++ b/docs/reference/ingest/processors/circle.asciidoc @@ -75,7 +75,6 @@ The response from the above index request: { "found": true, "_index": "circles", - "_type": "_doc", "_id": "1", "_version": 1, "_seq_no": 22, diff --git a/docs/reference/ingest/processors/geoip.asciidoc b/docs/reference/ingest/processors/geoip.asciidoc index 322719e4995c4..3ece7676e03ea 100644 --- a/docs/reference/ingest/processors/geoip.asciidoc +++ b/docs/reference/ingest/processors/geoip.asciidoc @@ -68,7 +68,6 @@ Which returns: { "found": true, "_index": "my_index", - "_type": "_doc", "_id": "my_id", "_version": 1, "_seq_no": 55, @@ -118,7 +117,6 @@ returns this: { "found": true, "_index": "my_index", - "_type": "_doc", "_id": "my_id", "_version": 1, "_seq_no": 65, @@ -169,7 +167,6 @@ Which returns: -------------------------------------------------- { "_index" : "my_index", - "_type" : "_doc", "_id" : "my_id", "_version" : 1, "_seq_no" : 71, diff --git a/docs/reference/ingest/processors/user-agent.asciidoc b/docs/reference/ingest/processors/user-agent.asciidoc index 67dc76c478ea7..f6a568485e62b 100644 --- a/docs/reference/ingest/processors/user-agent.asciidoc +++ b/docs/reference/ingest/processors/user-agent.asciidoc @@ -50,7 +50,6 @@ Which returns { "found": true, "_index": "my_index", - "_type": "_doc", "_id": "my_id", "_version": 1, "_seq_no": 22, diff --git a/docs/reference/mapping/removal_of_types.asciidoc b/docs/reference/mapping/removal_of_types.asciidoc index 36287da44e988..e048ccd33250f 100644 --- a/docs/reference/mapping/removal_of_types.asciidoc +++ b/docs/reference/mapping/removal_of_types.asciidoc @@ -621,7 +621,6 @@ GET index/_doc/1 -------------------------------------------------- { "_index" : "index", - "_type" : "_doc", "_id" : "1", "_version" : 1, "_seq_no" : 0, diff --git a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/200_dissect_processor.yml b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/200_dissect_processor.yml index 709d4b9e62d43..916a7fe656cc2 100644 --- a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/200_dissect_processor.yml +++ b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/200_dissect_processor.yml @@ -62,7 +62,6 @@ teardown: catch: '/Unable to find match for dissect pattern: \%\{a\},\%\{b\},\%\{c\} against source: foo bar baz/' index: index: test - type: test id: 2 pipeline: "my_pipeline" body: {message: "foo bar baz"} diff --git a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/80_foreach.yml b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/80_foreach.yml index ab2be3bf81c2d..df27e4279c8d4 100644 --- a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/80_foreach.yml +++ b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/80_foreach.yml @@ -31,7 +31,6 @@ teardown: - do: index: index: test - type: test id: 1 pipeline: "my_pipeline" body: > @@ -42,6 +41,5 @@ teardown: - do: get: index: test - type: test id: 1 - match: { _source.values: ["FOO", "BAR", "BAZ"] } diff --git a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/90_simulate.yml b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/90_simulate.yml index 65e888d8caa32..39ba96c678545 100644 --- a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/90_simulate.yml +++ b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/90_simulate.yml @@ -32,7 +32,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar" @@ -66,7 +65,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar" @@ -97,7 +95,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar" @@ -112,7 +109,7 @@ teardown: - match: { error.root_cause.0.property_name: "field" } --- -"Test simulate without index type and id": +"Test simulate without id": - do: ingest.simulate: body: > @@ -166,7 +163,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar" @@ -190,7 +186,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar" @@ -223,7 +218,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar" @@ -275,7 +269,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": { @@ -331,7 +324,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "not_foo": "bar" @@ -339,7 +331,6 @@ teardown: }, { "_index": "index", - "_type": "type", "_id": "id2", "_source": { "foo": "bar" @@ -379,7 +370,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar", @@ -388,7 +378,6 @@ teardown: }, { "_index": "index", - "_type": "type", "_id": "id2", "_source": { "foo": "5", @@ -463,7 +452,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " @@ -540,7 +528,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " @@ -589,7 +576,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " @@ -658,7 +644,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " @@ -733,7 +718,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " 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 0c8d62d6d1d34..bda33bbf45f85 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 @@ -8,7 +8,7 @@ "url":{ "paths":[ { - "path":"/{index}/_doc/{id}", + "path":"/{index}/{id}", "methods":[ "GET" ], @@ -22,31 +22,6 @@ "description":"The name of the index" } } - }, - { - "path":"/{index}/{type}/{id}", - "methods":[ - "GET" - ], - "parts":{ - "id":{ - "type":"string", - "description":"The document ID" - }, - "index":{ - "type":"string", - "description":"The name of the index" - }, - "type":{ - "type":"string", - "description":"The type of the document (use `_all` to fetch the first document matching the ID across all types)", - "deprecated":true - } - }, - "deprecated":{ - "version":"7.0.0", - "description":"Specifying types in urls has been deprecated" - } } ] }, diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/mget.json b/rest-api-spec/src/main/resources/rest-api-spec/api/mget.json index f1d35aee7d62f..12496718e714b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/mget.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/mget.json @@ -15,38 +15,16 @@ ] }, { - "path":"/{index}/_mget", - "methods":[ - "GET", - "POST" - ], - "parts":{ - "index":{ - "type":"string", - "description":"The name of the index" - } - } - }, - { - "path":"/{index}/{type}/_mget", - "methods":[ + "path": "/{index}/_mget", + "methods": [ "GET", "POST" ], - "parts":{ - "index":{ - "type":"string", - "description":"The name of the index" - }, - "type":{ - "type":"string", - "description":"The type of the document", - "deprecated":true + "parts": { + "index": { + "type": "string", + "description": "The name of the index" } - }, - "deprecated":{ - "version":"7.0.0", - "description":"Specifying types in urls has been deprecated" } } ] @@ -86,7 +64,7 @@ } }, "body":{ - "description":"Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL.", + "description":"Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL.", "required":true } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/100_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/100_mix_typeless_typeful.yml deleted file mode 100644 index 11d1e6ea45c7f..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/100_mix_typeless_typeful.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- -"GET with typeless API on an index that has types": - - - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - - do: - index: - index: index - type: not_doc - id: 1 - body: { foo: bar } - - - do: - catch: missing - get: - index: index - type: some_random_type - id: 1 - - - match: { _index: "index" } - - match: { _type: "some_random_type" } - - match: { _id: "1"} - - match: { found: false} - - - do: - get: - index: index - id: 1 - - - match: { _index: "index" } - - match: { _type: "_doc" } - - match: { _id: "1"} - - match: { _version: 1} - - match: { _source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml index 11be0f2cd5f4e..07ce7042a51d4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml @@ -13,6 +13,5 @@ id: 中文 - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: 中文 } - match: { _source: { foo: "Hello: 中文" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/11_basic_with_types.yml deleted file mode 100644 index 0689f714d6416..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/11_basic_with_types.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -"Basic": - - - do: - index: - index: test_1 - type: test - id: 中文 - body: { "foo": "Hello: 中文" } - - - do: - get: - index: test_1 - type: test - id: 中文 - - - match: { _index: test_1 } - - match: { _type: test } - - match: { _id: 中文 } - - match: { _source: { foo: "Hello: 中文" } } - - - do: - get: - index: test_1 - type: _all - id: 中文 - - - match: { _index: test_1 } - - match: { _type: test } - - match: { _id: 中文 } - - match: { _source: { foo: "Hello: 中文" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml index 2b32a6ab819aa..2717a365ff328 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml @@ -14,7 +14,6 @@ id: 1 - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: '1' } - match: { _source: { foo: "bar" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/16_default_values_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/16_default_values_with_types.yml deleted file mode 100644 index 5e08112253ef0..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/16_default_values_with_types.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -"Default values": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { "foo": "bar" } - - - do: - get: - index: test_1 - type: _all - id: 1 - - - match: { _index: test_1 } - - match: { _type: test } - - match: { _id: '1' } - - match: { _source: { foo: "bar" } } - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml index 207665b9c8849..69383a0b7b2b4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml @@ -26,7 +26,6 @@ stored_fields: foo - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: '1' } - match: { fields.foo: [bar] } - is_false: _source diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/21_stored_fields_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/21_stored_fields_with_types.yml deleted file mode 100644 index d1862fc0340d8..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/21_stored_fields_with_types.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- -"Stored fields": - - - do: - indices.create: - include_type_name: true - 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", "count": 1 } - - do: - get: - index: test_1 - type: test - id: 1 - stored_fields: foo - - - match: { _index: test_1 } - - match: { _type: test } - - match: { _id: '1' } - - match: { fields.foo: [bar] } - - is_false: _source - - - do: - get: - index: test_1 - type: test - id: 1 - stored_fields: [foo, count] - - - match: { fields.foo: [bar] } - - match: { fields.count: [1] } - - is_false: _source - - - do: - get: - index: test_1 - type: test - id: 1 - stored_fields: [foo, count, _source] - - - match: { fields.foo: [bar] } - - match: { fields.count: [1] } - - match: { _source.foo: bar } - - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/41_routing_with_types.yml deleted file mode 100644 index 276346cda4f98..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/41_routing_with_types.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -"Routing": - - - do: - indices.create: - index: test_1 - body: - settings: - index: - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - - do: - cluster.health: - wait_for_status: green - - - do: - index: - index: test_1 - type: test - id: 1 - routing: 5 - body: { foo: bar } - - - do: - get: - index: test_1 - type: test - id: 1 - routing: 5 - stored_fields: [_routing] - - - match: { _id: "1"} - - match: { _routing: "5"} - - - do: - catch: missing - get: - index: test_1 - type: test - id: 1 - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml index e5447fffdaf0f..9e143de5d1b63 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml @@ -16,7 +16,6 @@ id: 1 - match: {_index: "test_1"} - - match: { _type: _doc } - match: {_id: "1"} - match: {_version: 1} - match: {found: true} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/51_with_headers_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/51_with_headers_with_types.yml deleted file mode 100644 index b88dbaafc4fb2..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/51_with_headers_with_types.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -"REST test with headers": - - skip: - features: ["headers", "yaml"] - - - do: - index: - index: test_1 - type: test - id: 1 - body: { "body": "foo" } - - - do: - headers: - Accept: application/yaml - get: - index: test_1 - type: _all - id: 1 - - - match: {_index: "test_1"} - - match: {_type: "test"} - - match: {_id: "1"} - - match: {_version: 1} - - match: {found: true} - - match: { _source: { body: foo }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/61_realtime_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/61_realtime_refresh_with_types.yml deleted file mode 100644 index 7d02b4667efe7..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/61_realtime_refresh_with_types.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -"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: - catch: missing - get: - index: test_1 - type: test - id: 1 - realtime: false - - - do: - get: - index: test_1 - type: test - id: 1 - realtime: true - - - is_true: found - - - do: - get: - index: test_1 - type: test - id: 1 - realtime: false - refresh: true - - - is_true: found diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml index 952375cedd6d6..b154f020c5b60 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml @@ -21,7 +21,6 @@ get: { index: test_1, id: 1, _source: false } - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - is_false: _source @@ -60,7 +59,6 @@ _source: true - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - match: { fields.count: [1] } - match: { _source.include.field1: v1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/71_source_filtering_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/71_source_filtering_with_types.yml deleted file mode 100644 index 3ac493c629f20..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/71_source_filtering_with_types.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -"Source filtering": - - - do: - indices.create: - include_type_name: true - index: test_1 - body: - mappings: - test: - properties: - count: - type: integer - store: true - - - do: - index: - index: test_1 - type: test - id: 1 - body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } - - do: - get: { index: test_1, type: test, id: 1, _source: false } - - - match: { _index: test_1 } - - match: { _type: test } - - match: { _id: "1" } - - is_false: _source - - - do: - get: { index: test_1, type: test, id: 1, _source: true } - - match: { _source.include.field1: v1 } - - - do: - get: { index: test_1, type: test, id: 1, _source: include.field1 } - - match: { _source.include.field1: v1 } - - is_false: _source.include.field2 - - - do: - get: { index: test_1, type: test, id: 1, _source_includes: include.field1 } - - match: { _source.include.field1: v1 } - - is_false: _source.include.field2 - - - do: - get: { index: test_1, type: test, id: 1, _source_includes: "include.field1,include.field2" } - - match: { _source.include.field1: v1 } - - match: { _source.include.field2: v2 } - - is_false: _source.count - - - do: - get: { index: test_1, type: test, id: 1, _source_includes: include, _source_excludes: "*.field2" } - - match: { _source.include.field1: v1 } - - is_false: _source.include.field2 - - is_false: _source.count - - - - do: - get: - index: test_1 - type: test - id: 1 - stored_fields: count - _source: true - - - match: { _index: test_1 } - - match: { _type: test } - - match: { _id: "1" } - - match: { fields.count: [1] } - - match: { _source.include.field1: v1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/81_missing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/81_missing_with_types.yml deleted file mode 100644 index a60d11388566d..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/81_missing_with_types.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -"Missing document with catch": - - - do: - catch: missing - get: - index: test_1 - type: test - id: 1 - ---- -"Missing document with ignore": - - - do: - get: - index: test_1 - type: test - id: 1 - ignore: 404 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/91_versions_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/91_versions_with_types.yml deleted file mode 100644 index c6631b83b1867..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/91_versions_with_types.yml +++ /dev/null @@ -1,89 +0,0 @@ ---- -"Versions": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - match: { _version: 1} - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - match: { _version: 2} - - - do: - get: - index: test_1 - type: test - id: 1 - version: 2 - - match: { _id: "1" } - - - do: - catch: conflict - get: - index: test_1 - type: test - id: 1 - version: 1 - - - do: - get: - index: test_1 - type: test - id: 1 - version: 2 - version_type: external - - match: { _id: "1" } - - - do: - catch: conflict - get: - index: test_1 - type: test - id: 1 - version: 10 - version_type: external - - - do: - catch: conflict - get: - index: test_1 - type: test - id: 1 - version: 1 - version_type: external - - - do: - get: - index: test_1 - type: test - id: 1 - version: 2 - version_type: external_gte - - match: { _id: "1" } - - - do: - catch: conflict - get: - index: test_1 - type: test - id: 1 - version: 10 - version_type: external_gte - - - do: - catch: conflict - get: - index: test_1 - type: test - id: 1 - version: 1 - version_type: external_gte - 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 3b2b8103d882e..dc14cac06227f 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 @@ -24,17 +24,14 @@ - 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/11_default_index_type.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/11_default_index_type.yml deleted file mode 100644 index 773b7e3bcfe6b..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/11_default_index_type.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- -"Default index/type": - - do: - indices.create: - index: test_2 - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - - do: - mget: - index: test_1 - type: test - body: - docs: - - { _index: test_2, _id: 1} - - { _type: none, _id: 1} - - { _id: 2} - - { _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/12_non_existent_index.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/12_non_existent_index.yml index 5b2e941e6c3d6..49d75fbc739e2 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 @@ -16,7 +16,6 @@ - is_false: docs.0.found - match: { docs.0._index: test_2 } - - match: { docs.0._type: null } - match: { docs.0._id: "1" } - do: @@ -27,5 +26,4 @@ - is_true: docs.0.found - match: { docs.0._index: test_1 } - - 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 42f7a5039d64e..7ef1f11df1cae 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 @@ -41,7 +41,6 @@ - is_true: docs.0.found - match: { docs.0._index: test_1 } - - 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 dcf83b2c9b597..8d18ff7685117 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 @@ -32,12 +32,10 @@ - is_true: docs.0.found - match: { docs.0._index: test_1 } - - 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: 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 3981d6d86e74d..cf8a79223dfba 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 @@ -26,14 +26,12 @@ - is_true: docs.0.found - match: { docs.0._index: test_1 } - - 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: _doc } - match: { docs.1._id: "3" } - do: @@ -44,14 +42,12 @@ - is_true: docs.0.found - match: { docs.0._index: test_1 } - - 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: _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 deleted file mode 100644 index 0850772ad426c..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/16_basic_with_types.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- -"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 index 7d732e5ad8748..8ff660cf4ce33 100644 --- 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 @@ -22,17 +22,14 @@ - 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 deleted file mode 100644 index 0623464225072..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/18_non_existent_index_with_types.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -"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 deleted file mode 100644 index d7af1797f7a40..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/19_missing_metadata_with_types.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -"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/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 deleted file mode 100644 index 3a0fec04738b6..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/21_alias_to_multiple_indices_with_types.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -"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 deleted file mode 100644 index 6c233e4d92a9c..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/22_ids_with_types.yml +++ /dev/null @@ -1,72 +0,0 @@ ---- -"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 deleted file mode 100644 index 05b9738d46180..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/23_stored_fields_with_types.yml +++ /dev/null @@ -1,120 +0,0 @@ ---- -"Stored fields": - - - do: - indices.create: - include_type_name: true - 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 923d620bc9400..89c2b21c1673d 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 @@ -38,6 +38,5 @@ - is_true: docs.2.found - match: { docs.2._index: test_1 } - - 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 deleted file mode 100644 index d550dd26657c9..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/41_routing_with_types.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- -"Routing": - - - do: - indices.create: - index: test_1 - body: - settings: - index: - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - - do: - cluster.health: - wait_for_status: green - - - do: - index: - index: test_1 - type: test - id: 1 - routing: 5 - body: { foo: bar } - - - do: - 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/61_realtime_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/61_realtime_refresh_with_types.yml deleted file mode 100644 index 0cb7b71cf4368..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/61_realtime_refresh_with_types.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- -"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/71_source_filtering_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/71_source_filtering_with_types.yml deleted file mode 100644 index 4581e060b41a7..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/71_source_filtering_with_types.yml +++ /dev/null @@ -1,119 +0,0 @@ -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_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated_with_types.yml deleted file mode 100644 index c65a650dae563..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mget/80_deprecated_with_types.yml +++ /dev/null @@ -1,36 +0,0 @@ - ---- -"Deprecated parameters should fail in Multi Get query": - - - skip: - 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/rest/action/document/RestGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java index 6452e9e9124b3..d90431d2c0cdb 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,10 @@ 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.index.VersionType; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestController; @@ -42,18 +40,10 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestGetAction.class)); - public 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 RestController controller) { controller.registerHandler(GET, "/{index}/_doc/{id}", this); controller.registerHandler(HEAD, "/{index}/_doc/{id}", this); - - // Deprecated typed endpoints. - controller.registerHandler(GET, "/{index}/{type}/{id}", this); - controller.registerHandler(HEAD, "/{index}/{type}/{id}", this); } @Override @@ -63,13 +53,7 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - GetRequest getRequest; - if (request.hasParam("type")) { - deprecationLogger.deprecatedAndMaybeLog("get_with_types", TYPES_DEPRECATION_MESSAGE); - getRequest = new GetRequest(request.param("index"), request.param("id")); - } else { - getRequest = new GetRequest(request.param("index"), request.param("id")); - } + GetRequest getRequest = new GetRequest(request.param("index"), request.param("id")); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); getRequest.routing(request.param("routing")); 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 067e4029e3b76..7b1cb4aaaeba5 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,11 +19,9 @@ 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; @@ -38,10 +36,6 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestMultiGetAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestMultiGetAction.class)); - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal]" + - " Specifying types in multi get requests is deprecated."; private final boolean allowExplicitIndex; @@ -51,10 +45,6 @@ public RestMultiGetAction(Settings settings, RestController controller) { controller.registerHandler(GET, "/{index}/_mget", this); controller.registerHandler(POST, "/{index}/_mget", this); - // Deprecated typed endpoints. - controller.registerHandler(GET, "/{index}/{type}/_mget", this); - controller.registerHandler(POST, "/{index}/{type}/_mget", this); - this.allowExplicitIndex = MULTI_ALLOW_EXPLICIT_INDEX.get(settings); } @@ -65,9 +55,6 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - if (request.param("type") != null) { - deprecationLogger.deprecatedAndMaybeLog("mget_with_types", TYPES_DEPRECATION_MESSAGE); - } MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh())); From e76c646d1d1e0203f05ec05410d6f90ea4f1cf84 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 11:55:10 +0100 Subject: [PATCH 03/13] fix compilation --- .../java/org/elasticsearch/client/CrudIT.java | 30 ---------- .../elasticsearch/backwards/IndexingIT.java | 4 +- .../action/document/RestGetActionTests.java | 55 ------------------- 3 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java 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 03cd3a8fe38f2..1f7928dc4e99e 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 @@ -56,9 +56,7 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.rest.action.document.RestDeleteAction; -import org.elasticsearch.rest.action.document.RestGetAction; import org.elasticsearch.rest.action.document.RestIndexAction; -import org.elasticsearch.rest.action.document.RestMultiGetAction; import org.elasticsearch.rest.action.document.RestUpdateAction; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; @@ -349,20 +347,6 @@ public void testGetWithTypes() throws IOException { highLevelClient()::indexAsync, expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE) ); - - GetRequest getRequest = new GetRequest("index", "id"); - GetResponse getResponse = execute(getRequest, - highLevelClient()::get, - highLevelClient()::getAsync, - expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); - - assertEquals("index", getResponse.getIndex()); - assertEquals("id", getResponse.getId()); - - assertTrue(getResponse.isExists()); - assertFalse(getResponse.isSourceEmpty()); - assertEquals(1L, getResponse.getVersion()); - assertEquals(document, getResponse.getSourceAsString()); } public void testMultiGet() throws IOException { @@ -429,20 +413,6 @@ public void testMultiGetWithTypes() throws IOException { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add("index", "id1"); multiGetRequest.add("index", "id2"); - - MultiGetResponse response = execute(multiGetRequest, - highLevelClient()::mget, - highLevelClient()::mgetAsync, - expectWarnings(RestMultiGetAction.TYPES_DEPRECATION_MESSAGE)); - assertEquals(2, response.getResponses().length); - - GetResponse firstResponse = response.getResponses()[0].getResponse(); - assertEquals("index", firstResponse.getIndex()); - assertEquals("id1", firstResponse.getId()); - - GetResponse secondResponse = response.getResponses()[1].getResponse(); - assertEquals("index", secondResponse.getIndex()); - assertEquals("id2", secondResponse.getId()); } public void testIndex() throws IOException { 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 62527908e1670..40eef35168eb8 100644 --- a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java +++ b/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java @@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.index.seqno.SeqNoStats; -import org.elasticsearch.rest.action.document.RestGetAction; import org.elasticsearch.rest.action.document.RestIndexAction; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.yaml.ObjectPath; @@ -287,9 +286,8 @@ private void assertCount(final String index, final String preference, final int } private void assertVersion(final String index, final int docId, final String preference, final int expectedVersion) throws IOException { - Request request = new Request("GET", index + "/doc/" + docId); + Request request = new Request("GET", index + "/" + docId); request.addParameter("preference", preference); - request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); final Response response = client().performRequest(request); assertOK(response); 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 deleted file mode 100644 index 494e5cf9fb2d6..0000000000000 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestGetActionTests.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.rest.action.document; - -import org.elasticsearch.rest.RestRequest.Method; -import org.elasticsearch.test.rest.FakeRestRequest; -import org.elasticsearch.test.rest.RestActionTestCase; -import org.junit.Before; - -public class RestGetActionTests extends RestActionTestCase { - - @Before - public void setUpAction() { - new RestGetAction(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()); - } -} From 4cee1bfcb8192af6e5d9ac8afe754793d28dcc53 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 12:15:47 +0100 Subject: [PATCH 04/13] Fix GET api spec --- rest-api-spec/src/main/resources/rest-api-spec/api/get.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bda33bbf45f85..2ce77f17aff10 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 @@ -8,7 +8,7 @@ "url":{ "paths":[ { - "path":"/{index}/{id}", + "path":"/{index}/_doc/{id}", "methods":[ "GET" ], From fd9baa8848290ce16bfa5cff9be5600e1ab8e1d0 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 13:52:08 +0100 Subject: [PATCH 05/13] tests --- .../ingest/processors/circle.asciidoc | 1 - .../test/search-as-you-type/10_basic.yml | 1 - .../elasticsearch/backwards/IndexingIT.java | 2 +- .../resources/rest-api-spec/api/exists.json | 25 ----- .../rest-api-spec/api/get_source.json | 26 ------ .../test/create/11_with_id_with_types.yml | 2 - .../test/create/41_routing_with_types.yml | 2 - .../test/exists/11_basic_with_types.yml | 36 -------- .../test/exists/41_routing_with_types.yml | 41 --------- .../exists/61_realtime_refresh_with_types.yml | 50 ---------- .../test/exists/71_defaults_with_types.yml | 17 ---- .../test/explain/40_mix_typeless_typeful.yml | 15 --- .../test/get_source/11_basic_with_types.yml | 17 ---- .../16_default_values_with_types.yml | 16 ---- .../test/get_source/41_routing_with_types.yml | 42 --------- .../61_realtime_refresh_with_types.yml | 49 ---------- .../71_source_filtering_with_types.yml | 27 ------ .../test/get_source/81_missing_with_types.yml | 19 ---- .../86_source_missing_with_types.yml | 39 -------- .../rest-api-spec/test/index/10_with_id.yml | 1 - .../test/index/11_with_id_with_types.yml | 2 - .../test/index/15_without_id.yml | 1 - .../test/index/16_without_id_with_types.yml | 2 - .../test/index/41_routing_with_types.yml | 2 - .../test/index/70_mix_typeless_typeful.yml | 92 ------------------- .../test/indices.clone/10_basic.yml | 3 - .../test/indices.rollover/10_basic.yml | 2 - .../test/indices.shrink/10_basic.yml | 2 - .../test/indices.split/10_basic.yml | 6 -- .../test/update/21_doc_upsert_with_types.yml | 2 - .../update/24_doc_as_upsert_with_types.yml | 2 - .../test/update/41_routing_with_types.yml | 1 - .../test/update/90_mix_typeless_typeful.yml | 3 - .../authorization/alias-privileges.asciidoc | 2 +- .../integration/BulkUpdateTests.java | 4 +- .../integration/ClusterPrivilegeTests.java | 8 +- .../DateMathExpressionIntegTests.java | 2 +- .../DocumentLevelSecurityTests.java | 14 +-- .../integration/FieldLevelSecurityTests.java | 16 ++-- .../integration/IndexPrivilegeTests.java | 2 +- .../security/authz/ReadActionsTests.java | 10 +- 41 files changed, 30 insertions(+), 576 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/exists/11_basic_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/exists/41_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/exists/61_realtime_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/exists/71_defaults_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get_source/11_basic_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get_source/16_default_values_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get_source/41_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get_source/61_realtime_refresh_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get_source/71_source_filtering_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get_source/81_missing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/get_source/86_source_missing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/70_mix_typeless_typeful.yml diff --git a/docs/reference/ingest/processors/circle.asciidoc b/docs/reference/ingest/processors/circle.asciidoc index a20c1f3cc82f7..e2d5c428b9d5d 100644 --- a/docs/reference/ingest/processors/circle.asciidoc +++ b/docs/reference/ingest/processors/circle.asciidoc @@ -112,7 +112,6 @@ The response from the above index request: { "found": true, "_index": "circles", - "_type": "_doc", "_id": "2", "_version": 1, "_seq_no": 22, diff --git a/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/10_basic.yml b/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/10_basic.yml index ffe05097748a6..f1851d9c35757 100644 --- a/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/10_basic.yml +++ b/modules/mapper-extras/src/test/resources/rest-api-spec/test/search-as-you-type/10_basic.yml @@ -41,7 +41,6 @@ setup: - do: get: index: test - type: _doc id: 1 - is_true: found 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 40eef35168eb8..1f984a514d0e3 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 @@ -286,7 +286,7 @@ private void assertCount(final String index, final String preference, final int } private void assertVersion(final String index, final int docId, final String preference, final int expectedVersion) throws IOException { - Request request = new Request("GET", index + "/" + docId); + Request request = new Request("GET", index + "/_doc/" + docId); request.addParameter("preference", preference); final Response response = client().performRequest(request); 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 09042376a256b..fd221b474a070 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 @@ -22,31 +22,6 @@ "description":"The name of the index" } } - }, - { - "path":"/{index}/{type}/{id}", - "methods":[ - "HEAD" - ], - "parts":{ - "id":{ - "type":"string", - "description":"The document ID" - }, - "index":{ - "type":"string", - "description":"The name of the index" - }, - "type":{ - "type":"string", - "description":"The type of the document (use `_all` to fetch the first document matching the ID across all types)", - "deprecated":true - } - }, - "deprecated":{ - "version":"7.0.0", - "description":"Specifying types in urls has been deprecated" - } } ] }, diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/get_source.json b/rest-api-spec/src/main/resources/rest-api-spec/api/get_source.json index e8da013fd9462..ad79678388590 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/get_source.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/get_source.json @@ -22,32 +22,6 @@ "description":"The name of the index" } } - }, - { - "path":"/{index}/{type}/{id}/_source", - "methods":[ - "GET" - ], - "parts":{ - "id":{ - "type":"string", - "description":"The document ID" - }, - "index":{ - "type":"string", - "description":"The name of the index" - }, - "type":{ - "type":"string", - "required":false, - "description":"The type of the document; deprecated and optional starting with 7.0", - "deprecated":true - } - }, - "deprecated":{ - "version":"7.0.0", - "description":"Specifying types in urls has been deprecated" - } } ] }, diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/create/11_with_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/create/11_with_id_with_types.yml index 1e58c38c7b589..ecc5d0c89b23b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/create/11_with_id_with_types.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/create/11_with_id_with_types.yml @@ -15,11 +15,9 @@ - do: get: index: test_1 - type: test id: 1 - match: { _index: test_1 } - - match: { _type: test } - match: { _id: "1"} - match: { _version: 1} - match: { _source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/create/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/create/41_routing_with_types.yml index 752489f722c9e..0e27bb9640c05 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/create/41_routing_with_types.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/create/41_routing_with_types.yml @@ -26,7 +26,6 @@ - do: get: index: test_1 - type: test id: 1 routing: 5 stored_fields: [_routing] @@ -38,6 +37,5 @@ catch: missing get: index: test_1 - type: test id: 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 deleted file mode 100644 index 7e4e26b6b1c1c..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/11_basic_with_types.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -"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/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/41_routing_with_types.yml deleted file mode 100644 index 25315628d7ece..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/41_routing_with_types.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -"Routing": - - - do: - indices.create: - index: test_1 - body: - settings: - index: - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - - do: - cluster.health: - wait_for_status: green - - - do: - index: - index: test_1 - type: test - id: 1 - routing: 5 - body: { foo: bar } - - - do: - 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/61_realtime_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/61_realtime_refresh_with_types.yml deleted file mode 100644 index df8c697e4a1fb..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/61_realtime_refresh_with_types.yml +++ /dev/null @@ -1,50 +0,0 @@ ---- -"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/71_defaults_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/exists/71_defaults_with_types.yml deleted file mode 100644 index 2db28f6634bd6..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/exists/71_defaults_with_types.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -"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/explain/40_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/explain/40_mix_typeless_typeful.yml index af2feb4231f30..355f9d8591127 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/explain/40_mix_typeless_typeful.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/explain/40_mix_typeless_typeful.yml @@ -22,21 +22,6 @@ - do: indices.refresh: {} - - do: - catch: missing - explain: - index: index - type: some_random_type - id: 1 - body: - query: - match_all: {} - - - match: { _index: "index" } - - match: { _type: "some_random_type" } - - match: { _id: "1"} - - match: { matched: false} - - do: explain: index: index diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/11_basic_with_types.yml deleted file mode 100644 index 1446f569e86d8..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/11_basic_with_types.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -"Basic with types": - - - do: - index: - index: test_1 - type: test - id: 1 - body: { "foo": "bar" } - - - do: - get_source: - index: test_1 - type: test - id: 1 - - - match: { '': { foo: bar } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/16_default_values_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/16_default_values_with_types.yml deleted file mode 100644 index e2de7a9f0007c..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/16_default_values_with_types.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -"Default values": - - do: - index: - index: test_1 - type: test - id: 1 - body: { "foo": "bar" } - - - do: - get_source: - index: test_1 - type: test - id: 1 - - - match: { '': { foo: bar } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/41_routing_with_types.yml deleted file mode 100644 index db53a33ba597e..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/41_routing_with_types.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -"Routing": - - - - do: - indices.create: - index: test_1 - body: - settings: - index: - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - - do: - cluster.health: - wait_for_status: green - - - do: - index: - index: test_1 - type: test - id: 1 - routing: 5 - body: { foo: bar } - - - do: - get_source: - index: test_1 - type: test - id: 1 - routing: 5 - - - match: { '': {foo: bar}} - - - do: - catch: missing - get_source: - index: test_1 - type: test - id: 1 - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/61_realtime_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/61_realtime_refresh_with_types.yml deleted file mode 100644 index f5b406de28b4a..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/61_realtime_refresh_with_types.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -"Realtime": - - - do: - indices.create: - index: test_1 - body: - settings: - 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: - catch: missing - get_source: - index: test_1 - type: test - id: 1 - realtime: false - - - do: - get_source: - index: test_1 - type: test - id: 1 - realtime: true - - - match: { '': {foo: bar}} - - - do: - get_source: - index: test_1 - type: test - id: 1 - realtime: false - refresh: true - - - match: { '': {foo: bar}} - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/71_source_filtering_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/71_source_filtering_with_types.yml deleted file mode 100644 index b4f20fee53be2..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/71_source_filtering_with_types.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -"Source filtering": - - - - do: - index: - index: test_1 - type: test - id: 1 - body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } - - - do: - get_source: { index: test_1, type: test, id: 1, _source_includes: include.field1 } - - match: { include.field1: v1 } - - is_false: include.field2 - - - do: - get_source: { index: test_1, type: test, id: 1, _source_includes: "include.field1,include.field2" } - - match: { include.field1: v1 } - - match: { include.field2: v2 } - - is_false: count - - - do: - get_source: { index: test_1, type: test, id: 1, _source_includes: include, _source_excludes: "*.field2" } - - match: { include.field1: v1 } - - is_false: include.field2 - - is_false: count diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/81_missing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/81_missing_with_types.yml deleted file mode 100644 index 16eb5ea51e898..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/81_missing_with_types.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -"Missing document with catch": - - - do: - catch: missing - get_source: - index: test_1 - type: test - id: 1 - ---- -"Missing document with ignore": - - - do: - get_source: - index: test_1 - type: test - id: 1 - ignore: 404 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/86_source_missing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/86_source_missing_with_types.yml deleted file mode 100644 index d7cfced5164ec..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get_source/86_source_missing_with_types.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -setup: - - - do: - indices.create: - include_type_name: true - index: test_1 - body: - mappings: - test: - _source: { enabled: false } - - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - ---- -"Missing document source with catch": - - - do: - catch: missing - get_source: - index: test_1 - type: test - id: 1 - ---- -"Missing document source with ignore": - - - do: - get_source: - index: test_1 - type: test - id: 1 - ignore: 404 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml index ffc55a8d2908a..bae38ab41cbc2 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml @@ -20,7 +20,6 @@ id: 1 - match: { _index: test-weird-index-中文 } - - match: { _type: _doc } - match: { _id: "1"} - match: { _version: 1} - match: { _source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml index daac81849fb5e..1617cd9e09369 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml @@ -16,11 +16,9 @@ - do: get: index: test-weird-index-中文 - type: weird.type id: 1 - match: { _index: test-weird-index-中文 } - - match: { _type: weird.type } - match: { _id: "1"} - match: { _version: 1} - match: { _source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml index eea7882319fba..6471856c6df1c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml @@ -20,7 +20,6 @@ id: '$id' - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: $id } - match: { _version: 1 } - match: { _source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml index 3fff0512b9602..56b1ee1fe7b08 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml @@ -16,11 +16,9 @@ - do: get: index: test_1 - type: test id: '$id' - match: { _index: test_1 } - - match: { _type: test } - match: { _id: $id } - match: { _version: 1 } - match: { _source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml index 5b0cf94f4236b..4032ea1226829 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml @@ -26,7 +26,6 @@ - do: get: index: test_1 - type: test id: 1 routing: 5 stored_fields: [_routing] @@ -38,6 +37,5 @@ catch: missing get: index: test_1 - type: test id: 1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/70_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/70_mix_typeless_typeful.yml deleted file mode 100644 index 9770137cc6f5a..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/70_mix_typeless_typeful.yml +++ /dev/null @@ -1,92 +0,0 @@ ---- -"Index with typeless API on an index that has types": - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - - do: - index: - index: index - id: 1 - body: { foo: bar } - - - match: { _index: "index" } - - match: { _type: "_doc" } - - match: { _id: "1"} - - match: { _version: 1} - - - do: - get: # not using typeless API on purpose - index: index - type: not_doc - id: 1 - - - match: { _index: "index" } - - match: { _type: "not_doc" } # the important bit to check - - match: { _id: "1"} - - match: { _version: 1} - - match: { _source: { foo: bar }} - - - - do: - index: - index: index - body: { foo: bar } - - - match: { _index: "index" } - - match: { _type: "_doc" } - - match: { _version: 1} - - set: { _id: id } - - - do: - get: # using typeful API on purpose - index: index - type: not_doc - id: '$id' - - - match: { _index: "index" } - - match: { _type: "not_doc" } # the important bit to check - - match: { _id: $id} - - match: { _version: 1} - - match: { _source: { foo: bar }} - ---- -"Index call that introduces new field mappings": - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - do: - index: - index: index - id: 2 - body: { new_field: value } - - - match: { _index: "index" } - - match: { _type: "_doc" } - - match: { _id: "2" } - - match: { _version: 1 } - - - do: - get: # using typeful API on purpose - index: index - type: not_doc - id: 2 - - - match: { _index: "index" } - - match: { _type: "not_doc" } - - match: { _id: "2" } - - match: { _version: 1} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.clone/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.clone/10_basic.yml index 412d29905ffc2..a4d1841ed7108 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.clone/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.clone/10_basic.yml @@ -66,7 +66,6 @@ setup: id: "1" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } @@ -77,7 +76,6 @@ setup: id: "2" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "2" } - match: { _source: { foo: "hello world 2" } } @@ -88,7 +86,6 @@ setup: id: "3" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "3" } - match: { _source: { foo: "hello world 3" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml index 342adced0640d..9a364b5296bbe 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yml @@ -25,11 +25,9 @@ - do: get: index: logs_search - type: test id: "1" - match: { _index: logs-1 } - - match: { _type: test } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/10_basic.yml index 54d3d38903bf3..6697984003a20 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/10_basic.yml @@ -38,7 +38,6 @@ id: "1" - match: { _index: source } - - match: { _type: _doc } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } @@ -76,6 +75,5 @@ id: "1" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.split/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.split/10_basic.yml index 01d41856fe1ae..067b2bb5774c3 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.split/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.split/10_basic.yml @@ -64,7 +64,6 @@ setup: id: "1" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } @@ -75,7 +74,6 @@ setup: id: "2" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "2" } - match: { _source: { foo: "hello world 2" } } @@ -86,7 +84,6 @@ setup: id: "3" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "3" } - match: { _source: { foo: "hello world 3" } } @@ -157,7 +154,6 @@ setup: id: "1" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } @@ -168,7 +164,6 @@ setup: id: "2" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "2" } - match: { _source: { foo: "hello world 2" } } @@ -179,7 +174,6 @@ setup: id: "3" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "3" } - match: { _source: { foo: "hello world 3" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml index f34e030ff66a0..5e702c5a2b6bd 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml @@ -13,7 +13,6 @@ - do: get: index: test_1 - type: test id: 1 - match: { _source.foo: baz } @@ -32,7 +31,6 @@ - do: get: index: test_1 - type: test id: 1 - match: { _source.foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml index 7585b9f3e0b94..8331ad64e100c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml @@ -13,7 +13,6 @@ - do: get: index: test_1 - type: test id: 1 - match: { _source.foo: bar } @@ -32,7 +31,6 @@ - do: get: index: test_1 - type: test id: 1 - match: { _source.foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml index 977db506710c7..5bf883c031013 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml @@ -28,7 +28,6 @@ - do: get: index: test_1 - type: test id: 1 routing: 5 stored_fields: _routing diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/90_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/90_mix_typeless_typeful.yml index fff183daedc37..a76ed8a65933e 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/90_mix_typeless_typeful.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/90_mix_typeless_typeful.yml @@ -30,7 +30,6 @@ - do: get: index: index - type: not_doc id: 1 - match: { _source.foo: baz } @@ -67,11 +66,9 @@ - do: get: # using typeful API on purpose index: index - type: not_doc id: 1 - match: { _index: "index" } - - match: { _type: "not_doc" } - match: { _id: "1" } - match: { _version: 2} - match: { _source.foo: baz } diff --git a/x-pack/docs/en/security/authorization/alias-privileges.asciidoc b/x-pack/docs/en/security/authorization/alias-privileges.asciidoc index 860e3b868fa38..11183a7bbe5a4 100644 --- a/x-pack/docs/en/security/authorization/alias-privileges.asciidoc +++ b/x-pack/docs/en/security/authorization/alias-privileges.asciidoc @@ -27,7 +27,7 @@ The user attempts to retrieve a document from `current_year`: [source,console] ------------------------------------------------------------------------------- -GET /current_year/event/1 +GET /current_year/_doc/1 ------------------------------------------------------------------------------- // TEST[s/^/PUT 2015\n{"aliases": {"current_year": {}}}\nPUT 2015\/event\/1\n{}\n/] diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index c9ed889ffed27..88a72072c952f 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java @@ -71,7 +71,7 @@ public void testThatBulkUpdateDoesNotLoseFields() { } public void testThatBulkUpdateDoesNotLoseFieldsHttp() throws IOException { - final String path = "/index1/type/1"; + final String path = "/index1/_doc/1"; final RequestOptions.Builder optionsBuilder = RequestOptions.DEFAULT.toBuilder(); optionsBuilder.addHeader("Authorization", UsernamePasswordToken.basicAuthHeaderValue(SecuritySettingsSource.TEST_USER_NAME, new SecureString(SecuritySettingsSourceField.TEST_PASSWORD.toCharArray()))); @@ -107,7 +107,7 @@ public void testThatBulkUpdateDoesNotLoseFieldsHttp() throws IOException { Request bulkRequest = new Request("POST", "/_bulk"); bulkRequest.setOptions(options); bulkRequest.setJsonEntity( - "{\"update\": {\"_index\": \"index1\", \"_type\": \"type\", \"_id\": \"1\"}}\n" + + "{\"update\": {\"_index\": \"index1\", \"_type\": \"_doc\", \"_id\": \"1\"}}\n" + "{\"doc\": {\"bulk updated\":\"bulk updated\"}}\n"); getRestClient().performRequest(bulkRequest); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java index 384401edaf510..09a79ee03d54c 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java @@ -184,10 +184,10 @@ public void testThatSnapshotAndRestore() throws Exception { assertAccessIsDenied("user_d", restoreSnapshotRequest); assertAccessIsAllowed("user_a", restoreSnapshotRequest); - assertAccessIsDenied("user_a", "GET", "/someindex/bar/1"); - assertAccessIsDenied("user_b", "GET", "/someindex/bar/1"); - assertAccessIsDenied("user_d", "GET", "/someindex/bar/1"); - assertAccessIsAllowed("user_c", "GET", "/someindex/bar/1"); + assertAccessIsDenied("user_a", "GET", "/someindex/1"); + assertAccessIsDenied("user_b", "GET", "/someindex/1"); + assertAccessIsDenied("user_d", "GET", "/someindex/1"); + assertAccessIsAllowed("user_c", "GET", "/someindex/1"); assertAccessIsDenied("user_b", "DELETE", "/_snapshot/my-repo/my-snapshot"); assertAccessIsDenied("user_c", "DELETE", "/_snapshot/my-repo/my-snapshot"); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java index 033cb418a031c..a0b4e68351a67 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DateMathExpressionIntegTests.java @@ -103,7 +103,7 @@ public void testDateMathExpressionsCanBeAuthorized() throws Exception { // multi get doesn't support expressions - this is probably a bug MultiGetResponse multiGetResponse = client.prepareMultiGet() - .add(expression, "type", response.getId()) + .add(expression, response.getId()) .get(); assertFalse(multiGetResponse.getResponses()[0].isFailed()); assertTrue(multiGetResponse.getResponses()[0].getResponse().isExists()); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java index 84595c72fa1b0..fa98f4d20dd2b 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/DocumentLevelSecurityTests.java @@ -266,7 +266,7 @@ public void testMGetApi() throws Exception { MultiGetResponse response = client() .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -276,7 +276,7 @@ public void testMGetApi() throws Exception { response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "2") + .add("test", "2") .setRealtime(realtime) .setRefresh(true) .get(); @@ -286,8 +286,8 @@ public void testMGetApi() throws Exception { response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") - .add("test", "type1", "2") + .add("test", "1") + .add("test", "2") .setRealtime(realtime) .setRefresh(true) .get(); @@ -300,7 +300,7 @@ public void testMGetApi() throws Exception { response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -309,7 +309,7 @@ public void testMGetApi() throws Exception { response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "2") + .add("test", "2") .setRealtime(realtime) .setRefresh(true) .get(); @@ -318,7 +318,7 @@ public void testMGetApi() throws Exception { response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "3") + .add("test", "3") .setRealtime(realtime) .setRefresh(true) .get(); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java index 04b8deed639ee..e89830f56fec9 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/FieldLevelSecurityTests.java @@ -420,7 +420,7 @@ public void testMGetApi() throws Exception { MultiGetResponse response = client() .filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -432,7 +432,7 @@ public void testMGetApi() throws Exception { // user2 is granted access to field2 only: response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -444,7 +444,7 @@ public void testMGetApi() throws Exception { // user3 is granted access to field1 and field2: response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -457,7 +457,7 @@ public void testMGetApi() throws Exception { // user4 is granted access to no fields, so the get response does say the doc exist, but no fields are returned: response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -468,7 +468,7 @@ public void testMGetApi() throws Exception { // user5 has no field level security configured, so all fields are returned: response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user5", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -482,7 +482,7 @@ public void testMGetApi() throws Exception { // user6 has access to field* response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user6", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -496,7 +496,7 @@ public void testMGetApi() throws Exception { // user7 has roles with field level security and without field level security response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user7", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); @@ -510,7 +510,7 @@ public void testMGetApi() throws Exception { // user8 has roles with field level security with access to field1 and field2 response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user8", USERS_PASSWD))) .prepareMultiGet() - .add("test", "type1", "1") + .add("test", "1") .setRealtime(realtime) .setRefresh(true) .get(); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java index 1fe3eeaef52ee..8c0cd71e6d89d 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java @@ -356,7 +356,7 @@ public void testUserU13() throws Exception { assertAccessIsAllowed("u13", "GET", "/" + randomIndex() + "/_msearch", "{}\n{ \"query\" : { \"match_all\" : {} } }\n"); - assertAccessIsAllowed("u13", "POST", "/" + randomIndex() + "/foo/_mget", "{ \"ids\" : [ \"1\", \"2\" ] } "); + assertAccessIsAllowed("u13", "POST", "/" + randomIndex() + "/_mget", "{ \"ids\" : [ \"1\", \"2\" ] } "); assertAccessIsAllowed("u13", "PUT", "/a/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n"); assertBodyHasAccessIsDenied("u13", "PUT", "/b/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n"); assertAccessIsAllowed("u13", diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java index cf783478a3223..21986fb49407d 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/ReadActionsTests.java @@ -332,11 +332,11 @@ public void testGet() { public void testMultiGet() { createIndicesWithRandomAliases("test1", "test2", "test3", "index1"); MultiGetResponse multiGetResponse = client().prepareMultiGet() - .add("test1", "type", "id") - .add("index1", "type", "id") - .add("test3", "type", "id") - .add("missing", "type", "id") - .add("test5", "type", "id").get(); + .add("test1", "id") + .add("index1", "id") + .add("test3", "id") + .add("missing", "id") + .add("test5", "id").get(); assertEquals(5, multiGetResponse.getResponses().length); assertFalse(multiGetResponse.getResponses()[0].isFailed()); assertEquals("test1", multiGetResponse.getResponses()[0].getResponse().getIndex()); From c3bafdfc805f31f75b9a76d83a4f6ef655ae7563 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 14:26:51 +0100 Subject: [PATCH 06/13] tests --- .../java/org/elasticsearch/client/RequestConverters.java | 2 +- .../resources/rest-api-spec/test/reindex/85_scripting.yml | 6 +++--- .../test/ingest/10_pipeline_with_mustache_templates.yml | 6 ------ .../rest-api-spec/test/ingest/20_combine_processors.yml | 2 -- .../test/ingest/50_script_processor_using_painless.yml | 2 -- .../elasticsearch/integration/ClusterPrivilegeTests.java | 8 ++++---- .../resources/rest-api-spec/test/roles/11_idx_arrays.yml | 2 -- .../test/security/hidden-index/10_security_read.yml | 1 - .../test/security/hidden-index/11_security-6_read.yml | 1 - .../test/security/hidden-index/12_security-7_read.yml | 1 - .../rest-api-spec/test/mixed_cluster/50_token_auth.yml | 3 --- 11 files changed, 8 insertions(+), 26 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java index d34a1d9f124c4..197e9f020b658 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java @@ -731,7 +731,7 @@ static String endpoint(String index, String type, String id) { } static String endpoint(String index, String id) { - return new EndpointBuilder().addPathPart(index, id).build(); + return new EndpointBuilder().addPathPart(index, "_doc", id).build(); } @Deprecated diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/85_scripting.yml b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/85_scripting.yml index ee920a669a504..8716ad303c57f 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/85_scripting.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/85_scripting.yml @@ -399,9 +399,9 @@ mget: body: docs: - - { _index: index2, _type: _doc, _id: en_123} - - { _index: index2, _type: _doc, _id: en_456} - - { _index: index2, _type: _doc, _id: fr_789} + - { _index: index2, _id: en_123} + - { _index: index2, _id: en_456} + - { _index: index2, _id: fr_789} - is_true: docs.0.found - match: { docs.0._index: index2 } diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml index 5ffaebdcaef36..8c3252f72c73a 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/10_pipeline_with_mustache_templates.yml @@ -38,7 +38,6 @@ - do: get: index: test - type: test id: 1 - length: { _source: 2 } - match: { _source.index_type_id: "test/test/1" } @@ -123,7 +122,6 @@ - do: get: index: test - type: test id: 1 - length: { _source: 5 } - match: { _source.field1: "1" } @@ -145,7 +143,6 @@ - do: get: index: test - type: test id: 1 - length: { _source: 2 } - match: { _source.field1: "field2" } @@ -165,7 +162,6 @@ - do: get: index: test - type: test id: 1 - length: { _source: 1 } - match: { _source.field_to_remove: "field2" } @@ -214,7 +210,6 @@ - do: get: index: test - type: test id: 1 - length: { _source: 2 } - match: { _source.do_nothing: "foo" } @@ -268,7 +263,6 @@ - do: get: index: test - type: test id: 1 - length: { _source: 2 } - match: { _source.values_flat: ["foo_bar", "foo_baz"] } diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml index 0c0cf816b000d..2a68724fa8def 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml @@ -53,7 +53,6 @@ - do: get: index: test - type: test id: 1 - length: { _source: 13 } - match: { _source.request: "/presentations/logstash-scale11x/images/ahhh___rage_face_by_samusmmx-d5g5zap.png" } @@ -173,7 +172,6 @@ - do: get: index: test - type: test id: 1 - length: { _source: 11 } - is_false: _source.friends.0.id diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/50_script_processor_using_painless.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/50_script_processor_using_painless.yml index cce388c2ff737..ff0ccb5c340bf 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/50_script_processor_using_painless.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/50_script_processor_using_painless.yml @@ -30,7 +30,6 @@ - do: get: index: test - type: test id: 1 - match: { _source.bytes_in: 1234 } - match: { _source.bytes_out: 4321 } @@ -80,7 +79,6 @@ - do: get: index: test - type: test id: 1 - match: { _source.bytes_in: 1234 } - match: { _source.bytes_out: 4321 } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java index 09a79ee03d54c..0d7db3cc1ad94 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java @@ -184,10 +184,10 @@ public void testThatSnapshotAndRestore() throws Exception { assertAccessIsDenied("user_d", restoreSnapshotRequest); assertAccessIsAllowed("user_a", restoreSnapshotRequest); - assertAccessIsDenied("user_a", "GET", "/someindex/1"); - assertAccessIsDenied("user_b", "GET", "/someindex/1"); - assertAccessIsDenied("user_d", "GET", "/someindex/1"); - assertAccessIsAllowed("user_c", "GET", "/someindex/1"); + assertAccessIsDenied("user_a", "GET", "/someindex/_doc/1"); + assertAccessIsDenied("user_b", "GET", "/someindex/_doc/1"); + assertAccessIsDenied("user_d", "GET", "/someindex/_doc/1"); + assertAccessIsAllowed("user_c", "GET", "/someindex/_doc/1"); assertAccessIsDenied("user_b", "DELETE", "/_snapshot/my-repo/my-snapshot"); assertAccessIsDenied("user_c", "DELETE", "/_snapshot/my-repo/my-snapshot"); diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yml index 1046be6a1b6eb..61b3070f9df4f 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yml @@ -65,10 +65,8 @@ teardown: Authorization: "Basic am9lOnMza3JpdA==" get: index: foo - type: doc id: 1 - match: { _index: foo } - - match: { _type: doc } - match: { _id: "1"} - match: { _source: { foo: bar }} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/10_security_read.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/10_security_read.yml index c0eceee94dafe..9458eb2dbc951 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/10_security_read.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/10_security_read.yml @@ -63,7 +63,6 @@ teardown: headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user get: index: ".security" - type: "doc" id: "user-test_user" --- diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/11_security-6_read.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/11_security-6_read.yml index eb31b56e64d50..d754176a8b414 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/11_security-6_read.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/11_security-6_read.yml @@ -63,7 +63,6 @@ teardown: headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user get: index: ".security-6" - type: "doc" id: "user-test_user" --- diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/12_security-7_read.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/12_security-7_read.yml index cb910d4a88156..6e57a1a816741 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/12_security-7_read.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/security/hidden-index/12_security-7_read.yml @@ -63,7 +63,6 @@ teardown: headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user get: index: ".security-7" - type: "doc" id: "user-test_user" --- diff --git a/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/50_token_auth.yml b/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/50_token_auth.yml index f426d9b2525b4..9fac41b569048 100644 --- a/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/50_token_auth.yml +++ b/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/mixed_cluster/50_token_auth.yml @@ -13,7 +13,6 @@ id: "6" - match: { _index: token_index } - - match: { _type: _doc } - match: { _id: "6" } - is_true: _source.token - set: { _source.token : token } @@ -66,7 +65,6 @@ id: "7" - match: { _index: token_index } - - match: { _type: _doc } - match: { _id: "7" } - is_true: _source.token - set: { _source.token : token } @@ -118,7 +116,6 @@ id: "8" - match: { _index: token_index } - - match: { _type: _doc } - match: { _id: "8" } - is_true: _source.token - set: { _source.token : refresh_token } From f86205e0eae5afe6d19cd56ee8468cd7a5f42459 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 14:56:36 +0100 Subject: [PATCH 07/13] tests --- .../elasticsearch/client/RequestConvertersTests.java | 10 +--------- .../rest-api-spec/test/20_update_by_query.yml | 1 - .../rest-api-spec/test/mustache/10_webhook.yml | 1 - 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java index 42636e7c684d2..2d718fdc44ad0 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java @@ -152,10 +152,6 @@ public void testGet() { getAndExistsTest(RequestConverters::get, HttpGet.METHOD_NAME); } - public void testGetWithType() { - getAndExistsWithTypeTest(RequestConverters::get, HttpGet.METHOD_NAME); - } - public void testSourceExists() throws IOException { doTestSourceExists((index, id) -> new GetRequest(index, id)); } @@ -308,10 +304,6 @@ public void testExists() { getAndExistsTest(RequestConverters::exists, HttpHead.METHOD_NAME); } - public void testExistsWithType() { - getAndExistsWithTypeTest(RequestConverters::exists, HttpHead.METHOD_NAME); - } - private static void getAndExistsTest(Function requestConverter, String method) { String index = randomAlphaOfLengthBetween(3, 10); String id = randomAlphaOfLengthBetween(3, 10); @@ -363,7 +355,7 @@ private static void getAndExistsTest(Function requestConver } } Request request = requestConverter.apply(getRequest); - assertEquals("/" + index + "/" + id, request.getEndpoint()); + assertEquals("/" + index + "/_doc/" + id, request.getEndpoint()); assertEquals(expectedParams, request.getParameters()); assertNull(request.getEntity()); assertEquals(method, request.getMethod()); diff --git a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/20_update_by_query.yml b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/20_update_by_query.yml index b54925701bbe8..31202d1f20f63 100644 --- a/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/20_update_by_query.yml +++ b/x-pack/qa/reindex-tests-with-security/src/test/resources/rest-api-spec/test/20_update_by_query.yml @@ -210,7 +210,6 @@ setup: - do: get: index: source - type: _doc id: 1 # These were visible to the user running the update_by_query so they stayed. - match: { _source.foo: z } diff --git a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/10_webhook.yml b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/10_webhook.yml index 5a5a4dfe46205..6d03abd57293f 100644 --- a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/10_webhook.yml +++ b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/10_webhook.yml @@ -66,7 +66,6 @@ - do: get: index: my_index - type: my_type id: test_watch - match: { _source: { watch_id: "test_watch" } } From d2ad65f760e05ca318549c43008ddffc3c462fd5 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 15:20:46 +0100 Subject: [PATCH 08/13] tests --- .../rest-api-spec/test/store_smb/15_index_creation.yml | 1 - .../rest-api-spec/test/upgraded_cluster/50_token_auth.yml | 2 -- 2 files changed, 3 deletions(-) diff --git a/plugins/store-smb/src/test/resources/rest-api-spec/test/store_smb/15_index_creation.yml b/plugins/store-smb/src/test/resources/rest-api-spec/test/store_smb/15_index_creation.yml index 09e59c7fc9d9a..fbbdcb8f153e0 100644 --- a/plugins/store-smb/src/test/resources/rest-api-spec/test/store_smb/15_index_creation.yml +++ b/plugins/store-smb/src/test/resources/rest-api-spec/test/store_smb/15_index_creation.yml @@ -19,7 +19,6 @@ id: 1 - match: { _index: smb-test } - - match: { _type: _doc } - match: { _id: "1"} - match: { _version: 1} - match: { _source: { foo: bar }} diff --git a/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/50_token_auth.yml b/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/50_token_auth.yml index 430f94c1064d6..e2fc94ece9083 100644 --- a/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/50_token_auth.yml +++ b/x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/50_token_auth.yml @@ -13,7 +13,6 @@ id: "6" - match: { _index: token_index } - - match: { _type: _doc } - match: { _id: "6" } - is_true: _source.token - set: { _source.token : token } @@ -56,7 +55,6 @@ id: "8" - match: { _index: token_index } - - match: { _type: _doc } - match: { _id: "8" } - is_true: _source.token - set: { _source.token : refresh_token } From 4db5efb6f89e81eaa68a4dd7a4e5724e2ece4c78 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 16:48:06 +0100 Subject: [PATCH 09/13] more tests --- .../action/RoutingMissingException.java | 23 +++++++------------ .../action/bulk/TransportBulkAction.java | 2 +- .../explain/TransportExplainAction.java | 2 +- .../action/index/IndexRequest.java | 10 ++++---- .../action/update/TransportUpdateAction.java | 2 +- .../ElasticsearchExceptionTests.java | 6 ++--- .../ExceptionSerializationTests.java | 5 ++-- .../action/bulk/BulkProcessorIT.java | 2 +- .../action/bulk/BulkWithUpdatesIT.java | 2 -- .../org/elasticsearch/get/GetActionIT.java | 14 +++++------ ...DateMathIndexExpressionsIntegrationIT.java | 6 ++--- .../routing/SimpleRoutingIT.java | 2 +- .../org/elasticsearch/update/UpdateIT.java | 2 -- 13 files changed, 33 insertions(+), 45 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/RoutingMissingException.java b/server/src/main/java/org/elasticsearch/action/RoutingMissingException.java index e3ef791814ac8..b571d77a7fdd7 100644 --- a/server/src/main/java/org/elasticsearch/action/RoutingMissingException.java +++ b/server/src/main/java/org/elasticsearch/action/RoutingMissingException.java @@ -20,6 +20,7 @@ package org.elasticsearch.action; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.mapper.MapperService; @@ -30,28 +31,16 @@ public class RoutingMissingException extends ElasticsearchException { - private final String type; - private final String id; public RoutingMissingException(String index, String id) { - this(index, MapperService.SINGLE_MAPPING_NAME, id); - } - - public RoutingMissingException(String index, String type, String id) { - super("routing is required for [" + index + "]/[" + type + "]/[" + id + "]"); + super("routing is required for [" + index + "]/[" + id + "]"); Objects.requireNonNull(index, "index must not be null"); - Objects.requireNonNull(type, "type must not be null"); Objects.requireNonNull(id, "id must not be null"); setIndex(index); - this.type = type; this.id = id; } - public String getType() { - return type; - } - public String getId() { return id; } @@ -63,14 +52,18 @@ public RestStatus status() { public RoutingMissingException(StreamInput in) throws IOException{ super(in); - type = in.readString(); + if (in.getVersion().before(Version.V_8_0_0)) { + in.readString(); + } id = in.readString(); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeString(type); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); } } diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index a2f105df7e9b7..9c185db96c83f 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -383,7 +383,7 @@ protected void doRun() { docWriteRequest.routing(metaData.resolveWriteIndexRouting(docWriteRequest.routing(), docWriteRequest.index())); // check if routing is required, if so, throw error if routing wasn't specified if (docWriteRequest.routing() == null && metaData.routingRequired(concreteIndex.getName())) { - throw new RoutingMissingException(concreteIndex.getName(), docWriteRequest.type(), docWriteRequest.id()); + throw new RoutingMissingException(concreteIndex.getName(), docWriteRequest.id()); } break; default: throw new AssertionError("request type not supported: [" + docWriteRequest.opType() + "]"); diff --git a/server/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java b/server/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java index bcafaff3c404c..70b9704c77d7f 100644 --- a/server/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java +++ b/server/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java @@ -88,7 +88,7 @@ protected void resolveRequest(ClusterState state, InternalRequest request) { request.request().filteringAlias(aliasFilter); // Fail fast on the node that received the request. if (request.request().routing() == null && state.getMetaData().routingRequired(request.concreteIndex())) { - throw new RoutingMissingException(request.concreteIndex(), request.request().type(), request.request().id()); + throw new RoutingMissingException(request.concreteIndex(), request.request().id()); } } diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index aa5080d5e2a09..6b12942498703 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -249,7 +249,7 @@ public XContentType getContentType() { @Override public String type() { if (type == null) { - return MapperService.SINGLE_MAPPING_NAME; + return MapperService.SINGLE_MAPPING_NAME; } return type; } @@ -278,7 +278,7 @@ public IndexRequest defaultTypeIfNull(String defaultType) { type = defaultType; } return this; - } + } /** * The id of the indexed document. If not set, will be automatically generated. */ @@ -589,7 +589,7 @@ public void process(Version indexCreatedVersion, @Nullable MappingMetaData mappi if (mappingMd != null) { // might as well check for routing here if (mappingMd.routing().required() && routing == null) { - throw new RoutingMissingException(concreteIndex, type(), id); + throw new RoutingMissingException(concreteIndex, id); } } @@ -616,8 +616,8 @@ public void resolveRouting(MetaData metaData) { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. - // So we use the type accessor method here to make the type non-null (will default it to "_doc"). + // A 7.x request allows null types but if deserialized in a 6.x node will cause nullpointer exceptions. + // So we use the type accessor method here to make the type non-null (will default it to "_doc"). out.writeOptionalString(type()); out.writeOptionalString(id); out.writeOptionalString(routing); diff --git a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java index a2277a78ea90d..2781fe5ab9a32 100644 --- a/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java @@ -109,7 +109,7 @@ public static void resolveAndValidateRouting(MetaData metaData, String concreteI request.routing((metaData.resolveWriteIndexRouting(request.routing(), request.index()))); // Fail fast on the node that received the request, rather than failing when translating on the index or delete request. if (request.routing() == null && metaData.routingRequired(concreteIndex)) { - throw new RoutingMissingException(concreteIndex, request.type(), request.id()); + throw new RoutingMissingException(concreteIndex, request.id()); } } diff --git a/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java b/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java index 2706e14a361e1..65eb5c21cd7ee 100644 --- a/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java +++ b/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java @@ -465,7 +465,7 @@ public void testFromXContentWithCause() throws IOException { ElasticsearchException e = new ElasticsearchException("foo", new ElasticsearchException("bar", new ElasticsearchException("baz", - new RoutingMissingException("_test", "_type", "_id")))); + new RoutingMissingException("_test", "_id")))); final XContent xContent = randomFrom(XContentType.values()).xContent(); XContentBuilder builder = XContentBuilder.builder(xContent).startObject().value(e).endObject(); @@ -498,7 +498,7 @@ public void testFromXContentWithCause() throws IOException { } public void testFromXContentWithHeadersAndMetadata() throws IOException { - RoutingMissingException routing = new RoutingMissingException("_test", "_type", "_id"); + RoutingMissingException routing = new RoutingMissingException("_test", "_id"); ElasticsearchException baz = new ElasticsearchException("baz", routing); baz.addHeader("baz_0", "baz0"); baz.addMetadata("es.baz_1", "baz1"); @@ -771,7 +771,7 @@ public void testFailureToAndFromXContentWithDetails() throws IOException { break; case 4: // JDK exception with cause - failureCause = new RoutingMissingException("idx", "type", "id"); + failureCause = new RoutingMissingException("idx", "id"); failure = new RuntimeException("E", failureCause); expectedCause = new ElasticsearchException("Elasticsearch exception [type=routing_missing_exception, " + diff --git a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 411dc02f8adff..ca651dcd3f8d0 100644 --- a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -441,11 +441,10 @@ public void testSearchPhaseExecutionException() throws IOException { } public void testRoutingMissingException() throws IOException { - RoutingMissingException ex = serialize(new RoutingMissingException("idx", "type", "id")); + RoutingMissingException ex = serialize(new RoutingMissingException("idx", "id")); assertEquals("idx", ex.getIndex().getName()); - assertEquals("type", ex.getType()); assertEquals("id", ex.getId()); - assertEquals("routing is required for [idx]/[type]/[id]", ex.getMessage()); + assertEquals("routing is required for [idx]/[id]", ex.getMessage()); } public void testRepositoryException() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java index 79e1438956e52..f6d1651834232 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java @@ -268,7 +268,7 @@ private static MultiGetRequestBuilder indexDocs(Client client, BulkProcessor pro .startObject().field("field", randomRealisticUnicodeOfLengthBetween(1, 30)).endObject()) + "\n"; processor.add(new BytesArray(source), null, null, XContentType.JSON); } - multiGetRequestBuilder.add("test", "test", Integer.toString(i)); + multiGetRequestBuilder.add("test", Integer.toString(i)); } return multiGetRequestBuilder; } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java index 96f132e4de031..f79eed492519e 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java @@ -400,7 +400,6 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(response.getItems()[i].getItemId(), equalTo(i)); assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getIndex(), equalTo("test")); - assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE)); } @@ -419,7 +418,6 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(itemResponse.getItemId(), equalTo(i)); assertThat(itemResponse.getId(), equalTo(Integer.toString(i))); assertThat(itemResponse.getIndex(), equalTo("test")); - assertThat(itemResponse.getType(), equalTo("type1")); assertThat(itemResponse.getOpType(), equalTo(OpType.UPDATE)); for (int j = 0; j < 5; j++) { GetResponse getResponse = client().prepareGet("test", Integer.toString(i)).get(); diff --git a/server/src/test/java/org/elasticsearch/get/GetActionIT.java b/server/src/test/java/org/elasticsearch/get/GetActionIT.java index e63f37e94a34a..69ac022fa59c3 100644 --- a/server/src/test/java/org/elasticsearch/get/GetActionIT.java +++ b/server/src/test/java/org/elasticsearch/get/GetActionIT.java @@ -223,7 +223,7 @@ public void testSimpleMultiGet() throws Exception { .setSettings(Settings.builder().put("index.refresh_interval", -1))); ensureGreen(); - MultiGetResponse response = client().prepareMultiGet().add(indexOrAlias(), "type1", "1").get(); + MultiGetResponse response = client().prepareMultiGet().add(indexOrAlias(), "1").get(); assertThat(response.getResponses().length, equalTo(1)); assertThat(response.getResponses()[0].getResponse().isExists(), equalTo(false)); @@ -232,11 +232,11 @@ public void testSimpleMultiGet() throws Exception { } response = client().prepareMultiGet() - .add(indexOrAlias(), "type1", "1") - .add(indexOrAlias(), "type1", "15") - .add(indexOrAlias(), "type1", "3") - .add(indexOrAlias(), "type1", "9") - .add(indexOrAlias(), "type1", "11").get(); + .add(indexOrAlias(), "1") + .add(indexOrAlias(), "15") + .add(indexOrAlias(), "3") + .add(indexOrAlias(), "9") + .add(indexOrAlias(), "11").get(); assertThat(response.getResponses().length, equalTo(5)); assertThat(response.getResponses()[0].getId(), equalTo("1")); assertThat(response.getResponses()[0].getIndex(), equalTo("test")); @@ -412,7 +412,7 @@ public void testMultiGetWithVersion() throws Exception { .setSettings(Settings.builder().put("index.refresh_interval", -1))); ensureGreen(); - MultiGetResponse response = client().prepareMultiGet().add(indexOrAlias(), "type1", "1").get(); + MultiGetResponse response = client().prepareMultiGet().add(indexOrAlias(), "1").get(); assertThat(response.getResponses().length, equalTo(1)); assertThat(response.getResponses()[0].getResponse().isExists(), equalTo(false)); diff --git a/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java b/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java index 23c4904024e66..43d36f605b8e1 100644 --- a/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java @@ -114,9 +114,9 @@ public void testIndexNameDateMathExpressions() { assertThat(getResponse.getId(), equalTo("3")); MultiGetResponse mgetResponse = dateSensitiveGet(client().prepareMultiGet() - .add(dateMathExp1, "type", "1") - .add(dateMathExp2, "type", "2") - .add(dateMathExp3, "type", "3")); + .add(dateMathExp1, "1") + .add(dateMathExp2, "2") + .add(dateMathExp3, "3")); assertThat(mgetResponse.getResponses()[0].getResponse().isExists(), is(true)); assertThat(mgetResponse.getResponses()[0].getResponse().getId(), equalTo("1")); assertThat(mgetResponse.getResponses()[1].getResponse().isExists(), is(true)); diff --git a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java index fd7882cf7774e..67a5aaa3280d4 100644 --- a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -382,7 +382,7 @@ public void testRequiredRoutingCrudApis() throws Exception { fail("get with missing routing when routing is required should fail"); } catch (RoutingMissingException e) { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); - assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); + assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]")); } assertThat(client() .prepareGet(indexOrAlias(), "1") diff --git a/server/src/test/java/org/elasticsearch/update/UpdateIT.java b/server/src/test/java/org/elasticsearch/update/UpdateIT.java index 5d213cb27bbfb..61c0ff6ebe9fa 100644 --- a/server/src/test/java/org/elasticsearch/update/UpdateIT.java +++ b/server/src/test/java/org/elasticsearch/update/UpdateIT.java @@ -524,7 +524,6 @@ public void testContextVariables() throws Exception { GetResponse getResponse = client().prepareGet("test", "id1").setRouting("routing1").execute().actionGet(); Map updateContext = (Map) getResponse.getSourceAsMap().get("update_context"); assertEquals("test", updateContext.get("_index")); - assertEquals("type1", updateContext.get("_type")); assertEquals("id1", updateContext.get("_id")); assertEquals(1, updateContext.get("_version")); assertEquals("routing1", updateContext.get("_routing")); @@ -539,7 +538,6 @@ public void testContextVariables() throws Exception { getResponse = client().prepareGet("test", "id2").execute().actionGet(); updateContext = (Map) getResponse.getSourceAsMap().get("update_context"); assertEquals("test", updateContext.get("_index")); - assertEquals("type1", updateContext.get("_type")); assertEquals("id2", updateContext.get("_id")); assertEquals(1, updateContext.get("_version")); assertNull(updateContext.get("_routing")); From 97027b6f979f2c18907d9902bcc7b32e9b22b457 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 11 Sep 2019 17:11:53 +0100 Subject: [PATCH 10/13] tests --- .../java/org/elasticsearch/ElasticsearchExceptionTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java b/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java index 65eb5c21cd7ee..bfdaa248c042d 100644 --- a/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java +++ b/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java @@ -490,7 +490,7 @@ public void testFromXContentWithCause() throws IOException { cause = (ElasticsearchException) cause.getCause(); assertEquals(cause.getMessage(), - "Elasticsearch exception [type=routing_missing_exception, reason=routing is required for [_test]/[_type]/[_id]]"); + "Elasticsearch exception [type=routing_missing_exception, reason=routing is required for [_test]/[_id]]"); assertThat(cause.getHeaderKeys(), hasSize(0)); assertThat(cause.getMetadataKeys(), hasSize(2)); assertThat(cause.getMetadata("es.index"), hasItem("_test")); @@ -550,7 +550,7 @@ public void testFromXContentWithHeadersAndMetadata() throws IOException { cause = (ElasticsearchException) cause.getCause(); assertEquals(cause.getMessage(), - "Elasticsearch exception [type=routing_missing_exception, reason=routing is required for [_test]/[_type]/[_id]]"); + "Elasticsearch exception [type=routing_missing_exception, reason=routing is required for [_test]/[_id]]"); assertThat(cause.getHeaderKeys(), hasSize(0)); assertThat(cause.getMetadataKeys(), hasSize(2)); assertThat(cause.getMetadata("es.index"), hasItem("_test")); From 56b92ae52465af3ec1c29c035d80b6f462fcec14 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 12 Sep 2019 09:03:26 +0100 Subject: [PATCH 11/13] test --- .../java/org/elasticsearch/ElasticsearchExceptionTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java b/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java index bfdaa248c042d..55df6f9eae146 100644 --- a/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java +++ b/server/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java @@ -775,7 +775,7 @@ public void testFailureToAndFromXContentWithDetails() throws IOException { failure = new RuntimeException("E", failureCause); expectedCause = new ElasticsearchException("Elasticsearch exception [type=routing_missing_exception, " + - "reason=routing is required for [idx]/[type]/[id]]"); + "reason=routing is required for [idx]/[id]]"); expectedCause.addMetadata("es.index", "idx"); expectedCause.addMetadata("es.index_uuid", "_na_"); expected = new ElasticsearchException("Elasticsearch exception [type=runtime_exception, reason=E]", expectedCause); From f938b31d2f964e0cd0dc1b5a42f1be2449477516 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Thu, 12 Sep 2019 14:41:19 +0100 Subject: [PATCH 12/13] tests --- .../routing/SimpleRoutingIT.java | 20 +++++++++---------- .../search/morelikethis/MoreLikeThisIT.java | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java index 67a5aaa3280d4..ae1568fabc299 100644 --- a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -414,7 +414,7 @@ public void testRequiredRoutingCrudApis() throws Exception { fail(); } catch (RoutingMissingException e) { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); - assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); + assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]")); } GetResponse getResponse = client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); @@ -429,7 +429,7 @@ public void testRequiredRoutingCrudApis() throws Exception { fail(); } catch (RoutingMissingException e) { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); - assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); + assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]")); } assertThat(client() .prepareGet(indexOrAlias(), "1") @@ -465,7 +465,7 @@ public void testRequiredRoutingBulk() throws Exception { assertThat(bulkItemResponse.getOpType(), equalTo(DocWriteRequest.OpType.INDEX)); assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST)); assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class)); - assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]")); + assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[1]")); } } @@ -494,7 +494,7 @@ public void testRequiredRoutingBulk() throws Exception { assertThat(bulkItemResponse.getOpType(), equalTo(DocWriteRequest.OpType.UPDATE)); assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST)); assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class)); - assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]")); + assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[1]")); } } @@ -516,7 +516,7 @@ public void testRequiredRoutingBulk() throws Exception { assertThat(bulkItemResponse.getOpType(), equalTo(DocWriteRequest.OpType.DELETE)); assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST)); assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class)); - assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]")); + assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[1]")); } } @@ -564,7 +564,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { client().prepareGet(indexOrAlias(), "1").get(); fail(); } catch (RoutingMissingException e) { - assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); + assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]")); } logger.info("--> verifying explain with id [2], with routing [0], should succeed"); @@ -580,7 +580,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { .setQuery(QueryBuilders.matchAllQuery()).get(); fail(); } catch (RoutingMissingException e) { - assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[2]")); + assertThat(e.getMessage(), equalTo("routing is required for [test]/[2]")); } logger.info("--> verifying term vector with id [1], with routing [0], should succeed"); @@ -606,7 +606,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { client().prepareUpdate(indexOrAlias(), "type1", "1").setDoc(Requests.INDEX_CONTENT_TYPE, "field1", "value1").get(); fail(); } catch (RoutingMissingException e) { - assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); + assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]")); } logger.info("--> verifying mget with ids [1,2], with routing [0], should succeed"); @@ -626,10 +626,10 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { assertThat(multiGetResponse.getResponses().length, equalTo(2)); assertThat(multiGetResponse.getResponses()[0].isFailed(), equalTo(true)); assertThat(multiGetResponse.getResponses()[0].getFailure().getId(), equalTo("1")); - assertThat(multiGetResponse.getResponses()[0].getFailure().getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); + assertThat(multiGetResponse.getResponses()[0].getFailure().getMessage(), equalTo("routing is required for [test]/[1]")); assertThat(multiGetResponse.getResponses()[1].isFailed(), equalTo(true)); assertThat(multiGetResponse.getResponses()[1].getFailure().getId(), equalTo("2")); - assertThat(multiGetResponse.getResponses()[1].getFailure().getMessage(), equalTo("routing is required for [test]/[type1]/[2]")); + assertThat(multiGetResponse.getResponses()[1].getFailure().getMessage(), equalTo("routing is required for [test]/[2]")); MultiTermVectorsResponse multiTermVectorsResponse = client().prepareMultiTermVectors() .add(new TermVectorsRequest(indexOrAlias(), "1") diff --git a/server/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java b/server/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java index 3270dcc6212fc..e82100f4f5f87 100644 --- a/server/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java +++ b/server/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java @@ -753,7 +753,7 @@ public void testWithMissingRouting() throws IOException { Throwable cause = exception.getCause(); assertThat(cause, instanceOf(RoutingMissingException.class)); - assertThat(cause.getMessage(), equalTo("routing is required for [test]/[_doc]/[1]")); + assertThat(cause.getMessage(), equalTo("routing is required for [test]/[1]")); } { @@ -767,7 +767,7 @@ public void testWithMissingRouting() throws IOException { Throwable cause = exception.getCause(); assertThat(cause, instanceOf(RoutingMissingException.class)); - assertThat(cause.getMessage(), equalTo("routing is required for [test]/[_doc]/[2]")); + assertThat(cause.getMessage(), equalTo("routing is required for [test]/[2]")); } } } From ae46c13f7f4e45ffdf9e56feaf5e792bcc624c16 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 16 Sep 2019 15:54:33 +0100 Subject: [PATCH 13/13] Client multiget signature --- docs/reference/migration/migrate_8_0/search.asciidoc | 6 ++++-- .../elasticsearch/action/get/MultiGetRequestBuilder.java | 4 ++-- .../java/org/elasticsearch/action/bulk/BulkProcessorIT.java | 2 +- .../test/java/org/elasticsearch/cluster/NoMasterNodeIT.java | 4 ++-- .../java/org/elasticsearch/routing/SimpleRoutingIT.java | 6 +++--- .../xpack/security/authz/store/NativeRolesStore.java | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/reference/migration/migrate_8_0/search.asciidoc b/docs/reference/migration/migrate_8_0/search.asciidoc index 4c3be2b4fadd0..933b377dbaa16 100644 --- a/docs/reference/migration/migrate_8_0/search.asciidoc +++ b/docs/reference/migration/migrate_8_0/search.asciidoc @@ -5,9 +5,11 @@ [float] ==== Removal of types -The `/{index}/{type}/_search`, `/{index}/{type}/_msearch`, `/{index}/{type}/_search/template` and `/{index}/{type}/_msearch/template` REST endpoints have been removed in favour of `/{index}/_search`, `/{index}/_msearch`, `/{index}/_search/template` and `/{index}/_msearch/template`, since indexes no longer contain types, these typed endpoints are obsolete.. +The `/{index}/{type}/_search`, `/{index}/{type}/_msearch`, `/{index}/{type}/_search/template` and `/{index}/{type}/_msearch/template` REST endpoints have been removed in favour of `/{index}/_search`, `/{index}/_msearch`, `/{index}/_search/template` and `/{index}/_msearch/template`; since indexes no longer contain types, these typed endpoints are obsolete.. -The `/{index}/{type}/_termvectors`, `/{index}/{type}/{id}/_termvectors` and `/{index}/{type}/_mtermvectors` REST endpoints have been removed in favour of `/{index}/_termvectors`, `/{index}/{id}/_termvectors` and `/{index}/_mtermvectors`, since indexes no longer contain types, these typed endpoints are obsolete.. +The `/{index}/{type}/_termvectors`, `/{index}/{type}/{id}/_termvectors` and `/{index}/{type}/_mtermvectors` REST endpoints have been removed in favour of `/{index}/_termvectors`, `/{index}/{id}/_termvectors` and `/{index}/_mtermvectors`; since indexes no longer contain types, these typed endpoints are obsolete.. + +The `/{index}/{type}/{doc}` and `/{index}/{type}/_mget` REST endpoints have been removed in favour of `/{index}/_doc/{doc}` and `/{index}/_mget`; since indexes no longer contain types, these typed endpoints are obsolete. [float] ==== Removal of queries diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java index f4e6a73d453ac..29ac7b056c84f 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequestBuilder.java @@ -36,14 +36,14 @@ public MultiGetRequestBuilder add(String index, String id) { return this; } - public MultiGetRequestBuilder add(String index, Iterable ids) { + public MultiGetRequestBuilder addIds(String index, Iterable ids) { for (String id : ids) { request.add(index, id); } return this; } - public MultiGetRequestBuilder add(String index, String... ids) { + public MultiGetRequestBuilder addIds(String index, String... ids) { for (String id : ids) { request.add(index, id); } diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java index f6d1651834232..6e2f78f456148 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkProcessorIT.java @@ -217,7 +217,7 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception testDocs++; processor.add(new IndexRequest("test", "test", Integer.toString(testDocs)) .source(Requests.INDEX_CONTENT_TYPE, "field", "value")); - multiGetRequestBuilder.add("test", "test", Integer.toString(testDocs)); + multiGetRequestBuilder.add("test", Integer.toString(testDocs)); } else { testReadOnlyDocs++; processor.add(new IndexRequest("test-ro", "test", Integer.toString(testReadOnlyDocs)) diff --git a/server/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java b/server/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java index 8cac97fd06284..9e21a8f9f591f 100644 --- a/server/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java @@ -104,11 +104,11 @@ public void testNoMasterActions() throws Exception { ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); - assertThrows(clientToMasterlessNode.prepareMultiGet().add("test", "type1", "1"), + assertThrows(clientToMasterlessNode.prepareMultiGet().add("test", "1"), ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); - assertThrows(clientToMasterlessNode.prepareMultiGet().add("no_index", "type1", "1"), + assertThrows(clientToMasterlessNode.prepareMultiGet().add("no_index", "1"), ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); diff --git a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java index ae1568fabc299..41a72d1a09945 100644 --- a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -594,7 +594,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { client().prepareTermVectors(indexOrAlias(), "1").get(); fail(); } catch (RoutingMissingException e) { - assertThat(e.getMessage(), equalTo("routing is required for [test]/[_doc]/[1]")); + assertThat(e.getMessage(), equalTo("routing is required for [test]/[1]")); } UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1").setRouting(routingValue) @@ -654,14 +654,14 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { assertThat(multiTermVectorsResponse.getResponses()[0].isFailed(), equalTo(true)); assertThat(multiTermVectorsResponse.getResponses()[0].getFailure() .getCause() - .getMessage(), equalTo("routing is required for [test]/[_doc]/[1]")); + .getMessage(), equalTo("routing is required for [test]/[1]")); assertThat(multiTermVectorsResponse.getResponses()[0].getResponse(), nullValue()); assertThat(multiTermVectorsResponse.getResponses()[1].getId(), equalTo("2")); assertThat(multiTermVectorsResponse.getResponses()[1].isFailed(), equalTo(true)); assertThat(multiTermVectorsResponse.getResponses()[1].getResponse(), nullValue()); assertThat(multiTermVectorsResponse.getResponses()[1].getFailure() .getCause() - .getMessage(), equalTo("routing is required for [test]/[_doc]/[2]")); + .getMessage(), equalTo("routing is required for [test]/[2]")); } private static String indexOrAlias() { diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java index e6ba43f6fbaf9..e827fccc36a5e 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java @@ -131,7 +131,7 @@ public void getRoleDescriptors(Set names, final ActionListener { final String[] roleIds = names.stream().map(NativeRolesStore::getIdForRole).toArray(String[]::new); - MultiGetRequest multiGetRequest = client.prepareMultiGet().add(SECURITY_MAIN_ALIAS, roleIds).request(); + MultiGetRequest multiGetRequest = client.prepareMultiGet().addIds(SECURITY_MAIN_ALIAS, roleIds).request(); executeAsyncWithOrigin(client.threadPool().getThreadContext(), SECURITY_ORIGIN, multiGetRequest, ActionListener.wrap(mGetResponse -> { final MultiGetItemResponse[] responses = mGetResponse.getResponses();