From 0cc2c9be6af8075948dd7faa18cb56b6b12b2998 Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Fri, 4 Mar 2022 13:30:43 -0600 Subject: [PATCH] [Remove] types from PutMappingRequest (#2335) Remove type support from putMappingRequest, dependencies, and all tests. Signed-off-by: Nicholas Walter Knize --- .../org/opensearch/client/IndicesClient.java | 53 --------- .../client/IndicesRequestConverters.java | 25 ---- .../opensearch/client/IndicesClientIT.java | 32 ----- .../client/IndicesRequestConvertersTests.java | 31 ----- .../query/RankFeatureQueryBuilderTests.java | 1 - .../PercolateQueryBuilderTests.java | 10 +- .../PercolateWithNestedQueryBuilderTests.java | 2 +- .../documentation/ReindexDocumentationIT.java | 2 +- .../index/mapper/size/SizeMappingIT.java | 21 +--- .../opensearch/action/IndicesRequestIT.java | 3 +- .../admin/cluster/node/tasks/TasksIT.java | 2 +- .../admin/indices/create/ShrinkIndexIT.java | 3 +- .../admin/indices/create/SplitIndexIT.java | 9 +- .../put/ValidateMappingRequestPluginIT.java | 10 +- .../opensearch/aliases/IndexAliasesIT.java | 10 +- .../documentation/IndicesDocumentationIT.java | 111 ------------------ .../coordination/RareClusterStateIT.java | 14 ++- .../opensearch/gateway/MetadataNodesIT.java | 2 - .../mapper/MultiFieldsIntegrationIT.java | 2 +- .../indices/IndicesOptionsIntegrationIT.java | 16 +-- .../indices/analyze/AnalyzeActionIT.java | 4 +- .../mapping/SimpleGetFieldMappingsIT.java | 4 +- .../mapping/UpdateMappingIntegrationIT.java | 11 +- .../indices/recovery/IndexRecoveryIT.java | 7 +- .../routing/PartitionedRoutingIT.java | 13 +- .../aggregations/pipeline/BucketSortIT.java | 1 - .../search/fields/SearchFieldsIT.java | 49 ++++---- .../search/geo/GeoShapeIntegrationIT.java | 2 +- .../search/nested/SimpleNestedIT.java | 2 +- .../search/query/SearchQueryIT.java | 4 +- .../search/simple/SimpleSearchIT.java | 9 +- .../suggest/CompletionSuggestSearchIT.java | 2 - .../snapshots/RestoreSnapshotIT.java | 5 +- .../validate/SimpleValidateQueryIT.java | 11 +- .../indices/create/CreateIndexRequest.java | 2 +- .../PutMappingClusterStateUpdateRequest.java | 20 +--- .../mapping/put/PutMappingRequest.java | 43 +++---- .../mapping/put/PutMappingRequestBuilder.java | 8 -- .../put/TransportPutMappingAction.java | 13 +- .../template/put/PutIndexTemplateRequest.java | 2 +- .../action/bulk/MappingUpdatePerformer.java | 2 +- .../action/bulk/TransportShardBulkAction.java | 57 ++++----- .../action/index/MappingUpdatedAction.java | 7 +- .../metadata/MetadataMappingService.java | 13 +- .../opensearch/index/shard/IndexShard.java | 4 +- .../opensearch/index/shard/StoreRecovery.java | 8 +- .../opensearch/indices/IndicesService.java | 3 +- .../admin/indices/RestPutMappingAction.java | 2 - .../opensearch/tasks/TaskResultsService.java | 1 - .../mapping/put/PutMappingRequestTests.java | 17 +-- .../bulk/TransportShardBulkActionTests.java | 27 ++--- .../index/MappingUpdatedActionTests.java | 10 +- .../metadata/MetadataMappingServiceTests.java | 40 ++----- .../mapper/FieldFilterMapperPluginTests.java | 4 +- .../GenericStoreDynamicTemplateTests.java | 5 +- .../mapper/JavaMultiFieldMergeTests.java | 36 ++++-- .../index/mapper/MultiFieldTests.java | 14 ++- .../index/mapper/PathMapperTests.java | 2 +- .../mapper/PathMatchDynamicTemplateTests.java | 5 +- ...angeFieldQueryStringQueryBuilderTests.java | 1 - .../index/mapper/UpdateMappingTests.java | 2 - .../index/query/MatchQueryBuilderTests.java | 8 +- .../index/query/NestedQueryBuilderTests.java | 1 - .../query/QueryStringQueryBuilderTests.java | 6 +- .../query/TermsSetQueryBuilderTests.java | 2 +- .../index/shard/IndexShardTests.java | 6 +- .../genericstore/test-mapping.json | 4 +- .../pathmatch/test-mapping.json | 2 +- .../multifield/merge/test-mapping1.json | 2 +- .../multifield/merge/test-mapping2.json | 2 +- .../multifield/merge/test-mapping3.json | 2 +- .../multifield/merge/test-mapping4.json | 2 +- .../mapper/multifield/merge/upgrade1.json | 2 +- .../mapper/multifield/merge/upgrade2.json | 2 +- .../mapper/multifield/merge/upgrade3.json | 2 +- .../mapper/multifield/test-multi-fields.json | 2 +- .../index/mapper/path/test-mapping.json | 2 +- ...enSearchIndexLevelReplicationTestCase.java | 2 +- .../test/AbstractBuilderTestCase.java | 1 - 79 files changed, 250 insertions(+), 631 deletions(-) delete mode 100644 server/src/internalClusterTest/java/org/opensearch/client/documentation/IndicesDocumentationIT.java diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/opensearch/client/IndicesClient.java index 66e28e42903..8889b717ab8 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/IndicesClient.java @@ -456,59 +456,6 @@ public final class IndicesClient { ); } - /** - * Updates the mappings on an index using the Put Mapping API. - * - * @param putMappingRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - * @throws IOException in case there is a problem sending the request or parsing back the response - * - * @deprecated This method uses an old request object which still refers to types, a deprecated feature. The method - * {@link #putMapping(PutMappingRequest, RequestOptions)} should be used instead, which accepts a new request object. - */ - @Deprecated - public AcknowledgedResponse putMapping( - org.opensearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest, - RequestOptions options - ) throws IOException { - return restHighLevelClient.performRequestAndParseEntity( - putMappingRequest, - IndicesRequestConverters::putMapping, - options, - AcknowledgedResponse::fromXContent, - emptySet() - ); - } - - /** - * Asynchronously updates the mappings on an index using the Put Mapping API. - * - * @param putMappingRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @param listener the listener to be notified upon request completion - * - * @deprecated This method uses an old request object which still refers to types, a deprecated feature. The - * method {@link #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)} should be used instead, - * which accepts a new request object. - * @return cancellable that may be used to cancel the request - */ - @Deprecated - public Cancellable putMappingAsync( - org.opensearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest, - RequestOptions options, - ActionListener listener - ) { - return restHighLevelClient.performRequestAsyncAndParseEntity( - putMappingRequest, - IndicesRequestConverters::putMapping, - options, - AcknowledgedResponse::fromXContent, - listener, - emptySet() - ); - } - /** * Retrieves the mappings on an index or indices using the Get Mapping API. * diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/IndicesRequestConverters.java b/client/rest-high-level/src/main/java/org/opensearch/client/IndicesRequestConverters.java index 0f55c722d09..a3c9b2a99c0 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/IndicesRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/IndicesRequestConverters.java @@ -202,31 +202,6 @@ final class IndicesRequestConverters { return request; } - /** - * converter for the legacy server-side {@link org.opensearch.action.admin.indices.mapping.put.PutMappingRequest} that still supports - * types - */ - @Deprecated - static Request putMapping(org.opensearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest) throws IOException { - // The concreteIndex is an internal concept, not applicable to requests made over the REST API. - if (putMappingRequest.getConcreteIndex() != null) { - throw new IllegalArgumentException("concreteIndex cannot be set on PutMapping requests made over the REST API"); - } - - Request request = new Request( - HttpPut.METHOD_NAME, - RequestConverters.endpoint(putMappingRequest.indices(), "_mapping", putMappingRequest.type()) - ); - - RequestConverters.Params parameters = new RequestConverters.Params(); - parameters.withTimeout(putMappingRequest.timeout()); - parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout()); - parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - request.addParameters(parameters.asMap()); - request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); - return request; - } - static Request getMappings(GetMappingsRequest getMappingsRequest) { String[] indices = getMappingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getMappingsRequest.indices(); diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java index 0e50d55880e..1a875575308 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java @@ -1594,38 +1594,6 @@ public class IndicesClientIT extends OpenSearchRestHighLevelClientTestCase { ); } - @SuppressWarnings("unchecked") - public void testPutTemplateWithTypes() throws Exception { - org.opensearch.action.admin.indices.template.put.PutIndexTemplateRequest putTemplateRequest = - new org.opensearch.action.admin.indices.template.put.PutIndexTemplateRequest().name("my-template") - .patterns(Arrays.asList("pattern-1", "name-*")) - .order(10) - .create(randomBoolean()) - .settings(Settings.builder().put("number_of_shards", "3").put("number_of_replicas", "0")) - .mapping("doc", "host_name", "type=keyword", "description", "type=text") - .alias(new Alias("alias-1").indexRouting("abc")) - .alias(new Alias("{index}-write").searchRouting("xyz")); - - AcknowledgedResponse putTemplateResponse = execute( - putTemplateRequest, - highLevelClient().indices()::putTemplate, - highLevelClient().indices()::putTemplateAsync, - expectWarningsOnce(RestPutIndexTemplateAction.TYPES_DEPRECATION_MESSAGE) - ); - assertThat(putTemplateResponse.isAcknowledged(), equalTo(true)); - - Map templates = getAsMap("/_template/my-template"); - assertThat(templates.keySet(), hasSize(1)); - assertThat(extractValue("my-template.order", templates), equalTo(10)); - assertThat(extractRawValues("my-template.index_patterns", templates), contains("pattern-1", "name-*")); - assertThat(extractValue("my-template.settings.index.number_of_shards", templates), equalTo("3")); - assertThat(extractValue("my-template.settings.index.number_of_replicas", templates), equalTo("0")); - assertThat(extractValue("my-template.mappings.properties.host_name.type", templates), equalTo("keyword")); - assertThat(extractValue("my-template.mappings.properties.description.type", templates), equalTo("text")); - assertThat((Map) extractValue("my-template.aliases.alias-1", templates), hasEntry("index_routing", "abc")); - assertThat((Map) extractValue("my-template.aliases.{index}-write", templates), hasEntry("search_routing", "xyz")); - } - @SuppressWarnings("unchecked") public void testPutTemplate() throws Exception { PutIndexTemplateRequest putTemplateRequest = new PutIndexTemplateRequest("my-template").patterns( diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java index 7fbcdc7d831..b464a5dd361 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesRequestConvertersTests.java @@ -254,37 +254,6 @@ public class IndicesRequestConvertersTests extends OpenSearchTestCase { RequestConvertersTests.assertToXContentBody(putMappingRequest, request.getEntity()); } - public void testPutMappingWithTypes() throws IOException { - org.opensearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest = - new org.opensearch.action.admin.indices.mapping.put.PutMappingRequest(); - - String[] indices = RequestConvertersTests.randomIndicesNames(0, 5); - putMappingRequest.indices(indices); - - String type = OpenSearchTestCase.randomAlphaOfLengthBetween(3, 10); - putMappingRequest.type(type); - - Map expectedParams = new HashMap<>(); - - RequestConvertersTests.setRandomTimeout(putMappingRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); - RequestConvertersTests.setRandomMasterTimeout(putMappingRequest, expectedParams); - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); - - Request request = IndicesRequestConverters.putMapping(putMappingRequest); - StringJoiner endpoint = new StringJoiner("/", "/", ""); - String index = String.join(",", indices); - if (Strings.hasLength(index)) { - endpoint.add(index); - } - endpoint.add("_mapping"); - endpoint.add(type); - Assert.assertEquals(endpoint.toString(), request.getEndpoint()); - - Assert.assertEquals(expectedParams, request.getParameters()); - Assert.assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - RequestConvertersTests.assertToXContentBody(putMappingRequest, request.getEntity()); - } - public void testGetMapping() { GetMappingsRequest getMappingRequest = new GetMappingsRequest(); diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java index 40c4fd24b0b..b0d7bb9d2e1 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java @@ -63,7 +63,6 @@ public class RankFeatureQueryBuilderTests extends AbstractQueryTestCase client().admin().indices().putMapping(request).actionGet()); assertThat(e.getMessage(), equalTo("not allowed: index[index_1] origin[" + origin + "]")); } { PutMappingRequest request = new PutMappingRequest().indices("index_1") .origin(randomFrom("1", "2")) - .type("doc") .source("t1", "type=keyword"); assertAcked(client().admin().indices().putMapping(request).actionGet()); } { String origin = randomFrom("", "1", "4", "5"); - PutMappingRequest request = new PutMappingRequest().indices("index_2").type("doc").source("t2", "type=keyword").origin(origin); + PutMappingRequest request = new PutMappingRequest().indices("index_2").source("t2", "type=keyword").origin(origin); Exception e = expectThrows(IllegalStateException.class, () -> client().admin().indices().putMapping(request).actionGet()); assertThat(e.getMessage(), equalTo("not allowed: index[index_2] origin[" + origin + "]")); } { PutMappingRequest request = new PutMappingRequest().indices("index_2") .origin(randomFrom("2", "3")) - .type("doc") .source("t1", "type=keyword"); assertAcked(client().admin().indices().putMapping(request).actionGet()); } { String origin = randomFrom("", "1", "3", "4"); - PutMappingRequest request = new PutMappingRequest().indices("*").type("doc").source("t3", "type=keyword").origin(origin); + PutMappingRequest request = new PutMappingRequest().indices("*").source("t3", "type=keyword").origin(origin); Exception e = expectThrows(IllegalStateException.class, () -> client().admin().indices().putMapping(request).actionGet()); assertThat(e.getMessage(), containsString("not allowed:")); } { - PutMappingRequest request = new PutMappingRequest().indices("index_2").origin("2").type("doc").source("t3", "type=keyword"); + PutMappingRequest request = new PutMappingRequest().indices("index_2").origin("2").source("t3", "type=keyword"); assertAcked(client().admin().indices().putMapping(request).actionGet()); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java index 9c00bb5c822..2d01e4c0315 100644 --- a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java @@ -470,9 +470,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase { logger.info("--> creating indices"); createIndex("test1", "test2", "test3"); - assertAcked( - client().admin().indices().preparePutMapping("test1", "test2", "test3").setType("type1").setSource("name", "type=text") - ); + assertAcked(client().admin().indices().preparePutMapping("test1", "test2", "test3").setSource("name", "type=text")); ensureGreen(); @@ -862,11 +860,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase { createIndex("bazbar"); assertAcked( - client().admin() - .indices() - .preparePutMapping("foobar", "test", "test123", "foobarbaz", "bazbar") - .setType("type") - .setSource("field", "type=text") + client().admin().indices().preparePutMapping("foobar", "test", "test123", "foobarbaz", "bazbar").setSource("field", "type=text") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/client/documentation/IndicesDocumentationIT.java b/server/src/internalClusterTest/java/org/opensearch/client/documentation/IndicesDocumentationIT.java deleted file mode 100644 index bea1dc8b8dc..00000000000 --- a/server/src/internalClusterTest/java/org/opensearch/client/documentation/IndicesDocumentationIT.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.documentation; - -import org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse; -import org.opensearch.client.Client; -import org.opensearch.cluster.metadata.MappingMetadata; -import org.opensearch.common.xcontent.XContentType; -import org.opensearch.test.OpenSearchIntegTestCase; - -import static java.util.Collections.singletonMap; - -/** - * This class is used to generate the Java indices administration documentation. - * You need to wrap your code between two tags like: - * // tag::example[] - * // end::example[] - * - * Where example is your tag name. - * - * Then in the documentation, you can extract what is between tag and end tags - * with ["source","java",subs="attributes,callouts,macros"] - * -------------------------------------------------- - * include-tagged::{client-tests}/IndicesDocumentationIT.java[your-example-tag-here] - * -------------------------------------------------- - */ -public class IndicesDocumentationIT extends OpenSearchIntegTestCase { - - /** - * This test method is used to generate the Put Mapping Java Indices API documentation - * at "docs/java-api/admin/indices/put-mapping.asciidoc" so the documentation gets tested - * so that it compiles and runs without throwing errors at runtime. - */ - public void testPutMappingDocumentation() throws Exception { - Client client = client(); - - // tag::index-with-mapping - client.admin().indices().prepareCreate("twitter") // <1> - .addMapping("_doc", "message", "type=text") // <2> - .get(); - // end::index-with-mapping - GetMappingsResponse getMappingsResponse = client.admin().indices().prepareGetMappings("twitter").get(); - assertEquals(1, getMappingsResponse.getMappings().size()); - - // we need to delete in order to create a fresh new index with another type - client.admin().indices().prepareDelete("twitter").get(); - client.admin().indices().prepareCreate("twitter").get(); - - // tag::putMapping-request-source - client.admin().indices().preparePutMapping("twitter") // <1> - .setType("_doc") - .setSource("{\n" + - " \"properties\": {\n" + - " \"name\": {\n" + // <2> - " \"type\": \"text\"\n" + - " }\n" + - " }\n" + - "}", XContentType.JSON) - .get(); - - // You can also provide the type in the source document - client.admin().indices().preparePutMapping("twitter") - .setType("_doc") - .setSource("{\n" + - " \"_doc\":{\n" + // <3> - " \"properties\": {\n" + - " \"name\": {\n" + - " \"type\": \"text\"\n" + - " }\n" + - " }\n" + - " }\n" + - "}", XContentType.JSON) - .get(); - // end::putMapping-request-source - getMappingsResponse = client.admin().indices().prepareGetMappings("twitter").get(); - assertEquals(1, getMappingsResponse.getMappings().size()); - MappingMetadata indexMapping = getMappingsResponse.getMappings().get("twitter"); - assertEquals(singletonMap("properties", singletonMap("name", singletonMap("type", "text"))), indexMapping.getSourceAsMap()); - } - -} 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 773660f3fb6..9e3a693d9bd 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java @@ -176,14 +176,16 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase { internalCluster().startMasterOnlyNode(); String dataNode = internalCluster().startDataOnlyNode(); assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("2").get().isTimedOut()); - prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)).addMapping("type").get(); + prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)) + .addMapping(MapperService.SINGLE_MAPPING_NAME) + .get(); ensureGreen("test"); // block none master node. BlockClusterStateProcessing disruption = new BlockClusterStateProcessing(dataNode, random()); internalCluster().setDisruptionScheme(disruption); logger.info("--> indexing a doc"); - index("test", "type", "1"); + index("test", MapperService.SINGLE_MAPPING_NAME, "1"); refresh(); disruption.startDisrupting(); logger.info("--> delete index and recreate it"); @@ -263,7 +265,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase { // Add a new mapping... ActionFuture putMappingResponse = executeAndCancelCommittedPublication( - client().admin().indices().preparePutMapping("index").setType("type").setSource("field", "type=long") + client().admin().indices().preparePutMapping("index").setSource("field", "type=long") ); // ...and wait for mappings to be available on master @@ -353,7 +355,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase { internalCluster().setDisruptionScheme(disruption); disruption.startDisrupting(); final ActionFuture putMappingResponse = executeAndCancelCommittedPublication( - client().admin().indices().preparePutMapping("index").setType("type").setSource("field", "type=long") + client().admin().indices().preparePutMapping("index").setSource("field", "type=long") ); final Index index = resolveIndex("index"); @@ -363,7 +365,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase { final IndexService indexService = indicesService.indexServiceSafe(index); assertNotNull(indexService); final MapperService mapperService = indexService.mapperService(); - DocumentMapper mapper = mapperService.documentMapper("type"); + DocumentMapper mapper = mapperService.documentMapper(MapperService.SINGLE_MAPPING_NAME); assertNotNull(mapper); assertNotNull(mapper.mappers().getMapper("field")); }); @@ -387,7 +389,7 @@ public class RareClusterStateIT extends OpenSearchIntegTestCase { final IndexService indexService = indicesService.indexServiceSafe(index); assertNotNull(indexService); final MapperService mapperService = indexService.mapperService(); - DocumentMapper mapper = mapperService.documentMapper("type"); + DocumentMapper mapper = mapperService.documentMapper(MapperService.SINGLE_MAPPING_NAME); assertNotNull(mapper); assertNotNull(mapper.mappers().getMapper("field2")); }); diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/MetadataNodesIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/MetadataNodesIT.java index 7e16a4ad838..2731eb9a290 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/MetadataNodesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/MetadataNodesIT.java @@ -135,7 +135,6 @@ public class MetadataNodesIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping(index) - .setType("_doc") .setSource( jsonBuilder().startObject() .startObject("properties") @@ -173,7 +172,6 @@ public class MetadataNodesIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping(index) - .setType("_doc") .setSource( jsonBuilder().startObject() .startObject("properties") diff --git a/server/src/internalClusterTest/java/org/opensearch/index/mapper/MultiFieldsIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/index/mapper/MultiFieldsIntegrationIT.java index e0a20b6b2b3..c9f3ddbc9e8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/mapper/MultiFieldsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/mapper/MultiFieldsIntegrationIT.java @@ -76,7 +76,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase { searchResponse = client().prepareSearch("my-index").setQuery(matchQuery("title.not_analyzed", "Multi fields")).get(); assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L)); - assertAcked(client().admin().indices().preparePutMapping("my-index").setType("my-type").setSource(createPutMappingSource())); + assertAcked(client().admin().indices().preparePutMapping("my-index").setSource(createPutMappingSource())); getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get(); mappingMetadata = getMappingsResponse.mappings().get("my-index"); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesOptionsIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesOptionsIntegrationIT.java index 8c54b09626d..3432cc967bf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesOptionsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesOptionsIntegrationIT.java @@ -595,33 +595,33 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase { } public void testPutMapping() throws Exception { - verify(client().admin().indices().preparePutMapping("foo").setType("type1").setSource("field", "type=text"), true); - verify(client().admin().indices().preparePutMapping("_all").setType("type1").setSource("field", "type=text"), true); + verify(client().admin().indices().preparePutMapping("foo").setSource("field", "type=text"), true); + verify(client().admin().indices().preparePutMapping("_all").setSource("field", "type=text"), true); for (String index : Arrays.asList("foo", "foobar", "bar", "barbaz")) { assertAcked(prepareCreate(index)); } - verify(client().admin().indices().preparePutMapping("foo").setType("type").setSource("field", "type=text"), false); + verify(client().admin().indices().preparePutMapping("foo").setSource("field", "type=text"), false); assertThat(client().admin().indices().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue()); - verify(client().admin().indices().preparePutMapping("b*").setType("type").setSource("field", "type=text"), false); + verify(client().admin().indices().preparePutMapping("b*").setSource("field", "type=text"), false); assertThat(client().admin().indices().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue()); assertThat(client().admin().indices().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue()); - verify(client().admin().indices().preparePutMapping("_all").setType("type").setSource("field", "type=text"), false); + verify(client().admin().indices().preparePutMapping("_all").setSource("field", "type=text"), false); assertThat(client().admin().indices().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue()); assertThat(client().admin().indices().prepareGetMappings("foobar").get().mappings().get("foobar"), notNullValue()); assertThat(client().admin().indices().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue()); assertThat(client().admin().indices().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue()); - verify(client().admin().indices().preparePutMapping().setType("type").setSource("field", "type=text"), false); + verify(client().admin().indices().preparePutMapping().setSource("field", "type=text"), false); assertThat(client().admin().indices().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue()); assertThat(client().admin().indices().prepareGetMappings("foobar").get().mappings().get("foobar"), notNullValue()); assertThat(client().admin().indices().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue()); assertThat(client().admin().indices().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue()); - verify(client().admin().indices().preparePutMapping("c*").setType("type").setSource("field", "type=text"), true); + verify(client().admin().indices().preparePutMapping("c*").setSource("field", "type=text"), true); assertAcked(client().admin().indices().prepareClose("barbaz").get()); - verify(client().admin().indices().preparePutMapping("barbaz").setType("type").setSource("field", "type=text"), false); + verify(client().admin().indices().preparePutMapping("barbaz").setSource("field", "type=text"), false); assertThat(client().admin().indices().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue()); } diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java index 8c34656c34e..72184958986 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java @@ -155,7 +155,7 @@ public class AnalyzeActionIT extends OpenSearchIntegTestCase { assertAcked(prepareCreate("test").addAlias(new Alias("alias"))); ensureGreen(); - client().admin().indices().preparePutMapping("test").setType("document").setSource("simple", "type=text,analyzer=simple").get(); + client().admin().indices().preparePutMapping("test").setSource("simple", "type=text,analyzer=simple").get(); for (int i = 0; i < 10; i++) { final AnalyzeRequestBuilder requestBuilder = client().admin().indices().prepareAnalyze("THIS IS A TEST"); @@ -201,7 +201,6 @@ public class AnalyzeActionIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("document") .setSource("simple", "type=text,analyzer=simple,position_increment_gap=100") .get(); @@ -304,7 +303,6 @@ public class AnalyzeActionIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("document") .setSource("simple", "type=text,analyzer=simple,position_increment_gap=100") .get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetFieldMappingsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetFieldMappingsIT.java index 52e2fe303c3..da0f88276f2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetFieldMappingsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/SimpleGetFieldMappingsIT.java @@ -159,8 +159,8 @@ public class SimpleGetFieldMappingsIT extends OpenSearchIntegTestCase { @SuppressWarnings("unchecked") public void testSimpleGetFieldMappingsWithDefaults() throws Exception { assertAcked(prepareCreate("test").addMapping("type", getMappingForType("type"))); - client().admin().indices().preparePutMapping("test").setType("type").setSource("num", "type=long").get(); - client().admin().indices().preparePutMapping("test").setType("type").setSource("field2", "type=text,index=false").get(); + client().admin().indices().preparePutMapping("test").setSource("num", "type=long").get(); + client().admin().indices().preparePutMapping("test").setSource("field2", "type=text,index=false").get(); GetFieldMappingsResponse response = client().admin() .indices() diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/UpdateMappingIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/UpdateMappingIntegrationIT.java index 889e71ecb7e..32584a9e33b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/UpdateMappingIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/UpdateMappingIntegrationIT.java @@ -153,7 +153,6 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase { AcknowledgedResponse putMappingResponse = client().admin() .indices() .preparePutMapping("test") - .setType("_doc") .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON) .execute() .actionGet(); @@ -179,7 +178,6 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase { AcknowledgedResponse putMappingResponse = client().admin() .indices() .preparePutMapping("test") - .setType("_doc") .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON) .execute() .actionGet(); @@ -207,7 +205,6 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("type") .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}", XContentType.JSON) .execute() .actionGet(); @@ -228,7 +225,6 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("type") .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\", \"norms\": true }}}}", XContentType.JSON) .execute() .actionGet(); @@ -254,7 +250,6 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase { AcknowledgedResponse putMappingResponse = client().admin() .indices() .preparePutMapping("test") - .setType("type") .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON) .execute() .actionGet(); @@ -288,17 +283,15 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase { Client client1 = clientArray.get(i % clientArray.size()); Client client2 = clientArray.get((i + 1) % clientArray.size()); String indexName = i % 2 == 0 ? "test2" : "test1"; - String typeName = "type"; String fieldName = Thread.currentThread().getName() + "_" + i; AcknowledgedResponse response = client1.admin() .indices() .preparePutMapping(indexName) - .setType(typeName) .setSource( JsonXContent.contentBuilder() .startObject() - .startObject(typeName) + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject(fieldName) .field("type", "text") @@ -348,7 +341,6 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("_doc") .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON) ); } finally { @@ -363,7 +355,6 @@ public class UpdateMappingIntegrationIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("_doc") .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON) ); } finally { diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java index 73261dd1538..042b98c3368 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java @@ -1434,12 +1434,7 @@ public class IndexRecoveryIT extends OpenSearchIntegTestCase { .put("index.number_of_shards", 1) .build() ); - client().admin() - .indices() - .preparePutMapping("test") - .setType("_doc") - .setSource("test_field", "type=text,analyzer=test_analyzer") - .get(); + client().admin().indices().preparePutMapping("test").setSource("test_field", "type=text,analyzer=test_analyzer").get(); int numDocs = between(1, 10); for (int i = 0; i < numDocs; i++) { client().prepareIndex("test") diff --git a/server/src/internalClusterTest/java/org/opensearch/routing/PartitionedRoutingIT.java b/server/src/internalClusterTest/java/org/opensearch/routing/PartitionedRoutingIT.java index 77adfcfa3c2..99742166cda 100644 --- a/server/src/internalClusterTest/java/org/opensearch/routing/PartitionedRoutingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/routing/PartitionedRoutingIT.java @@ -37,6 +37,7 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilders; import org.opensearch.test.OpenSearchIntegTestCase; import org.mockito.internal.util.collections.Sets; @@ -62,7 +63,11 @@ public class PartitionedRoutingIT extends OpenSearchIntegTestCase { .put("index.number_of_routing_shards", shards) .put("index.routing_partition_size", partitionSize) ) - .addMapping("type", "{\"type\":{\"_routing\":{\"required\":true}}}", XContentType.JSON) + .addMapping( + MapperService.SINGLE_MAPPING_NAME, + "{\"" + MapperService.SINGLE_MAPPING_NAME + "\":{\"_routing\":{\"required\":true}}}", + XContentType.JSON + ) .execute() .actionGet(); ensureGreen(); @@ -96,7 +101,11 @@ public class PartitionedRoutingIT extends OpenSearchIntegTestCase { .put("index.number_of_replicas", numberOfReplicas()) .put("index.routing_partition_size", partitionSize) ) - .addMapping("type", "{\"type\":{\"_routing\":{\"required\":true}}}", XContentType.JSON) + .addMapping( + MapperService.SINGLE_MAPPING_NAME, + "{\"" + MapperService.SINGLE_MAPPING_NAME + "\":{\"_routing\":{\"required\":true}}}", + XContentType.JSON + ) .execute() .actionGet(); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketSortIT.java index 7ba45cde9b2..d05740a5a0f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/BucketSortIT.java @@ -84,7 +84,6 @@ public class BucketSortIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping(INDEX) - .setType("doc") .setSource("time", "type=date", "foo", "type=keyword", "value_1", "type=float", "value_2", "type=float") .get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java index ab32e8439b2..d5cd358612a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java @@ -48,6 +48,7 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.index.fielddata.ScriptDocValues; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilders; import org.opensearch.plugins.Plugin; import org.opensearch.rest.RestStatus; @@ -187,7 +188,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { String mapping = Strings.toString( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("field1") .field("type", "text") @@ -206,7 +207,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() ); - client().admin().indices().preparePutMapping().setType("type1").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); client().prepareIndex("test") .setId("1") @@ -290,7 +291,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { String mapping = Strings.toString( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("num1") .field("type", "double") @@ -301,7 +302,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() ); - client().admin().indices().preparePutMapping().setType("type1").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); client().prepareIndex("test") .setId("1") @@ -392,7 +393,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { String mapping = Strings.toString( XContentFactory.jsonBuilder() .startObject() - .startObject("doc") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("date") .field("type", "date_nanos") @@ -402,7 +403,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() ); - client().admin().indices().preparePutMapping().setType("doc").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); String date = "2019-01-31T10:00:00.123456789Z"; indexRandom( true, @@ -625,7 +626,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { String mapping = Strings.toString( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("_source") .field("enabled", false) .endObject() @@ -671,7 +672,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() ); - client().admin().indices().preparePutMapping().setType("type1").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); ZonedDateTime date = ZonedDateTime.of(2012, 3, 22, 0, 0, 0, 0, ZoneOffset.UTC); client().prepareIndex("test") @@ -774,9 +775,9 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .prepareCreate("my-index") .setSettings(Settings.builder().put("index.refresh_interval", -1)) .addMapping( - "doc", + MapperService.SINGLE_MAPPING_NAME, jsonBuilder().startObject() - .startObject("doc") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("field1") .field("type", "object") @@ -858,7 +859,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { String mapping = Strings.toString( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("_source") .field("enabled", false) .endObject() @@ -906,7 +907,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() ); - client().admin().indices().preparePutMapping().setType("type1").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping().setSource(mapping, XContentType.JSON).get(); ZonedDateTime date = ZonedDateTime.of(2012, 3, 22, 0, 0, 0, 0, ZoneOffset.UTC); client().prepareIndex("test") @@ -1180,7 +1181,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { public void testDocValueFieldsWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("_source") .field("enabled", false) .endObject() @@ -1204,13 +1205,13 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mapping)); + assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); ensureGreen("test"); DateTime date = new DateTime(1990, 12, 29, 0, 0, DateTimeZone.UTC); org.joda.time.format.DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); - index("test", "type", "1", "text_field", "foo", "date_field", formatter.print(date)); + index("test", MapperService.SINGLE_MAPPING_NAME, "1", "text_field", "foo", "date_field", formatter.print(date)); refresh("test"); SearchRequestBuilder builder = client().prepareSearch() @@ -1243,7 +1244,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { public void testWildcardDocValueFieldsWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("_source") .field("enabled", false) .endObject() @@ -1267,13 +1268,13 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mapping)); + assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); ensureGreen("test"); DateTime date = new DateTime(1990, 12, 29, 0, 0, DateTimeZone.UTC); org.joda.time.format.DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); - index("test", "type", "1", "text_field", "foo", "date_field", formatter.print(date)); + index("test", MapperService.SINGLE_MAPPING_NAME, "1", "text_field", "foo", "date_field", formatter.print(date)); refresh("test"); SearchRequestBuilder builder = client().prepareSearch() @@ -1305,7 +1306,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { public void testStoredFieldsWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("field1") .field("type", "text") @@ -1326,9 +1327,9 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mapping)); + assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); - index("test", "type", "1", "field1", "value1", "field2", "value2"); + index("test", MapperService.SINGLE_MAPPING_NAME, "1", "field1", "value1", "field2", "value2"); refresh("test"); SearchResponse searchResponse = client().prepareSearch() @@ -1349,7 +1350,7 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { public void testWildcardStoredFieldsWithFieldAlias() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() - .startObject("type") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("field1") .field("type", "text") @@ -1370,9 +1371,9 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase { .endObject() .endObject() .endObject(); - assertAcked(prepareCreate("test").addMapping("type", mapping)); + assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)); - index("test", "type", "1", "field1", "value1", "field2", "value2"); + index("test", MapperService.SINGLE_MAPPING_NAME, "1", "field1", "value1", "field2", "value2"); refresh("test"); SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addStoredField("field*").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java index f49f03e2b88..74474788f3f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java @@ -206,7 +206,7 @@ public class GeoShapeIntegrationIT extends OpenSearchIntegTestCase { IllegalArgumentException e = expectThrows( IllegalArgumentException.class, - () -> client().admin().indices().preparePutMapping("test").setType("geometry").setSource(update, XContentType.JSON).get() + () -> client().admin().indices().preparePutMapping("test").setSource(update, XContentType.JSON).get() ); assertThat(e.getMessage(), containsString("using [BKD] strategy cannot be merged with")); } 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 9fa9994d240..e4ad46c7599 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java @@ -1634,7 +1634,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); // Now add nested mapping - assertAcked(client().admin().indices().preparePutMapping("test").setType("type").setSource("array1", "type=nested")); + assertAcked(client().admin().indices().preparePutMapping("test").setSource("array1", "type=nested")); XContentBuilder builder = jsonBuilder().startObject() .startArray("array1") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java index 92a3cc1f8bf..69a8fa138d1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java @@ -1782,9 +1782,7 @@ public class SearchQueryIT extends OpenSearchIntegTestCase { public void testDateProvidedAsNumber() throws InterruptedException { createIndex("test"); - assertAcked( - client().admin().indices().preparePutMapping("test").setType("type").setSource("field", "type=date,format=epoch_millis").get() - ); + assertAcked(client().admin().indices().preparePutMapping("test").setSource("field", "type=date,format=epoch_millis").get()); indexRandom( true, client().prepareIndex("test").setId("1").setSource("field", 1000000000001L), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java index efec723b0a8..0652b38228e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java @@ -43,6 +43,7 @@ import org.opensearch.common.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.index.IndexSettings; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.query.TermQueryBuilder; import org.opensearch.rest.RestStatus; @@ -118,11 +119,10 @@ public class SimpleSearchIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("type1") .setSource( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("from") .field("type", "ip") @@ -151,11 +151,10 @@ public class SimpleSearchIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("type1") .setSource( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("ip") .field("type", "ip") @@ -296,7 +295,7 @@ public class SimpleSearchIT extends OpenSearchIntegTestCase { public void testSimpleIndexSortEarlyTerminate() throws Exception { prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0).put("index.sort.field", "rank") - ).addMapping("type1", "rank", "type=integer").get(); + ).addMapping(MapperService.SINGLE_MAPPING_NAME, "rank", "type=integer").get(); ensureGreen(); int max = randomIntBetween(3, 29); List docbuilders = new ArrayList<>(max); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java index f76bfa67351..099ffbc278f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/CompletionSuggestSearchIT.java @@ -701,7 +701,6 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase { AcknowledgedResponse putMappingResponse = client().admin() .indices() .preparePutMapping(INDEX) - .setType(MapperService.SINGLE_MAPPING_NAME) .setSource( jsonBuilder().startObject() .startObject(MapperService.SINGLE_MAPPING_NAME) @@ -967,7 +966,6 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase { AcknowledgedResponse putMappingResponse = client().admin() .indices() .preparePutMapping(INDEX) - .setType(MapperService.SINGLE_MAPPING_NAME) .setSource( jsonBuilder().startObject() .startObject(MapperService.SINGLE_MAPPING_NAME) diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java index f70cfb65e79..643a301c025 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/RestoreSnapshotIT.java @@ -284,7 +284,7 @@ public class RestoreSnapshotIT extends AbstractSnapshotIntegTestCase { NumShards numShards = getNumShards("test-idx"); - assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("_doc").setSource("baz", "type=text")); + assertAcked(client().admin().indices().preparePutMapping("test-idx").setSource("baz", "type=text")); ensureGreen(); logger.info("--> snapshot it"); @@ -310,7 +310,7 @@ public class RestoreSnapshotIT extends AbstractSnapshotIntegTestCase { .put("refresh_interval", 5, TimeUnit.SECONDS) ) ); - assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("_doc").setSource("foo", "type=text")); + assertAcked(client().admin().indices().preparePutMapping("test-idx").setSource("foo", "type=text")); ensureGreen(); logger.info("--> close index"); @@ -735,7 +735,6 @@ public class RestoreSnapshotIT extends AbstractSnapshotIntegTestCase { client().admin() .indices() .preparePutMapping("test-idx") - .setType("_doc") .setSource("field1", "type=text,analyzer=standard,search_analyzer=my_analyzer") ); final int numdocs = randomIntBetween(10, 100); diff --git a/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java index 2ca24552ff0..51d0a439512 100644 --- a/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java @@ -39,6 +39,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.Fuzziness; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.index.IndexNotFoundException; +import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.MoreLikeThisQueryBuilder.Item; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; @@ -77,11 +78,10 @@ public class SimpleValidateQueryIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("type1") .setSource( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("foo") .field("type", "text") @@ -179,11 +179,10 @@ public class SimpleValidateQueryIT extends OpenSearchIntegTestCase { client().admin() .indices() .preparePutMapping("test") - .setType("type1") .setSource( XContentFactory.jsonBuilder() .startObject() - .startObject("type1") + .startObject(MapperService.SINGLE_MAPPING_NAME) .startObject("properties") .startObject("foo") .field("type", "text") @@ -319,7 +318,7 @@ public class SimpleValidateQueryIT extends OpenSearchIntegTestCase { client().admin() .indices() .prepareCreate("test") - .addMapping("type1", "field", "type=text,analyzer=whitespace") + .addMapping(MapperService.SINGLE_MAPPING_NAME, "field", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) .get(); client().prepareIndex("test").setId("1").setSource("field", "quick lazy huge brown pidgin").get(); @@ -381,7 +380,7 @@ public class SimpleValidateQueryIT extends OpenSearchIntegTestCase { client().admin() .indices() .prepareCreate("test") - .addMapping("type1", "field", "type=text,analyzer=whitespace") + .addMapping(MapperService.SINGLE_MAPPING_NAME, "field", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put("index.number_of_routing_shards", 2)) .get(); // We are relying on specific routing behaviors for the result to be right, so diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java index 882ff3fedde..b4cab8cea25 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java @@ -304,7 +304,7 @@ public class CreateIndexRequest extends AcknowledgedRequest */ @Deprecated public CreateIndexRequest mapping(String type, Object... source) { - mapping(type, PutMappingRequest.buildFromSimplifiedDef(type, source)); + mapping(type, PutMappingRequest.buildFromSimplifiedDef(source)); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingClusterStateUpdateRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingClusterStateUpdateRequest.java index 2237ac57357..27081048fcd 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingClusterStateUpdateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingClusterStateUpdateRequest.java @@ -39,29 +39,13 @@ import org.opensearch.cluster.ack.IndicesClusterStateUpdateRequest; */ public class PutMappingClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest { - private String type; - private String source; - public PutMappingClusterStateUpdateRequest() { - - } - - public String type() { - return type; - } - - public PutMappingClusterStateUpdateRequest type(String type) { - this.type = type; - return this; + public PutMappingClusterStateUpdateRequest(String source) { + this.source = source; } public String source() { return source; } - - public PutMappingClusterStateUpdateRequest source(String source) { - this.source = source; - return this; - } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java index fa691b94182..52be45054ba 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -35,6 +35,7 @@ package org.opensearch.action.admin.indices.mapping.put; import com.carrotsearch.hppc.ObjectHashSet; import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; +import org.opensearch.Version; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.IndicesOptions; @@ -52,6 +53,7 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.index.Index; +import org.opensearch.index.mapper.MapperService; import java.io.IOException; import java.io.InputStream; @@ -63,7 +65,7 @@ import java.util.Objects; import static org.opensearch.action.ValidateActions.addValidationError; /** - * Puts mapping definition registered under a specific type into one or more indices. Best created with + * Puts mapping definition into one or more indices. Best created with * {@link org.opensearch.client.Requests#putMappingRequest(String...)}. *

* If the mappings already exists, the new mappings will be merged with the new one. If there are elements @@ -95,8 +97,6 @@ public class PutMappingRequest extends AcknowledgedRequest im private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, true); - private String type; - private String source; private String origin = ""; @@ -108,7 +108,12 @@ public class PutMappingRequest extends AcknowledgedRequest im super(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - type = in.readOptionalString(); + if (in.getVersion().before(Version.V_2_0_0)) { + String type = in.readOptionalString(); + if (MapperService.SINGLE_MAPPING_NAME.equals(type) == false) { + throw new IllegalArgumentException("Expected type [_doc] but received [" + type + "]"); + } + } source = in.readString(); if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { in.readBoolean(); // updateAllTypes @@ -133,11 +138,6 @@ public class PutMappingRequest extends AcknowledgedRequest im @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; - if (type == null) { - validationException = addValidationError("mapping type is missing", validationException); - } else if (type.isEmpty()) { - validationException = addValidationError("mapping type is empty", validationException); - } if (source == null) { validationException = addValidationError("mapping source is missing", validationException); } else if (source.isEmpty()) { @@ -203,21 +203,6 @@ public class PutMappingRequest extends AcknowledgedRequest im return true; } - /** - * The mapping type. - */ - public String type() { - return type; - } - - /** - * The type of the mappings. - */ - public PutMappingRequest type(String type) { - this.type = type; - return this; - } - /** * The mapping source definition. */ @@ -233,7 +218,7 @@ public class PutMappingRequest extends AcknowledgedRequest im * mapping fields will automatically be put on the top level mapping object. */ public PutMappingRequest source(Object... source) { - return source(buildFromSimplifiedDef(type, source)); + return source(buildFromSimplifiedDef(source)); } public String origin() { @@ -247,8 +232,6 @@ public class PutMappingRequest extends AcknowledgedRequest im } /** - * @param type - * the mapping type * @param source * consisting of field/properties pairs (e.g. "field1", * "type=string,store=true") @@ -256,7 +239,7 @@ public class PutMappingRequest extends AcknowledgedRequest im * if the number of the source arguments is not divisible by two * @return the mappings definition */ - public static XContentBuilder buildFromSimplifiedDef(String type, Object... source) { + public static XContentBuilder buildFromSimplifiedDef(Object... source) { if (source.length % 2 != 0) { throw new IllegalArgumentException("mapping source must be pairs of fieldnames and properties definition."); } @@ -360,7 +343,9 @@ public class PutMappingRequest extends AcknowledgedRequest im super.writeTo(out); out.writeStringArrayNullable(indices); indicesOptions.writeIndicesOptions(out); - out.writeOptionalString(type); + if (out.getVersion().before(Version.V_2_0_0)) { + out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME); + } out.writeString(source); if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeBoolean(true); // updateAllTypes diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java index fcf35891df8..a1b3b40d4e9 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java @@ -74,14 +74,6 @@ public class PutMappingRequestBuilder extends AcknowledgedRequestBuilder< return this; } - /** - * The type of the mappings. - */ - public PutMappingRequestBuilder setType(String type) { - request.type(type); - return this; - } - /** * The mapping source definition. */ diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java index 6c580ec8aa2..f1093a15a3d 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/TransportPutMappingAction.java @@ -132,10 +132,7 @@ public class TransportPutMappingAction extends TransportMasterNodeAction new ParameterizedMessage("failed to put mappings on indices [{}], type [{}]", request.indices(), request.type()), - ex - ); + logger.debug(() -> new ParameterizedMessage("failed to put mappings on indices [{}]", Arrays.asList(request.indices())), ex); throw ex; } } @@ -170,11 +167,9 @@ public class TransportPutMappingAction extends TransportMasterNodeAction listener, MetadataMappingService metadataMappingService ) { - PutMappingClusterStateUpdateRequest updateRequest = new PutMappingClusterStateUpdateRequest().ackTimeout(request.timeout()) - .masterNodeTimeout(request.masterNodeTimeout()) - .indices(concreteIndices) - .type(request.type()) - .source(request.source()); + PutMappingClusterStateUpdateRequest updateRequest = new PutMappingClusterStateUpdateRequest(request.source()).indices( + concreteIndices + ).ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout()); metadataMappingService.putMapping(updateRequest, new ActionListener() { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index d331a1f9a55..2ea2e492ffe 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -304,7 +304,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest listener); + void updateMappings(Mapping update, ShardId shardId, ActionListener listener); } diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java index b97219782e9..f3ab9673a02 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java @@ -162,10 +162,10 @@ public class TransportShardBulkAction extends TransportWriteAction> listener ) { ClusterStateObserver observer = new ClusterStateObserver(clusterService, request.timeout(), logger, threadPool.getThreadContext()); - performOnPrimary(request, primary, updateHelper, threadPool::absoluteTimeInMillis, (update, shardId, type, mappingListener) -> { + performOnPrimary(request, primary, updateHelper, threadPool::absoluteTimeInMillis, (update, shardId, mappingListener) -> { assert update != null; assert shardId != null; - mappingUpdatedAction.updateMappingOnMaster(shardId.getIndex(), type, update, mappingListener); + mappingUpdatedAction.updateMappingOnMaster(shardId.getIndex(), update, mappingListener); }, mappingUpdateListener -> observer.waitForNextChange(new ClusterStateObserver.Listener() { @Override public void onNewClusterState(ClusterState state) { @@ -380,37 +380,32 @@ public class TransportShardBulkAction extends TransportWriteAction() { - @Override - public void onResponse(Void v) { - context.markAsRequiringMappingUpdate(); - waitForMappingUpdate.accept(ActionListener.runAfter(new ActionListener() { - @Override - public void onResponse(Void v) { - assert context.requiresWaitingForMappingUpdate(); - context.resetForExecutionForRetry(); - } + mappingUpdater.updateMappings(result.getRequiredMappingUpdate(), primary.shardId(), new ActionListener() { + @Override + public void onResponse(Void v) { + context.markAsRequiringMappingUpdate(); + waitForMappingUpdate.accept(ActionListener.runAfter(new ActionListener() { + @Override + public void onResponse(Void v) { + assert context.requiresWaitingForMappingUpdate(); + context.resetForExecutionForRetry(); + } - @Override - public void onFailure(Exception e) { - context.failOnMappingUpdate(e); - } - }, () -> itemDoneListener.onResponse(null))); - } - - @Override - public void onFailure(Exception e) { - onComplete(exceptionToResult(e, primary, isDelete, version), context, updateResult); - // Requesting mapping update failed, so we don't have to wait for a cluster state update - assert context.isInitial(); - itemDoneListener.onResponse(null); - } + @Override + public void onFailure(Exception e) { + context.failOnMappingUpdate(e); + } + }, () -> itemDoneListener.onResponse(null))); } - ); + + @Override + public void onFailure(Exception e) { + onComplete(exceptionToResult(e, primary, isDelete, version), context, updateResult); + // Requesting mapping update failed, so we don't have to wait for a cluster state update + assert context.isInitial(); + itemDoneListener.onResponse(null); + } + }); return false; } else { onComplete(result, context, updateResult); diff --git a/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java b/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java index d7100a194a4..f22d489ec6f 100644 --- a/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java +++ b/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java @@ -109,7 +109,7 @@ public class MappingUpdatedAction { * {@code timeout} is the master node timeout ({@link MasterNodeRequest#masterNodeTimeout()}), * potentially waiting for a master node to be available. */ - public void updateMappingOnMaster(Index index, String type, Mapping mappingUpdate, ActionListener listener) { + public void updateMappingOnMaster(Index index, Mapping mappingUpdate, ActionListener listener) { final RunOnce release = new RunOnce(() -> semaphore.release()); try { @@ -121,7 +121,7 @@ public class MappingUpdatedAction { } boolean successFullySent = false; try { - sendUpdateMapping(index, type, mappingUpdate, ActionListener.runBefore(listener, release::run)); + sendUpdateMapping(index, mappingUpdate, ActionListener.runBefore(listener, release::run)); successFullySent = true; } finally { if (successFullySent == false) { @@ -136,10 +136,9 @@ public class MappingUpdatedAction { } // can be overridden by tests - protected void sendUpdateMapping(Index index, String type, Mapping mappingUpdate, ActionListener listener) { + protected void sendUpdateMapping(Index index, Mapping mappingUpdate, ActionListener listener) { PutMappingRequest putMappingRequest = new PutMappingRequest(); putMappingRequest.setConcreteIndex(index); - putMappingRequest.type(type); putMappingRequest.source(mappingUpdate.toString(), XContentType.JSON); putMappingRequest.masterNodeTimeout(dynamicMappingUpdateTimeout); putMappingRequest.timeout(TimeValue.ZERO); diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java index 7b135c97466..69145bdee72 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java @@ -274,7 +274,7 @@ public class MetadataMappingService { updateList.add(indexMetadata); // try and parse it (no need to add it here) so we can bail early in case of parsing exception DocumentMapper existingMapper = mapperService.documentMapper(); - DocumentMapper newMapper = mapperService.parse(request.type(), mappingUpdateSource); + DocumentMapper newMapper = mapperService.parse(MapperService.SINGLE_MAPPING_NAME, mappingUpdateSource); if (existingMapper != null) { // first, simulate: just call merge and ignore the result existingMapper.merge(newMapper.mapping(), MergeReason.MAPPING_UPDATE); @@ -294,7 +294,11 @@ public class MetadataMappingService { if (existingMapper != null) { existingSource = existingMapper.mappingSource(); } - DocumentMapper mergedMapper = mapperService.merge(request.type(), mappingUpdateSource, MergeReason.MAPPING_UPDATE); + DocumentMapper mergedMapper = mapperService.merge( + MapperService.SINGLE_MAPPING_NAME, + mappingUpdateSource, + MergeReason.MAPPING_UPDATE + ); CompressedXContent updatedSource = mergedMapper.mappingSource(); if (existingSource != null) { @@ -343,11 +347,6 @@ public class MetadataMappingService { return currentState; } } - - @Override - public String describeTasks(List tasks) { - return String.join(", ", tasks.stream().map(t -> (CharSequence) t.type())::iterator); - } } public void putMapping(final PutMappingClusterStateUpdateRequest request, final ActionListener listener) { 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 b93fe71e3f7..1474785f5f4 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -2182,7 +2182,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl } public void recoverFromLocalShards( - BiConsumer mappingUpdateConsumer, + Consumer mappingUpdateConsumer, List localShards, ActionListener listener ) throws IOException { @@ -2929,7 +2929,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl PeerRecoveryTargetService recoveryTargetService, PeerRecoveryTargetService.RecoveryListener recoveryListener, RepositoriesService repositoriesService, - BiConsumer mappingUpdateConsumer, + Consumer mappingUpdateConsumer, IndicesService indicesService ) { // TODO: Create a proper object to encapsulate the recovery context diff --git a/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java b/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java index 485d43d9a47..6cf6ad645ca 100644 --- a/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java +++ b/server/src/main/java/org/opensearch/index/shard/StoreRecovery.java @@ -72,7 +72,7 @@ import java.util.HashMap; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.BiConsumer; +import java.util.function.Consumer; import java.util.stream.Collectors; import static org.opensearch.common.unit.TimeValue.timeValueMillis; @@ -116,9 +116,9 @@ final class StoreRecovery { } void recoverFromLocalShards( - BiConsumer mappingUpdateConsumer, + Consumer mappingUpdateConsumer, IndexShard indexShard, - List shards, + final List shards, ActionListener listener ) { if (canRecover(indexShard)) { @@ -133,7 +133,7 @@ final class StoreRecovery { } IndexMetadata sourceMetadata = shards.get(0).getIndexMetadata(); for (ObjectObjectCursor mapping : sourceMetadata.getMappings()) { - mappingUpdateConsumer.accept(mapping.key, mapping.value); + mappingUpdateConsumer.accept(mapping.value); } indexShard.mapperService().merge(sourceMetadata, MapperService.MergeReason.MAPPING_RECOVERY); // now that the mapping is merged we can validate the index sort configuration. diff --git a/server/src/main/java/org/opensearch/indices/IndicesService.java b/server/src/main/java/org/opensearch/indices/IndicesService.java index 392bda21a03..22ab5a9cd9c 100644 --- a/server/src/main/java/org/opensearch/indices/IndicesService.java +++ b/server/src/main/java/org/opensearch/indices/IndicesService.java @@ -849,14 +849,13 @@ public class IndicesService extends AbstractLifecycleComponent RecoveryState recoveryState = indexService.createRecoveryState(shardRouting, targetNode, sourceNode); IndexShard indexShard = indexService.createShard(shardRouting, globalCheckpointSyncer, retentionLeaseSyncer); indexShard.addShardFailureCallback(onShardFailure); - indexShard.startRecovery(recoveryState, recoveryTargetService, recoveryListener, repositoriesService, (type, mapping) -> { + indexShard.startRecovery(recoveryState, recoveryTargetService, recoveryListener, repositoriesService, mapping -> { assert recoveryState.getRecoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS : "mapping update consumer only required by local shards recovery"; client.admin() .indices() .preparePutMapping() .setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid - .setType(type) .setSource(mapping.source().string(), XContentType.JSON) .get(); }, this); diff --git a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestPutMappingAction.java b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestPutMappingAction.java index 5da0b016c86..19043db9aa1 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestPutMappingAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestPutMappingAction.java @@ -85,8 +85,6 @@ public class RestPutMappingAction extends BaseRestHandler { deprecationLogger.deprecate("put_mapping_with_types", TYPES_DEPRECATION_MESSAGE); } - putMappingRequest.type(MapperService.SINGLE_MAPPING_NAME); - Map sourceAsMap = XContentHelper.convertToMap(request.requiredContent(), false, request.getXContentType()).v2(); if (includeTypeName == false && MapperService.isMappingSourceTyped(MapperService.SINGLE_MAPPING_NAME, sourceAsMap)) { diff --git a/server/src/main/java/org/opensearch/tasks/TaskResultsService.java b/server/src/main/java/org/opensearch/tasks/TaskResultsService.java index 140c0b91940..60de452c314 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskResultsService.java +++ b/server/src/main/java/org/opensearch/tasks/TaskResultsService.java @@ -146,7 +146,6 @@ public class TaskResultsService { client.admin() .indices() .preparePutMapping(TASK_INDEX) - .setType(TASK_TYPE) .setSource(taskResultIndexMapping(), XContentType.JSON) .execute(ActionListener.delegateFailure(listener, (l, r) -> doStoreResult(taskResult, listener))); } else { diff --git a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java index b45e7d12250..fd6fc3b6839 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java @@ -66,13 +66,9 @@ import static org.hamcrest.Matchers.containsString; public class PutMappingRequestTests extends OpenSearchTestCase { public void testValidation() { - PutMappingRequest r = new PutMappingRequest("myindex").type(""); + PutMappingRequest r = new PutMappingRequest("myindex"); ActionRequestValidationException ex = r.validate(); - assertNotNull("type validation should fail", ex); - assertTrue(ex.getMessage().contains("type is empty")); - r.type("mytype"); - ex = r.validate(); assertNotNull("source validation should fail", ex); assertTrue(ex.getMessage().contains("source is missing")); @@ -96,21 +92,20 @@ public class PutMappingRequestTests extends OpenSearchTestCase { } /** - * Test that {@link PutMappingRequest#buildFromSimplifiedDef(String, Object...)} + * Test that {@link PutMappingRequest#buildFromSimplifiedDef(Object...)} * rejects inputs where the {@code Object...} varargs of field name and properties are not * paired correctly */ public void testBuildFromSimplifiedDef() { IllegalArgumentException e = expectThrows( IllegalArgumentException.class, - () -> PutMappingRequest.buildFromSimplifiedDef("type", "only_field") + () -> PutMappingRequest.buildFromSimplifiedDef("only_field") ); assertEquals("mapping source must be pairs of fieldnames and properties definition.", e.getMessage()); } public void testToXContent() throws IOException { PutMappingRequest request = new PutMappingRequest("foo"); - request.type("my_type"); XContentBuilder mapping = JsonXContent.contentBuilder().startObject(); mapping.startObject("properties"); @@ -128,7 +123,6 @@ public class PutMappingRequestTests extends OpenSearchTestCase { public void testToXContentWithEmptySource() throws IOException { PutMappingRequest request = new PutMappingRequest("foo"); - request.type("my_type"); String actualRequestBody = Strings.toString(request); String expectedRequestBody = "{}"; @@ -166,10 +160,7 @@ public class PutMappingRequestTests extends OpenSearchTestCase { String index = randomAlphaOfLength(5); PutMappingRequest request = new PutMappingRequest(index); - - String type = randomAlphaOfLength(5); - request.type(type); - request.source(RandomCreateIndexGenerator.randomMapping(type)); + request.source(RandomCreateIndexGenerator.randomMapping("_doc")); return request; } diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportShardBulkActionTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportShardBulkActionTests.java index 733d0912600..a812dd2888e 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportShardBulkActionTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportShardBulkActionTests.java @@ -286,19 +286,12 @@ public class TransportShardBulkActionTests extends IndexShardTestCase { // Pretend the mappings haven't made it to the node yet BulkPrimaryExecutionContext context = new BulkPrimaryExecutionContext(bulkShardRequest, shard); AtomicInteger updateCalled = new AtomicInteger(); - TransportShardBulkAction.executeBulkItemRequest( - context, - null, - threadPool::absoluteTimeInMillis, - (update, shardId, type, listener) -> { - // There should indeed be a mapping update - assertNotNull(update); - updateCalled.incrementAndGet(); - listener.onResponse(null); - }, - listener -> listener.onResponse(null), - ASSERTING_DONE_LISTENER - ); + TransportShardBulkAction.executeBulkItemRequest(context, null, threadPool::absoluteTimeInMillis, (update, shardId, listener) -> { + // There should indeed be a mapping update + assertNotNull(update); + updateCalled.incrementAndGet(); + listener.onResponse(null); + }, listener -> listener.onResponse(null), ASSERTING_DONE_LISTENER); assertTrue(context.isInitial()); assertTrue(context.hasMoreOperationsToExecute()); @@ -315,7 +308,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase { context, null, threadPool::absoluteTimeInMillis, - (update, shardId, type, listener) -> fail("should not have had to update the mappings"), + (update, shardId, listener) -> fail("should not have had to update the mappings"), listener -> {}, ASSERTING_DONE_LISTENER ); @@ -989,7 +982,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase { shard, null, rejectingThreadPool::absoluteTimeInMillis, - (update, shardId, type, listener) -> { + (update, shardId, listener) -> { // There should indeed be a mapping update assertNotNull(update); updateCalled.incrementAndGet(); @@ -1090,7 +1083,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase { /** Doesn't perform any mapping updates */ public static class NoopMappingUpdatePerformer implements MappingUpdatePerformer { @Override - public void updateMappings(Mapping update, ShardId shardId, String type, ActionListener listener) { + public void updateMappings(Mapping update, ShardId shardId, ActionListener listener) { listener.onResponse(null); } } @@ -1104,7 +1097,7 @@ public class TransportShardBulkActionTests extends IndexShardTestCase { } @Override - public void updateMappings(Mapping update, ShardId shardId, String type, ActionListener listener) { + public void updateMappings(Mapping update, ShardId shardId, ActionListener listener) { listener.onFailure(e); } } diff --git a/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java b/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java index d6812f7e531..2278d09722f 100644 --- a/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java @@ -124,19 +124,19 @@ public class MappingUpdatedActionTests extends OpenSearchTestCase { ) { @Override - protected void sendUpdateMapping(Index index, String type, Mapping mappingUpdate, ActionListener listener) { + protected void sendUpdateMapping(Index index, Mapping mappingUpdate, ActionListener listener) { inFlightListeners.add(listener); } }; PlainActionFuture fut1 = new PlainActionFuture<>(); - mua.updateMappingOnMaster(null, "test", null, fut1); + mua.updateMappingOnMaster(null, null, fut1); assertEquals(1, inFlightListeners.size()); assertEquals(0, mua.blockedThreads()); PlainActionFuture fut2 = new PlainActionFuture<>(); Thread thread = new Thread(() -> { - mua.updateMappingOnMaster(null, "test", null, fut2); // blocked + mua.updateMappingOnMaster(null, null, fut2); // blocked }); thread.start(); assertBusy(() -> assertEquals(1, mua.blockedThreads())); @@ -180,7 +180,7 @@ public class MappingUpdatedActionTests extends OpenSearchTestCase { RootObjectMapper rootObjectMapper = new RootObjectMapper.Builder("name").build(context); Mapping update = new Mapping(LegacyESVersion.V_7_8_0, rootObjectMapper, new MetadataFieldMapper[0], Map.of()); - mua.sendUpdateMapping(new Index("name", "uuid"), "type", update, ActionListener.wrap(() -> {})); + mua.sendUpdateMapping(new Index("name", "uuid"), update, ActionListener.wrap(() -> {})); verify(indicesAdminClient).putMapping(any(), any()); } @@ -210,7 +210,7 @@ public class MappingUpdatedActionTests extends OpenSearchTestCase { RootObjectMapper rootObjectMapper = new RootObjectMapper.Builder("name").build(context); Mapping update = new Mapping(LegacyESVersion.V_7_9_0, rootObjectMapper, new MetadataFieldMapper[0], Map.of()); - mua.sendUpdateMapping(new Index("name", "uuid"), "type", update, ActionListener.wrap(() -> {})); + mua.sendUpdateMapping(new Index("name", "uuid"), update, ActionListener.wrap(() -> {})); verify(indicesAdminClient).execute(eq(AutoPutMappingAction.INSTANCE), any(), any()); } } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java index f25cf07455b..b1043dba0a0 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java @@ -39,7 +39,6 @@ import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.compress.CompressedXContent; import org.opensearch.index.Index; import org.opensearch.index.IndexService; -import org.opensearch.index.mapper.MapperService; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchSingleNodeTestCase; import org.opensearch.test.InternalSettingsPlugin; @@ -64,9 +63,10 @@ public class MetadataMappingServiceTests extends OpenSearchSingleNodeTestCase { final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); // TODO - it will be nice to get a random mapping generator - final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest().type("type"); + final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest( + "{ \"properties\": { \"field\": { \"type\": \"text\" }}}" + ); request.indices(new Index[] { indexService.index() }); - request.source("{ \"properties\": { \"field\": { \"type\": \"text\" }}}"); final ClusterStateTaskExecutor.ClusterTasksResult result = mappingService.putMappingExecutor .execute(clusterService.state(), Collections.singletonList(request)); // the task completed successfully @@ -86,8 +86,9 @@ public class MetadataMappingServiceTests extends OpenSearchSingleNodeTestCase { final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); - final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest().type("type"); - request.source("{ \"properties\" { \"field\": { \"type\": \"text\" }}}"); + final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest( + "{ \"properties\" { \"field\": { \"type\": \"text\" }}}" + ); ClusterState result = mappingService.putMappingExecutor.execute( clusterService.state(), Collections.singletonList(request) @@ -105,9 +106,10 @@ public class MetadataMappingServiceTests extends OpenSearchSingleNodeTestCase { final long previousVersion = indexService.getMetadata().getMappingVersion(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); - final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest().type("type"); + final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest( + "{ \"properties\": { \"field\": { \"type\": \"text\" }}}" + ); request.indices(new Index[] { indexService.index() }); - request.source("{ \"properties\": { \"field\": { \"type\": \"text\" }}}"); final ClusterStateTaskExecutor.ClusterTasksResult result = mappingService.putMappingExecutor .execute(clusterService.state(), Collections.singletonList(request)); assertThat(result.executionResults.size(), equalTo(1)); @@ -120,34 +122,12 @@ public class MetadataMappingServiceTests extends OpenSearchSingleNodeTestCase { final long previousVersion = indexService.getMetadata().getMappingVersion(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); - final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest().type("type"); + final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest("{ \"properties\": {}}"); request.indices(new Index[] { indexService.index() }); - request.source("{ \"properties\": {}}"); final ClusterStateTaskExecutor.ClusterTasksResult result = mappingService.putMappingExecutor .execute(clusterService.state(), Collections.singletonList(request)); assertThat(result.executionResults.size(), equalTo(1)); assertTrue(result.executionResults.values().iterator().next().isSuccess()); assertThat(result.resultingState.metadata().index("test").getMappingVersion(), equalTo(previousVersion)); } - - public void testMappingUpdateAccepts_docAsType() throws Exception { - final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").addMapping("my_type")); - final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); - final ClusterService clusterService = getInstanceFromNode(ClusterService.class); - final PutMappingClusterStateUpdateRequest request = new PutMappingClusterStateUpdateRequest().type( - MapperService.SINGLE_MAPPING_NAME - ); - request.indices(new Index[] { indexService.index() }); - request.source("{ \"properties\": { \"foo\": { \"type\": \"keyword\" } }}"); - final ClusterStateTaskExecutor.ClusterTasksResult result = mappingService.putMappingExecutor - .execute(clusterService.state(), Collections.singletonList(request)); - assertThat(result.executionResults.size(), equalTo(1)); - assertTrue(result.executionResults.values().iterator().next().isSuccess()); - MappingMetadata mappingMetadata = result.resultingState.metadata().index("test").mapping(); - assertEquals("my_type", mappingMetadata.type()); - assertEquals( - Collections.singletonMap("properties", Collections.singletonMap("foo", Collections.singletonMap("type", "keyword"))), - mappingMetadata.sourceAsMap() - ); - } } diff --git a/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java b/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java index f388fb0d18d..27e895ee64f 100644 --- a/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/FieldFilterMapperPluginTests.java @@ -74,9 +74,7 @@ public class FieldFilterMapperPluginTests extends OpenSearchSingleNodeTestCase { public void putMappings() { assertAcked(client().admin().indices().prepareCreate("index1")); assertAcked(client().admin().indices().prepareCreate("filtered")); - assertAcked( - client().admin().indices().preparePutMapping("index1", "filtered").setType("_doc").setSource(TEST_ITEM, XContentType.JSON) - ); + assertAcked(client().admin().indices().preparePutMapping("index1", "filtered").setSource(TEST_ITEM, XContentType.JSON)); } public void testGetMappings() { diff --git a/server/src/test/java/org/opensearch/index/mapper/GenericStoreDynamicTemplateTests.java b/server/src/test/java/org/opensearch/index/mapper/GenericStoreDynamicTemplateTests.java index 856b3b2cd20..cc4626bc896 100644 --- a/server/src/test/java/org/opensearch/index/mapper/GenericStoreDynamicTemplateTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/GenericStoreDynamicTemplateTests.java @@ -47,17 +47,16 @@ public class GenericStoreDynamicTemplateTests extends OpenSearchSingleNodeTestCa public void testSimple() throws Exception { String mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/dynamictemplate/genericstore/test-mapping.json"); IndexService index = createIndex("test"); - client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping("test").setSource(mapping, XContentType.JSON).get(); MapperService mapperService = index.mapperService(); byte[] json = copyToBytesFromClasspath("/org/opensearch/index/mapper/dynamictemplate/genericstore/test-data.json"); ParsedDocument parsedDoc = mapperService.documentMapper() - .parse(new SourceToParse("test", "person", "1", new BytesArray(json), XContentType.JSON)); + .parse(new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", new BytesArray(json), XContentType.JSON)); client().admin() .indices() .preparePutMapping("test") - .setType("person") .setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON) .get(); Document doc = parsedDoc.rootDoc(); diff --git a/server/src/test/java/org/opensearch/index/mapper/JavaMultiFieldMergeTests.java b/server/src/test/java/org/opensearch/index/mapper/JavaMultiFieldMergeTests.java index 3905ac09698..b5989d93b52 100644 --- a/server/src/test/java/org/opensearch/index/mapper/JavaMultiFieldMergeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/JavaMultiFieldMergeTests.java @@ -50,20 +50,22 @@ public class JavaMultiFieldMergeTests extends OpenSearchSingleNodeTestCase { String mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/multifield/merge/test-mapping1.json"); MapperService mapperService = createIndex("test").mapperService(); - mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + mapperService.merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); assertTrue(mapperService.fieldType("name").isSearchable()); assertThat(mapperService.fieldType("name.indexed"), nullValue()); BytesReference json = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("name", "some name").endObject()); - Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc(); + Document doc = mapperService.documentMapper() + .parse(new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", json, XContentType.JSON)) + .rootDoc(); IndexableField f = doc.getField("name"); assertThat(f, notNullValue()); f = doc.getField("name.indexed"); assertThat(f, nullValue()); mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/multifield/merge/test-mapping2.json"); - mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + mapperService.merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); assertTrue(mapperService.fieldType("name").isSearchable()); @@ -72,14 +74,16 @@ public class JavaMultiFieldMergeTests extends OpenSearchSingleNodeTestCase { assertThat(mapperService.fieldType("name.not_indexed2"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue()); - doc = mapperService.documentMapper().parse(new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc(); + doc = mapperService.documentMapper() + .parse(new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", json, XContentType.JSON)) + .rootDoc(); f = doc.getField("name"); assertThat(f, notNullValue()); f = doc.getField("name.indexed"); assertThat(f, notNullValue()); mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/multifield/merge/test-mapping3.json"); - mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + mapperService.merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); assertTrue(mapperService.fieldType("name").isSearchable()); @@ -89,7 +93,7 @@ public class JavaMultiFieldMergeTests extends OpenSearchSingleNodeTestCase { assertThat(mapperService.fieldType("name.not_indexed3"), nullValue()); mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/multifield/merge/test-mapping4.json"); - mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + mapperService.merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); assertTrue(mapperService.fieldType("name").isSearchable()); @@ -103,20 +107,22 @@ public class JavaMultiFieldMergeTests extends OpenSearchSingleNodeTestCase { String mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/multifield/merge/test-mapping1.json"); MapperService mapperService = createIndex("test").mapperService(); - mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + mapperService.merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); assertTrue(mapperService.fieldType("name").isSearchable()); assertThat(mapperService.fieldType("name.indexed"), nullValue()); BytesReference json = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("name", "some name").endObject()); - Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc(); + Document doc = mapperService.documentMapper() + .parse(new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", json, XContentType.JSON)) + .rootDoc(); IndexableField f = doc.getField("name"); assertThat(f, notNullValue()); f = doc.getField("name.indexed"); assertThat(f, nullValue()); mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/multifield/merge/upgrade1.json"); - mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + mapperService.merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); assertTrue(mapperService.fieldType("name").isSearchable()); @@ -125,14 +131,16 @@ public class JavaMultiFieldMergeTests extends OpenSearchSingleNodeTestCase { assertThat(mapperService.fieldType("name.not_indexed2"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue()); - doc = mapperService.documentMapper().parse(new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc(); + doc = mapperService.documentMapper() + .parse(new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", json, XContentType.JSON)) + .rootDoc(); f = doc.getField("name"); assertThat(f, notNullValue()); f = doc.getField("name.indexed"); assertThat(f, notNullValue()); mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/multifield/merge/upgrade2.json"); - mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + mapperService.merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); assertTrue(mapperService.fieldType("name").isSearchable()); @@ -143,7 +151,11 @@ public class JavaMultiFieldMergeTests extends OpenSearchSingleNodeTestCase { mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/multifield/merge/upgrade3.json"); try { - mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + mapperService.merge( + MapperService.SINGLE_MAPPING_NAME, + new CompressedXContent(mapping), + MapperService.MergeReason.MAPPING_UPDATE + ); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("Cannot update parameter [index] from [true] to [false]")); diff --git a/server/src/test/java/org/opensearch/index/mapper/MultiFieldTests.java b/server/src/test/java/org/opensearch/index/mapper/MultiFieldTests.java index c2c96737506..918f5b325d8 100644 --- a/server/src/test/java/org/opensearch/index/mapper/MultiFieldTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/MultiFieldTests.java @@ -72,10 +72,13 @@ public class MultiFieldTests extends OpenSearchSingleNodeTestCase { IndexService indexService = createIndex("test"); MapperService mapperService = indexService.mapperService(); - indexService.mapperService().merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); + indexService.mapperService() + .merge(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/opensearch/index/mapper/multifield/test-data.json")); - Document doc = mapperService.documentMapper().parse(new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc(); + Document doc = mapperService.documentMapper() + .parse(new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", json, XContentType.JSON)) + .rootDoc(); IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); @@ -139,7 +142,7 @@ public class MultiFieldTests extends OpenSearchSingleNodeTestCase { public void testBuildThenParse() throws Exception { IndexService indexService = createIndex("test"); DocumentMapper builderDocMapper = new DocumentMapper.Builder( - new RootObjectMapper.Builder("person").add( + new RootObjectMapper.Builder(MapperService.SINGLE_MAPPING_NAME).add( new TextFieldMapper.Builder("name", createDefaultIndexAnalyzers()).store(true) .addMultiField(new TextFieldMapper.Builder("indexed", createDefaultIndexAnalyzers()).index(true)) .addMultiField(new TextFieldMapper.Builder("not_indexed", createDefaultIndexAnalyzers()).index(false).store(true)) @@ -151,10 +154,11 @@ public class MultiFieldTests extends OpenSearchSingleNodeTestCase { // reparse it DocumentMapper docMapper = indexService.mapperService() .documentMapperParser() - .parse("person", new CompressedXContent(builtMapping)); + .parse(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(builtMapping)); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/opensearch/index/mapper/multifield/test-data.json")); - Document doc = docMapper.parse(new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc(); + Document doc = docMapper.parse(new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", json, XContentType.JSON)) + .rootDoc(); IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); diff --git a/server/src/test/java/org/opensearch/index/mapper/PathMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/PathMapperTests.java index 9fbe349c609..ed5470b8618 100644 --- a/server/src/test/java/org/opensearch/index/mapper/PathMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/PathMapperTests.java @@ -46,7 +46,7 @@ public class PathMapperTests extends OpenSearchSingleNodeTestCase { String mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/path/test-mapping.json"); DocumentMapper docMapper = createIndex("test").mapperService() .documentMapperParser() - .parse("person", new CompressedXContent(mapping)); + .parse(MapperService.SINGLE_MAPPING_NAME, new CompressedXContent(mapping)); // test full name assertThat(docMapper.mappers().getMapper("first1"), nullValue()); diff --git a/server/src/test/java/org/opensearch/index/mapper/PathMatchDynamicTemplateTests.java b/server/src/test/java/org/opensearch/index/mapper/PathMatchDynamicTemplateTests.java index a2fa7c68f67..4976372ceaf 100644 --- a/server/src/test/java/org/opensearch/index/mapper/PathMatchDynamicTemplateTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/PathMatchDynamicTemplateTests.java @@ -47,17 +47,16 @@ public class PathMatchDynamicTemplateTests extends OpenSearchSingleNodeTestCase public void testSimple() throws Exception { String mapping = copyToStringFromClasspath("/org/opensearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json"); IndexService index = createIndex("test"); - client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping, XContentType.JSON).get(); + client().admin().indices().preparePutMapping("test").setSource(mapping, XContentType.JSON).get(); MapperService mapperService = index.mapperService(); byte[] json = copyToBytesFromClasspath("/org/opensearch/index/mapper/dynamictemplate/pathmatch/test-data.json"); ParsedDocument parsedDoc = mapperService.documentMapper() - .parse(new SourceToParse("test", "person", "1", new BytesArray(json), XContentType.JSON)); + .parse(new SourceToParse("test", MapperService.SINGLE_MAPPING_NAME, "1", new BytesArray(json), XContentType.JSON)); client().admin() .indices() .preparePutMapping("test") - .setType("person") .setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON) .get(); Document doc = parsedDoc.rootDoc(); diff --git a/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java index aca124fcb8a..0a01d86e76d 100644 --- a/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java @@ -74,7 +74,6 @@ public class RangeFieldQueryStringQueryBuilderTests extends AbstractQueryTestCas new CompressedXContent( Strings.toString( PutMappingRequest.buildFromSimplifiedDef( - "_doc", INTEGER_RANGE_FIELD_NAME, "type=integer_range", LONG_RANGE_FIELD_NAME, diff --git a/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java b/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java index 42a37c0b2ec..d54283f0375 100644 --- a/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java @@ -257,7 +257,6 @@ public class UpdateMappingTests extends OpenSearchSingleNodeTestCase { final long previousVersion = clusterService.state().metadata().index("test").getMappingVersion(); final PutMappingRequest request = new PutMappingRequest(); request.indices("test"); - request.type("type"); request.source("field", "type=text"); client().admin().indices().putMapping(request).actionGet(); assertThat(clusterService.state().metadata().index("test").getMappingVersion(), Matchers.equalTo(1 + previousVersion)); @@ -267,7 +266,6 @@ public class UpdateMappingTests extends OpenSearchSingleNodeTestCase { final long previousVersion = clusterService.state().metadata().index("test").getMappingVersion(); final PutMappingRequest request = new PutMappingRequest(); request.indices("test"); - request.type("type"); request.source("field", "type=text"); client().admin().indices().putMapping(request).actionGet(); // the version should be unchanged after putting the same mapping again diff --git a/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java index c4aba907f4f..bf42aca1568 100644 --- a/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java @@ -390,13 +390,7 @@ public class MatchQueryBuilderTests extends AbstractQueryTestCase mappingConsumer = (type, mapping) -> { - assertNull(requestedMappingUpdates.put(type, mapping)); + Consumer mappingConsumer = mapping -> { + assertNull(requestedMappingUpdates.put(MapperService.SINGLE_MAPPING_NAME, mapping)); }; final IndexShard differentIndex = newShard(new ShardId("index_2", "index_2", 0), true); diff --git a/server/src/test/resources/org/opensearch/index/mapper/dynamictemplate/genericstore/test-mapping.json b/server/src/test/resources/org/opensearch/index/mapper/dynamictemplate/genericstore/test-mapping.json index 70bf6dc7b5d..557704b0bd4 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/dynamictemplate/genericstore/test-mapping.json +++ b/server/src/test/resources/org/opensearch/index/mapper/dynamictemplate/genericstore/test-mapping.json @@ -1,5 +1,5 @@ { - "person":{ + "_doc":{ "dynamic_templates":[ { "template_1":{ @@ -11,4 +11,4 @@ } ] } -} \ No newline at end of file +} diff --git a/server/src/test/resources/org/opensearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json b/server/src/test/resources/org/opensearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json index ad461063426..8aa6d6ef8a6 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json +++ b/server/src/test/resources/org/opensearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json @@ -1,5 +1,5 @@ { - "person":{ + "_doc":{ "dynamic_templates":[ { "template_1":{ diff --git a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping1.json b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping1.json index dbd74d33780..7828a4dbf58 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping1.json +++ b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping1.json @@ -1,5 +1,5 @@ { - "person":{ + "_doc":{ "properties":{ "name":{ "type": "text", diff --git a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping2.json b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping2.json index b4d18439288..0d6274dd50d 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping2.json +++ b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping2.json @@ -1,5 +1,5 @@ { - "person" :{ + "_doc" :{ "properties" :{ "name":{ "type": "text", diff --git a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping3.json b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping3.json index 459d9fc9b1e..60a2751ede6 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping3.json +++ b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping3.json @@ -1,5 +1,5 @@ { - "person" : { + "_doc" : { "properties" :{ "name" : { "type" : "text", diff --git a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping4.json b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping4.json index 416633c4fc1..fe3fb35fc7d 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping4.json +++ b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/test-mapping4.json @@ -1,5 +1,5 @@ { - "person":{ + "_doc":{ "properties":{ "name":{ "type": "text", diff --git a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade1.json b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade1.json index b00ea46b56d..acffa310053 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade1.json +++ b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade1.json @@ -1,5 +1,5 @@ { - "person":{ + "_doc":{ "properties":{ "name":{ "type": "text", diff --git a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade2.json b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade2.json index 563567f463e..8acb62e0a1f 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade2.json +++ b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade2.json @@ -1,5 +1,5 @@ { - "person":{ + "_doc":{ "properties":{ "name":{ "type": "text", diff --git a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade3.json b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade3.json index 5985ff316a7..c8552f41f8c 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade3.json +++ b/server/src/test/resources/org/opensearch/index/mapper/multifield/merge/upgrade3.json @@ -1,5 +1,5 @@ { - "person":{ + "_doc":{ "properties":{ "name":{ "type": "text", diff --git a/server/src/test/resources/org/opensearch/index/mapper/multifield/test-multi-fields.json b/server/src/test/resources/org/opensearch/index/mapper/multifield/test-multi-fields.json index b7317aba3c1..9f9c18a30f8 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/multifield/test-multi-fields.json +++ b/server/src/test/resources/org/opensearch/index/mapper/multifield/test-multi-fields.json @@ -1,5 +1,5 @@ { - "person": { + "_doc": { "properties": { "name": { "type": "text", diff --git a/server/src/test/resources/org/opensearch/index/mapper/path/test-mapping.json b/server/src/test/resources/org/opensearch/index/mapper/path/test-mapping.json index 8d7505624b1..e3a14f83b47 100644 --- a/server/src/test/resources/org/opensearch/index/mapper/path/test-mapping.json +++ b/server/src/test/resources/org/opensearch/index/mapper/path/test-mapping.json @@ -1,5 +1,5 @@ { - "person":{ + "_doc":{ "properties":{ "name1":{ "type":"object", diff --git a/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java b/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java index 5bb4ee5f29f..dfc34add386 100644 --- a/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/replication/OpenSearchIndexLevelReplicationTestCase.java @@ -907,7 +907,7 @@ public abstract class OpenSearchIndexLevelReplicationTestCase extends IndexShard final PlainActionFuture permitAcquiredFuture = new PlainActionFuture<>(); primary.acquirePrimaryOperationPermit(permitAcquiredFuture, ThreadPool.Names.SAME, request); try (Releasable ignored = permitAcquiredFuture.actionGet()) { - MappingUpdatePerformer noopMappingUpdater = (update, shardId, type, listener1) -> {}; + MappingUpdatePerformer noopMappingUpdater = (update, shardId, listener1) -> {}; TransportShardBulkAction.performOnPrimary( request, primary, diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java index 5f585434a4e..e5d14333de8 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java @@ -439,7 +439,6 @@ public abstract class AbstractBuilderTestCase extends OpenSearchTestCase { new CompressedXContent( Strings.toString( PutMappingRequest.buildFromSimplifiedDef( - "_doc", TEXT_FIELD_NAME, "type=text", KEYWORD_FIELD_NAME,