From 053f00f53d8d135f2029425d9f8ad2a5efa8eea9 Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Fri, 18 Feb 2022 01:14:27 -0600 Subject: [PATCH 1/7] [Remove] Types from GET/MGET Removes type support from the get and mget transport and rest actions along with removal from ShardGetService. Signed-off-by: Nicholas Walter Knize --- .../opensearch/client/RequestConverters.java | 14 +- .../opensearch/client/BulkProcessorIT.java | 1 - .../java/org/opensearch/client/CrudIT.java | 32 +---- .../client/RequestConvertersTests.java | 30 +---- .../documentation/CRUDDocumentationIT.java | 1 - .../ingest/common/IngestRestartIT.java | 10 +- .../rest-api-spec/test/ingest/90_simulate.yml | 18 +-- .../test/search-as-you-type/10_basic.yml | 1 - .../percolator/PercolateQueryBuilder.java | 8 +- .../PercolateQueryBuilderTests.java | 3 - .../index/reindex/ReindexVersioningTests.java | 6 +- .../reindex/UpdateByQueryBasicTests.java | 50 +++---- .../UpdateByQueryWhileModifyingTests.java | 4 +- .../test/reindex/85_scripting.yml | 6 +- .../index/mapper/size/SizeMappingIT.java | 2 +- .../test/store_smb/15_index_creation.yml | 1 - .../org/opensearch/backwards/IndexingIT.java | 3 - .../org/opensearch/upgrades/RecoveryIT.java | 1 - .../resources/rest-api-spec/api/exists.json | 25 ---- .../main/resources/rest-api-spec/api/get.json | 25 ---- .../rest-api-spec/api/get_source.json | 25 ---- .../resources/rest-api-spec/api/mget.json | 24 +--- .../rest-api-spec/test/get/10_basic.yml | 1 - .../test/get/15_default_values.yml | 1 - .../test/get/20_stored_fields.yml | 1 - .../test/get/50_with_headers.yml | 1 - .../test/get/70_source_filtering.yml | 2 - .../rest-api-spec/test/index/10_with_id.yml | 2 - .../test/index/15_without_id.yml | 2 - .../test/index/70_mix_typeless_typeful.yml | 102 -------------- .../test/indices.clone/10_basic.yml | 3 - .../test/indices.shrink/10_basic.yml | 2 - .../test/indices.split/10_basic.yml | 6 - .../rest-api-spec/test/mget/10_basic.yml | 3 - .../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 | 2 - .../test/mget/17_default_index.yml | 3 - .../rest-api-spec/test/mget/40_routing.yml | 1 - .../opensearch/action/IndicesRequestIT.java | 4 +- .../admin/indices/create/SplitIndexIT.java | 4 +- .../action/bulk/BulkIntegrationIT.java | 6 +- .../action/bulk/BulkProcessorIT.java | 5 +- .../action/bulk/BulkWithUpdatesIT.java | 16 +-- .../action/termvectors/GetTermVectorsIT.java | 8 +- .../opensearch/cluster/NoMasterNodeIT.java | 10 +- .../coordination/RareClusterStateIT.java | 4 +- .../UnsafeBootstrapAndDetachCommandIT.java | 4 +- .../discovery/ClusterDisruptionIT.java | 6 +- .../document/DocumentActionsIT.java | 20 +-- .../env/NodeRepurposeCommandIT.java | 4 +- .../opensearch/explain/ExplainActionIT.java | 2 +- .../gateway/GatewayIndexStateIT.java | 4 +- .../java/org/opensearch/get/GetActionIT.java | 124 +++++++++--------- .../org/opensearch/index/FinalPipelineIT.java | 6 +- .../index/mapper/DynamicMappingIT.java | 2 +- ...DateMathIndexExpressionsIntegrationIT.java | 12 +- .../indices/stats/IndexStatsIT.java | 4 +- .../org/opensearch/ingest/IngestClientIT.java | 10 +- .../org/opensearch/mget/SimpleMgetIT.java | 22 ++-- .../recovery/RecoveryWhileUnderLoadIT.java | 2 +- .../opensearch/recovery/SimpleRecoveryIT.java | 20 +-- .../opensearch/routing/AliasRoutingIT.java | 46 +++---- .../routing/PartitionedRoutingIT.java | 2 +- .../opensearch/routing/SimpleRoutingIT.java | 58 ++++---- .../search/morelikethis/MoreLikeThisIT.java | 4 +- .../search/nested/SimpleNestedIT.java | 4 +- .../opensearch/search/sort/GeoDistanceIT.java | 2 +- .../snapshots/RestoreSnapshotIT.java | 8 +- .../SharedClusterSnapshotRestoreIT.java | 6 +- .../java/org/opensearch/update/UpdateIT.java | 30 ++--- .../ConcurrentDocumentOperationIT.java | 4 +- .../versioning/SimpleVersioningIT.java | 28 ++-- .../tasks/get/TransportGetTaskAction.java | 2 +- .../action/bulk/TransportBulkAction.java | 2 +- .../explain/TransportExplainAction.java | 4 +- .../org/opensearch/action/get/GetRequest.java | 60 ++------- .../action/get/GetRequestBuilder.java | 9 -- .../opensearch/action/get/GetResponse.java | 11 +- .../action/get/MultiGetItemResponse.java | 10 -- .../action/get/MultiGetRequest.java | 68 ++-------- .../action/get/MultiGetRequestBuilder.java | 13 +- .../action/get/MultiGetResponse.java | 31 ++--- .../action/get/TransportGetAction.java | 3 +- .../action/get/TransportMultiGetAction.java | 15 +-- .../get/TransportShardMultiGetAction.java | 17 +-- .../action/update/UpdateHelper.java | 12 +- .../action/update/UpdateResponse.java | 4 +- .../java/org/opensearch/client/Client.java | 4 +- .../java/org/opensearch/client/Requests.java | 2 +- .../client/support/AbstractClient.java | 4 +- .../org/opensearch/index/engine/Engine.java | 9 +- .../org/opensearch/index/get/GetResult.java | 32 ++--- .../opensearch/index/get/ShardGetService.java | 54 +++----- .../query/AbstractGeometryQueryBuilder.java | 15 +-- .../index/query/TermsQueryBuilder.java | 4 +- .../opensearch/index/shard/IndexShard.java | 2 +- .../index/termvectors/TermVectorsService.java | 7 +- .../rest/action/document/RestGetAction.java | 23 +--- .../action/document/RestGetSourceAction.java | 27 +--- .../action/document/RestMultiGetAction.java | 35 +---- .../ExceptionSerializationTests.java | 4 +- .../opensearch/OpenSearchExceptionTests.java | 10 +- .../action/explain/ExplainResponseTests.java | 2 - .../action/get/GetRequestTests.java | 4 +- .../action/get/GetResponseTests.java | 8 +- .../action/get/MultiGetRequestTests.java | 12 +- .../action/get/MultiGetResponseTests.java | 15 +-- .../action/get/MultiGetShardRequestTests.java | 7 +- .../get/TransportMultiGetActionTests.java | 8 +- .../action/update/UpdateRequestTests.java | 20 +-- .../action/update/UpdateResponseTests.java | 30 ++++- .../client/AbstractClientHeadersTestCase.java | 4 +- .../index/engine/InternalEngineTests.java | 39 +++--- .../opensearch/index/get/GetResultTests.java | 20 +-- .../query/GeoShapeQueryBuilderTests.java | 8 +- .../index/query/TermsQueryBuilderTests.java | 4 +- .../index/shard/IndexShardTests.java | 28 +--- .../index/shard/RefreshListenersTests.java | 2 +- .../index/shard/ShardGetServiceTests.java | 44 +++---- .../document/RestGetSourceActionTests.java | 12 +- .../opensearch/search/geo/GeoQueryTests.java | 2 +- .../index/engine/EngineTestCase.java | 2 +- .../test/hamcrest/OpenSearchAssertions.java | 8 +- 125 files changed, 505 insertions(+), 1185 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/index/70_mix_typeless_typeful.yml diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java index dd96f692e1b29..f4c88fcb05b12 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/RequestConverters.java @@ -284,7 +284,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()); @@ -315,13 +315,7 @@ private static Request sourceRequest(GetSourceRequest getSourceRequest, String h parameters.withRealtime(getSourceRequest.realtime()); parameters.withFetchSourceContext(getSourceRequest.fetchSourceContext()); - String optionalType = getSourceRequest.type(); - String endpoint; - if (optionalType == null) { - endpoint = endpoint(getSourceRequest.index(), "_source", getSourceRequest.id()); - } else { - endpoint = endpoint(getSourceRequest.index(), optionalType, getSourceRequest.id(), "_source"); - } + String endpoint = endpoint(getSourceRequest.index(), "_source", getSourceRequest.id()); Request request = new Request(httpMethodName, endpoint); request.addParameters(parameters.asMap()); return request; @@ -799,6 +793,10 @@ static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType, return new NByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType)); } + static String endpoint(String index, String id) { + return new EndpointBuilder().addPathPart(index, MapperService.SINGLE_MAPPING_NAME, id).build(); + } + @Deprecated static String endpoint(String index, String type, String id) { return new EndpointBuilder().addPathPart(index, type, id).build(); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorIT.java index cae1298a8793d..edaf0a9e2aead 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/BulkProcessorIT.java @@ -565,7 +565,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/opensearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java index d26a71701341e..22a89bc7c7c86 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java @@ -70,7 +70,6 @@ import org.opensearch.index.get.GetResult; import org.opensearch.rest.RestStatus; import org.opensearch.rest.action.document.RestBulkAction; -import org.opensearch.rest.action.document.RestMultiGetAction; import org.opensearch.script.Script; import org.opensearch.script.ScriptType; import org.opensearch.search.fetch.subphase.FetchSourceContext; @@ -337,7 +336,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()); @@ -348,7 +346,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()); @@ -360,7 +357,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()); @@ -376,7 +372,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()); @@ -398,7 +393,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( "OpenSearch exception [type=index_not_found_exception, reason=no such index [index]]", @@ -408,7 +402,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( "OpenSearch exception [type=index_not_found_exception, reason=no such index [index]]", @@ -434,14 +427,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()); } @@ -456,25 +447,7 @@ public void testMultiGetWithTypes() throws IOException { highLevelClient().bulk(bulk, expectWarningsOnce(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.add("index", "id1"); - multiGetRequest.add("index", "type", "id2"); - - MultiGetResponse response = execute( - multiGetRequest, - highLevelClient()::mget, - highLevelClient()::mgetAsync, - expectWarningsOnce(RestMultiGetAction.TYPES_DEPRECATION_MESSAGE) - ); - assertEquals(2, response.getResponses().length); - - GetResponse firstResponse = response.getResponses()[0].getResponse(); - assertEquals("index", firstResponse.getIndex()); - assertEquals("type", firstResponse.getType()); - assertEquals("id1", firstResponse.getId()); - - GetResponse secondResponse = response.getResponses()[1].getResponse(); - assertEquals("index", secondResponse.getIndex()); - assertEquals("type", secondResponse.getType()); - assertEquals("id2", secondResponse.getId()); + multiGetRequest.add("index", "id2"); } public void testGetSource() throws IOException { @@ -1077,7 +1050,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()); } @@ -1095,7 +1067,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()); } @@ -1119,7 +1090,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/opensearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java index 037e9ee625a36..862d35902d611 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/RequestConvertersTests.java @@ -172,10 +172,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 GetSourceRequest(index, id)); } @@ -221,13 +217,7 @@ private static void doTestSourceExists(BiFunction requestConverter, String method) { String index = randomAlphaOfLengthBetween(3, 10); String id = randomAlphaOfLengthBetween(3, 10); @@ -435,18 +421,6 @@ private static void getAndExistsTest(Function requestConver assertEquals(method, request.getMethod()); } - 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); - - Request request = requestConverter.apply(getRequest); - assertEquals("/" + index + "/" + type + "/" + id, request.getEndpoint()); - assertNull(request.getEntity()); - assertEquals(method, request.getMethod()); - } - public void testReindex() throws IOException { ReindexRequest reindexRequest = new ReindexRequest(); reindexRequest.setSourceIndices("source_idx"); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java index 3a9bc7a02ecca..959c5a827f143 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/CRUDDocumentationIT.java @@ -2050,7 +2050,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/internalClusterTest/java/org/opensearch/ingest/common/IngestRestartIT.java b/modules/ingest-common/src/internalClusterTest/java/org/opensearch/ingest/common/IngestRestartIT.java index babf024da019b..6efd7cbcd9c41 100644 --- a/modules/ingest-common/src/internalClusterTest/java/org/opensearch/ingest/common/IngestRestartIT.java +++ b/modules/ingest-common/src/internalClusterTest/java/org/opensearch/ingest/common/IngestRestartIT.java @@ -209,7 +209,7 @@ public Settings onNodeStopped(String nodeName) { ) ); - 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)); } @@ -242,7 +242,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)); @@ -260,7 +260,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)); @@ -281,7 +281,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)); @@ -294,7 +294,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/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/90_simulate.yml b/modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/90_simulate.yml index 2224d56165fd3..e012a82b15927 100644 --- a/modules/ingest-common/src/yamlRestTest/resources/rest-api-spec/test/ingest/90_simulate.yml +++ b/modules/ingest-common/src/yamlRestTest/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": { @@ -335,7 +328,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "not_foo": "bar" @@ -343,7 +335,6 @@ teardown: }, { "_index": "index", - "_type": "type", "_id": "id2", "_source": { "foo": "bar" @@ -383,7 +374,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "foo": "bar", @@ -392,7 +382,6 @@ teardown: }, { "_index": "index", - "_type": "type", "_id": "id2", "_source": { "foo": "5", @@ -525,7 +514,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " @@ -602,7 +590,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " @@ -655,7 +642,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " @@ -729,7 +715,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " @@ -804,7 +789,6 @@ teardown: "docs": [ { "_index": "index", - "_type": "type", "_id": "id", "_source": { "field1": "123.42 400 " diff --git a/modules/mapper-extras/src/yamlRestTest/resources/rest-api-spec/test/search-as-you-type/10_basic.yml b/modules/mapper-extras/src/yamlRestTest/resources/rest-api-spec/test/search-as-you-type/10_basic.yml index ffe05097748a6..f1851d9c35757 100644 --- a/modules/mapper-extras/src/yamlRestTest/resources/rest-api-spec/test/search-as-you-type/10_basic.yml +++ b/modules/mapper-extras/src/yamlRestTest/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/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java index 5e245f7082ada..672d4dd15a254 100644 --- a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java @@ -501,13 +501,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) { return rewritten; } } - GetRequest getRequest; - if (indexedDocumentType != null) { - deprecationLogger.deprecate("percolate_with_type", TYPE_DEPRECATION_MESSAGE); - getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentType, indexedDocumentId); - } else { - getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId); - } + GetRequest getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId); getRequest.preference("_local"); getRequest.routing(indexedDocumentRouting); getRequest.preference(indexedDocumentPreference); diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java index 3b0830b7e4519..705cc89ace777 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java @@ -184,7 +184,6 @@ 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)); @@ -193,7 +192,6 @@ protected GetResponse executeGet(GetRequest getRequest) { return new GetResponse( new GetResult( indexedDocumentIndex, - MapperService.SINGLE_MAPPING_NAME, indexedDocumentId, 0, 1, @@ -208,7 +206,6 @@ protected GetResponse executeGet(GetRequest getRequest) { return new GetResponse( new GetResult( indexedDocumentIndex, - MapperService.SINGLE_MAPPING_NAME, indexedDocumentId, UNASSIGNED_SEQ_NO, 0, diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexVersioningTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexVersioningTests.java index 7181fa9f4d273..e516be131e6a4 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexVersioningTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexVersioningTests.java @@ -130,7 +130,7 @@ private void setupSourceAbsent() throws Exception { 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 { @@ -140,7 +140,7 @@ private void setupDest(int version) throws Exception { 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 { @@ -152,7 +152,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/opensearch/index/reindex/UpdateByQueryBasicTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryBasicTests.java index 89e748352a31e..3ed1f7b563546 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryBasicTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryBasicTests.java @@ -56,35 +56,35 @@ public void testBasics() throws Exception { 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 { @@ -96,8 +96,8 @@ public void testSlices() throws Exception { 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"); @@ -107,26 +107,26 @@ public void testSlices() throws Exception { updateByQuery().source("test").refresh(true).setSlices(slices).get(), 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( updateByQuery().source("test").filter(termQuery("foo", "no_match")).setSlices(slices).refresh(true).get(), 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( updateByQuery().source("test").filter(termQuery("foo", "a")).refresh(true).setSlices(slices).get(), 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 { @@ -159,7 +159,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/opensearch/index/reindex/UpdateByQueryWhileModifyingTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWhileModifyingTests.java index 3685fc5f124c9..3e4c61432c34a 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWhileModifyingTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/UpdateByQueryWhileModifyingTests.java @@ -76,7 +76,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") @@ -106,7 +106,7 @@ public void testUpdateWhileReindexing() throws Exception { get.getVersion(), attempts ); - get = client().prepareGet("test", "test", "test").get(); + get = client().prepareGet("test", "test").get(); } } } diff --git a/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/reindex/85_scripting.yml b/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/reindex/85_scripting.yml index 770f372c210a8..9c38b13bb1ff0 100644 --- a/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/reindex/85_scripting.yml +++ b/modules/reindex/src/yamlRestTest/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/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java index 4811c7d12759c..10edd6d2586d9 100644 --- a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java +++ b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java @@ -137,7 +137,7 @@ public void testBasic() throws Exception { assertAcked(prepareCreate("test").addMapping("type", "_size", "enabled=true")); 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/plugins/store-smb/src/yamlRestTest/resources/rest-api-spec/test/store_smb/15_index_creation.yml b/plugins/store-smb/src/yamlRestTest/resources/rest-api-spec/test/store_smb/15_index_creation.yml index 09e59c7fc9d9a..fbbdcb8f153e0 100644 --- a/plugins/store-smb/src/yamlRestTest/resources/rest-api-spec/test/store_smb/15_index_creation.yml +++ b/plugins/store-smb/src/yamlRestTest/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/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java b/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java index a0c8e8b9a03ac..b133a6462a525 100644 --- a/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java +++ b/qa/mixed-cluster/src/test/java/org/opensearch/backwards/IndexingIT.java @@ -46,8 +46,6 @@ import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.rest.RestStatus; -import org.opensearch.rest.action.document.RestGetAction; -import org.opensearch.rest.action.document.RestIndexAction; import org.opensearch.test.rest.OpenSearchRestTestCase; import org.opensearch.test.rest.yaml.ObjectPath; @@ -365,7 +363,6 @@ 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.addParameter("preference", preference); - request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); final Response response = client().performRequest(request); assertOK(response); diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java index 41af456d3c44a..0354c23618525 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java @@ -668,7 +668,6 @@ public void testUpdateDoc() throws Exception { client().performRequest(new Request("POST", index + "/_refresh")); for (int docId : updates.keySet()) { Request get = new Request("GET", index + "/_doc/" + docId); - get.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); Map doc = entityAsMap(client().performRequest(get)); assertThat(XContentMapValues.extractValue("_source.updated_field", doc), equalTo(updates.get(docId))); } 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.json b/rest-api-spec/src/main/resources/rest-api-spec/api/get.json index 0c8d62d6d1d34..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 @@ -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/get_source.json b/rest-api-spec/src/main/resources/rest-api-spec/api/get_source.json index e5336059d3924..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,31 +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", - "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/api/mget.json b/rest-api-spec/src/main/resources/rest-api-spec/api/mget.json index f1d35aee7d62f..e0b58139ed684 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 @@ -26,28 +26,6 @@ "description":"The name of the index" } } - }, - { - "path":"/{index}/{type}/_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 - } - }, - "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/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml index 9183c70c29bce..13576ce7e560c 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 @@ -17,6 +17,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/15_default_values.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml index 67065270665cf..43c5ba5ada555 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 @@ -16,7 +16,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/20_stored_fields.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml index ab27842e4516e..e1fd3f3237e5c 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 @@ -29,7 +29,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/50_with_headers.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml index 38130cee59810..d79a3bd300da8 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 @@ -18,7 +18,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/70_source_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml index f4a5ba39be3b8..88e2b3f7ee6e8 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 @@ -23,7 +23,6 @@ get: { index: test_1, id: 1, _source: false } - match: { _index: test_1 } - - match: { _type: _doc } - match: { _id: "1" } - is_false: _source @@ -62,7 +61,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/index/10_with_id.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml index a129dcab80d9a..97eb9be1547ba 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 @@ -12,7 +12,6 @@ body: { foo: bar } - match: { _index: test-weird-index-中文 } - - match: { _type: _doc } - match: { _id: "1"} - match: { _version: 1} @@ -22,7 +21,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/15_without_id.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml index 073a4704b4ef8..54f203e3621bc 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 @@ -12,7 +12,6 @@ - is_true: _id - match: { _index: test_1 } - - match: { _type: _doc } - match: { _version: 1 } - set: { _id: id } @@ -22,7 +21,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/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 f3629fbb7cc18..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/70_mix_typeless_typeful.yml +++ /dev/null @@ -1,102 +0,0 @@ ---- -"Index with typeless API on an index that has types": - - - skip: - version: " - 6.99.99" - reason: Typeless APIs were introduced in 7.0.0 - - - 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": - - - skip: - version: " - 6.99.99" - reason: Typeless APIs were introduced in 7.0.0 - - - 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.shrink/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/10_basic.yml index 41c851b71cc6c..c898935a3157b 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 @@ -40,7 +40,6 @@ id: "1" - match: { _index: source } - - match: { _type: _doc } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } @@ -78,6 +77,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 2baa82ea78842..e73459386e9c0 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 @@ -69,7 +69,6 @@ setup: id: "1" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } @@ -80,7 +79,6 @@ setup: id: "2" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "2" } - match: { _source: { foo: "hello world 2" } } @@ -91,7 +89,6 @@ setup: id: "3" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "3" } - match: { _source: { foo: "hello world 3" } } @@ -162,7 +159,6 @@ setup: id: "1" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "1" } - match: { _source: { foo: "hello world" } } @@ -173,7 +169,6 @@ setup: id: "2" - match: { _index: target } - - match: { _type: _doc } - match: { _id: "2" } - match: { _source: { foo: "hello world 2" } } @@ -184,7 +179,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/mget/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/10_basic.yml index 798d699ae80a0..bef9b475aab29 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 @@ -26,17 +26,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/12_non_existent_index.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/12_non_existent_index.yml index a1101a903f896..e32bef6853291 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 @@ -18,7 +18,6 @@ - is_false: docs.0.found - match: { docs.0._index: test_2 } - - match: { docs.0._type: null } - match: { docs.0._id: "1" } - do: @@ -29,5 +28,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 2711bed58dbb1..a958793f910ef 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 @@ -43,7 +43,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 9c1d0242b05c9..a9c32114d3813 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 @@ -34,12 +34,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: "/[aA]lias.\\[test_two_and_three\\].has.more.than.one.index.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 fbdc9b265a95a..82c79797c73da 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 @@ -28,14 +28,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: 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 d03f99be39517..394fe63992ab3 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 @@ -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/40_routing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/mget/40_routing.yml index df2924f274bdf..50bf9a158852b 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 @@ -40,6 +40,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/server/src/internalClusterTest/java/org/opensearch/action/IndicesRequestIT.java b/server/src/internalClusterTest/java/org/opensearch/action/IndicesRequestIT.java index c328e742d951e..0e2e2b7e812e8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/IndicesRequestIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/IndicesRequestIT.java @@ -338,7 +338,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(); @@ -394,7 +394,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/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java index 86974322388ab..e39262d427f70 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java @@ -229,7 +229,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()); } @@ -274,7 +274,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/internalClusterTest/java/org/opensearch/action/bulk/BulkIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkIntegrationIT.java index e33b140d288ac..c96d4319c0caf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkIntegrationIT.java @@ -127,14 +127,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()); } // allowing the auto-generated timestamp to externally be set would allow making the index inconsistent with duplicate docs diff --git a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkProcessorIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkProcessorIT.java index 20791f46ade59..8b52d52df2477 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkProcessorIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkProcessorIT.java @@ -255,7 +255,7 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception 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( @@ -320,7 +320,7 @@ private static MultiGetRequestBuilder indexDocs(Client client, BulkProcessor pro + "\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; } @@ -345,7 +345,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/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java index 570d1055a7a6c..391e741e411a1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java @@ -177,17 +177,17 @@ 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().actionGet(); + 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")); @@ -217,15 +217,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)); @@ -447,7 +447,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().actionGet(); + GetResponse getResponse = client().prepareGet("test", Integer.toString(i)).execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); assertThat(getResponse.getVersion(), equalTo(1L)); assertThat(((Number) getResponse.getSource().get("counter")).longValue(), equalTo(1L)); @@ -553,7 +553,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/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java index 23003807ce41c..52333061f3e6b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java @@ -860,7 +860,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 @@ -883,7 +883,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 @@ -902,7 +902,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 @@ -925,7 +925,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/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java index 1fd61c9e063d0..746aa4c1a8af1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java @@ -115,13 +115,13 @@ public void testNoMasterActions() throws Exception { }); assertRequestBuilderThrows( - clientToMasterlessNode.prepareGet("test", "type1", "1"), + clientToMasterlessNode.prepareGet("test", "1"), ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); assertRequestBuilderThrows( - clientToMasterlessNode.prepareGet("no_index", "type1", "1"), + clientToMasterlessNode.prepareGet("no_index", "1"), ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); @@ -275,7 +275,7 @@ public void testNoMasterActionsWriteMasterBlock() throws Exception { assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID)); }); - 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(); @@ -371,10 +371,10 @@ public void testNoMasterActionsMetadataWriteMasterBlock() throws Exception { } }); - GetResponse getResponse = client(randomFrom(nodesWithShards)).prepareGet("test1", "type1", "1").get(); + GetResponse getResponse = client(randomFrom(nodesWithShards)).prepareGet("test1", "1").get(); assertExists(getResponse); - expectThrows(Exception.class, () -> client(partitionedNode).prepareGet("test1", "type1", "1").get()); + expectThrows(Exception.class, () -> client(partitionedNode).prepareGet("test1", "1").get()); SearchResponse countResponse = client(randomFrom(nodesWithShards)).prepareSearch("test1") .setAllowPartialSearchResults(true) diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java index 6317d633f25ea..233dca2dabb28 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java @@ -378,7 +378,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 @@ -400,7 +400,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/internalClusterTest/java/org/opensearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java index 5c07ef8e7baea..ea5bb145cfd75 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java @@ -439,7 +439,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 = Settings.builder() @@ -474,7 +474,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/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java index 0bfd3e22a3bc9..6da62ab5107c9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java @@ -255,7 +255,7 @@ public void testAckedIndexing() throws Exception { 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) { @@ -316,7 +316,7 @@ public void testRejoinDocumentExistsInAllShardCopies() throws Exception { logger.info("Verifying if document exists via node[{}]", notIsolatedNode); GetResponse getResponse = internalCluster().client(notIsolatedNode) - .prepareGet("test", "type", indexResponse.getId()) + .prepareGet("test", indexResponse.getId()) .setPreference("_local") .get(); assertThat(getResponse.isExists(), is(true)); @@ -330,7 +330,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()).setPreference("_local").get(); + getResponse = internalCluster().client(node).prepareGet("test", indexResponse.getId()).setPreference("_local").get(); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getVersion(), equalTo(1L)); assertThat(getResponse.getId(), equalTo(indexResponse.getId())); diff --git a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java index d1138351bde76..c960cf31ec75c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java @@ -117,18 +117,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()); @@ -137,7 +137,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)); } @@ -151,7 +151,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)); } @@ -169,10 +169,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)); @@ -266,15 +266,15 @@ public void testBulk() throws Exception { assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards)); 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/internalClusterTest/java/org/opensearch/env/NodeRepurposeCommandIT.java b/server/src/internalClusterTest/java/org/opensearch/env/NodeRepurposeCommandIT.java index ccb2920c274eb..c90aa333604d3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/env/NodeRepurposeCommandIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/env/NodeRepurposeCommandIT.java @@ -69,7 +69,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); @@ -112,7 +112,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/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java index 79fe3a9119eae..4833a36dd8726 100644 --- a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java @@ -255,7 +255,7 @@ 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(), 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/internalClusterTest/java/org/opensearch/gateway/GatewayIndexStateIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/GatewayIndexStateIT.java index f306425fc9458..4c0fa15a55824 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/GatewayIndexStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/GatewayIndexStateIT.java @@ -214,7 +214,7 @@ public void testSimpleOpenClose() throws Exception { ); 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..."); @@ -255,7 +255,7 @@ public void testSimpleOpenClose() throws Exception { ); 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/internalClusterTest/java/org/opensearch/get/GetActionIT.java b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java index f8079aa1d93f3..327e35dbc7d0b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java @@ -90,25 +90,25 @@ public void testSimpleGet() { ); 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()); @@ -116,7 +116,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()); @@ -124,14 +124,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()); @@ -139,7 +139,7 @@ public void testSimpleGet() { assertThat(response.getField("field2"), nullValue()); logger.info("--> realtime fetch of field & source"); - response = client().prepareGet(indexOrAlias(), "type1", "1").setStoredFields("field1").setFetchSource("field1", null).get(); + response = client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").setFetchSource("field1", null).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsMap(), hasKey("field1")); @@ -148,7 +148,7 @@ public void testSimpleGet() { assertThat(response.getField("field2"), nullValue()); 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")); @@ -158,14 +158,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()); @@ -173,7 +173,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").setStoredFields("field1").setFetchSource(true).get(); + response = client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").setFetchSource(true).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getIndex(), equalTo("test")); assertThat(response.getSourceAsBytes(), not(nullValue())); @@ -184,7 +184,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")); @@ -193,7 +193,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")); @@ -202,7 +202,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)); } @@ -222,7 +222,7 @@ public void testGetWithAliasPointingToMultipleIndices() { 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")); } @@ -239,7 +239,7 @@ public void testSimpleMultiGet() throws Exception { ); 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)); @@ -248,11 +248,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") + .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")); @@ -278,8 +278,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)); @@ -304,16 +304,15 @@ public void testGetDocWithMultivaluedFields() throws Exception { assertAcked(prepareCreate("test").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)); @@ -322,7 +321,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()); @@ -336,7 +335,7 @@ public void testGetWithVersion() { assertAcked(prepareCreate("test").addAlias(new Alias("alias")).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"); @@ -344,18 +343,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 @@ -364,20 +363,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 @@ -388,20 +387,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")); @@ -410,20 +409,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")); @@ -434,7 +433,7 @@ public void testMultiGetWithVersion() throws Exception { assertAcked(prepareCreate("test").addAlias(new Alias("alias")).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)); @@ -444,9 +443,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 @@ -468,9 +467,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)); @@ -494,9 +493,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 @@ -518,9 +517,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)); @@ -569,16 +568,13 @@ 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() - ); + exc = expectThrows(IllegalArgumentException.class, () -> client().prepareGet(indexOrAlias(), "1").setStoredFields("field1").get()); assertThat(exc.getMessage(), equalTo("field [field1] isn't a leaf field")); } @@ -649,13 +645,13 @@ 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).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).getValues().size(), equalTo(2)); assertThat(getResponse.getField(field).getValues().get(0).toString(), equalTo("value1")); @@ -680,7 +676,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).getValues().size(), equalTo(2)); assertThat(getResponse.getField(field).getValues().get(0).toString(), equalTo("value1")); @@ -891,7 +887,7 @@ protected void assertGetFieldNull(String index, String type, String docId, Strin } 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); + MultiGetRequest.Item getItem = new MultiGetRequest.Item(index, docId).storedFields(field); if (routing != null) { getItem.routing(routing); } @@ -902,7 +898,7 @@ private GetResponse multiGetDocument(String index, String type, String docId, St } 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); + GetRequestBuilder getRequestBuilder = client().prepareGet().setIndex(index).setId(docId).setStoredFields(field); if (routing != null) { getRequestBuilder.setRouting(routing); } diff --git a/server/src/internalClusterTest/java/org/opensearch/index/FinalPipelineIT.java b/server/src/internalClusterTest/java/org/opensearch/index/FinalPipelineIT.java index 84e1231a7b8b4..359d40e3b7b9f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/FinalPipelineIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/FinalPipelineIT.java @@ -224,7 +224,7 @@ public void testRequestPipelineAndFinalPipeline() { index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); final IndexResponse response = index.get(); assertThat(response.status(), equalTo(RestStatus.CREATED)); - final GetRequestBuilder get = client().prepareGet("index", "_doc", "1"); + final GetRequestBuilder get = client().prepareGet("index", "1"); final GetResponse getResponse = get.get(); assertTrue(getResponse.isExists()); final Map source = getResponse.getSourceAsMap(); @@ -252,7 +252,7 @@ public void testDefaultAndFinalPipeline() { index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); final IndexResponse response = index.get(); assertThat(response.status(), equalTo(RestStatus.CREATED)); - final GetRequestBuilder get = client().prepareGet("index", "_doc", "1"); + final GetRequestBuilder get = client().prepareGet("index", "1"); final GetResponse getResponse = get.get(); assertTrue(getResponse.isExists()); final Map source = getResponse.getSourceAsMap(); @@ -302,7 +302,7 @@ public void testDefaultAndFinalPipelineFromTemplates() { index.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); final IndexResponse response = index.get(); assertThat(response.status(), equalTo(RestStatus.CREATED)); - final GetRequestBuilder get = client().prepareGet("index", "_doc", "1"); + final GetRequestBuilder get = client().prepareGet("index", "1"); final GetResponse getResponse = get.get(); assertTrue(getResponse.isExists()); final Map source = getResponse.getSourceAsMap(); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/mapper/DynamicMappingIT.java b/server/src/internalClusterTest/java/org/opensearch/index/mapper/DynamicMappingIT.java index 28d92909a7f93..96188b2c8b71d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/mapper/DynamicMappingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/mapper/DynamicMappingIT.java @@ -139,7 +139,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/internalClusterTest/java/org/opensearch/indices/DateMathIndexExpressionsIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/DateMathIndexExpressionsIntegrationIT.java index ec90d271b9127..19e1e196daad0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/DateMathIndexExpressionsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/DateMathIndexExpressionsIntegrationIT.java @@ -80,22 +80,22 @@ public void testIndexNameDateMathExpressions() { assertHitCount(searchResponse, 3); assertSearchHits(searchResponse, "1", "2", "3"); - GetResponse getResponse = client().prepareGet(dateMathExp1, "type", "1").get(); + GetResponse getResponse = client().prepareGet(dateMathExp1, "1").get(); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("1")); - getResponse = client().prepareGet(dateMathExp2, "type", "2").get(); + getResponse = client().prepareGet(dateMathExp2, "2").get(); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("2")); - getResponse = client().prepareGet(dateMathExp3, "type", "3").get(); + getResponse = client().prepareGet(dateMathExp3, "3").get(); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("3")); MultiGetResponse mgetResponse = client().prepareMultiGet() - .add(dateMathExp1, "type", "1") - .add(dateMathExp2, "type", "2") - .add(dateMathExp3, "type", "3") + .add(dateMathExp1, "1") + .add(dateMathExp2, "2") + .add(dateMathExp3, "3") .get(); assertThat(mgetResponse.getResponses()[0].getResponse().isExists(), is(true)); assertThat(mgetResponse.getResponses()[0].getResponse().getId(), equalTo("1")); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java index 9cd91cab2b122..6448728076707 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java @@ -694,7 +694,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(); @@ -703,7 +703,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/internalClusterTest/java/org/opensearch/ingest/IngestClientIT.java b/server/src/internalClusterTest/java/org/opensearch/ingest/IngestClientIT.java index 4ef8b2ba38e67..20fd693868049 100644 --- a/server/src/internalClusterTest/java/org/opensearch/ingest/IngestClientIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/ingest/IngestClientIT.java @@ -227,10 +227,10 @@ 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").get().getSourceAsMap(); + 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").get().getSourceAsMap(); + Map upserted = client().prepareGet("index", "2").get().getSourceAsMap(); assertThat(upserted.get("field1"), equalTo("upserted_val")); assertThat(upserted.get("processed"), equalTo(true)); } @@ -258,14 +258,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").get().getSourceAsMap(); + 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)); @@ -452,7 +452,7 @@ public void testPipelineProcessorOnFailure() throws Exception { } client().prepareIndex("test", "_doc").setId("1").setSource("{}", XContentType.JSON).setPipeline("1").get(); - Map inserted = client().prepareGet("test", "_doc", "1").get().getSourceAsMap(); + Map inserted = client().prepareGet("test", "1").get().getSourceAsMap(); assertThat(inserted.get("readme"), equalTo("pipeline with id [3] is a bad pipeline")); } diff --git a/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java b/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java index e2480e0705ae3..3967f93f3a9b8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/mget/SimpleMgetIT.java @@ -68,8 +68,8 @@ public void testThatMgetShouldWorkWithOneIndexMissing() throws IOException { .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)); @@ -84,7 +84,7 @@ public void testThatMgetShouldWorkWithOneIndexMissing() throws IOException { is("nonExistingIndex") ); - mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("nonExistingIndex", "test", "1")).get(); + mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("nonExistingIndex", "1")).get(); assertThat(mgetResponse.getResponses().length, is(1)); assertThat(mgetResponse.getResponses()[0].getIndex(), is("nonExistingIndex")); assertThat(mgetResponse.getResponses()[0].isFailed(), is(true)); @@ -105,8 +105,8 @@ public void testThatMgetShouldWorkWithMultiIndexAlias() throws IOException { .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)); @@ -117,7 +117,7 @@ public void testThatMgetShouldWorkWithMultiIndexAlias() throws IOException { assertThat(mgetResponse.getResponses()[1].isFailed(), is(true)); assertThat(mgetResponse.getResponses()[1].getFailure().getMessage(), containsString("more than one index")); - mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("multiIndexAlias", "test", "1")).get(); + mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("multiIndexAlias", "1")).get(); assertThat(mgetResponse.getResponses().length, is(1)); assertThat(mgetResponse.getResponses()[0].getIndex(), is("multiIndexAlias")); assertThat(mgetResponse.getResponses()[0].isFailed(), is(true)); @@ -144,7 +144,7 @@ public void testThatMgetShouldWorkWithAliasRouting() throws IOException { .setRefreshPolicy(IMMEDIATE) .get(); - MultiGetResponse mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("alias1", "test", "1")).get(); + MultiGetResponse mgetResponse = client().prepareMultiGet().add(new MultiGetRequest.Item("alias1", "1")).get(); assertEquals(1, mgetResponse.getResponses().length); assertEquals("test", mgetResponse.getResponses()[0].getIndex()); @@ -172,13 +172,13 @@ public void testThatSourceFilteringIsSupported() throws Exception { for (int i = 0; i < 100; i++) { if (i % 2 == 0) { request.add( - new MultiGetRequest.Item(indexOrAlias(), "type", Integer.toString(i)).fetchSourceContext( + 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)).fetchSourceContext(new FetchSourceContext(false)) + new MultiGetRequest.Item(indexOrAlias(), Integer.toString(i)).fetchSourceContext(new FetchSourceContext(false)) ); } } @@ -219,8 +219,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/internalClusterTest/java/org/opensearch/recovery/RecoveryWhileUnderLoadIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/RecoveryWhileUnderLoadIT.java index 3ada65909b72f..26b3e9ae336dc 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/RecoveryWhileUnderLoadIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/RecoveryWhileUnderLoadIT.java @@ -419,7 +419,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()) { diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/SimpleRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/SimpleRecoveryIT.java index cb80dddb81cb6..6dec99be51194 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/SimpleRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/SimpleRecoveryIT.java @@ -86,13 +86,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"))); } @@ -103,17 +103,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/internalClusterTest/java/org/opensearch/routing/AliasRoutingIT.java b/server/src/internalClusterTest/java/org/opensearch/routing/AliasRoutingIT.java index 3b05b6d3bb21b..a1dd32aa300c9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/routing/AliasRoutingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/routing/AliasRoutingIT.java @@ -66,16 +66,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"); @@ -85,9 +85,9 @@ public void testAliasCrudRouting() throws Exception { .execute() .actionGet(); 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)); assertThat( - client().prepareGet("alias0", "type1", "1").execute().actionGet().getSourceAsMap().get("field").toString(), + client().prepareGet("alias0", "1").execute().actionGet().getSourceAsMap().get("field").toString(), equalTo("value2") ); } @@ -95,29 +95,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)); } } @@ -137,11 +137,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"); @@ -494,22 +494,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)); } logger.info("--> search with alias-a1,alias-b0, should not find"); @@ -655,7 +655,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()) @@ -717,8 +717,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()) diff --git a/server/src/internalClusterTest/java/org/opensearch/routing/PartitionedRoutingIT.java b/server/src/internalClusterTest/java/org/opensearch/routing/PartitionedRoutingIT.java index 8dd2bd7c1235e..905445b2d7aeb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/routing/PartitionedRoutingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/routing/PartitionedRoutingIT.java @@ -231,7 +231,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/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java b/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java index 0bcd4def4836b..bff90e219e281 100644 --- a/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java @@ -100,25 +100,25 @@ 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").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); } 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(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); } 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").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false)); } logger.info("--> indexing with id [1], and routing [0]"); @@ -129,11 +129,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").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); } } @@ -150,11 +150,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").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); } logger.info("--> search with no routing, should fine one"); @@ -381,10 +381,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").setRouting(routingValue).execute().actionGet().isExists(), - equalTo(true) - ); + assertThat(client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); } logger.info("--> deleting with no routing, should fail"); @@ -397,16 +394,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("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").setRouting(routingValue).execute().actionGet().isExists(), - equalTo(true) - ); + assertThat(client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); } try { @@ -427,13 +421,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")); } @@ -442,16 +436,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]")); } - assertThat( - client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), - equalTo(false) - ); + assertThat(client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false)); } } @@ -588,14 +579,11 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { .get(); logger.info("--> verifying get with id [1] with routing [0], should succeed"); - assertThat( - client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), - equalTo(true) - ); + assertThat(client().prepareGet(indexOrAlias(), "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); 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]")); @@ -645,8 +633,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")) + .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)); @@ -656,8 +644,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")) + .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)); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java index a7909daeab599..e250daa54a399 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java @@ -922,7 +922,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]")); } { @@ -941,7 +941,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]")); } } } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java index 0240dda658170..dac0a5d01b516 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java @@ -101,7 +101,7 @@ public void testSimpleNested() throws Exception { .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(); @@ -263,7 +263,7 @@ public void testMultiNested() throws Exception { ) .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/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java index 3774f4e7c7f4c..f964baead2534 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java @@ -590,7 +590,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()) diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java index b2e8f2df1e2f3..a131ab9ff70e7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java @@ -147,8 +147,8 @@ public void testParallelRestoreOperations() { assertThat(restoreSnapshotResponse1.status(), equalTo(RestStatus.ACCEPTED)); assertThat(restoreSnapshotResponse2.status(), equalTo(RestStatus.ACCEPTED)); ensureGreen(restoredIndexName1, restoredIndexName2); - assertThat(client.prepareGet(restoredIndexName1, "_doc", docId).get().isExists(), equalTo(true)); - assertThat(client.prepareGet(restoredIndexName2, "_doc", 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 { @@ -206,8 +206,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, "_doc", docId).get().isExists(), equalTo(true)); - assertThat(client.prepareGet(restoredIndexName2, "_doc", 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/internalClusterTest/java/org/opensearch/snapshots/SharedClusterSnapshotRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/SharedClusterSnapshotRestoreIT.java index b8b2d4c1b665a..f3190585cff85 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/SharedClusterSnapshotRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/SharedClusterSnapshotRestoreIT.java @@ -73,6 +73,7 @@ import org.opensearch.index.IndexService; import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.EngineTestCase; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.shard.ShardId; import org.opensearch.indices.IndicesService; @@ -288,12 +289,11 @@ public void testSingleGetAfterRestore() throws Exception { Path absolutePath = randomRepoPath().toAbsolutePath(); logger.info("Path [{}]", absolutePath); String restoredIndexName = indexName + "-restored"; - String typeName = "actions"; String expectedValue = "expected"; // Write a document String docId = Integer.toString(randomInt()); - index(indexName, typeName, docId, "value", expectedValue); + index(indexName, MapperService.SINGLE_MAPPING_NAME, docId, "value", expectedValue); createRepository(repoName, "fs", absolutePath); createSnapshot(repoName, snapshotName, Collections.singletonList(indexName)); @@ -305,7 +305,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() { diff --git a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java index 661c572d4c959..67a3519ae1ab9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java @@ -176,7 +176,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")); } @@ -189,7 +189,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")); } } @@ -219,7 +219,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")); } @@ -234,7 +234,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")); } } @@ -339,7 +339,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")); } @@ -355,7 +355,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")); } @@ -376,7 +376,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")); } @@ -397,7 +397,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)); } @@ -423,7 +423,7 @@ public void testUpdate() throws Exception { .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")); } @@ -434,7 +434,7 @@ public void testUpdate() throws Exception { .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")); } @@ -455,7 +455,7 @@ public void testUpdate() throws Exception { .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)); @@ -575,7 +575,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")); @@ -591,7 +591,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")); @@ -675,7 +675,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)); @@ -892,7 +892,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/internalClusterTest/java/org/opensearch/versioning/ConcurrentDocumentOperationIT.java b/server/src/internalClusterTest/java/org/opensearch/versioning/ConcurrentDocumentOperationIT.java index 1eb4d088d260d..81e27c64f821a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/versioning/ConcurrentDocumentOperationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/versioning/ConcurrentDocumentOperationIT.java @@ -77,9 +77,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/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java b/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java index 5edb3cf5f314d..2be21d8531182 100644 --- a/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/versioning/SimpleVersioningIT.java @@ -135,7 +135,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. @@ -203,7 +203,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. @@ -349,7 +349,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)); } @@ -420,7 +420,7 @@ public void testSimpleVersioningWithFlush() throws Exception { ); 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(); @@ -787,7 +787,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; @@ -839,11 +839,7 @@ public void testDeleteNotLost() throws Exception { client().prepareDelete("test", "type", "id").setVersion(11).setVersionType(VersionType.EXTERNAL).execute().actionGet(); // Real-time get should reflect delete: - assertThat( - "doc should have been deleted", - client().prepareGet("test", "type", "id").execute().actionGet().getVersion(), - equalTo(-1L) - ); + assertThat("doc should have been deleted", client().prepareGet("test", "id").execute().actionGet().getVersion(), equalTo(-1L)); // ThreadPool.relativeTimeInMillis has default granularity of 200 msec, so we must sleep at least that long; sleep much longer in // case system is busy: @@ -853,11 +849,7 @@ public void testDeleteNotLost() throws Exception { client().prepareDelete("test", "type", "id2").setVersion(11).setVersionType(VersionType.EXTERNAL).execute().actionGet(); // Real-time get should still reflect delete: - assertThat( - "doc should have been deleted", - client().prepareGet("test", "type", "id").execute().actionGet().getVersion(), - equalTo(-1L) - ); + assertThat("doc should have been deleted", client().prepareGet("test", "id").execute().actionGet().getVersion(), equalTo(-1L)); } public void testGCDeletesZero() throws Exception { @@ -887,11 +879,7 @@ public void testGCDeletesZero() throws Exception { client().prepareDelete("test", "type", "id").setVersion(11).setVersionType(VersionType.EXTERNAL).execute().actionGet(); // Real-time get should reflect delete even though index.gc_deletes is 0: - assertThat( - "doc should have been deleted", - client().prepareGet("test", "type", "id").execute().actionGet().getVersion(), - equalTo(-1L) - ); + assertThat("doc should have been deleted", client().prepareGet("test", "id").execute().actionGet().getVersion(), equalTo(-1L)); } public void testSpecialVersioning() { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java index b3b12f5e6d124..80049b5e30fdf 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java @@ -206,7 +206,7 @@ void waitedForCompletion( * 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/opensearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java index 7121636eabc90..569ab79543e1b 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java @@ -568,7 +568,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: diff --git a/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java b/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java index 899050bdece1a..02355155224c9 100644 --- a/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java +++ b/server/src/main/java/org/opensearch/action/explain/TransportExplainAction.java @@ -140,7 +140,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); } @@ -158,7 +158,7 @@ protected ExplainResponse shardOperation(ExplainRequest request, ShardId shardId // doc isn't deleted between the initial get and this call. GetResult getResult = context.indexShard() .getService() - .get(result, request.id(), request.type(), request.storedFields(), request.fetchSourceContext()); + .get(result, request.id(), request.storedFields(), request.fetchSourceContext()); return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), true, explanation, getResult); } else { return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), true, explanation); diff --git a/server/src/main/java/org/opensearch/action/get/GetRequest.java b/server/src/main/java/org/opensearch/action/get/GetRequest.java index 2796a8e9e47d7..9badf2db92f67 100644 --- a/server/src/main/java/org/opensearch/action/get/GetRequest.java +++ b/server/src/main/java/org/opensearch/action/get/GetRequest.java @@ -33,11 +33,11 @@ package org.opensearch.action.get; import org.opensearch.LegacyESVersion; +import org.opensearch.Version; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.RealtimeRequest; import org.opensearch.action.ValidateActions; import org.opensearch.action.support.single.shard.SingleShardRequest; -import org.opensearch.common.Nullable; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -54,7 +54,7 @@ * A request to get a document (its source) from an index based on its id. Best created using * {@link org.opensearch.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 GetResponse @@ -63,7 +63,6 @@ */ public class GetRequest extends SingleShardRequest implements RealtimeRequest { - private String type; private String id; private String routing; private String preference; @@ -79,13 +78,13 @@ 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; - } + public GetRequest() {} GetRequest(StreamInput in) throws IOException { super(in); - type = in.readString(); + if (in.getVersion().before(Version.V_2_0_0)) { + in.readString(); + } id = in.readString(); routing = in.readOptionalString(); if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { @@ -106,22 +105,6 @@ public GetRequest() { */ 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; } /** @@ -133,15 +116,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); } @@ -154,19 +133,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. */ @@ -194,14 +160,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; } @@ -295,7 +253,9 @@ public VersionType versionType() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeString(type); + if (out.getVersion().before(Version.V_2_0_0)) { + out.writeString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); out.writeOptionalString(routing); if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { @@ -313,7 +273,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/opensearch/action/get/GetRequestBuilder.java b/server/src/main/java/org/opensearch/action/get/GetRequestBuilder.java index e47965595be2d..492a88b9d3821 100644 --- a/server/src/main/java/org/opensearch/action/get/GetRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/get/GetRequestBuilder.java @@ -52,15 +52,6 @@ public GetRequestBuilder(OpenSearchClient client, GetAction action, @Nullable St 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/opensearch/action/get/GetResponse.java b/server/src/main/java/org/opensearch/action/get/GetResponse.java index b10057ed282b5..a15607d696195 100644 --- a/server/src/main/java/org/opensearch/action/get/GetResponse.java +++ b/server/src/main/java/org/opensearch/action/get/GetResponse.java @@ -84,13 +84,6 @@ public String getIndex() { return getResult.getIndex(); } - /** - * The type of the document. - */ - public String getType() { - return getResult.getType(); - } - /** * The id of the document. */ @@ -209,10 +202,10 @@ 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/opensearch/action/get/MultiGetItemResponse.java b/server/src/main/java/org/opensearch/action/get/MultiGetItemResponse.java index 4308a9223919b..1ff684fcc5872 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetItemResponse.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetItemResponse.java @@ -71,16 +71,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/opensearch/action/get/MultiGetRequest.java b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java index 220659cfd894e..974799dd7bf4c 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java @@ -34,6 +34,7 @@ import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchParseException; +import org.opensearch.Version; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.CompositeIndicesRequest; @@ -54,6 +55,7 @@ import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentParser.Token; import org.opensearch.index.VersionType; +import org.opensearch.index.mapper.MapperService; import org.opensearch.search.fetch.subphase.FetchSourceContext; import java.io.IOException; @@ -73,7 +75,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"); @@ -88,7 +89,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; @@ -102,7 +102,9 @@ public Item() { public Item(StreamInput in) throws IOException { index = in.readString(); - type = in.readOptionalString(); + if (in.getVersion().before(Version.V_2_0_0)) { + in.readOptionalString(); + } id = in.readString(); routing = in.readOptionalString(); if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { @@ -115,22 +117,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; @@ -155,10 +141,6 @@ public Item index(String index) { return this; } - public String type() { - return this.type; - } - public String id() { return this.id; } @@ -217,7 +199,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_2_0_0)) { + out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); out.writeOptionalString(routing); if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { @@ -234,7 +218,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); @@ -259,7 +242,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; @@ -268,7 +250,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); @@ -308,16 +289,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; @@ -377,7 +348,6 @@ public MultiGetRequest refresh(boolean refresh) { public MultiGetRequest add( @Nullable String defaultIndex, - @Nullable String defaultType, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource, @Nullable String defaultRouting, @@ -395,18 +365,9 @@ public MultiGetRequest add( currentFieldName = parser.currentName(); } else if (token == Token.START_ARRAY) { if ("docs".equals(currentFieldName)) { - parseDocuments( - parser, - this.items, - defaultIndex, - defaultType, - defaultFields, - defaultFetchSource, - defaultRouting, - allowExplicitIndex - ); + 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, @@ -434,7 +395,6 @@ private static void parseDocuments( XContentParser parser, List items, @Nullable String defaultIndex, - @Nullable String defaultType, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource, @Nullable String defaultRouting, @@ -447,7 +407,6 @@ private static void parseDocuments( 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; @@ -465,8 +424,6 @@ private static void parseDocuments( 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())) { @@ -565,7 +522,7 @@ private static void parseDocuments( aFields = defaultFields; } items.add( - new Item(index, type, id).routing(routing) + new Item(index, id).routing(routing) .storedFields(aFields) .version(version) .versionType(versionType) @@ -578,7 +535,6 @@ public static void parseIds( XContentParser parser, List items, @Nullable String defaultIndex, - @Nullable String defaultType, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource, @Nullable String defaultRouting @@ -589,7 +545,7 @@ public static void parseIds( throw new IllegalArgumentException("ids array element should only contain ids"); } items.add( - new Item(defaultIndex, defaultType, parser.text()).storedFields(defaultFields) + new Item(defaultIndex, parser.text()).storedFields(defaultFields) .fetchSourceContext(defaultFetchSource) .routing(defaultRouting) ); diff --git a/server/src/main/java/org/opensearch/action/get/MultiGetRequestBuilder.java b/server/src/main/java/org/opensearch/action/get/MultiGetRequestBuilder.java index a068e4c66e5fa..56ac6cbd1b8c9 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetRequestBuilder.java @@ -34,7 +34,6 @@ import org.opensearch.action.ActionRequestBuilder; import org.opensearch.client.OpenSearchClient; -import org.opensearch.common.Nullable; /** * A multi get document action request builder. @@ -45,21 +44,21 @@ public MultiGetRequestBuilder(OpenSearchClient 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/opensearch/action/get/MultiGetResponse.java b/server/src/main/java/org/opensearch/action/get/MultiGetResponse.java index a5cf07c32b3e9..ca6249861dd50 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetResponse.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetResponse.java @@ -33,6 +33,7 @@ package org.opensearch.action.get; import org.opensearch.OpenSearchException; +import org.opensearch.Version; import org.opensearch.action.ActionResponse; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; @@ -43,6 +44,7 @@ import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentParser.Token; import org.opensearch.index.get.GetResult; +import org.opensearch.index.mapper.MapperService; import java.io.IOException; import java.util.ArrayList; @@ -53,7 +55,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"); @@ -64,20 +65,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/opensearch/action/update/UpdateHelper.java b/server/src/main/java/org/opensearch/action/update/UpdateHelper.java index d70cd9fbca8f4..2621778e20eab 100644 --- a/server/src/main/java/org/opensearch/action/update/UpdateHelper.java +++ b/server/src/main/java/org/opensearch/action/update/UpdateHelper.java @@ -51,6 +51,7 @@ import org.opensearch.index.engine.DocumentMissingException; import org.opensearch.index.engine.DocumentSourceMissingException; import org.opensearch.index.get.GetResult; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.mapper.RoutingFieldMapper; import org.opensearch.index.shard.IndexShard; import org.opensearch.index.shard.ShardId; @@ -82,8 +83,7 @@ public UpdateHelper(ScriptService scriptService) { * Prepares an update request by converting it into an index or delete request or an update response (no action). */ public Result prepare(UpdateRequest request, IndexShard indexShard, LongSupplier nowInMillis) { - final GetResult getResult = indexShard.getService() - .getForUpdate(request.type(), request.id(), request.ifSeqNo(), request.ifPrimaryTerm()); + final GetResult getResult = indexShard.getService().getForUpdate(request.id(), request.ifSeqNo(), request.ifPrimaryTerm()); return prepare(indexShard.shardId(), request, getResult, nowInMillis); } @@ -156,7 +156,7 @@ Result prepareUpsert(ShardId shardId, UpdateRequest request, final GetResult get case NONE: UpdateResponse update = new UpdateResponse( shardId, - getResult.getType(), + MapperService.SINGLE_MAPPING_NAME, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -221,7 +221,7 @@ Result prepareUpdateIndexRequest(ShardId shardId, UpdateRequest request, GetResu if (detectNoop && noop) { UpdateResponse update = new UpdateResponse( shardId, - getResult.getType(), + MapperService.SINGLE_MAPPING_NAME, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -271,7 +271,6 @@ 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.ID, getResult.getId()); ctx.put(ContextFields.VERSION, getResult.getVersion()); ctx.put(ContextFields.ROUTING, routing); @@ -313,7 +312,7 @@ Result prepareUpdateScriptRequest(ShardId shardId, UpdateRequest request, GetRes // If it was neither an INDEX or DELETE operation, treat it as a noop UpdateResponse update = new UpdateResponse( shardId, - getResult.getType(), + MapperService.SINGLE_MAPPING_NAME, getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -386,7 +385,6 @@ public static GetResult extractGetResult( // 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, diff --git a/server/src/main/java/org/opensearch/action/update/UpdateResponse.java b/server/src/main/java/org/opensearch/action/update/UpdateResponse.java index 4842d7dd03b77..3f640b53d8b81 100644 --- a/server/src/main/java/org/opensearch/action/update/UpdateResponse.java +++ b/server/src/main/java/org/opensearch/action/update/UpdateResponse.java @@ -38,6 +38,7 @@ import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.index.get.GetResult; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.shard.ShardId; import org.opensearch.rest.RestStatus; @@ -83,7 +84,7 @@ public UpdateResponse( long version, Result result ) { - super(shardId, type, id, seqNo, primaryTerm, version, result); + super(shardId, MapperService.SINGLE_MAPPING_NAME, id, seqNo, primaryTerm, version, result); setShardInfo(shardInfo); } @@ -198,7 +199,6 @@ public UpdateResponse build() { update.setGetResult( new GetResult( update.getIndex(), - update.getType(), update.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), diff --git a/server/src/main/java/org/opensearch/client/Client.java b/server/src/main/java/org/opensearch/client/Client.java index 5ec701edad092..dedfb2af1a10e 100644 --- a/server/src/main/java/org/opensearch/client/Client.java +++ b/server/src/main/java/org/opensearch/client/Client.java @@ -271,9 +271,9 @@ public interface Client extends OpenSearchClient, 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/opensearch/client/Requests.java b/server/src/main/java/org/opensearch/client/Requests.java index a7818e9ac136b..762676586d8e0 100644 --- a/server/src/main/java/org/opensearch/client/Requests.java +++ b/server/src/main/java/org/opensearch/client/Requests.java @@ -129,7 +129,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/opensearch/client/support/AbstractClient.java b/server/src/main/java/org/opensearch/client/support/AbstractClient.java index c0310c623d4a8..28b1c852399d2 100644 --- a/server/src/main/java/org/opensearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/opensearch/client/support/AbstractClient.java @@ -532,8 +532,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/opensearch/index/engine/Engine.java b/server/src/main/java/org/opensearch/index/engine/Engine.java index 969fae0a466b1..2384bcef2648d 100644 --- a/server/src/main/java/org/opensearch/index/engine/Engine.java +++ b/server/src/main/java/org/opensearch/index/engine/Engine.java @@ -1704,16 +1704,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; @@ -1723,10 +1722,6 @@ public boolean realtime() { return this.realtime; } - public String type() { - return type; - } - public String id() { return id; } diff --git a/server/src/main/java/org/opensearch/index/get/GetResult.java b/server/src/main/java/org/opensearch/index/get/GetResult.java index fe626f47b6389..aa2bf43c5b290 100644 --- a/server/src/main/java/org/opensearch/index/get/GetResult.java +++ b/server/src/main/java/org/opensearch/index/get/GetResult.java @@ -34,6 +34,7 @@ import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchParseException; +import org.opensearch.Version; import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.compress.CompressorFactory; @@ -65,7 +66,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"; @@ -74,7 +74,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; @@ -88,7 +87,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_2_0_0)) { + in.readOptionalString(); + } id = in.readString(); seqNo = in.readZLong(); primaryTerm = in.readVLong(); @@ -121,7 +122,6 @@ public GetResult(StreamInput in) throws IOException { public GetResult( String index, - String type, String id, long seqNo, long primaryTerm, @@ -132,7 +132,6 @@ public GetResult( Map metaFields ) { this.index = index; - this.type = type; this.id = id; this.seqNo = seqNo; this.primaryTerm = primaryTerm; @@ -163,13 +162,6 @@ public String getIndex() { return index; } - /** - * The type of the document. - */ - public String getType() { - return type; - } - /** * The id of the document. */ @@ -337,7 +329,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) { @@ -354,10 +345,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); - 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); @@ -375,8 +366,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)) { @@ -414,7 +403,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 { @@ -442,7 +431,9 @@ private Map readFields(StreamInput in) throws IOException @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(index); - out.writeOptionalString(type); + if (out.getVersion().before(Version.V_2_0_0)) { + out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(id); out.writeZLong(seqNo); out.writeVLong(primaryTerm); @@ -484,7 +475,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) @@ -493,7 +483,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/opensearch/index/get/ShardGetService.java b/server/src/main/java/org/opensearch/index/get/ShardGetService.java index 992a53e9ae0da..8cf315e2fffa8 100644 --- a/server/src/main/java/org/opensearch/index/get/ShardGetService.java +++ b/server/src/main/java/org/opensearch/index/get/ShardGetService.java @@ -107,7 +107,6 @@ public GetStats stats() { } public GetResult get( - String type, String id, String[] gFields, boolean realtime, @@ -115,11 +114,10 @@ public GetResult get( VersionType versionType, FetchSourceContext fetchSourceContext ) { - return get(type, id, gFields, realtime, version, versionType, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, fetchSourceContext); + return get(id, gFields, realtime, version, versionType, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, fetchSourceContext); } private GetResult get( - String type, String id, String[] gFields, boolean realtime, @@ -132,7 +130,7 @@ private GetResult get( currentMetric.inc(); try { long now = System.nanoTime(); - GetResult getResult = innerGet(type, id, gFields, realtime, version, versionType, ifSeqNo, ifPrimaryTerm, fetchSourceContext); + GetResult getResult = innerGet(id, gFields, realtime, version, versionType, ifSeqNo, ifPrimaryTerm, fetchSourceContext); if (getResult.isExists()) { existsMetric.inc(System.nanoTime() - now); @@ -145,9 +143,8 @@ private GetResult get( } } - public GetResult getForUpdate(String type, String id, long ifSeqNo, long ifPrimaryTerm) { + public GetResult getForUpdate(String id, long ifSeqNo, long ifPrimaryTerm) { return get( - type, id, new String[] { RoutingFieldMapper.NAME }, true, @@ -166,16 +163,16 @@ 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, String[] fields, FetchSourceContext fetchSourceContext) { + 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 { @@ -206,7 +203,6 @@ private FetchSourceContext normalizeFetchSourceContent(@Nullable FetchSourceCont } private GetResult innerGet( - String type, String id, String[] gFields, boolean realtime, @@ -217,40 +213,31 @@ private GetResult innerGet( FetchSourceContext fetchSourceContext ) { 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, realtime, type, id, uidTerm).version(version) - .versionType(versionType) - .setIfSeqNo(ifSeqNo) - .setIfPrimaryTerm(ifPrimaryTerm) - ); - assert get.isFromTranslog() == false || realtime : "should only read from translog if realtime enabled"; - if (get.exists() == false) { - get.close(); - } + Term uidTerm = new Term(IdFieldMapper.NAME, Uid.encodeId(id)); + Engine.GetResult get = indexShard.get( + new Engine.Get(realtime, true, 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[] storedFields, FetchSourceContext fetchSourceContext, @@ -289,7 +276,7 @@ private GetResult innerGetLoadFromStoredFields( try { docIdAndVersion.reader.document(docIdAndVersion.docId, fieldVisitor); } catch (IOException e) { - throw new OpenSearchException("Failed to get type [" + type + "] and id [" + id + "]", e); + throw new OpenSearchException("Failed to get id [" + id + "]", e); } source = fieldVisitor.source(); @@ -308,7 +295,7 @@ private GetResult innerGetLoadFromStoredFields( assert source != null : "original source in translog must exist"; SourceToParse sourceToParse = new SourceToParse( shardId.getIndexName(), - type, + MapperService.SINGLE_MAPPING_NAME, id, source, XContentHelper.xContentType(source), @@ -417,13 +404,12 @@ private GetResult innerGetLoadFromStoredFields( try { source = BytesReference.bytes(XContentFactory.contentBuilder(sourceContentType).map(sourceAsMap)); } catch (IOException e) { - throw new OpenSearchException("Failed to get type [" + type + "] and id [" + id + "] with includes/excludes set", e); + throw new OpenSearchException("Failed to get id [" + id + "] with includes/excludes set", e); } } return new GetResult( shardId.getIndexName(), - type, id, get.docIdAndVersion().seqNo, get.docIdAndVersion().primaryTerm, diff --git a/server/src/main/java/org/opensearch/index/query/AbstractGeometryQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/AbstractGeometryQueryBuilder.java index ca7e97cfb8bac..b5b4abdbaf118 100644 --- a/server/src/main/java/org/opensearch/index/query/AbstractGeometryQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/AbstractGeometryQueryBuilder.java @@ -423,14 +423,10 @@ private void fetch(Client client, GetRequest getRequest, String path, ActionList 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("\\."); @@ -549,12 +545,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws } else if (this.shape == null) { SetOnce supplier = new SetOnce<>(); queryRewriteContext.registerAsyncAction((client, listener) -> { - GetRequest getRequest; - if (indexedShapeType == null) { - getRequest = new GetRequest(indexedShapeIndex, indexedShapeId); - } else { - getRequest = new GetRequest(indexedShapeIndex, indexedShapeType, indexedShapeId); - } + GetRequest getRequest = new GetRequest(indexedShapeIndex, indexedShapeId); getRequest.routing(indexedShapeRouting); fetch(client, getRequest, indexedShapePath, ActionListener.wrap(builder -> { supplier.set(builder); diff --git a/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java index 9e0446ae4d802..e797730ac0dff 100644 --- a/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java @@ -479,9 +479,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/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index 735acc769e3ad..bc4ea006613bb 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -1184,7 +1184,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/opensearch/index/termvectors/TermVectorsService.java b/server/src/main/java/org/opensearch/index/termvectors/TermVectorsService.java index 5b9351ce66b03..50cd160ecb00d 100644 --- a/server/src/main/java/org/opensearch/index/termvectors/TermVectorsService.java +++ b/server/src/main/java/org/opensearch/index/termvectors/TermVectorsService.java @@ -106,9 +106,8 @@ static TermVectorsResponse getTermVectors(IndexShard indexShard, TermVectorsRequ try ( Engine.GetResult get = indexShard.get( - new Engine.Get(request.realtime(), false, MapperService.SINGLE_MAPPING_NAME, request.id(), uidTerm).version( - request.version() - ).versionType(request.versionType()) + new Engine.Get(request.realtime(), false, request.id(), uidTerm).version(request.version()) + .versionType(request.versionType()) ); Engine.Searcher searcher = indexShard.acquireSearcher("term_vector") ) { @@ -235,7 +234,7 @@ private static Fields addGeneratedTermVectors( /* 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(), diff --git a/server/src/main/java/org/opensearch/rest/action/document/RestGetAction.java b/server/src/main/java/org/opensearch/rest/action/document/RestGetAction.java index 18d39edf887b5..a0ec48ee55451 100644 --- a/server/src/main/java/org/opensearch/rest/action/document/RestGetAction.java +++ b/server/src/main/java/org/opensearch/rest/action/document/RestGetAction.java @@ -36,7 +36,6 @@ import org.opensearch.action.get.GetResponse; import org.opensearch.client.node.NodeClient; import org.opensearch.common.Strings; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.index.VersionType; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; @@ -56,9 +55,6 @@ import static org.opensearch.rest.RestStatus.OK; public class RestGetAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.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."; @Override public String getName() { @@ -67,27 +63,12 @@ public String getName() { @Override public List routes() { - return unmodifiableList( - asList( - new Route(GET, "/{index}/_doc/{id}"), - new Route(HEAD, "/{index}/_doc/{id}"), - // Deprecated typed endpoints. - new Route(GET, "/{index}/{type}/{id}"), - new Route(HEAD, "/{index}/{type}/{id}") - ) - ); + return unmodifiableList(asList(new Route(GET, "/{index}/_doc/{id}"), new Route(HEAD, "/{index}/_doc/{id}"))); } @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - GetRequest getRequest; - if (request.hasParam("type")) { - deprecationLogger.deprecate("get_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")); - } - + 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")); diff --git a/server/src/main/java/org/opensearch/rest/action/document/RestGetSourceAction.java b/server/src/main/java/org/opensearch/rest/action/document/RestGetSourceAction.java index cd6b3b16e79cd..801ab85039d2d 100644 --- a/server/src/main/java/org/opensearch/rest/action/document/RestGetSourceAction.java +++ b/server/src/main/java/org/opensearch/rest/action/document/RestGetSourceAction.java @@ -38,7 +38,6 @@ import org.opensearch.action.get.GetResponse; import org.opensearch.client.node.NodeClient; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.rest.BaseRestHandler; @@ -64,20 +63,9 @@ */ public class RestGetSourceAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetSourceAction.class); - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in get_source and exist_source" - + "requests is deprecated."; - @Override public List routes() { - return unmodifiableList( - asList( - new Route(GET, "/{index}/_source/{id}"), - new Route(HEAD, "/{index}/_source/{id}"), - new Route(GET, "/{index}/{type}/{id}/_source"), - new Route(HEAD, "/{index}/{type}/{id}/_source") - ) - ); + return unmodifiableList(asList(new Route(GET, "/{index}/_source/{id}"), new Route(HEAD, "/{index}/_source/{id}"))); } @Override @@ -87,13 +75,7 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - final GetRequest getRequest; - if (request.hasParam("type")) { - deprecationLogger.deprecate("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")); @@ -140,13 +122,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/opensearch/rest/action/document/RestMultiGetAction.java b/server/src/main/java/org/opensearch/rest/action/document/RestMultiGetAction.java index 514dc26b3e7ee..6713bddfd837d 100644 --- a/server/src/main/java/org/opensearch/rest/action/document/RestMultiGetAction.java +++ b/server/src/main/java/org/opensearch/rest/action/document/RestMultiGetAction.java @@ -35,7 +35,6 @@ import org.opensearch.action.get.MultiGetRequest; import org.opensearch.client.node.NodeClient; import org.opensearch.common.Strings; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentParser; import org.opensearch.rest.BaseRestHandler; @@ -52,9 +51,6 @@ import static org.opensearch.rest.RestRequest.Method.POST; public class RestMultiGetAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestMultiGetAction.class); - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal]" + " Specifying types in multi get requests is deprecated."; - private final boolean allowExplicitIndex; public RestMultiGetAction(Settings settings) { @@ -64,15 +60,7 @@ public RestMultiGetAction(Settings settings) { @Override public List routes() { return unmodifiableList( - asList( - new Route(GET, "/_mget"), - new Route(POST, "/_mget"), - new Route(GET, "/{index}/_mget"), - new Route(POST, "/{index}/_mget"), - // Deprecated typed endpoints. - new Route(GET, "/{index}/{type}/_mget"), - new Route(POST, "/{index}/{type}/_mget") - ) + asList(new Route(GET, "/_mget"), new Route(POST, "/_mget"), new Route(GET, "/{index}/_mget"), new Route(POST, "/{index}/_mget")) ); } @@ -83,10 +71,6 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - if (request.param("type") != null) { - deprecationLogger.deprecate("mget_with_types", TYPES_DEPRECATION_MESSAGE); - } - MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh())); multiGetRequest.preference(request.param("preference")); @@ -105,22 +89,7 @@ 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, - request.param("routing"), - parser, - allowExplicitIndex - ); - } - - for (MultiGetRequest.Item item : multiGetRequest.getItems()) { - if (item.type() != null) { - deprecationLogger.deprecate("mget_with_types", TYPES_DEPRECATION_MESSAGE); - break; - } + multiGetRequest.add(request.param("index"), sFields, defaultFetchSource, request.param("routing"), parser, allowExplicitIndex); } return channel -> client.multiGet(multiGetRequest, new RestToXContentListener<>(channel)); diff --git a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java index a1455a715e461..bc7605598a9ad 100644 --- a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java @@ -465,11 +465,11 @@ 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/opensearch/OpenSearchExceptionTests.java b/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java index 3d0b334622cd5..c3162fe10b5fe 100644 --- a/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java +++ b/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java @@ -566,7 +566,7 @@ public void testFromXContent() throws IOException { public void testFromXContentWithCause() throws IOException { OpenSearchException e = new OpenSearchException( "foo", - new OpenSearchException("bar", new OpenSearchException("baz", new RoutingMissingException("_test", "_type", "_id"))) + new OpenSearchException("bar", new OpenSearchException("baz", new RoutingMissingException("_test", "_id"))) ); final XContent xContent = randomFrom(XContentType.values()).xContent(); @@ -594,7 +594,7 @@ public void testFromXContentWithCause() throws IOException { cause = (OpenSearchException) cause.getCause(); assertEquals( cause.getMessage(), - "OpenSearch exception [type=routing_missing_exception, reason=routing is required for [_test]/[_type]/[_id]]" + "OpenSearch exception [type=routing_missing_exception, reason=routing is required for [_test]/[_id]]" ); assertThat(cause.getHeaderKeys(), hasSize(0)); assertThat(cause.getMetadataKeys(), hasSize(2)); @@ -603,7 +603,7 @@ public void testFromXContentWithCause() throws IOException { } public void testFromXContentWithHeadersAndMetadata() throws IOException { - RoutingMissingException routing = new RoutingMissingException("_test", "_type", "_id"); + RoutingMissingException routing = new RoutingMissingException("_test", "_id"); OpenSearchException baz = new OpenSearchException("baz", routing); baz.addHeader("baz_0", "baz0"); baz.addMetadata("opensearch.baz_1", "baz1"); @@ -656,7 +656,7 @@ public void testFromXContentWithHeadersAndMetadata() throws IOException { cause = (OpenSearchException) cause.getCause(); assertEquals( cause.getMessage(), - "OpenSearch exception [type=routing_missing_exception, reason=routing is required for [_test]/[_type]/[_id]]" + "OpenSearch exception [type=routing_missing_exception, reason=routing is required for [_test]/[_id]]" ); assertThat(cause.getHeaderKeys(), hasSize(0)); assertThat(cause.getMetadataKeys(), hasSize(2)); @@ -878,7 +878,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 OpenSearchException( diff --git a/server/src/test/java/org/opensearch/action/explain/ExplainResponseTests.java b/server/src/test/java/org/opensearch/action/explain/ExplainResponseTests.java index 8b95b06b0ee8b..fef46d256cb9b 100644 --- a/server/src/test/java/org/opensearch/action/explain/ExplainResponseTests.java +++ b/server/src/test/java/org/opensearch/action/explain/ExplainResponseTests.java @@ -78,7 +78,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, @@ -104,7 +103,6 @@ public void testToXContent() throws IOException { boolean exist = true; Explanation explanation = Explanation.match(1.0f, "description", Collections.emptySet()); GetResult getResult = new GetResult( - null, null, null, 0, diff --git a/server/src/test/java/org/opensearch/action/get/GetRequestTests.java b/server/src/test/java/org/opensearch/action/get/GetRequestTests.java index 91fcf57be8bef..562b84463cbae 100644 --- a/server/src/test/java/org/opensearch/action/get/GetRequestTests.java +++ b/server/src/test/java/org/opensearch/action/get/GetRequestTests.java @@ -42,14 +42,14 @@ public class GetRequestTests extends OpenSearchTestCase { 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())); diff --git a/server/src/test/java/org/opensearch/action/get/GetResponseTests.java b/server/src/test/java/org/opensearch/action/get/GetResponseTests.java index 108eeda79e173..aa4ecbff8d9ff 100644 --- a/server/src/test/java/org/opensearch/action/get/GetResponseTests.java +++ b/server/src/test/java/org/opensearch/action/get/GetResponseTests.java @@ -108,7 +108,6 @@ public void testToXContent() { GetResponse getResponse = new GetResponse( new GetResult( "index", - "type", "id", 0, 1, @@ -127,9 +126,7 @@ public void testToXContent() { ); } { - GetResponse getResponse = new GetResponse( - new GetResult("index", "type", "id", UNASSIGNED_SEQ_NO, 0, 1, false, null, null, null) - ); + 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); } @@ -139,7 +136,6 @@ public void testToString() { GetResponse getResponse = new GetResponse( new GetResult( "index", - "type", "id", 0, 1, @@ -167,7 +163,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), randomBoolean(), null, null, null) + new GetResult(null, null, UNASSIGNED_SEQ_NO, 0, randomIntBetween(1, 5), randomBoolean(), null, null, null) ); XContentType xContentType = randomFrom(XContentType.values()); diff --git a/server/src/test/java/org/opensearch/action/get/MultiGetRequestTests.java b/server/src/test/java/org/opensearch/action/get/MultiGetRequestTests.java index 54432fa2fb9fb..cf26117210dfb 100644 --- a/server/src/test/java/org/opensearch/action/get/MultiGetRequestTests.java +++ b/server/src/test/java/org/opensearch/action/get/MultiGetRequestTests.java @@ -71,9 +71,8 @@ public void testAddWithInvalidKey() throws IOException { final MultiGetRequest mgr = new MultiGetRequest(); final ParsingException e = expectThrows(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(), containsString("unknown key [doc] for a START_ARRAY, expected [docs] or [ids]")); } @@ -95,9 +94,8 @@ public void testUnexpectedField() throws IOException { final MultiGetRequest mgr = new MultiGetRequest(); final ParsingException e = expectThrows(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(), containsString("unexpected token [START_OBJECT], expected [FIELD_NAME] or [START_ARRAY]")); } @@ -118,7 +116,7 @@ public void testAddWithValidSourceValueIsAccepted() throws Exception { ); MultiGetRequest multiGetRequest = new MultiGetRequest(); - multiGetRequest.add(randomAlphaOfLength(5), randomAlphaOfLength(3), null, FetchSourceContext.FETCH_SOURCE, null, parser, true); + multiGetRequest.add(randomAlphaOfLength(5), null, FetchSourceContext.FETCH_SOURCE, null, parser, true); assertEquals(2, multiGetRequest.getItems().size()); } @@ -130,7 +128,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())); @@ -147,7 +145,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/opensearch/action/get/MultiGetResponseTests.java b/server/src/test/java/org/opensearch/action/get/MultiGetResponseTests.java index 36960ac2f322d..a167f41d41b66 100644 --- a/server/src/test/java/org/opensearch/action/get/MultiGetResponseTests.java +++ b/server/src/test/java/org/opensearch/action/get/MultiGetResponseTests.java @@ -64,7 +64,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)); @@ -84,18 +83,7 @@ private static MultiGetResponse createTestInstance() { if (randomBoolean()) { items[i] = new MultiGetItemResponse( new GetResponse( - new GetResult( - randomAlphaOfLength(4), - randomAlphaOfLength(4), - randomAlphaOfLength(4), - 0, - 1, - randomNonNegativeLong(), - true, - null, - null, - null - ) + new GetResult(randomAlphaOfLength(4), randomAlphaOfLength(4), 0, 1, randomNonNegativeLong(), true, null, null, null) ), null ); @@ -103,7 +91,6 @@ private static MultiGetResponse createTestInstance() { items[i] = new MultiGetItemResponse( null, new MultiGetResponse.Failure( - randomAlphaOfLength(4), randomAlphaOfLength(4), randomAlphaOfLength(4), new RuntimeException(randomAlphaOfLength(4)) diff --git a/server/src/test/java/org/opensearch/action/get/MultiGetShardRequestTests.java b/server/src/test/java/org/opensearch/action/get/MultiGetShardRequestTests.java index fc4c7c18d528f..5bf4f50c50c63 100644 --- a/server/src/test/java/org/opensearch/action/get/MultiGetShardRequestTests.java +++ b/server/src/test/java/org/opensearch/action/get/MultiGetShardRequestTests.java @@ -58,11 +58,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]; @@ -97,7 +93,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/opensearch/action/get/TransportMultiGetActionTests.java b/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java index 9141b86ded5a7..09bab1af7fc43 100644 --- a/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java +++ b/server/src/test/java/org/opensearch/action/get/TransportMultiGetActionTests.java @@ -225,8 +225,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( @@ -257,8 +257,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( diff --git a/server/src/test/java/org/opensearch/action/update/UpdateRequestTests.java b/server/src/test/java/org/opensearch/action/update/UpdateRequestTests.java index d339a37b51188..09cb4bd3cf054 100644 --- a/server/src/test/java/org/opensearch/action/update/UpdateRequestTests.java +++ b/server/src/test/java/org/opensearch/action/update/UpdateRequestTests.java @@ -380,7 +380,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)); @@ -392,7 +392,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)); @@ -400,14 +400,14 @@ 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); + final GetResult getResult = new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); final UpdateRequest updateRequest = new UpdateRequest("test", "type", "1").script(mockInlineScript("return")) .timeout(randomTimeValue()); runTimeoutTest(getResult, updateRequest); } public void testDeleteTimeout() { - final GetResult getResult = new GetResult("test", "type", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); + final GetResult getResult = new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"f\":\"v\"}"), null, null); final UpdateRequest updateRequest = new UpdateRequest("test", "type", "1").script(mockInlineScript("ctx.op = delete")) .timeout(randomTimeValue()); runTimeoutTest(getResult, updateRequest); @@ -416,7 +416,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(); { @@ -561,7 +561,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 @@ -571,7 +571,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)); @@ -580,7 +580,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")); @@ -588,7 +588,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, new BytesArray("{\"body\": \"foo\"}"), null, null); + GetResult getResult = new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"body\": \"foo\"}"), null, null); UpdateRequest request = new UpdateRequest("test", "type1", "1").fromXContent( createParser(JsonXContent.jsonXContent, new BytesArray("{\"doc\": {\"body\": \"foo\"}}")) @@ -619,7 +619,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, new BytesArray("{\"body\": \"bar\"}"), null, null); + GetResult getResult = new GetResult("test", "1", 0, 1, 0, true, new BytesArray("{\"body\": \"bar\"}"), null, null); UpdateRequest request = new UpdateRequest("test", "type1", "1").script(mockInlineScript("ctx._source.body = \"foo\"")); diff --git a/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java b/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java index 8ba87114f542c..99ae088047b1c 100644 --- a/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java +++ b/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java @@ -45,6 +45,7 @@ import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.get.GetResult; import org.opensearch.index.get.GetResultTests; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.index.shard.ShardId; import org.opensearch.test.OpenSearchTestCase; @@ -110,7 +111,7 @@ public void testToXContent() throws IOException { 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( @@ -192,7 +193,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; @@ -211,11 +211,29 @@ 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, + MapperService.SINGLE_MAPPING_NAME, + id, + seqNo, + primaryTerm, + version, + result + ); + expected = new UpdateResponse( + shardInfos.v2(), + expectedShardId, + MapperService.SINGLE_MAPPING_NAME, + 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, MapperService.SINGLE_MAPPING_NAME, id, seqNo, primaryTerm, version, result); + expected = new UpdateResponse(expectedShardId, MapperService.SINGLE_MAPPING_NAME, id, seqNo, primaryTerm, version, result); } if (actualGetResult.isExists()) { diff --git a/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java b/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java index d37ff7d480bd8..e4e6594207a5e 100644 --- a/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java +++ b/server/src/test/java/org/opensearch/client/AbstractClientHeadersTestCase.java @@ -121,7 +121,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() @@ -156,7 +156,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").execute(new AssertingActionListener<>(GetAction.NAME, expected, client.threadPool())); + client.prepareGet("idx", "id").execute(new AssertingActionListener<>(GetAction.NAME, expected, client.threadPool())); client.admin() .cluster() diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index ec96f2f509c1c..980ee4fd95a95 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -1305,7 +1305,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()), searcherFactory)) { + try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.id(), create.uid()), searcherFactory)) { assertEquals(1, get.version()); } @@ -1313,7 +1313,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()), searcherFactory)) { + try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.id(), create.uid()), searcherFactory)) { assertEquals(2, get.version()); } @@ -1321,7 +1321,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()), searcherFactory)) { + try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.id(), create.uid()), searcherFactory)) { assertEquals(3, get.version()); } @@ -1341,8 +1341,7 @@ public void testGetIfSeqNoIfPrimaryTerm() throws IOException { } try ( Engine.GetResult get = engine.get( - new Engine.Get(true, true, doc.type(), doc.id(), create.uid()).setIfSeqNo(indexResult.getSeqNo()) - .setIfPrimaryTerm(primaryTerm.get()), + new Engine.Get(true, true, doc.id(), create.uid()).setIfSeqNo(indexResult.getSeqNo()).setIfPrimaryTerm(primaryTerm.get()), searcherFactory ) ) { @@ -1352,7 +1351,7 @@ public void testGetIfSeqNoIfPrimaryTerm() throws IOException { expectThrows( VersionConflictEngineException.class, () -> engine.get( - new Engine.Get(true, false, doc.type(), doc.id(), create.uid()).setIfSeqNo(indexResult.getSeqNo() + 1) + new Engine.Get(true, false, doc.id(), create.uid()).setIfSeqNo(indexResult.getSeqNo() + 1) .setIfPrimaryTerm(primaryTerm.get()), searcherFactory ) @@ -1361,7 +1360,7 @@ public void testGetIfSeqNoIfPrimaryTerm() throws IOException { expectThrows( VersionConflictEngineException.class, () -> engine.get( - new Engine.Get(true, false, doc.type(), doc.id(), create.uid()).setIfSeqNo(indexResult.getSeqNo()) + new Engine.Get(true, false, doc.id(), create.uid()).setIfSeqNo(indexResult.getSeqNo()) .setIfPrimaryTerm(primaryTerm.get() + 1), searcherFactory ) @@ -1370,7 +1369,7 @@ public void testGetIfSeqNoIfPrimaryTerm() throws IOException { final VersionConflictEngineException versionConflictEngineException = expectThrows( VersionConflictEngineException.class, () -> engine.get( - new Engine.Get(true, false, doc.type(), doc.id(), create.uid()).setIfSeqNo(indexResult.getSeqNo() + 1) + new Engine.Get(true, false, doc.id(), create.uid()).setIfSeqNo(indexResult.getSeqNo() + 1) .setIfPrimaryTerm(primaryTerm.get() + 1), searcherFactory ) @@ -2231,7 +2230,7 @@ public void testVersioningPromotedReplica() throws IOException { final int opsOnPrimary = assertOpsOnPrimary(primaryOps, finalReplicaVersion, deletedOnReplica, replicaEngine); final long currentSeqNo = getSequenceID( replicaEngine, - new Engine.Get(false, false, "type", lastReplicaOp.uid().text(), lastReplicaOp.uid()) + new Engine.Get(false, false, lastReplicaOp.uid().text(), lastReplicaOp.uid()) ).v1(); try (Engine.Searcher searcher = engine.acquireSearcher("test", Engine.SearcherScope.INTERNAL)) { final TotalHitCountCollector collector = new TotalHitCountCollector(); @@ -2297,7 +2296,7 @@ class OpAndVersion { throw new AssertionError(e); } for (int op = 0; op < opsPerThread; op++) { - try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.type(), doc.id(), uidTerm), searcherFactory)) { + try (Engine.GetResult get = engine.get(new Engine.Get(true, false, 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())); @@ -2353,7 +2352,7 @@ class OpAndVersion { assertTrue(op.added + " should not exist", exists); } - try (Engine.GetResult get = engine.get(new Engine.Get(true, false, doc.type(), doc.id(), uidTerm), searcherFactory)) { + try (Engine.GetResult get = engine.get(new Engine.Get(true, false, 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())); @@ -2860,7 +2859,7 @@ public void testEnableGcDeletes() throws Exception { ); // Get should not find the document (we never indexed uid=2): - getResult = engine.get(new Engine.Get(true, false, "type", "2", newUid("2")), searcherFactory); + getResult = engine.get(new Engine.Get(true, false, "2", newUid("2")), searcherFactory); assertThat(getResult.exists(), equalTo(false)); // Try to index uid=1 with a too-old version, should fail: @@ -4501,7 +4500,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"))); + Tuple seqID = getSequenceID(engine, new Engine.Get(false, false, "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)); @@ -4854,7 +4853,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)) { + try (Engine.GetResult result = engine.get(new Engine.Get(true, false, "2", uid), searcherFactory)) { assertThat(result.exists(), equalTo(exists)); } } @@ -5979,22 +5978,14 @@ public void testStressUpdateSameDocWhileGettingIt() throws IOException, Interrup Thread thread = new Thread(() -> { awaitStarted.countDown(); try ( - Engine.GetResult getResult = engine.get( - new Engine.Get(true, false, doc3.type(), doc3.id(), doc3.uid()), - engine::acquireSearcher - ) + Engine.GetResult getResult = engine.get(new Engine.Get(true, false, doc3.id(), doc3.uid()), engine::acquireSearcher) ) { assertTrue(getResult.exists()); } }); thread.start(); awaitStarted.await(); - try ( - Engine.GetResult getResult = engine.get( - new Engine.Get(true, false, doc.type(), doc.id(), doc.uid()), - engine::acquireSearcher - ) - ) { + try (Engine.GetResult getResult = engine.get(new Engine.Get(true, false, doc.id(), doc.uid()), engine::acquireSearcher)) { assertFalse(getResult.exists()); } thread.join(); diff --git a/server/src/test/java/org/opensearch/index/get/GetResultTests.java b/server/src/test/java/org/opensearch/index/get/GetResultTests.java index 2c9cbe5edbd77..5b96522438e0e 100644 --- a/server/src/test/java/org/opensearch/index/get/GetResultTests.java +++ b/server/src/test/java/org/opensearch/index/get/GetResultTests.java @@ -97,7 +97,6 @@ public void testToXContent() throws IOException { { GetResult getResult = new GetResult( "index", - "type", "id", 0, 1, @@ -116,7 +115,7 @@ public void testToXContent() 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); String output = Strings.toString(getResult); assertEquals("{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"found\":false}", output); } @@ -129,7 +128,6 @@ public void testToAndFromXContentEmbedded() throws Exception { // 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(), @@ -166,7 +164,6 @@ public void testToXContentEmbedded() throws IOException { GetResult getResult = new GetResult( "index", - "type", "id", 0, 1, @@ -186,7 +183,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()); @@ -194,7 +191,7 @@ public void testToXContentEmbeddedNotFound() throws IOException { public void testSerializationNotFound() throws IOException { // serializes and deserializes with streamable, then prints back to xcontent - 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); BytesStreamOutput out = new BytesStreamOutput(); getResult.writeTo(out); @@ -222,7 +219,6 @@ public void testEqualsAndHashcode() { public static GetResult copyGetResult(GetResult getResult) { return new GetResult( getResult.getIndex(), - getResult.getType(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -239,7 +235,6 @@ public static GetResult mutateGetResult(GetResult getResult) { mutations.add( () -> new GetResult( randomUnicodeOfLength(15), - getResult.getType(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -253,7 +248,6 @@ public static GetResult mutateGetResult(GetResult getResult) { mutations.add( () -> new GetResult( getResult.getIndex(), - randomUnicodeOfLength(15), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -267,7 +261,6 @@ public static GetResult mutateGetResult(GetResult getResult) { mutations.add( () -> new GetResult( getResult.getIndex(), - getResult.getType(), randomUnicodeOfLength(15), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -281,7 +274,6 @@ public static GetResult mutateGetResult(GetResult getResult) { mutations.add( () -> new GetResult( getResult.getIndex(), - getResult.getType(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -295,7 +287,6 @@ public static GetResult mutateGetResult(GetResult getResult) { mutations.add( () -> new GetResult( getResult.getIndex(), - getResult.getType(), getResult.getId(), getResult.isExists() ? UNASSIGNED_SEQ_NO : getResult.getSeqNo(), getResult.isExists() ? 0 : getResult.getPrimaryTerm(), @@ -309,7 +300,6 @@ public static GetResult mutateGetResult(GetResult getResult) { mutations.add( () -> new GetResult( getResult.getIndex(), - getResult.getType(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -323,7 +313,6 @@ public static GetResult mutateGetResult(GetResult getResult) { mutations.add( () -> new GetResult( getResult.getIndex(), - getResult.getType(), getResult.getId(), getResult.getSeqNo(), getResult.getPrimaryTerm(), @@ -373,10 +362,9 @@ public static Tuple randomGetResult(XContentType xContentT version = -1; exists = false; } - GetResult getResult = new GetResult(index, type, id, seqNo, primaryTerm, version, exists, source, docFields, metaFields); + GetResult getResult = new GetResult(index, id, seqNo, primaryTerm, version, exists, source, docFields, metaFields); GetResult expectedGetResult = new GetResult( index, - type, id, seqNo, primaryTerm, diff --git a/server/src/test/java/org/opensearch/index/query/GeoShapeQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/GeoShapeQueryBuilderTests.java index 9aac0e033dcef..3eab92d7e2112 100644 --- a/server/src/test/java/org/opensearch/index/query/GeoShapeQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/GeoShapeQueryBuilderTests.java @@ -51,7 +51,6 @@ import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.get.GetResult; -import org.opensearch.index.mapper.MapperService; import org.opensearch.test.AbstractQueryTestCase; import org.opensearch.test.VersionUtils; import org.opensearch.test.geo.RandomShapeGenerator; @@ -94,12 +93,9 @@ protected GeoShapeQueryBuilder doCreateTestQueryBuilder() { @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)); @@ -116,9 +112,7 @@ protected GetResponse executeGet(GetRequest getRequest) { } catch (IOException ex) { throw new OpenSearchException("boom", ex); } - return new GetResponse( - new GetResult(indexedShapeIndex, indexedType, indexedShapeId, 0, 1, 0, true, new BytesArray(json), null, null) - ); + return new GetResponse(new GetResult(indexedShapeIndex, indexedShapeId, 0, 1, 0, true, new BytesArray(json), null, null)); } @After diff --git a/server/src/test/java/org/opensearch/index/query/TermsQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/TermsQueryBuilderTests.java index 9e6c496c1a0ca..e37b4f1a1c39f 100644 --- a/server/src/test/java/org/opensearch/index/query/TermsQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/TermsQueryBuilderTests.java @@ -241,9 +241,7 @@ public GetResponse executeGet(GetRequest getRequest) { } catch (IOException ex) { throw new OpenSearchException("boom", ex); } - return new GetResponse( - new GetResult(getRequest.index(), getRequest.type(), getRequest.id(), 0, 1, 0, true, new BytesArray(json), null, null) - ); + return new GetResponse(new GetResult(getRequest.index(), getRequest.id(), 0, 1, 0, true, new BytesArray(json), null, null)); } public void testNumeric() throws IOException { diff --git a/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java b/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java index 0c771a46ab226..22be2feae7dbe 100644 --- a/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/opensearch/index/shard/IndexShardTests.java @@ -1736,9 +1736,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", new Term(IdFieldMapper.NAME, Uid.encodeId("test"))) - ) + 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)); } @@ -1764,9 +1762,7 @@ public void testExternalRefreshMetric() throws IOException { 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", new Term(IdFieldMapper.NAME, Uid.encodeId("test"))) - ) + 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)); @@ -2660,11 +2656,7 @@ public void testReaderWrapperIsUsed() throws IOException { indexDoc(shard, "_doc", "1", "{\"foobar\" : \"bar\"}"); shard.refresh("test"); - try ( - Engine.GetResult getResult = shard.get( - new Engine.Get(false, false, "_doc", "1", new Term(IdFieldMapper.NAME, Uid.encodeId("1"))) - ) - ) { + try (Engine.GetResult getResult = shard.get(new Engine.Get(false, false, "1", new Term(IdFieldMapper.NAME, Uid.encodeId("1"))))) { assertTrue(getResult.exists()); assertNotNull(getResult.searcher()); } @@ -2698,9 +2690,7 @@ public void testReaderWrapperIsUsed() throws IOException { assertEquals(search.totalHits.value, 1); } try ( - Engine.GetResult getResult = newShard.get( - new Engine.Get(false, false, "_doc", "1", new Term(IdFieldMapper.NAME, Uid.encodeId("1"))) - ) + Engine.GetResult getResult = newShard.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 @@ -4351,19 +4341,11 @@ public void testTypelessGet() throws IOException { assertTrue(indexResult.isCreated()); org.opensearch.index.engine.Engine.GetResult getResult = shard.get( - new Engine.Get(true, true, "some_type", "0", new Term("_id", Uid.encodeId("0"))) + new Engine.Get(true, true, "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")))); - assertTrue(getResult.exists()); - getResult.close(); - closeShards(shard); } diff --git a/server/src/test/java/org/opensearch/index/shard/RefreshListenersTests.java b/server/src/test/java/org/opensearch/index/shard/RefreshListenersTests.java index 593c409bf75b4..97fd7fc8f279f 100644 --- a/server/src/test/java/org/opensearch/index/shard/RefreshListenersTests.java +++ b/server/src/test/java/org/opensearch/index/shard/RefreshListenersTests.java @@ -367,7 +367,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/opensearch/index/shard/ShardGetServiceTests.java b/server/src/test/java/org/opensearch/index/shard/ShardGetServiceTests.java index fc8fe408a0c6d..a04be37176389 100644 --- a/server/src/test/java/org/opensearch/index/shard/ShardGetServiceTests.java +++ b/server/src/test/java/org/opensearch/index/shard/ShardGetServiceTests.java @@ -39,6 +39,7 @@ import org.opensearch.index.engine.Engine; import org.opensearch.index.engine.VersionConflictEngineException; import org.opensearch.index.get.GetResult; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.mapper.RoutingFieldMapper; import org.opensearch.search.fetch.subphase.FetchSourceContext; @@ -66,7 +67,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)) { @@ -75,7 +76,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()); @@ -90,23 +91,17 @@ 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) - ); - expectThrows( - VersionConflictEngineException.class, - () -> primary.getService().getForUpdate("test", "1", test2.getSeqNo(), primaryTerm + 1) - ); + expectThrows(VersionConflictEngineException.class, () -> primary.getService().getForUpdate("1", test2.getSeqNo() + 1, primaryTerm)); + expectThrows(VersionConflictEngineException.class, () -> primary.getService().getForUpdate("1", test2.getSeqNo(), primaryTerm + 1)); closeShards(primary); } @@ -139,7 +134,7 @@ private void runGetFromTranslogWithOptions( IndexMetadata metadata = IndexMetadata.builder("test") .putMapping( - "test", + MapperService.SINGLE_MAPPING_NAME, "{ \"properties\": { \"foo\": { \"type\": " + fieldType + ", \"store\": true }, " @@ -154,18 +149,18 @@ private void runGetFromTranslogWithOptions( .build(); IndexShard primary = newShard(new ShardId(metadata.getIndex(), 0), true, "n1", metadata, null); recoverShardFromStore(primary); - Engine.IndexResult test = indexDoc(primary, "test", "0", docToIndex); + Engine.IndexResult test = indexDoc(primary, MapperService.SINGLE_MAPPING_NAME, "0", docToIndex); 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() == null ? new byte[0] : testGet.source(), StandardCharsets.UTF_8), expectedResult); try (Engine.Searcher searcher = primary.getEngine().acquireSearcher("test", Engine.SearcherScope.INTERNAL)) { assertEquals(searcher.getIndexReader().maxDoc(), 1); // we refreshed } - Engine.IndexResult test1 = indexDoc(primary, "test", "1", docToIndex, XContentType.JSON, "foobar"); + Engine.IndexResult test1 = indexDoc(primary, MapperService.SINGLE_MAPPING_NAME, "1", docToIndex, 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() == null ? new byte[0] : testGet1.source(), StandardCharsets.UTF_8), expectedResult); assertTrue(testGet1.getFields().containsKey(RoutingFieldMapper.NAME)); assertEquals("foobar", testGet1.getFields().get(RoutingFieldMapper.NAME).getValue()); @@ -177,10 +172,10 @@ private void runGetFromTranslogWithOptions( assertEquals(searcher.getIndexReader().maxDoc(), 2); } - Engine.IndexResult test2 = indexDoc(primary, "test", "2", docToIndex, XContentType.JSON, "foobar"); + Engine.IndexResult test2 = indexDoc(primary, MapperService.SINGLE_MAPPING_NAME, "2", docToIndex, XContentType.JSON, "foobar"); assertTrue(primary.getEngine().refreshNeeded()); GetResult testGet2 = primary.getService() - .get("test", "2", new String[] { "foo" }, true, 1, VersionType.INTERNAL, FetchSourceContext.FETCH_SOURCE); + .get("2", new String[] { "foo" }, true, 1, VersionType.INTERNAL, FetchSourceContext.FETCH_SOURCE); assertEquals(new String(testGet2.source() == null ? new byte[0] : testGet2.source(), StandardCharsets.UTF_8), expectedResult); assertTrue(testGet2.getFields().containsKey(RoutingFieldMapper.NAME)); assertTrue(testGet2.getFields().containsKey("foo")); @@ -193,8 +188,7 @@ private void runGetFromTranslogWithOptions( assertEquals(searcher.getIndexReader().maxDoc(), 3); } - testGet2 = primary.getService() - .get("test", "2", new String[] { "foo" }, true, 1, VersionType.INTERNAL, FetchSourceContext.FETCH_SOURCE); + testGet2 = primary.getService().get("2", new String[] { "foo" }, true, 1, VersionType.INTERNAL, FetchSourceContext.FETCH_SOURCE); assertEquals(new String(testGet2.source() == null ? new byte[0] : testGet2.source(), StandardCharsets.UTF_8), expectedResult); assertTrue(testGet2.getFields().containsKey(RoutingFieldMapper.NAME)); assertTrue(testGet2.getFields().containsKey("foo")); @@ -219,13 +213,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/opensearch/rest/action/document/RestGetSourceActionTests.java b/server/src/test/java/org/opensearch/rest/action/document/RestGetSourceActionTests.java index 66b6fcb6412f7..80083c9b60049 100644 --- a/server/src/test/java/org/opensearch/rest/action/document/RestGetSourceActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/document/RestGetSourceActionTests.java @@ -72,7 +72,7 @@ public static void cleanupReferences() { 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 GetResult("index1", "1", UNASSIGNED_SEQ_NO, 0, -1, true, source, emptyMap(), null) ); final RestResponse restResponse = listener.buildResponse(response); @@ -83,9 +83,7 @@ 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) - ); + final GetResponse response = new GetResponse(new GetResult("index1", "1", UNASSIGNED_SEQ_NO, 0, -1, false, null, emptyMap(), null)); final ResourceNotFoundException exception = expectThrows(ResourceNotFoundException.class, () -> listener.buildResponse(response)); @@ -93,12 +91,10 @@ public void testRestGetSourceActionWithMissingDocument() { } public void testRestGetSourceActionWithMissingDocumentSource() { - final GetResponse response = new GetResponse( - new GetResult("index1", "_doc", "1", UNASSIGNED_SEQ_NO, 0, -1, true, null, emptyMap(), null) - ); + final GetResponse response = 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/opensearch/search/geo/GeoQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java index 190cf677c10c5..e6280e5c6924a 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoQueryTests.java @@ -90,7 +90,7 @@ public void testNullShape() throws Exception { .setSource("{\"geo\": null}", XContentType.JSON) .setRefreshPolicy(IMMEDIATE) .get(); - GetResponse result = client().prepareGet(defaultIndexName, "_doc", "aNullshape").get(); + GetResponse result = client().prepareGet(defaultIndexName, "aNullshape").get(); assertThat(result.getField("location"), nullValue()); } diff --git a/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java b/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java index 7654606767e43..f723570272cfa 100644 --- a/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java @@ -965,7 +965,7 @@ public static Term newUid(ParsedDocument doc) { } protected Engine.Get newGet(boolean realtime, ParsedDocument doc) { - return new Engine.Get(realtime, realtime, doc.type(), doc.id(), newUid(doc)); + return new Engine.Get(realtime, realtime, doc.id(), newUid(doc)); } protected Engine.Index indexForDoc(ParsedDocument doc) { diff --git a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java index e0e05bf103dbe..f5f5d5aad1640 100644 --- a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java +++ b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java @@ -318,13 +318,7 @@ 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/%s to exist, but does not", response.getIndex(), response.getId()); assertThat(message, response.isExists(), is(true)); } From 57eb3d871ae7b4d6291ebb33c8b1a045f7e33bc3 Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Fri, 18 Feb 2022 10:45:17 -0600 Subject: [PATCH 2/7] fix test failures Signed-off-by: Nicholas Walter Knize --- .../java/org/opensearch/client/CrudIT.java | 2 +- .../PercolateQueryBuilderTests.java | 1 - .../rest-api-spec/test/mget/15_ids.yml | 2 - .../test/update/15_result_with_types.yml | 52 ----------------- .../test/update/21_doc_upsert_with_types.yml | 41 ------------- .../update/24_doc_as_upsert_with_types.yml | 41 ------------- .../test/update/41_routing_with_types.yml | 58 ------------------- .../update/81_source_filtering_with_types.yml | 19 ------ .../test/update/86_fields_meta_with_types.yml | 33 ----------- 9 files changed, 1 insertion(+), 248 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java index 22a89bc7c7c86..46a75985a936b 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/CrudIT.java @@ -482,7 +482,7 @@ public void testGetSource() throws IOException { ); assertEquals(RestStatus.NOT_FOUND, exception.status()); assertEquals( - "OpenSearch exception [type=resource_not_found_exception, " + "reason=Document not found [index]/[_doc]/[does_not_exist]]", + "OpenSearch exception [type=resource_not_found_exception, " + "reason=Document not found [index]/[does_not_exist]]", exception.getMessage() ); } diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java index 705cc89ace777..5f11feee8f441 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java @@ -338,7 +338,6 @@ public void testFromJsonWithType() throws IOException { + "\"}}" ); rewriteAndFetch(queryBuilder, queryShardContext).toQuery(queryShardContext); - assertWarnings(PercolateQueryBuilder.TYPE_DEPRECATION_MESSAGE); } public void testBothDocumentAndDocumentsSpecified() { 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 82c79797c73da..3c3cf41be3648 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 @@ -44,14 +44,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/update/15_result_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml deleted file mode 100644 index 9adada6d54b4f..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -"Update result field": - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar } - doc_as_upsert: true - - - match: { _version: 1 } - - match: { result: created } - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar } - doc_as_upsert: true - - - match: { _version: 1 } - - match: { result: noop } - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar } - doc_as_upsert: true - detect_noop: false - - - match: { _version: 2 } - - match: { result: updated } - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: baz } - doc_as_upsert: true - detect_noop: true - - - match: { _version: 3 } - - match: { result: updated } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml deleted file mode 100644 index f34e030ff66a0..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -"Doc upsert": - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar, count: 1 } - upsert: { foo: baz } - - - do: - get: - index: test_1 - type: test - id: 1 - - - match: { _source.foo: baz } - - is_false: _source.count - - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar, count: 1 } - upsert: { foo: baz } - - - do: - get: - index: test_1 - type: test - id: 1 - - - match: { _source.foo: bar } - - match: { _source.count: 1 } - - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml deleted file mode 100644 index 7585b9f3e0b94..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -"Doc as upsert": - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: bar, count: 1 } - doc_as_upsert: true - - - do: - get: - index: test_1 - type: test - id: 1 - - - match: { _source.foo: bar } - - match: { _source.count: 1 } - - - - do: - update: - index: test_1 - type: test - id: 1 - body: - doc: { count: 2 } - doc_as_upsert: true - - - do: - get: - index: test_1 - type: test - id: 1 - - - match: { _source.foo: bar } - - match: { _source.count: 2 } - - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml deleted file mode 100644 index 977db506710c7..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml +++ /dev/null @@ -1,58 +0,0 @@ ---- -"Routing": - - - do: - indices.create: - index: test_1 - body: - settings: - index: - number_of_shards: 5 - number_of_routing_shards: 5 - number_of_replicas: 0 - - - do: - cluster.health: - wait_for_status: green - - - do: - update: - index: test_1 - type: test - id: 1 - routing: 5 - body: - doc: { foo: baz } - upsert: { foo: bar } - - - do: - get: - index: test_1 - type: test - id: 1 - routing: 5 - stored_fields: _routing - - - match: { _routing: "5"} - - - do: - catch: missing - update: - index: test_1 - type: test - id: 1 - body: - doc: { foo: baz } - - - do: - update: - index: test_1 - type: test - id: 1 - routing: 5 - _source: foo - body: - doc: { foo: baz } - - - match: { get._source.foo: baz } - diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml deleted file mode 100644 index 4bb22e6b8012e..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -"Source filtering": - - - do: - update: - index: test_1 - type: test - id: 1 - _source: [foo, bar] - body: - doc: { foo: baz } - upsert: { foo: bar } - - - match: { get._source.foo: bar } - - is_false: get._source.bar - -# TODO: -# -# - Add _routing diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml deleted file mode 100644 index f7791d0986399..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -"Metadata Fields": - - - skip: - version: "all" - reason: "Update doesn't return metadata fields, waiting for #3259" - - - do: - indices.create: - index: test_1 - - - do: - update: - index: test_1 - type: test - id: 1 - parent: 5 - fields: [ _routing ] - body: - doc: { foo: baz } - upsert: { foo: bar } - - - match: { get._routing: "5" } - - - do: - get: - index: test_1 - type: test - id: 1 - parent: 5 - stored_fields: [ _routing ] - - From c540dd4e5ca3f1261a6875da726f86064bc15f14 Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Fri, 18 Feb 2022 11:41:38 -0600 Subject: [PATCH 3/7] fix more failing tests w/ typos Signed-off-by: Nicholas Walter Knize --- .../org/opensearch/action/RoutingMissingException.java | 2 +- .../java/org/opensearch/ExceptionSerializationTests.java | 1 - .../java/org/opensearch/action/get/GetRequestTests.java | 4 ++-- .../java/org/opensearch/action/get/GetResponseTests.java | 8 ++++---- .../org/opensearch/action/update/UpdateResponseTests.java | 6 +++--- .../java/org/opensearch/index/get/GetResultTests.java | 4 ++-- .../rest/action/document/RestGetSourceActionTests.java | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/RoutingMissingException.java b/server/src/main/java/org/opensearch/action/RoutingMissingException.java index a7ea0c3702648..4f34a7847da4d 100644 --- a/server/src/main/java/org/opensearch/action/RoutingMissingException.java +++ b/server/src/main/java/org/opensearch/action/RoutingMissingException.java @@ -52,7 +52,7 @@ public RoutingMissingException(String index, String 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"); diff --git a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java index bc7605598a9ad..b5859e1fb18a9 100644 --- a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java @@ -467,7 +467,6 @@ public void testSearchPhaseExecutionException() throws IOException { public void testRoutingMissingException() throws IOException { 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]/[id]", ex.getMessage()); } diff --git a/server/src/test/java/org/opensearch/action/get/GetRequestTests.java b/server/src/test/java/org/opensearch/action/get/GetRequestTests.java index 562b84463cbae..13d12cdc8af87 100644 --- a/server/src/test/java/org/opensearch/action/get/GetRequestTests.java +++ b/server/src/test/java/org/opensearch/action/get/GetRequestTests.java @@ -53,8 +53,8 @@ public void testValidation() { 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/opensearch/action/get/GetResponseTests.java b/server/src/test/java/org/opensearch/action/get/GetResponseTests.java index aa4ecbff8d9ff..39b330fa10a7b 100644 --- a/server/src/test/java/org/opensearch/action/get/GetResponseTests.java +++ b/server/src/test/java/org/opensearch/action/get/GetResponseTests.java @@ -120,7 +120,7 @@ public void testToXContent() { ); String output = Strings.toString(getResponse); assertEquals( - "{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "\"found\":true,\"_source\":{ \"field1\" : \"value1\", \"field2\":\"value2\"},\"fields\":{\"field1\":[\"value1\"]}}", output ); @@ -128,7 +128,7 @@ public void testToXContent() { { 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); } } @@ -147,7 +147,7 @@ public void testToString() { ) ); assertEquals( - "{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "{\"_index\":\"index\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "\"found\":true,\"_source\":{ \"field1\" : \"value1\", \"field2\":\"value2\"},\"fields\":{\"field1\":[\"value1\"]}}", getResponse.toString() ); @@ -171,7 +171,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/opensearch/action/update/UpdateResponseTests.java b/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java index 99ae088047b1c..783c0ec33d63a 100644 --- a/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java +++ b/server/src/test/java/org/opensearch/action/update/UpdateResponseTests.java @@ -72,7 +72,7 @@ public void testToXContent() throws IOException { UpdateResponse updateResponse = new UpdateResponse(new ShardId("index", "index_uuid", 0), "type", "id", -2, 0, 0, NOT_FOUND); String output = Strings.toString(updateResponse); assertEquals( - "{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":0,\"result\":\"not_found\"," + "{\"_index\":\"index\",\"_type\":\"_doc\",\"_id\":\"id\",\"_version\":0,\"result\":\"not_found\"," + "\"_shards\":{\"total\":0,\"successful\":0,\"failed\":0}}", output ); @@ -90,7 +90,7 @@ public void testToXContent() throws IOException { ); String output = Strings.toString(updateResponse); assertEquals( - "{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"result\":\"deleted\"," + "{\"_index\":\"index\",\"_type\":\"_doc\",\"_id\":\"id\",\"_version\":1,\"result\":\"deleted\"," + "\"_shards\":{\"total\":10,\"successful\":6,\"failed\":0},\"_seq_no\":3,\"_primary_term\":17}", output ); @@ -115,7 +115,7 @@ public void testToXContent() throws IOException { String output = Strings.toString(updateResponse); assertEquals( - "{\"_index\":\"books\",\"_type\":\"book\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\"," + "{\"_index\":\"books\",\"_type\":\"_doc\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\"," + "\"_shards\":{\"total\":3,\"successful\":2,\"failed\":0},\"_seq_no\":7,\"_primary_term\":17,\"get\":{" + "\"_seq_no\":0,\"_primary_term\":1,\"found\":true," + "\"_source\":{\"title\":\"Book title\",\"isbn\":\"ABC-123\"},\"fields\":{\"isbn\":[\"ABC-123\"],\"title\":[\"Book " diff --git a/server/src/test/java/org/opensearch/index/get/GetResultTests.java b/server/src/test/java/org/opensearch/index/get/GetResultTests.java index 5b96522438e0e..1337632ac6e07 100644 --- a/server/src/test/java/org/opensearch/index/get/GetResultTests.java +++ b/server/src/test/java/org/opensearch/index/get/GetResultTests.java @@ -108,7 +108,7 @@ public void testToXContent() throws IOException { ); String output = Strings.toString(getResult); assertEquals( - "{\"_index\":\"index\",\"_type\":\"type\",\"_id\":\"id\",\"_version\":1,\"_seq_no\":0,\"_primary_term\":1," + "{\"_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 @@ -117,7 +117,7 @@ public void testToXContent() throws IOException { { 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); } } diff --git a/server/src/test/java/org/opensearch/rest/action/document/RestGetSourceActionTests.java b/server/src/test/java/org/opensearch/rest/action/document/RestGetSourceActionTests.java index 80083c9b60049..ca6ecd052fe6a 100644 --- a/server/src/test/java/org/opensearch/rest/action/document/RestGetSourceActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/document/RestGetSourceActionTests.java @@ -87,7 +87,7 @@ public void testRestGetSourceActionWithMissingDocument() { 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() { From c00e0e917d1275307dafb2bea0e1c732dace0f4b Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Fri, 18 Feb 2022 14:46:38 -0600 Subject: [PATCH 4/7] Fix GetResultTests mutation Signed-off-by: Nicholas Walter Knize --- .../org/opensearch/index/get/GetResultTests.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/server/src/test/java/org/opensearch/index/get/GetResultTests.java b/server/src/test/java/org/opensearch/index/get/GetResultTests.java index 1337632ac6e07..9519b83fa54b1 100644 --- a/server/src/test/java/org/opensearch/index/get/GetResultTests.java +++ b/server/src/test/java/org/opensearch/index/get/GetResultTests.java @@ -245,19 +245,6 @@ public static GetResult mutateGetResult(GetResult getResult) { null ) ); - mutations.add( - () -> new GetResult( - getResult.getIndex(), - getResult.getId(), - getResult.getSeqNo(), - getResult.getPrimaryTerm(), - getResult.getVersion(), - getResult.isExists(), - getResult.internalSourceRef(), - getResult.getFields(), - null - ) - ); mutations.add( () -> new GetResult( getResult.getIndex(), From 1624b8d73a94e8f9714f482214afed5eb659063b Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Fri, 18 Feb 2022 16:04:00 -0600 Subject: [PATCH 5/7] more test failure fixes Signed-off-by: Nicholas Walter Knize --- .../java/org/opensearch/action/bulk/BulkWithUpdatesIT.java | 2 -- .../java/org/opensearch/cluster/NoMasterNodeIT.java | 4 ++-- .../java/org/opensearch/explain/ExplainActionIT.java | 1 - .../java/org/opensearch/routing/SimpleRoutingIT.java | 6 +++--- .../java/org/opensearch/update/UpdateIT.java | 1 - .../org/opensearch/test/hamcrest/OpenSearchAssertions.java | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java index 391e741e411a1..cf091fff03d3e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java @@ -440,7 +440,6 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getVersion(), equalTo(1L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); - assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE)); assertThat(response.getItems()[i].getResponse().getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getResponse().getVersion(), equalTo(1L)); @@ -550,7 +549,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/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java index 746aa4c1a8af1..f8f686b27f29b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java @@ -127,13 +127,13 @@ public void testNoMasterActions() throws Exception { ); assertRequestBuilderThrows( - clientToMasterlessNode.prepareMultiGet().add("test", "type1", "1"), + clientToMasterlessNode.prepareMultiGet().add("test", "1"), ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); assertRequestBuilderThrows( - clientToMasterlessNode.prepareMultiGet().add("no_index", "type1", "1"), + clientToMasterlessNode.prepareMultiGet().add("no_index", "1"), ClusterBlockException.class, RestStatus.SERVICE_UNAVAILABLE ); diff --git a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java index 4833a36dd8726..152d55e8fea88 100644 --- a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java @@ -255,7 +255,6 @@ public void testExplainWithFilteredAliasFetchSource() throws Exception { assertThat(response.getId(), equalTo("1")); assertThat(response.getGetResult(), notNullValue()); assertThat(response.getGetResult().getIndex(), equalTo("test")); - assertThat(response.getGetResult(), 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/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java b/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java index bff90e219e281..99a1eb3361c33 100644 --- a/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java @@ -398,7 +398,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").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); } @@ -478,7 +478,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]")); } } @@ -586,7 +586,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"); diff --git a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java index 67a3519ae1ab9..78fe10e292515 100644 --- a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java @@ -578,7 +578,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")); diff --git a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java index f5f5d5aad1640..68009a7494ba3 100644 --- a/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java +++ b/test/framework/src/main/java/org/opensearch/test/hamcrest/OpenSearchAssertions.java @@ -318,7 +318,7 @@ 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.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)); } From 2173446948e49c71d42a156630329fa1f97250f6 Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Fri, 18 Feb 2022 17:06:02 -0600 Subject: [PATCH 6/7] fix internalClusterTests Signed-off-by: Nicholas Walter Knize --- .../action/bulk/BulkWithUpdatesIT.java | 3 --- .../gateway/RecoveryFromGatewayIT.java | 2 +- .../opensearch/routing/SimpleRoutingIT.java | 22 +++++++++---------- .../java/org/opensearch/update/UpdateIT.java | 1 - 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java index cf091fff03d3e..b9bbb70759163 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java @@ -479,7 +479,6 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getVersion(), equalTo(2L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); - assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE)); assertThat(response.getItems()[i].getResponse().getId(), equalTo(Integer.toString(i))); assertThat(response.getItems()[i].getResponse().getVersion(), equalTo(2L)); @@ -503,7 +502,6 @@ public void testBulkUpdateLargerVolume() throws Exception { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(id))); assertThat(response.getItems()[i].getVersion(), equalTo(3L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); - assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo(OpType.UPDATE)); } } @@ -525,7 +523,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)); } diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java index 217c422f9335f..3d61fbeb521f4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java @@ -223,7 +223,7 @@ public void testSingleNodeNoFlush() throws Exception { int numberOfShards = numberOfShards(); assertAcked( prepareCreate("test").setSettings( - Settings.builder().put(SETTING_NUMBER_OF_SHARDS, numberOfShards()).put(SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 1)) + Settings.builder().put("index.codec", "Lucene86").put(SETTING_NUMBER_OF_SHARDS, numberOfShards()).put(SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 1)) ).addMapping("type1", mapping, XContentType.JSON) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java b/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java index 99a1eb3361c33..9a481d94e36f7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/routing/SimpleRoutingIT.java @@ -425,7 +425,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)); @@ -440,7 +440,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").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false)); } @@ -509,7 +509,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]")); } } @@ -534,7 +534,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]")); } } @@ -602,7 +602,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { client().prepareExplain(indexOrAlias(), "type1", "2").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"); @@ -614,7 +614,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") @@ -628,7 +628,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"); @@ -650,10 +650,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").routing(routingValue)) @@ -678,7 +678,7 @@ 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]") + equalTo("routing is required for [test]/[1]") ); assertThat(multiTermVectorsResponse.getResponses()[0].getResponse(), nullValue()); assertThat(multiTermVectorsResponse.getResponses()[1].getId(), equalTo("2")); @@ -686,7 +686,7 @@ public void testRequiredRoutingMappingVariousAPIs() throws Exception { assertThat(multiTermVectorsResponse.getResponses()[1].getResponse(), nullValue()); assertThat( multiTermVectorsResponse.getResponses()[1].getFailure().getCause().getMessage(), - equalTo("routing is required for [test]/[_doc]/[2]") + equalTo("routing is required for [test]/[2]") ); } diff --git a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java index 78fe10e292515..3799d3325dc97 100644 --- a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java @@ -593,7 +593,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 8c02c3266e1fcdf66899ea8bdd3e3058efae41f8 Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Fri, 18 Feb 2022 17:28:26 -0600 Subject: [PATCH 7/7] revert codec test Signed-off-by: Nicholas Walter Knize --- .../java/org/opensearch/gateway/RecoveryFromGatewayIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java index 3d61fbeb521f4..217c422f9335f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java @@ -223,7 +223,7 @@ public void testSingleNodeNoFlush() throws Exception { int numberOfShards = numberOfShards(); assertAcked( prepareCreate("test").setSettings( - Settings.builder().put("index.codec", "Lucene86").put(SETTING_NUMBER_OF_SHARDS, numberOfShards()).put(SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 1)) + Settings.builder().put(SETTING_NUMBER_OF_SHARDS, numberOfShards()).put(SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 1)) ).addMapping("type1", mapping, XContentType.JSON) );