diff --git a/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java b/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java index 02c3bdfd70ec2..8c2f83bf83d85 100644 --- a/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java +++ b/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java @@ -73,7 +73,7 @@ public void testCustomWordDelimiterQueryString() { .put("analysis.filter.custom_word_delimiter.split_on_numerics", "false") .put("analysis.filter.custom_word_delimiter.stem_english_possessive", "false") ) - .addMapping("type1", "field1", "type=text,analyzer=my_analyzer", "field2", "type=text,analyzer=my_analyzer") + .setMapping("field1", "type=text,analyzer=my_analyzer", "field2", "type=text,analyzer=my_analyzer") ); client().prepareIndex("test").setId("1").setSource("field1", "foo bar baz", "field2", "not needed").get(); diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java index a8dd2d2578541..57c959a4f0b65 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java @@ -149,8 +149,7 @@ public void testMultiPhraseCutoff() throws IOException { * query. We cut off and extract terms if there are more than 16 terms in the query */ assertAcked( - prepareCreate("test").addMapping( - "test", + prepareCreate("test").setMapping( "body", "type=text,analyzer=custom_analyzer," + "search_analyzer=custom_analyzer,term_vector=with_positions_offsets" ) @@ -225,8 +224,7 @@ public void testSynonyms() throws IOException { assertAcked( prepareCreate("test").setSettings(builder.build()) - .addMapping( - "type1", + .setMapping( "field1", "type=text,term_vector=with_positions_offsets,search_analyzer=synonym," + "analyzer=standard,index_options=offsets" ) @@ -335,8 +333,7 @@ public void testPhrasePrefix() throws IOException { assertAcked( prepareCreate("second_test_index").setSettings(builder.build()) - .addMapping( - "doc", + .setMapping( "field4", "type=text,term_vector=with_positions_offsets,analyzer=synonym", "field3", diff --git a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java index 450e70c3c8938..952b00dda608c 100644 --- a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java +++ b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java @@ -158,7 +158,7 @@ public void testScore() throws Exception { } public void testDateMethods() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "date0", "type=date", "date1", "type=date")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("date0", "type=date", "date1", "type=date")); ensureGreen("test"); indexRandom( true, @@ -188,7 +188,7 @@ public void testDateMethods() throws Exception { } public void testDateObjectMethods() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "date0", "type=date", "date1", "type=date")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("date0", "type=date", "date1", "type=date")); ensureGreen("test"); indexRandom( true, @@ -219,7 +219,7 @@ public void testDateObjectMethods() throws Exception { public void testMultiValueMethods() throws Exception { OpenSearchAssertions.assertAcked( - prepareCreate("test").addMapping("doc", "double0", "type=double", "double1", "type=double", "double2", "type=double") + prepareCreate("test").setMapping("double0", "type=double", "double1", "type=double", "double2", "type=double") ); ensureGreen("test"); @@ -322,7 +322,7 @@ public void testMultiValueMethods() throws Exception { } public void testInvalidDateMethodCall() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "double", "type=double")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("double", "type=double")); ensureGreen("test"); indexRandom(true, client().prepareIndex("test").setId("1").setSource("double", "178000000.0")); try { @@ -343,7 +343,7 @@ public void testInvalidDateMethodCall() throws Exception { } public void testSparseField() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "x", "type=long", "y", "type=long")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("x", "type=long", "y", "type=long")); ensureGreen("test"); indexRandom( true, @@ -528,7 +528,7 @@ public void testSpecialValueVariable() throws Exception { public void testStringSpecialValueVariable() throws Exception { // i.e. expression script for term aggregations, which is not allowed - assertAcked(client().admin().indices().prepareCreate("test").addMapping("doc", "text", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("text", "type=keyword").get()); ensureGreen("test"); indexRandom( true, diff --git a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java index 11fc61d6c6d99..f78b74e272ebf 100644 --- a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java @@ -101,7 +101,7 @@ public void testPercolatorQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -183,8 +183,7 @@ public void testPercolatorRangeQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type", + .setMapping( "field1", "type=long", "field2", @@ -315,17 +314,7 @@ public void testPercolatorGeoQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type", - "id", - "type=keyword", - "field1", - "type=geo_point", - "field2", - "type=geo_shape", - "query", - "type=percolator" - ) + .setMapping("id", "type=keyword", "field1", "type=geo_point", "field2", "type=geo_shape", "query", "type=percolator") ); client().prepareIndex("test") @@ -380,7 +369,7 @@ public void testPercolatorQueryExistingDocument() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -438,7 +427,7 @@ public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception client().admin() .indices() .prepareCreate("test") - .addMapping("type", "_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator") + .setMapping("_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject()).get(); @@ -459,7 +448,7 @@ public void testPercolatorSpecificQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator") ); client().prepareIndex("test") @@ -565,7 +554,7 @@ public void testPercolatorQueryWithHighlighting() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", fieldMapping.toString(), "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", fieldMapping.toString(), "query", "type=percolator") ); client().prepareIndex("test") .setId("1") @@ -810,7 +799,7 @@ public void testTakePositionOffsetGapIntoAccount() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "field", "type=text,position_increment_gap=5", "query", "type=percolator") + .setMapping("field", "type=text,position_increment_gap=5", "query", "type=percolator") ); client().prepareIndex("test") .setId("1") @@ -832,13 +821,13 @@ public void testTakePositionOffsetGapIntoAccount() throws Exception { public void testManyPercolatorFields() throws Exception { String queryFieldName = randomAlphaOfLength(8); assertAcked( - client().admin().indices().prepareCreate("test1").addMapping("type", queryFieldName, "type=percolator", "field", "type=keyword") + client().admin().indices().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() .indices() .prepareCreate("test2") - .addMapping("type", queryFieldName, "type=percolator", "second_query_field", "type=percolator", "field", "type=keyword") + .setMapping(queryFieldName, "type=percolator", "second_query_field", "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() @@ -867,7 +856,7 @@ public void testManyPercolatorFields() throws Exception { public void testWithMultiplePercolatorFields() throws Exception { String queryFieldName = randomAlphaOfLength(8); assertAcked( - client().admin().indices().prepareCreate("test1").addMapping("type", queryFieldName, "type=percolator", "field", "type=keyword") + client().admin().indices().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() @@ -1130,7 +1119,7 @@ public void testPercolateQueryWithNestedDocuments() throws Exception { } public void testPercolatorQueryViaMultiSearch() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "field1", "type=text", "query", "type=percolator")); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=text", "query", "type=percolator")); client().prepareIndex("test") .setId("1") @@ -1248,7 +1237,7 @@ public void testDisallowExpensiveQueries() throws IOException { client().admin() .indices() .prepareCreate("test") - .addMapping("_doc", "id", "type=keyword", "field1", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -1298,7 +1287,7 @@ public void testDisallowExpensiveQueries() throws IOException { public void testWrappedWithConstantScore() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", "d", "type=date", "q", "type=percolator")); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("d", "type=date", "q", "type=percolator")); client().prepareIndex("test") .setId("1") diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java index d3da99ffbc102..1d77c9d472864 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java @@ -96,7 +96,7 @@ protected Map, Object>> pluginScripts() { } public void testPercolateScriptQuery() throws IOException { - client().admin().indices().prepareCreate("index").addMapping("type", "query", "type=percolator").get(); + client().admin().indices().prepareCreate("index").setMapping("query", "type=percolator").get(); client().prepareIndex("index") .setId("1") .setSource( diff --git a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java index 375222cd2af44..3a430331167f6 100644 --- a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java +++ b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java @@ -36,7 +36,6 @@ import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.mapper.MapperService; import org.opensearch.plugin.mapper.MapperSizePlugin; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -122,7 +121,7 @@ private void assertSizeMappingEnabled(String index, boolean enabled) throws IOEx } public void testBasic() throws Exception { - assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, "_size", "enabled=true")); + assertAcked(prepareCreate("test").setMapping("_size", "enabled=true")); final String source = "{\"f\":10}"; indexRandom(true, client().prepareIndex("test").setId("1").setSource(source, XContentType.JSON)); GetResponse getResponse = client().prepareGet("test", "1").setStoredFields("_size").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java index ef5c56c50ed83..e8a6c68a41076 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java @@ -71,7 +71,6 @@ import org.opensearch.index.Index; import org.opensearch.index.IndexService; import org.opensearch.index.engine.SegmentsStats; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.index.shard.IndexShard; @@ -527,7 +526,7 @@ public void testCreateShrinkWithIndexSort() throws Exception { .put("sort.order", "desc") .put("number_of_shards", 8) .put("number_of_replicas", 0) - ).addMapping(MapperService.SINGLE_MAPPING_NAME, "id", "type=keyword,doc_values=true").get(); + ).setMapping("id", "type=keyword,doc_values=true").get(); for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java index 42b1d5f4a757f..89e11984621da 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java @@ -65,7 +65,6 @@ import org.opensearch.index.Index; import org.opensearch.index.IndexService; import org.opensearch.index.engine.SegmentsStats; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.index.shard.IndexShard; @@ -136,12 +135,12 @@ private void splitToN(int sourceShards, int firstSplitShards, int secondSplitSha int numRoutingShards = MetadataCreateIndexService.calculateNumRoutingShards(secondSplitShards, Version.CURRENT) - 1; settings.put("index.routing_partition_size", randomIntBetween(1, numRoutingShards)); if (useNested) { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "_routing", "required=true", "nested1", "type=nested"); + createInitialIndex.setMapping("_routing", "required=true", "nested1", "type=nested"); } else { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "_routing", "required=true"); + createInitialIndex.setMapping("_routing", "required=true"); } } else if (useNested) { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "nested1", "type=nested"); + createInitialIndex.setMapping("nested1", "type=nested"); } logger.info("use routing {} use mixed routing {} use nested {}", useRouting, useMixedRouting, useNested); createInitialIndex.setSettings(settings).get(); @@ -523,7 +522,7 @@ public void testCreateSplitWithIndexSort() throws Exception { .put("sort.order", "desc") .put("number_of_shards", 2) .put("number_of_replicas", 0) - ).addMapping(MapperService.SINGLE_MAPPING_NAME, "id", "type=keyword,doc_values=true").get(); + ).setMapping("id", "type=keyword,doc_values=true").get(); for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java index c7985d972de5e..a356d273f7060 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java @@ -348,7 +348,7 @@ public void testSearchIdle() throws Exception { .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 5)) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) .put(IndexSettings.INDEX_SEARCH_IDLE_AFTER.getKey(), TimeValue.timeValueMillis(randomIntBetween(50, 500))); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("_doc", "created_date", "type=date,format=yyyy-MM-dd")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("created_date", "type=date,format=yyyy-MM-dd")); ensureGreen("test"); assertBusy(() -> { for (String node : internalCluster().nodesInclude("test")) { diff --git a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java index 8ab6450ead2af..b5e60f44983f5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java @@ -161,8 +161,7 @@ public void testNotIndexedField() throws Exception { // must be of type string and indexed. assertAcked( prepareCreate("test").addAlias(new Alias("alias")) - .addMapping( - "type1", + .setMapping( "field0", "type=integer,", // no tvs "field1", @@ -548,10 +547,8 @@ private void checkBrownFoxTermVector(Fields fields, String fieldName, boolean wi public void testDuelWithAndWithoutTermVectors() throws IOException, ExecutionException, InterruptedException { // setup indices String[] indexNames = new String[] { "with_tv", "without_tv" }; - assertAcked( - prepareCreate(indexNames[0]).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets,analyzer=keyword") - ); - assertAcked(prepareCreate(indexNames[1]).addMapping("type1", "field1", "type=text,term_vector=no,analyzer=keyword")); + assertAcked(prepareCreate(indexNames[0]).setMapping("field1", "type=text,term_vector=with_positions_offsets,analyzer=keyword")); + assertAcked(prepareCreate(indexNames[1]).setMapping("field1", "type=text,term_vector=no,analyzer=keyword")); ensureGreen(); // index documents with and without term vectors @@ -656,9 +653,7 @@ public void testSimpleWildCards() throws IOException { public void testArtificialVsExisting() throws ExecutionException, InterruptedException, IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked( - prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets") - ); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text,term_vector=with_positions_offsets")); ensureGreen(); // index documents existing document @@ -704,7 +699,7 @@ public void testArtificialVsExisting() throws ExecutionException, InterruptedExc public void testArtificialNoDoc() throws IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text")); ensureGreen(); // request tvs from artificial document @@ -929,7 +924,7 @@ public void testTermVectorsWithVersion() { public void testFilterLength() throws ExecutionException, InterruptedException, IOException { logger.info("Setting up the index ..."); Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "keyword"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); int numTerms = scaledRandomIntBetween(10, 50); logger.info("Indexing one document with tags of increasing length ..."); @@ -962,7 +957,7 @@ public void testFilterLength() throws ExecutionException, InterruptedException, public void testFilterTermFreq() throws ExecutionException, InterruptedException, IOException { logger.info("Setting up the index ..."); Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "keyword"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); logger.info("Indexing one document with tags of increasing frequencies ..."); int numTerms = scaledRandomIntBetween(10, 50); @@ -1000,7 +995,7 @@ public void testFilterDocFreq() throws ExecutionException, InterruptedException, .put(indexSettings()) .put("index.analysis.analyzer", "keyword") .put("index.number_of_shards", 1); // no dfs - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); int numDocs = scaledRandomIntBetween(10, 50); // as many terms as there are docs logger.info("Indexing {} documents with tags of increasing dfs ...", numDocs); @@ -1030,9 +1025,7 @@ public void testFilterDocFreq() throws ExecutionException, InterruptedException, public void testArtificialDocWithPreference() throws InterruptedException, IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked( - prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets") - ); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text,term_vector=with_positions_offsets")); ensureGreen(); // index document @@ -1076,8 +1069,7 @@ public void testWithKeywordAndNormalizer() throws IOException, ExecutionExceptio .putList("index.analysis.normalizer.my_normalizer.filter", "lowercase"); assertAcked( prepareCreate(indexNames[0]).setSettings(builder.build()) - .addMapping( - "type1", + .setMapping( "field1", "type=text,term_vector=with_positions_offsets,analyzer=my_analyzer", "field2", @@ -1086,7 +1078,7 @@ public void testWithKeywordAndNormalizer() throws IOException, ExecutionExceptio ); assertAcked( prepareCreate(indexNames[1]).setSettings(builder.build()) - .addMapping("type1", "field1", "type=keyword,normalizer=my_normalizer", "field2", "type=keyword") + .setMapping("field1", "type=keyword,normalizer=my_normalizer", "field2", "type=keyword") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java index 2d01e4c031538..ff64a2cd90cb8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java @@ -226,7 +226,7 @@ public void testFailedFilter() throws Exception { public void testFilteringAliases() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type", "user", "type=text")); + assertAcked(prepareCreate("test").setMapping("user", "type=text")); ensureGreen(); @@ -260,7 +260,7 @@ public void testEmptyFilter() throws Exception { public void testSearchingFilteringAliasesSingleIndex() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type1", "id", "type=text", "name", "type=text,fielddata=true")); + assertAcked(prepareCreate("test").setMapping("id", "type=text", "name", "type=text,fielddata=true")); ensureGreen(); @@ -363,9 +363,9 @@ public void testSearchingFilteringAliasesSingleIndex() throws Exception { public void testSearchingFilteringAliasesTwoIndices() throws Exception { logger.info("--> creating index [test1]"); - assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); logger.info("--> creating index [test2]"); - assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -593,8 +593,8 @@ public void testSearchingFilteringAliasesMultipleIndices() throws Exception { public void testDeletingByQueryFilteringAliases() throws Exception { logger.info("--> creating index [test1] and [test2"); - assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=text")); - assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -648,8 +648,8 @@ public void testDeletingByQueryFilteringAliases() throws Exception { public void testDeleteAliases() throws Exception { logger.info("--> creating index [test1] and [test2]"); - assertAcked(prepareCreate("test1").addMapping("type", "name", "type=text")); - assertAcked(prepareCreate("test2").addMapping("type", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -780,7 +780,7 @@ public void run() { public void testSameAlias() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type", "name", "type=text")); + assertAcked(prepareCreate("test").setMapping("name", "type=text")); ensureGreen(); logger.info("--> creating alias1 "); @@ -1073,7 +1073,7 @@ public void testGetAllAliasesWorks() { public void testCreateIndexWithAliases() throws Exception { assertAcked( - prepareCreate("test").addMapping("type", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .addAlias(new Alias("alias1")) .addAlias(new Alias("alias2").filter(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("field")))) .addAlias(new Alias("alias3").indexRouting("index").searchRouting("search")) @@ -1103,7 +1103,7 @@ public void testCreateIndexWithAliasesInSource() throws Exception { public void testCreateIndexWithAliasesSource() throws Exception { assertAcked( - prepareCreate("test").addMapping("type", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .setAliases( "{\n" + " \"alias1\" : {},\n" @@ -1180,7 +1180,7 @@ public void testAddAliasWithFilterNoMapping() throws Exception { } public void testAliasFilterWithNowInRangeFilterAndQuery() throws Exception { - assertAcked(prepareCreate("my-index").addMapping("my-type", "timestamp", "type=date")); + assertAcked(prepareCreate("my-index").setMapping("timestamp", "type=date")); assertAliasesVersionIncreases( "my-index", () -> assertAcked( 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 3060b5c23fe75..6f4c6fca77196 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java @@ -176,9 +176,7 @@ public void testDeleteCreateInOneBulk() throws Exception { 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(MapperService.SINGLE_MAPPING_NAME) - .get(); + prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)).get(); ensureGreen("test"); // block none master node. diff --git a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java index f3693be3b7227..1e40cc14bbb36 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java @@ -69,7 +69,7 @@ */ public class DocumentActionsIT extends OpenSearchIntegTestCase { protected void createIndex() { - OpenSearchAssertions.assertAcked(prepareCreate(getConcreteIndexName()).addMapping("type1", "name", "type=keyword,store=true")); + OpenSearchAssertions.assertAcked(prepareCreate(getConcreteIndexName()).setMapping("name", "type=keyword,store=true")); } protected String getConcreteIndexName() { diff --git a/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java b/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java index be1335bd56ba9..5f217548794db 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java @@ -125,7 +125,7 @@ private void prepareIndex(int numberOfPrimaryShards, boolean routingRequired) th Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfPrimaryShards) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numCopies - 1) - ).addMapping("type", "_routing", "required=" + routingRequired).get() + ).setMapping("_routing", "required=" + routingRequired).get() ); for (int i = 0; i < numberOfPrimaryShards; i++) { ensureActiveShardCopies(i, numNodes); diff --git a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java index 78069970c1a60..53da0309aa602 100644 --- a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java @@ -115,7 +115,7 @@ public void testSimple() throws Exception { public void testExplainWithFields() throws Exception { assertAcked( - prepareCreate("test").addMapping("test", "obj1.field1", "type=keyword,store=true", "obj1.field2", "type=keyword,store=true") + prepareCreate("test").setMapping("obj1.field1", "type=keyword,store=true", "obj1.field2", "type=keyword,store=true") .addAlias(new Alias("alias")) ); ensureGreen("test"); @@ -212,7 +212,7 @@ public void testExplainWithSource() throws Exception { public void testExplainWithFilteredAlias() { assertAcked( - prepareCreate("test").addMapping("test", "field2", "type=text") + prepareCreate("test").setMapping("field2", "type=text") .addAlias(new Alias("alias1").filter(QueryBuilders.termQuery("field2", "value2"))) ); ensureGreen("test"); @@ -231,7 +231,7 @@ public void testExplainWithFilteredAliasFetchSource() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("test", "field2", "type=text") + .setMapping("field2", "type=text") .addAlias(new Alias("alias1").filter(QueryBuilders.termQuery("field2", "value2"))) ); ensureGreen("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java index a09778582b604..2f811d4a901bf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java @@ -84,7 +84,7 @@ protected Collection> nodePlugins() { public void testSimpleGet() { assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=keyword,store=true", "field2", "type=keyword,store=true") + prepareCreate("test").setMapping("field1", "type=keyword,store=true", "field2", "type=keyword,store=true") .setSettings(Settings.builder().put("index.refresh_interval", -1)) .addAlias(new Alias("alias").writeIndex(randomFrom(true, false, null))) ); @@ -234,7 +234,7 @@ static String indexOrAlias() { public void testSimpleMultiGet() throws Exception { assertAcked( prepareCreate("test").addAlias(new Alias("alias").writeIndex(randomFrom(true, false, null))) - .addMapping("type1", "field", "type=keyword,store=true") + .setMapping("field", "type=keyword,store=true") .setSettings(Settings.builder().put("index.refresh_interval", -1)) ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java index 1137a3038fd18..9940b1eb13a52 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java @@ -79,12 +79,12 @@ public void testSimpleStats() throws Exception { assertAcked( prepareCreate("test1").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("type", "f", "type=text") + ).setMapping("f", "type=text") ); assertAcked( prepareCreate("test2").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx2).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("type", "f", "type=text") + ).setMapping("f", "type=text") ); assertThat(shardsIdx1 + shardsIdx2, equalTo(numAssignedShards("test1", "test2"))); assertThat(numAssignedShards("test1", "test2"), greaterThanOrEqualTo(2)); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java index 18940cba80799..12fee85288bc2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java @@ -73,7 +73,7 @@ public void testCacheAggs() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "f", "type=date") + .setMapping("f", "type=date") .setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)) .get() ); @@ -137,7 +137,7 @@ public void testQueryRewrite() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=date") + .setMapping("s", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -208,7 +208,7 @@ public void testQueryRewriteMissingValues() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=date") + .setMapping("s", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -274,7 +274,7 @@ public void testQueryRewriteDates() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "d", "type=date") + .setMapping("d", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -345,9 +345,9 @@ public void testQueryRewriteDatesWithNow() throws Exception { .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build(); - assertAcked(client.admin().indices().prepareCreate("index-1").addMapping("type", "d", "type=date").setSettings(settings).get()); - assertAcked(client.admin().indices().prepareCreate("index-2").addMapping("type", "d", "type=date").setSettings(settings).get()); - assertAcked(client.admin().indices().prepareCreate("index-3").addMapping("type", "d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings).get()); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); DateFormatter formatter = DateFormatter.forPattern("strict_date_optional_time"); indexRandom( @@ -426,7 +426,7 @@ public void testCanCache() throws Exception { .put("index.number_of_routing_shards", 2) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build(); - assertAcked(client.admin().indices().prepareCreate("index").addMapping("type", "s", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index").setMapping("s", "type=date").setSettings(settings).get()); indexRandom( true, client.prepareIndex("index").setId("1").setRouting("1").setSource("s", "2016-03-19"), @@ -529,7 +529,7 @@ public void testCacheWithFilteredAlias() { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "created_at", "type=date") + .setMapping("created_at", "type=date") .setSettings(settings) .addAlias(new Alias("last_week").filter(QueryBuilders.rangeQuery("created_at").gte("now-7d/d"))) .get() @@ -578,7 +578,7 @@ public void testProfileDisableCache() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("_doc", "k", "type=keyword") + .setMapping("k", "type=keyword") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) 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 7218495898677..1d25051eefe44 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java @@ -99,7 +99,7 @@ public void testSimpleAnalyzerTests() throws Exception { } public void testAnalyzeNumericField() throws IOException { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("test", "long", "type=long", "double", "type=double")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping("long", "type=long", "double", "type=double")); ensureGreen("test"); expectThrows( @@ -413,7 +413,7 @@ public void testCustomTokenFilterInRequest() throws Exception { } public void testAnalyzeKeywordField() throws IOException { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("test", "keyword", "type=keyword")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping("keyword", "type=keyword")); ensureGreen("test"); AnalyzeAction.Response analyzeResponse = client().admin().indices().prepareAnalyze(indexOrAlias(), "ABC").setField("keyword").get(); @@ -435,7 +435,7 @@ public void testAnalyzeNormalizedKeywordField() throws IOException { .put("index.analysis.normalizer.my_normalizer.type", "custom") .putList("index.analysis.normalizer.my_normalizer.filter", "lowercase") ) - .addMapping("test", "keyword", "type=keyword,normalizer=my_normalizer") + .setMapping("keyword", "type=keyword,normalizer=my_normalizer") ); ensureGreen("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java index e9bb9f5a90477..2dc6b2085b866 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java @@ -142,8 +142,7 @@ public void testMemoryBreaker() throws Exception { return; } assertAcked( - prepareCreate("cb-test", 1, Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))).addMapping( - "type", + prepareCreate("cb-test", 1, Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))).setMapping( "test", "type=text,fielddata=true" ) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java index 7fd2466647272..08cf33a342c65 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -62,7 +62,7 @@ public void testPrimaryRelocationWhileIndexing() throws Exception { .indices() .prepareCreate("test") .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) - .addMapping("type", "field", "type=text") + .setMapping("field", "type=text") .get(); ensureGreen("test"); AtomicInteger numAutoGenDocs = new AtomicInteger(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java index a24f55be3f010..be8a1ad4f0c61 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java @@ -148,7 +148,7 @@ public void testFieldDataStats() { .indices() .prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", 2)) - .addMapping("type", "field", "type=text,fielddata=true", "field2", "type=text,fielddata=true") + .setMapping("field", "type=text,fielddata=true", "field2", "type=text,fielddata=true") .get() ); ensureGreen(); @@ -270,7 +270,7 @@ public void testClearAllCaches() throws Exception { .indices() .prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) - .addMapping("type", "field", "type=text,fielddata=true") + .setMapping("field", "type=text,fielddata=true") .get() ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java index 6065db46d8ee2..090cf81de60a3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java @@ -624,7 +624,7 @@ public void testIndexTemplateWithAliasesInSource() { ) .get(); - assertAcked(prepareCreate("test_index").addMapping("_doc")); + assertAcked(prepareCreate("test_index")); ensureGreen(); GetAliasesResponse getAliasesResponse = client().admin().indices().prepareGetAliases().setIndices("test_index").get(); @@ -663,7 +663,7 @@ public void testIndexTemplateWithAliasesSource() { ) .get(); - assertAcked(prepareCreate("test_index").addMapping("_doc")); + assertAcked(prepareCreate("test_index")); ensureGreen(); GetAliasesResponse getAliasesResponse = client().admin().indices().prepareGetAliases().setIndices("test_index").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java index 71da9168c6205..1708454faf7b3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java @@ -108,7 +108,7 @@ public void testCancelRecoveryAndResume() throws Exception { // create the index and prevent allocation on any other nodes than the lucky one // we have no replicas so far and make sure that we allocate the primary on the lucky node assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text", "the_id", "type=text") + prepareCreate("test").setMapping("field1", "type=text", "the_id", "type=text") .setSettings( Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java index 303b84151cf3e..6778765599fe9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java @@ -52,7 +52,7 @@ public class AggregationsIntegrationIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "f", "type=keyword").get()); + assertAcked(prepareCreate("index").setMapping("f", "type=keyword").get()); numDocs = randomIntBetween(1, 20); List docs = new ArrayList<>(); for (int i = 0; i < numDocs; ++i) { diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java index c00152a54bd37..f210af7c10fb3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java @@ -53,7 +53,7 @@ public class MetadataIT extends OpenSearchIntegTestCase { public void testMetadataSetOnAggregationResult() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "name", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("name", "type=keyword").get()); IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)]; for (int i = 0; i < builders.length; i++) { String name = "name_" + randomIntBetween(1, 10); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java index 9135ca0f0a364..7d3f06760882d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java @@ -67,9 +67,7 @@ protected int maximumNumberOfShards() { @Override protected void setupSuiteScopeCluster() throws Exception { - assertAcked( - prepareCreate("idx").addMapping("type", "date", "type=date", "location", "type=geo_point", "str", "type=keyword").get() - ); + assertAcked(prepareCreate("idx").setMapping("date", "type=date", "location", "type=geo_point", "str", "type=keyword").get()); indexRandom( true, client().prepareIndex("idx").setId("1").setSource(), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java index 5d54359152816..af3cc85ed40c0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java @@ -117,7 +117,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java index 2c095857089e1..782bcde39ce8d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java @@ -144,7 +144,7 @@ private IndexRequestBuilder indexDoc(int month, int day, int value) throws Excep public void setupSuiteScopeCluster() throws Exception { createIndex("idx", "idx_unmapped"); // TODO: would be nice to have more random data here - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping("value", "type=integer")); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -188,7 +188,7 @@ private void getMultiSortDocs(List builders) throws IOExcep addExpectedBucket(date(1, 6), 1, 5, 1); addExpectedBucket(date(1, 7), 1, 5, 1); - assertAcked(client().admin().indices().prepareCreate("sort_idx").addMapping("type", "date", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("sort_idx").setMapping("date", "type=date").get()); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -1038,7 +1038,7 @@ public void testEmptyAggregation() throws Exception { } public void testSingleValueWithTimeZone() throws Exception { - prepareCreate("idx2").addMapping("type", "date", "type=date").get(); + prepareCreate("idx2").setMapping("date", "type=date").get(); IndexRequestBuilder[] reqs = new IndexRequestBuilder[5]; ZonedDateTime date = date("2014-03-11T00:00:00+00:00"); for (int i = 0; i < reqs.length; i++) { @@ -1394,7 +1394,7 @@ public void testIssue6965() { } public void testDSTBoundaryIssue9491() throws InterruptedException, ExecutionException { - assertAcked(client().admin().indices().prepareCreate("test9491").addMapping("type", "d", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("test9491").setMapping("d", "type=date").get()); indexRandom( true, client().prepareIndex("test9491").setSource("d", "2014-10-08T13:00:00Z"), @@ -1417,7 +1417,7 @@ public void testDSTBoundaryIssue9491() throws InterruptedException, ExecutionExc } public void testIssue8209() throws InterruptedException, ExecutionException { - assertAcked(client().admin().indices().prepareCreate("test8209").addMapping("type", "d", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("test8209").setMapping("d", "type=date").get()); indexRandom( true, client().prepareIndex("test8209").setSource("d", "2014-01-01T00:00:00Z"), @@ -1498,7 +1498,7 @@ public void testFormatIndexUnmapped() throws InterruptedException, ExecutionExce */ public void testRewriteTimeZone_EpochMillisFormat() throws InterruptedException, ExecutionException { String index = "test31392"; - assertAcked(client().admin().indices().prepareCreate(index).addMapping("type", "d", "type=date,format=epoch_millis").get()); + assertAcked(client().admin().indices().prepareCreate(index).setMapping("d", "type=date,format=epoch_millis").get()); indexRandom(true, client().prepareIndex(index).setSource("d", "1477954800000")); ensureSearchable(index); SearchResponse response = client().prepareSearch(index) @@ -1608,7 +1608,7 @@ public void testDSTEndTransition() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=date") + prepareCreate("cache_test_idx").setMapping("d", "type=date") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1828,7 +1828,7 @@ private ZonedDateTime key(Histogram.Bucket bucket) { * timeZones. */ public void testDateNanosHistogram() throws Exception { - assertAcked(prepareCreate("nanos").addMapping("_doc", "date", "type=date_nanos").get()); + assertAcked(prepareCreate("nanos").setMapping("date", "type=date_nanos").get()); indexRandom(true, client().prepareIndex("nanos").setId("1").setSource("date", "2000-01-01")); indexRandom(true, client().prepareIndex("nanos").setId("2").setSource("date", "2000-01-02")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java index 2505cb48245c3..19e5bdb8916b8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java @@ -72,7 +72,7 @@ private ZonedDateTime date(String date) { @Before public void beforeEachTest() throws IOException { - prepareCreate("idx2").addMapping("type", "date", "type=date").get(); + prepareCreate("idx2").setMapping("date", "type=date").get(); } @After diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java index 7a28df00980cc..470ee6a4d2cea 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java @@ -125,7 +125,7 @@ public void setupSuiteScopeCluster() throws Exception { for (int i = docs.size(); i < numDocs; ++i) { docs.add(indexDoc(randomIntBetween(6, 10), randomIntBetween(1, 20), randomInt(100))); } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping("value", "type=integer")); for (int i = 0; i < 2; i++) { docs.add( client().prepareIndex("empty_bucket_idx") @@ -913,7 +913,7 @@ public void testNoRangesInQuery() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "date", "type=date") + prepareCreate("cache_test_idx").setMapping("date", "type=date") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1070,7 +1070,7 @@ public void testScriptCaching() throws Exception { */ public void testRangeWithFormatStringValue() throws Exception { String indexName = "dateformat_test_idx"; - assertAcked(prepareCreate(indexName).addMapping("type", "date", "type=date,format=strict_hour_minute_second")); + assertAcked(prepareCreate(indexName).setMapping("date", "type=date,format=strict_hour_minute_second")); indexRandom( true, client().prepareIndex(indexName).setId("1").setSource(jsonBuilder().startObject().field("date", "00:16:40").endObject()), @@ -1132,7 +1132,7 @@ public void testRangeWithFormatStringValue() throws Exception { */ public void testRangeWithFormatNumericValue() throws Exception { String indexName = "dateformat_numeric_test_idx"; - assertAcked(prepareCreate(indexName).addMapping("type", "date", "type=date,format=epoch_second")); + assertAcked(prepareCreate(indexName).setMapping("date", "type=date,format=epoch_second")); indexRandom( true, client().prepareIndex(indexName).setId("1").setSource(jsonBuilder().startObject().field("date", 1002).endObject()), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java index aa4bb671d14e8..5b01e7573908c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java @@ -78,14 +78,14 @@ public void setupSuiteScopeCluster() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "author", "type=keyword", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") + ).setMapping("author", "type=keyword", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") ); createIndex("idx_unmapped"); // idx_unmapped_author is same as main index but missing author field assertAcked( prepareCreate("idx_unmapped_author").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") + ).setMapping("name", "type=keyword", "genre", "type=keyword", "price", "type=float") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java index 6c6e6ccc679e8..3093c7490a2a5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java @@ -178,7 +178,7 @@ public void setupSuiteScopeCluster() throws Exception { } createIndex("idx_unmapped"); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -238,7 +238,7 @@ private void getMultiSortDocs(List builders) throws IOExcep bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); - assertAcked(prepareCreate("sort_idx").addMapping("multi_sort_type", SINGLE_VALUED_FIELD_NAME, "type=double")); + assertAcked(prepareCreate("sort_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=double")); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -980,7 +980,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=float") + prepareCreate("cache_test_idx").setMapping("d", "type=float") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java index b938db8891d7b..0845db4f332d7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java @@ -90,7 +90,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java index 0b895f32a1259..a64fe61b29b8a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java @@ -109,7 +109,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java index a2d6533ae0afb..603a141abcaec 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java @@ -93,9 +93,9 @@ private IndexRequestBuilder indexCity(String idx, String name, String... latLons @Override public void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - prepareCreate("idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword").get(); + prepareCreate("idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword").get(); - prepareCreate("idx-multi").addMapping("type", "location", "type=geo_point", "city", "type=keyword").get(); + prepareCreate("idx-multi").setMapping("location", "type=geo_point", "city", "type=keyword").get(); createIndex("idx_unmapped"); @@ -138,7 +138,7 @@ public void setupSuiteScopeCluster() throws Exception { cities.add(indexCity("idx-multi", cityName)); } indexRandom(true, cities); - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer", "location", "type=geo_point").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer", "location", "type=geo_point").get(); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java index c7c21c203af61..56d918feef9d8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java @@ -101,7 +101,7 @@ public void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword")); + assertAcked(prepareCreate("idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword")); List cities = new ArrayList<>(); Random random = random(); @@ -126,7 +126,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, cities); assertAcked( - prepareCreate("multi_valued_idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword") + prepareCreate("multi_valued_idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword") ); cities = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java index fbdcc6b878943..dae788abe0d10 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java @@ -180,7 +180,7 @@ public void setupSuiteScopeCluster() throws Exception { getMultiSortDocs(builders); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -211,7 +211,7 @@ private void getMultiSortDocs(List builders) throws IOExcep addExpectedBucket(6, 1, 5, 1); addExpectedBucket(7, 1, 5, 1); - assertAcked(client().admin().indices().prepareCreate("sort_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=double").get()); + assertAcked(client().admin().indices().prepareCreate("sort_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=double").get()); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -1124,7 +1124,7 @@ public void testExeptionOnNegativerInterval() { } public void testDecimalIntervalAndOffset() throws Exception { - assertAcked(prepareCreate("decimal_values").addMapping("type", "d", "type=float").get()); + assertAcked(prepareCreate("decimal_values").setMapping("d", "type=float").get()); indexRandom( true, client().prepareIndex("decimal_values").setId("1").setSource("d", -0.6), @@ -1151,7 +1151,7 @@ public void testDecimalIntervalAndOffset() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=float") + prepareCreate("cache_test_idx").setMapping("d", "type=float") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1349,7 +1349,7 @@ public void testInvalidBounds() { } public void testHardBounds() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "d", "type=double").get()); + assertAcked(prepareCreate("test").setMapping("d", "type=double").get()); indexRandom( true, client().prepareIndex("test").setId("1").setSource("d", -0.6), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java index b768631225b90..f8f666aaa3c1b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java @@ -70,7 +70,7 @@ protected Collection> nodePlugins() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "ip", "type=ip", "ips", "type=ip")); + assertAcked(prepareCreate("idx").setMapping("ip", "type=ip", "ips", "type=ip")); waitForRelocation(ClusterHealthStatus.GREEN); indexRandom( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java index 53ff70dd240d1..cff51e74fdbd0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java @@ -76,7 +76,7 @@ protected Map, Object>> pluginScripts() { } public void testScriptValue() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), @@ -104,7 +104,7 @@ public void testScriptValue() throws Exception { } public void testScriptValues() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), @@ -132,7 +132,7 @@ public void testScriptValues() throws Exception { } public void testMissingValue() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java index 115b30643ff21..87968bd2117c6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java @@ -164,7 +164,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, highCardBuilders); createIndex("idx_unmapped"); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -928,7 +928,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java index 47cddbf856090..08e696245209e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java @@ -117,7 +117,7 @@ protected Map, Object>> pluginScripts() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "s", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("s", "type=keyword").get()); cardinality = randomIntBetween(8, 30); final List indexRequests = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java index f03a3bdeb1716..3a3e02c577096 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java @@ -132,7 +132,7 @@ public String sortKey() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "string_value", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("string_value", "type=keyword").get()); final int numDocs = randomIntBetween(2, 10); for (int i = 0; i < numDocs; ++i) { final long value = randomInt(5); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java index 969a48b514f1a..fcde2f628ecd7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java @@ -96,7 +96,7 @@ public class NestedIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "nested", "type=nested", "incorrect", "type=object")); + assertAcked(prepareCreate("idx").setMapping("nested", "type=nested", "incorrect", "type=object")); ensureGreen("idx"); List builders = new ArrayList<>(); @@ -126,7 +126,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i + 1).setSource(source)); } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer", "nested", "type=nested").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer", "nested", "type=nested").get(); ensureGreen("empty_bucket_idx"); for (int i = 0; i < 2; i++) { builders.add( @@ -539,7 +539,7 @@ public void testParentFilterResolvedCorrectly() throws Exception { public void testNestedSameDocIdProcessedMultipleTime() throws Exception { assertAcked( prepareCreate("idx4").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + .setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idx4"); @@ -808,7 +808,7 @@ public void testExtractInnerHitBuildersWithDuplicateHitName() throws Exception { assertAcked( prepareCreate("idxduplicatehitnames").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + ).setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idxduplicatehitnames"); @@ -832,7 +832,7 @@ public void testExtractInnerHitBuildersWithDuplicatePath() throws Exception { assertAcked( prepareCreate("idxnullhitnames").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + ).setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idxnullhitnames"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java index bfbfc53ed7e76..c46d6dcd847e1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java @@ -136,7 +136,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } createIndex("idx_unmapped"); - prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -152,8 +152,8 @@ public void setupSuiteScopeCluster() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance").get(); - prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double").get(); + prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance").get(); + prepareCreate("new_index").setMapping("route_length_miles", "type=double").get(); builders.add(client().prepareIndex("old_index").setSource("distance", 42.0)); builders.add(client().prepareIndex("old_index").setSource("distance", 50.5)); @@ -931,7 +931,7 @@ public void testEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "i", "type=integer") + prepareCreate("cache_test_idx").setMapping("i", "type=integer") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java index 94204b6519374..0bfeff9297ce8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java @@ -77,14 +77,14 @@ public void setupSuiteScopeCluster() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "author", "type=keyword", "name", "type=text", "genre", "type=keyword", "price", "type=float") + ).setMapping("author", "type=keyword", "name", "type=text", "genre", "type=keyword", "price", "type=float") ); createIndex("idx_unmapped"); // idx_unmapped_author is same as main index but missing author field assertAcked( prepareCreate("idx_unmapped_author").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "name", "type=text", "genre", "type=keyword", "price", "type=float") + ).setMapping("name", "type=text", "genre", "type=keyword", "price", "type=float") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java index 2300e42b84bbc..7352dc7170a21 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java @@ -94,8 +94,7 @@ private IndexRequestBuilder indexDoc(String date, int value) throws Exception { @Override public void setupSuiteScopeCluster() throws Exception { assertAcked( - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( "nested", "type=nested", "ip", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java index cbcc9c396fc06..9c334df1d806b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java @@ -40,7 +40,6 @@ import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.plugins.Plugin; @@ -215,7 +214,7 @@ public void testPopularTermManyDeletedDocs() throws Exception { String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}"; assertAcked( prepareCreate(INDEX_NAME).setSettings(settings, XContentType.JSON) - .addMapping("_doc", "text", "type=keyword", CLASS_FIELD, "type=keyword") + .setMapping("text", "type=keyword", CLASS_FIELD, "type=keyword") ); String[] cat1v1 = { "constant", "one" }; String[] cat1v2 = { "constant", "uno" }; @@ -453,7 +452,7 @@ public void testSubAggregations() throws Exception { private void indexEqualTestData() throws ExecutionException, InterruptedException { assertAcked( prepareCreate("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("_doc", "text", "type=text,fielddata=true", "class", "type=keyword") + .setMapping("text", "type=text,fielddata=true", "class", "type=keyword") ); createIndex("idx_unmapped"); @@ -545,9 +544,7 @@ private void indexRandomFrequencies01(String type) throws ExecutionException, In if (type.equals("text")) { textMappings += ",fielddata=true"; } - assertAcked( - prepareCreate(INDEX_NAME).addMapping(MapperService.SINGLE_MAPPING_NAME, TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword") - ); + assertAcked(prepareCreate(INDEX_NAME).setMapping(TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword")); String[] gb = { "0", "1" }; List indexRequestBuilderList = new ArrayList<>(); for (int i = 0; i < randomInt(20); i++) { @@ -575,7 +572,7 @@ public void testReduceFromSeveralShards() throws IOException, ExecutionException */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java index 9b941860177bb..3d76b994ebac3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java @@ -74,7 +74,7 @@ public static String randomExecutionHint() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", STRING_FIELD_NAME, "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping(STRING_FIELD_NAME, "type=keyword").get()); List builders = new ArrayList<>(); int numDocs = between(10, 200); int numUniqueTerms = between(2, numDocs / 2); @@ -92,7 +92,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } assertAcked( - prepareCreate("idx_single_shard").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_single_shard").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); for (int i = 0; i < numDocs; i++) { @@ -125,7 +125,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } assertAcked( - prepareCreate("idx_fixed_docs_0").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_0").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard0DocsPerTerm = new HashMap<>(); @@ -151,7 +151,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( - prepareCreate("idx_fixed_docs_1").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_1").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard1DocsPerTerm = new HashMap<>(); @@ -177,7 +177,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( - prepareCreate("idx_fixed_docs_2").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_2").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard2DocsPerTerm = new HashMap<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java index af006210326d8..852c3760751b3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java @@ -35,7 +35,6 @@ import org.opensearch.action.search.SearchResponse; 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.search.aggregations.BucketOrder; import org.opensearch.search.aggregations.bucket.filter.InternalFilter; @@ -73,7 +72,7 @@ public void testShardMinDocCountSignificantTermsTest() throws Exception { } assertAcked( prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping(MapperService.SINGLE_MAPPING_NAME, "text", textMappings) + .setMapping("text", textMappings) ); List indexBuilders = new ArrayList<>(); @@ -142,7 +141,7 @@ public void testShardMinDocCountTermsTest() throws Exception { } assertAcked( prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping(MapperService.SINGLE_MAPPING_NAME, "text", termMappings) + .setMapping("text", termMappings) ); List indexBuilders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java index 252ffeb4ca0e7..3190bcb72fcbb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java @@ -157,15 +157,7 @@ public void setupSuiteScopeCluster() throws Exception { client().admin() .indices() .prepareCreate("idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); List builders = new ArrayList<>(); @@ -193,15 +185,7 @@ public void setupSuiteScopeCluster() throws Exception { client().admin() .indices() .prepareCreate("high_card_idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); for (int i = 0; i < 100; i++) { @@ -218,7 +202,7 @@ public void setupSuiteScopeCluster() throws Exception { ) ); } - prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( @@ -281,15 +265,7 @@ private void getMultiSortDocs(List builders) throws IOExcep client().admin() .indices() .prepareCreate("sort_idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); for (int i = 1; i <= 3; i++) { @@ -1262,7 +1238,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=keyword") + prepareCreate("cache_test_idx").setMapping("d", "type=keyword") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java index 7996e2bee44c1..147f451c14de8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java @@ -491,7 +491,7 @@ public void testAsSubAgg() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java index 9549aad5399b5..cd0a649659c6e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java @@ -869,7 +869,7 @@ private void checkUpperLowerBounds(ExtendedStats stats, double sigma) { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java index 7aa602fff2ee8..20fc6aaee20c9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java @@ -585,7 +585,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java index 68f8cf6da575a..2660dbe0a88ed 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java @@ -554,7 +554,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java index 79f1809fc2f3a..226b4dbca18d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java @@ -137,7 +137,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, builders); - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { @@ -516,7 +516,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java index beacf7aa1ccec..27dbc56cf3b79 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java @@ -310,7 +310,7 @@ public void setupSuiteScopeCluster() throws Exception { // "1". then each test will have // to check that this bucket exists with the appropriate sub // aggregations. - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -1183,7 +1183,7 @@ public void testScriptCaching() throws Exception { Script ndRandom = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return Math.random()", Collections.emptyMap()); assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java index 27fc26a114cc4..debdde8e13fe7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java @@ -258,7 +258,7 @@ private void assertShardExecutionState(SearchResponse response, int expectedFail */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java index e9b8c91090695..fe236f04c19e8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java @@ -79,8 +79,7 @@ public void setupSuiteScopeCluster() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - prepareCreate("old_index").addMapping( - "_doc", + prepareCreate("old_index").setMapping( "transit_mode", "type=keyword", "distance", @@ -88,7 +87,7 @@ public void setupSuiteScopeCluster() throws Exception { "route_length_miles", "type=alias,path=distance" ).get(); - prepareCreate("new_index").addMapping("_doc", "transit_mode", "type=keyword", "route_length_miles", "type=double").get(); + prepareCreate("new_index").setMapping("transit_mode", "type=keyword", "route_length_miles", "type=double").get(); List builders = new ArrayList<>(); builders.add(client().prepareIndex("old_index").setSource("transit_mode", "train", "distance", 42.0)); @@ -236,7 +235,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java index 8b28261f7f00b..adf027222d7d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java @@ -497,7 +497,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java index 2da6ac3f9e586..fda15f9b90ea2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java @@ -469,7 +469,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java index 53a3cd4da5446..c3240c5eef7c5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java @@ -135,8 +135,8 @@ public static String randomExecutionHint() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", TERMS_AGGS_FIELD, "type=keyword")); - assertAcked(prepareCreate("field-collapsing").addMapping("type", "group", "type=keyword")); + assertAcked(prepareCreate("idx").setMapping(TERMS_AGGS_FIELD, "type=keyword")); + assertAcked(prepareCreate("field-collapsing").setMapping("group", "type=keyword")); createIndex("empty"); assertAcked( prepareCreate("articles").setMapping( @@ -1143,7 +1143,7 @@ public void testNoStoredFields() throws Exception { public void testScriptCaching() throws Exception { try { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings( Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1) ) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java index 6d3fe1ed3f190..82e667bccc576 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java @@ -238,7 +238,7 @@ public void testMultiValuedScriptWithParams() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java index 590587185b80e..6cd16a47e98d2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java @@ -71,7 +71,7 @@ public class AvgBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java index d7f16b25a46e8..2c7890fb7b1cb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java @@ -103,7 +103,7 @@ public void setupSuiteScopeCluster() throws Exception { createIndex("idx"); createIndex("idx_unmapped"); // TODO: would be nice to have more random data here - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java index cff655e040124..c03ed8277a3b4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java @@ -140,7 +140,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts_empty = new Long[] { 1L, 1L, 2L, 0L, 2L, 2L, 0L, 0L, 0L, 3L, 2L, 1L }; firstDerivValueCounts_empty = new Double[] { null, 0d, 1d, -2d, 2d, 0d, -2d, 0d, 0d, 3d, -1d, -1d }; - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < valueCounts_empty.length; i++) { for (int docs = 0; docs < valueCounts_empty[i]; docs++) { builders.add(client().prepareIndex("empty_bucket_idx").setSource(newDocBuilder(i))); @@ -154,7 +154,7 @@ public void setupSuiteScopeCluster() throws Exception { firstDerivValueCounts_empty_rnd = new Double[numBuckets_empty_rnd]; firstDerivValueCounts_empty_rnd[0] = null; - assertAcked(prepareCreate("empty_bucket_idx_rnd").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx_rnd").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < numBuckets_empty_rnd; i++) { valueCounts_empty_rnd[i] = (long) randomIntBetween(1, 10); // make approximately half of the buckets empty diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java index 4400181eb2226..85fe794b05fc6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java @@ -74,7 +74,7 @@ public class ExtendedStatsBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped", "idx_gappy"); numDocs = randomIntBetween(6, 20); @@ -113,7 +113,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java index 0d63e6d719610..22890620d6b15 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java @@ -85,7 +85,7 @@ public class MaxBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -114,7 +114,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java index 33cc350f10ff1..b3929943f0d02 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java @@ -71,7 +71,7 @@ public class MinBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java index 6728c9f888aeb..1da079781dc63 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java @@ -75,7 +75,7 @@ public class PercentilesBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -104,7 +104,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java index 90b0aba10e40a..e9f34f6aa65d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java @@ -71,7 +71,7 @@ public class StatsBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java index 873c43d8b0f4c..5bd962017c247 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java @@ -71,7 +71,7 @@ public class SumBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java index fedb6b18d93fb..c184d876dcb33 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java @@ -65,7 +65,7 @@ private void testSearchAndRelocateConcurrently(final int numberOfReplicas) throw .indices() .prepareCreate("test") .setSettings(Settings.builder().put("index.number_of_shards", numShards).put("index.number_of_replicas", numberOfReplicas)) - .addMapping("type", "loc", "type=geo_point", "test", "type=text") + .setMapping("loc", "type=geo_point", "test", "type=text") .get(); ensureGreen(); List indexBuilders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java index 7982d9f5781fc..34b202cc09cf7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java @@ -65,7 +65,7 @@ protected int maximumNumberOfReplicas() { public void testFailedSearchWithWrongQuery() throws Exception { logger.info("Start Testing failed search with wrong query"); - assertAcked(prepareCreate("test", 1).addMapping("type", "foo", "type=geo_point")); + assertAcked(prepareCreate("test", 1).setMapping("foo", "type=geo_point")); NumShards test = getNumShards("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java index e28ef3c00a485..837e1e7e23ddf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java @@ -242,7 +242,7 @@ public void testSimpleNested() throws Exception { } public void testRandomNested() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "field1", "type=nested", "field2", "type=nested")); + assertAcked(prepareCreate("idx").setMapping("field1", "type=nested", "field2", "type=nested")); int numDocs = scaledRandomIntBetween(25, 100); List requestBuilders = new ArrayList<>(); @@ -538,7 +538,7 @@ public void testNestedMultipleLayers() throws Exception { // Issue #9723 public void testNestedDefinedAsObject() throws Exception { - assertAcked(prepareCreate("articles").addMapping("article", "comments", "type=nested", "title", "type=text")); + assertAcked(prepareCreate("articles").setMapping("comments", "type=nested", "title", "type=text")); List requests = new ArrayList<>(); requests.add( @@ -852,7 +852,7 @@ public void testMatchesQueriesNestedInnerHits() throws Exception { } public void testNestedSource() throws Exception { - assertAcked(prepareCreate("index1").addMapping("message", "comments", "type=nested")); + assertAcked(prepareCreate("index1").setMapping("comments", "type=nested")); client().prepareIndex("index1") .setId("1") .setSource( @@ -947,7 +947,7 @@ public void testNestedSource() throws Exception { } public void testInnerHitsWithIgnoreUnmapped() throws Exception { - assertAcked(prepareCreate("index1").addMapping("_doc", "nested_type", "type=nested")); + assertAcked(prepareCreate("index1").setMapping("nested_type", "type=nested")); createIndex("index2"); client().prepareIndex("index1").setId("1").setSource("nested_type", Collections.singletonMap("key", "value")).get(); client().prepareIndex("index2").setId("3").setSource("key", "value").get(); @@ -967,7 +967,7 @@ public void testInnerHitsWithIgnoreUnmapped() throws Exception { } public void testUseMaxDocInsteadOfSize() throws Exception { - assertAcked(prepareCreate("index2").addMapping("type", "nested", "type=nested")); + assertAcked(prepareCreate("index2").setMapping("nested", "type=nested")); client().admin() .indices() .prepareUpdateSettings("index2") @@ -990,7 +990,7 @@ public void testUseMaxDocInsteadOfSize() throws Exception { } public void testTooHighResultWindow() throws Exception { - assertAcked(prepareCreate("index2").addMapping("type", "nested", "type=nested")); + assertAcked(prepareCreate("index2").setMapping("nested", "type=nested")); client().prepareIndex("index2") .setId("1") .setSource( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java index 74c2922ebf328..193a48cf0daa6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java @@ -332,9 +332,7 @@ public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOExc // see #3486 public void testHighTermFrequencyDoc() throws IOException { - assertAcked( - prepareCreate("test").addMapping("test", "name", "type=text,term_vector=with_positions_offsets,store=" + randomBoolean()) - ); + assertAcked(prepareCreate("test").setMapping("name", "type=text,term_vector=with_positions_offsets,store=" + randomBoolean())); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 6000; i++) { builder.append("abc").append(" "); @@ -350,8 +348,7 @@ public void testHighTermFrequencyDoc() throws IOException { public void testEnsureNoNegativeOffsets() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "no_long_term", "type=text,term_vector=with_positions_offsets", "long_term", @@ -620,8 +617,7 @@ public void testSourceLookupHighlightingUsingPostingsHighlighter() throws Except public void testHighlightIssue1994() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "title", "type=text,store=false", "titleTV", @@ -697,8 +693,7 @@ public void testGlobalHighlightingSettingsOverriddenAtFieldLevel() { // Issue #5175 public void testHighlightingOnWildcardFields() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "field-postings", "type=text,index_options=offsets", "field-fvh", @@ -1277,7 +1272,7 @@ public XContentBuilder type1TermVectorMapping() throws IOException { } public void testSameContent() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1305,7 +1300,7 @@ public void testSameContent() throws Exception { } public void testFastVectorHighlighterOffsetParameter() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets").get()); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets").get()); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1327,7 +1322,7 @@ public void testFastVectorHighlighterOffsetParameter() throws Exception { } public void testEscapeHtml() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < indexRequestBuilders.length; i++) { @@ -1348,7 +1343,7 @@ public void testEscapeHtml() throws Exception { } public void testEscapeHtmlVector() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1547,7 +1542,7 @@ public void testMultiMapperNoVectorFromSource() throws Exception { } public void testFastVectorHighlighterShouldFailIfNoTermVectors() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=no")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=no")); ensureGreen(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1584,9 +1579,7 @@ public void testFastVectorHighlighterShouldFailIfNoTermVectors() throws Exceptio } public void testDisableFastVectorHighlighter() throws Exception { - assertAcked( - prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets,analyzer=classic")); ensureGreen(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1645,7 +1638,7 @@ public void testDisableFastVectorHighlighter() throws Exception { } public void testFSHHighlightAllMvFragments() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "tags", "type=text,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("tags", "type=text,term_vector=with_positions_offsets")); ensureGreen(); client().prepareIndex("test") .setId("1") @@ -1737,7 +1730,7 @@ public void testCommonTermsTermVector() throws IOException { } public void testPlainHighlightDifferentFragmenter() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setMapping("tags", "type=text")); ensureGreen(); client().prepareIndex("test") .setId("1") @@ -1824,8 +1817,7 @@ public void testPlainHighlighterMultipleFields() { public void testFastVectorHighlighterMultipleFields() { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "field1", "type=text,term_vector=with_positions_offsets", "field2", @@ -1849,7 +1841,7 @@ public void testFastVectorHighlighterMultipleFields() { } public void testMissingStoredField() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "highlight_field", "type=text,store=true")); + assertAcked(prepareCreate("test").setMapping("highlight_field", "type=text,store=true")); ensureGreen(); client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("field", "highlight").endObject()).get(); refresh(); @@ -1869,8 +1861,7 @@ public void testMissingStoredField() throws Exception { // Issue #3211 public void testNumericHighlighting() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "test", + prepareCreate("test").setMapping( "text", "type=text", "byte", @@ -1911,7 +1902,7 @@ public void testResetTwice() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(indexSettings()).put("analysis.analyzer.my_analyzer.type", "mock_whitespace").build() - ).addMapping("type", "text", "type=text,analyzer=my_analyzer") + ).setMapping("text", "type=text,analyzer=my_analyzer") ); ensureGreen(); client().prepareIndex("test").setId("1").setSource("text", "opensearch test").get(); @@ -1927,8 +1918,7 @@ public void testResetTwice() throws Exception { public void testHighlightUsesHighlightQuery() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -1974,8 +1964,7 @@ private static String randomStoreField() { public void testHighlightNoMatchSize() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2085,8 +2074,7 @@ public void testHighlightNoMatchSize() throws IOException { public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2181,8 +2169,7 @@ public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException { public void testHighlightNoMatchSizeNumberOfFragments() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2506,7 +2493,7 @@ public void testPostingsHighlighterOrderByScore() throws Exception { } public void testPostingsHighlighterEscapeHtml() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text," + randomStoreField() + "index_options=offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text," + randomStoreField() + "index_options=offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -3342,7 +3329,7 @@ public void testHighlightQueryRewriteDatesWithNow() throws Exception { client().admin() .indices() .prepareCreate("index-1") - .addMapping("type", "d", "type=date", "field", "type=text,store=true,term_vector=with_positions_offsets") + .setMapping("d", "type=date", "field", "type=text,store=true,term_vector=with_positions_offsets") .setSettings(Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) .get() ); @@ -3461,9 +3448,7 @@ public void testWithNestedQuery() throws Exception { public void testWithNormalizer() throws Exception { Builder builder = Settings.builder().put(indexSettings()).putList("index.analysis.normalizer.my_normalizer.filter", "lowercase"); - assertAcked( - prepareCreate("test").setSettings(builder.build()).addMapping("doc", "keyword", "type=keyword,normalizer=my_normalizer") - ); + assertAcked(prepareCreate("test").setSettings(builder.build()).setMapping("keyword", "type=keyword,normalizer=my_normalizer")); ensureGreen(); client().prepareIndex("test") @@ -3485,7 +3470,7 @@ public void testWithNormalizer() throws Exception { } public void testDisableHighlightIdField() throws Exception { - assertAcked(prepareCreate("test").addMapping("doc", "keyword", "type=keyword")); + assertAcked(prepareCreate("test").setMapping("keyword", "type=keyword")); ensureGreen(); client().prepareIndex("test") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java index aed2975ed3234..dacf388e2faa0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java @@ -222,8 +222,8 @@ public void testWithIndexAlias() { } public void testWithIndexFilter() throws InterruptedException { - assertAcked(prepareCreate("index-1").addMapping("_doc", "timestamp", "type=date", "field1", "type=keyword")); - assertAcked(prepareCreate("index-2").addMapping("_doc", "timestamp", "type=date", "field1", "type=long")); + assertAcked(prepareCreate("index-1").setMapping("timestamp", "type=date", "field1", "type=keyword")); + assertAcked(prepareCreate("index-2").setMapping("timestamp", "type=date", "field1", "type=long")); List reqs = new ArrayList<>(); reqs.add(client().prepareIndex("index-1").setSource("timestamp", "2015-07-08")); 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 46d47d838f68b..25782f8dc18db 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java @@ -444,7 +444,7 @@ public void testScriptFieldWithNanos() throws Exception { } public void testIdBasedScriptFields() throws Exception { - prepareCreate("test").addMapping("type1", "num1", "type=long").get(); + prepareCreate("test").setMapping("num1", "type=long").get(); int numDocs = randomIntBetween(1, 30); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[numDocs]; @@ -839,7 +839,7 @@ public void testGetFieldsComplexField() throws Exception { // see #8203 public void testSingleValueFieldDatatField() throws ExecutionException, InterruptedException { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "test_field", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("test_field", "type=keyword").get()); indexRandom(true, client().prepareIndex("test").setId("1").setSource("test_field", "foobar")); refresh(); SearchResponse searchResponse = client().prepareSearch("test") @@ -1114,8 +1114,7 @@ public void testDocValueFields() throws Exception { public void testScriptFields() throws Exception { assertAcked( - prepareCreate("index").addMapping( - "type", + prepareCreate("index").setMapping( "s", "type=keyword", "l", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java index 670f5e65eb575..0701e96b71f38 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java @@ -168,8 +168,7 @@ public void testConsistentHitsWithSameSeed() throws Exception { public void testScoreAccessWithinScript() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( "body", "type=text", "index", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java index c2d75b6aa55af..d0b017732b270 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java @@ -66,8 +66,7 @@ protected void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked( - prepareCreate("test").setSettings(settings) - .addMapping("type1", "location", "type=geo_point", "alias", "type=alias,path=location") + prepareCreate("test").setSettings(settings).setMapping("location", "type=geo_point", "alias", "type=alias,path=location") ); ensureGreen(); 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 7315155e39520..89eb6038d8110 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java @@ -136,9 +136,7 @@ public void testOrientationPersistence() throws Exception { */ public void testIgnoreMalformed() throws Exception { // create index - assertAcked( - client().admin().indices().prepareCreate("test").addMapping("geometry", "shape", "type=geo_shape,ignore_malformed=true").get() - ); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,ignore_malformed=true").get()); ensureGreen(); // test self crossing ccw poly not crossing dateline @@ -188,7 +186,7 @@ public void testIgnoreMalformed() throws Exception { public void testMappingUpdate() throws Exception { // create index - assertAcked(client().admin().indices().prepareCreate("test").addMapping("geometry", "shape", "type=geo_shape").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape").get()); ensureGreen(); String update = "{\n" diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java index 28b00acd21479..61af97d46e7f3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java @@ -131,11 +131,7 @@ public void testOrientationPersistence() throws Exception { public void testIgnoreMalformed() throws Exception { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("geometry", "shape", "type=geo_shape,tree=quadtree,ignore_malformed=true") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,tree=quadtree,ignore_malformed=true").get() ); ensureGreen(); @@ -226,11 +222,7 @@ public void testIndexShapeRouting() throws Exception { public void testLegacyCircle() throws Exception { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("geometry", "shape", "type=geo_shape,strategy=recursive,tree=geohash") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,strategy=recursive,tree=geohash").get() ); ensureGreen(); @@ -255,11 +247,7 @@ public void testDisallowExpensiveQueries() throws InterruptedException, IOExcept try { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("_doc", "shape", "type=geo_shape,strategy=recursive,tree=geohash") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,strategy=recursive,tree=geohash").get() ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java index 69b2e655dd0ad..b3253b036bda6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java @@ -42,7 +42,6 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.MoreLikeThisQueryBuilder; import org.opensearch.index.query.MoreLikeThisQueryBuilder.Item; import org.opensearch.index.query.QueryBuilder; @@ -183,7 +182,7 @@ public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Excep public void testSimpleMoreLikeOnLongField() throws Exception { logger.info("Creating index test"); - assertAcked(prepareCreate("test").addMapping("type1", "some_long", "type=long")); + assertAcked(prepareCreate("test").setMapping("some_long", "type=long")); logger.info("Running Cluster Health"); assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); @@ -598,7 +597,7 @@ public void testSimpleMoreLikeThisIds() throws Exception { public void testMoreLikeThisMultiValueFields() throws Exception { logger.info("Creating the index ..."); assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=keyword") + prepareCreate("test").setMapping("text", "type=text,analyzer=keyword") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) ); ensureGreen(); @@ -632,7 +631,7 @@ public void testMoreLikeThisMultiValueFields() throws Exception { public void testMinimumShouldMatch() throws ExecutionException, InterruptedException { logger.info("Creating the index ..."); assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=whitespace") + prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) ); ensureGreen(); @@ -693,15 +692,7 @@ public void testMoreLikeThisArtificialDocs() throws Exception { public void testMoreLikeThisMalformedArtificialDocs() throws Exception { logger.info("Creating the index ..."); - assertAcked( - prepareCreate("test").addMapping( - MapperService.SINGLE_MAPPING_NAME, - "text", - "type=text,analyzer=whitespace", - "date", - "type=date" - ) - ); + assertAcked(prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace", "date", "type=date")); ensureGreen("test"); logger.info("Creating an index with a single document ..."); @@ -790,9 +781,7 @@ public void testMoreLikeThisUnlike() throws ExecutionException, InterruptedExcep } public void testSelectFields() throws IOException, ExecutionException, InterruptedException { - assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=whitespace", "text1", "type=text,analyzer=whitespace") - ); + assertAcked(prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace", "text1", "type=text,analyzer=whitespace")); ensureGreen("test"); indexRandom( 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 e3c1abff5d206..d2d23cd47fc01 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java @@ -73,7 +73,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { public void testSimpleNested() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "nested1", "type=nested")); + assertAcked(prepareCreate("test").setMapping("nested1", "type=nested")); ensureGreen(); // check on no data, see it works @@ -1597,7 +1597,7 @@ public void testCheckFixedBitSetCache() throws Exception { if (loadFixedBitSeLazily) { settingsBuilder.put("index.load_fixed_bitset_filters_eagerly", false); } - assertAcked(prepareCreate("test").setSettings(settingsBuilder).addMapping("type")); + assertAcked(prepareCreate("test").setSettings(settingsBuilder)); client().prepareIndex("test").setId("0").setSource("field", "value").get(); client().prepareIndex("test").setId("1").setSource("field", "value").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java index 7d63db78e205a..f3d1a479f1b46 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java @@ -108,7 +108,7 @@ protected void setupSuiteScopeCluster() throws Exception { .indices() .prepareCreate("idx") .setSettings(org.opensearch.common.collect.Map.of("number_of_shards", 1, "number_of_replicas", 0)) - .addMapping("type", STRING_FIELD, "type=keyword", NUMBER_FIELD, "type=integer", TAG_FIELD, "type=keyword") + .setMapping(STRING_FIELD, "type=keyword", NUMBER_FIELD, "type=integer", TAG_FIELD, "type=keyword") .get() ); List builders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java index 66b42fe266887..d87bbfb1fb69c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java @@ -1015,7 +1015,7 @@ public void testFuzzyFieldLevelBoosting() throws InterruptedException, Execution CreateIndexRequestBuilder builder = prepareCreate(idx).setSettings( Settings.builder().put(indexSettings()).put(SETTING_NUMBER_OF_SHARDS, 3).put(SETTING_NUMBER_OF_REPLICAS, 0) ); - assertAcked(builder.addMapping("type", "title", "type=text", "body", "type=text")); + assertAcked(builder.setMapping("title", "type=text", "body", "type=text")); ensureGreen(); List builders = new ArrayList<>(); builders.add(client().prepareIndex(idx).setId("1").setSource("title", "foo", "body", "bar")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java index 59f9e020df0d9..d736365a6e236 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java @@ -88,7 +88,7 @@ protected Map, Object>> pluginScripts() { // 2) score is calculated based on a script with params // 3) min score applied public void testScriptScore() { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + (i % 2), "field2", i).get(); @@ -114,7 +114,7 @@ public void testScriptScore() { } public void testScriptScoreBoolQuery() { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + i, "field2", i).get(); @@ -136,7 +136,7 @@ public void testScriptScoreBoolQuery() { public void testRewrittenQuery() { assertAcked( prepareCreate("test-index2").setSettings(Settings.builder().put("index.number_of_shards", 1)) - .addMapping("_doc", "field1", "type=date", "field2", "type=double") + .setMapping("field1", "type=date", "field2", "type=double") ); client().prepareIndex("test-index2").setId("1").setSource("field1", "2019-09-01", "field2", 1).get(); client().prepareIndex("test-index2").setId("2").setSource("field1", "2019-10-01", "field2", 2).get(); @@ -154,7 +154,7 @@ public void testRewrittenQuery() { public void testDisallowExpensiveQueries() { try { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + (i % 2), "field2", i).get(); 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 fa2d79ecb2017..fed5561c1df64 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java @@ -211,7 +211,7 @@ public void testIssue3177() { } public void testIndexOptions() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=text,index_options=docs")); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,index_options=docs")); indexRandom( true, client().prepareIndex("test").setId("1").setSource("field1", "quick brown fox", "field2", "quick brown fox"), @@ -337,7 +337,7 @@ public void testCommonTermsQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type1", "field1", "type=text,analyzer=whitespace") + .setMapping("field1", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) .get(); indexRandom( @@ -479,7 +479,7 @@ public void testLowercaseExpandedTerms() { public void testDateRangeInQueryString() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date", "future", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date", "future", "type=date")); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); String aMonthAgo = DateTimeFormatter.ISO_LOCAL_DATE.format(now.minusMonths(1)); @@ -505,7 +505,7 @@ public void testDateRangeInQueryString() { public void testDateRangeInQueryStringWithTimeZone_7880() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date")); ZoneId timeZone = randomZone(); String now = DateFormatter.forPattern("strict_date_optional_time").format(Instant.now().atZone(timeZone)); @@ -523,7 +523,7 @@ public void testDateRangeInQueryStringWithTimeZone_7880() { public void testDateRangeInQueryStringWithTimeZone_10477() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date")); client().prepareIndex("test").setId("1").setSource("past", "2015-04-05T23:00:00+0000").get(); client().prepareIndex("test").setId("2").setSource("past", "2015-04-06T00:00:00+0000").get(); @@ -732,7 +732,7 @@ public void testFiltersWithCustomCacheKey() throws Exception { } public void testMatchQueryNumeric() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "long", "type=long", "double", "type=double")); + assertAcked(prepareCreate("test").setMapping("long", "type=long", "double", "type=double")); indexRandom( true, @@ -752,7 +752,7 @@ public void testMatchQueryNumeric() throws Exception { } public void testMatchQueryFuzzy() throws Exception { - assertAcked(prepareCreate("test").addMapping("_doc", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); indexRandom( true, @@ -846,9 +846,7 @@ public void testMultiMatchQuery() throws Exception { } public void testMatchQueryZeroTermsQuery() { - assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic")); client().prepareIndex("test").setId("1").setSource("field1", "value1").get(); client().prepareIndex("test").setId("2").setSource("field1", "value2").get(); refresh(); @@ -869,9 +867,7 @@ public void testMatchQueryZeroTermsQuery() { } public void testMultiMatchQueryZeroTermsQuery() { - assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic")); client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value2").get(); client().prepareIndex("test").setId("2").setSource("field1", "value3", "field2", "value4").get(); refresh(); @@ -1039,7 +1035,7 @@ public void testSpecialRangeSyntaxInQueryString() { } public void testEmptytermsQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "term", "type=text")); + assertAcked(prepareCreate("test").setMapping("term", "type=text")); indexRandom( true, @@ -1059,7 +1055,7 @@ public void testEmptytermsQuery() throws Exception { } public void testTermsQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "str", "type=text", "lng", "type=long", "dbl", "type=double")); + assertAcked(prepareCreate("test").setMapping("str", "type=text", "lng", "type=long", "dbl", "type=double")); indexRandom( true, @@ -1117,7 +1113,7 @@ public void testTermsQuery() throws Exception { } public void testTermsLookupFilter() throws Exception { - assertAcked(prepareCreate("lookup").addMapping("type", "terms", "type=text", "other", "type=text")); + assertAcked(prepareCreate("lookup").setMapping("terms", "type=text", "other", "type=text")); assertAcked( prepareCreate("lookup2").setMapping( jsonBuilder().startObject() @@ -1133,8 +1129,8 @@ public void testTermsLookupFilter() throws Exception { .endObject() ) ); - assertAcked(prepareCreate("lookup3").addMapping("type", "_source", "enabled=false", "terms", "type=text")); - assertAcked(prepareCreate("test").addMapping("type", "term", "type=text")); + assertAcked(prepareCreate("lookup3").setMapping("_source", "enabled=false", "terms", "type=text")); + assertAcked(prepareCreate("test").setMapping("term", "type=text")); indexRandom( true, @@ -1283,8 +1279,7 @@ public void testBasicQueryById() throws Exception { public void testNumericTermsAndRanges() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "num_byte", "type=byte", "num_short", @@ -1400,8 +1395,7 @@ public void testNumericTermsAndRanges() throws Exception { public void testNumericRangeFilter_2826() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "num_byte", "type=byte", "num_short", @@ -1780,7 +1774,7 @@ public void testDateProvidedAsNumber() throws InterruptedException { } public void testRangeQueryWithTimeZone() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "date", "type=date", "num", "type=integer")); + assertAcked(prepareCreate("test").setMapping("date", "type=date", "num", "type=integer")); indexRandom( true, @@ -1955,7 +1949,7 @@ public void testQueryStringParserCache() throws Exception { } public void testRangeQueryRangeFields_24744() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "int_range", "type=integer_range")); + assertAcked(prepareCreate("test").setMapping("int_range", "type=integer_range")); client().prepareIndex("test") .setId("1") @@ -2064,7 +2058,7 @@ public void testWildcardQueryNormalizationOnKeywordField() { .put("index.analysis.normalizer.lowercase_normalizer.type", "custom") .putList("index.analysis.normalizer.lowercase_normalizer.filter", "lowercase") .build() - ).addMapping("_doc", "field1", "type=keyword,normalizer=lowercase_normalizer") + ).setMapping("field1", "type=keyword,normalizer=lowercase_normalizer") ); client().prepareIndex("test").setId("1").setSource("field1", "Bbb Aaa").get(); refresh(); @@ -2091,7 +2085,7 @@ public void testWildcardQueryNormalizationOnTextField() { .put("index.analysis.analyzer.lowercase_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.lowercase_analyzer.filter", "lowercase") .build() - ).addMapping("_doc", "field1", "type=text,analyzer=lowercase_analyzer") + ).setMapping("field1", "type=text,analyzer=lowercase_analyzer") ); client().prepareIndex("test").setId("1").setSource("field1", "Bbb Aaa").get(); refresh(); @@ -2119,7 +2113,7 @@ public void testWildcardQueryNormalizationKeywordSpecialCharacters() { .put("index.analysis.normalizer.no_wildcard.type", "custom") .put("index.analysis.normalizer.no_wildcard.char_filter", "no_wildcard") .build() - ).addMapping("_doc", "field", "type=keyword,normalizer=no_wildcard") + ).setMapping("field", "type=keyword,normalizer=no_wildcard") ); client().prepareIndex("test").setId("1").setSource("field", "label-1").get(); refresh(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java index 3bc9eb5b25261..5e45fd8d0ad2a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java @@ -240,7 +240,7 @@ public void testCustomScriptBoost() throws Exception { public void testDisallowExpensiveQueries() { try { - assertAcked(prepareCreate("test-index").addMapping("_doc", "num1", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("num1", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("num1", i).get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java b/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java index 5c56671384868..3818566e2eb11 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java @@ -541,7 +541,7 @@ public void testStringSortMissingAscTerminates() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("test", "no_field", "type=keyword", "some_field", "type=keyword") + ).setMapping("no_field", "type=keyword", "some_field", "type=keyword") ); client().prepareIndex("test").setId("1").setSource("some_field", "test").get(); refresh(); @@ -718,7 +718,7 @@ public void testScrollRewrittenToMatchNoDocs() { .indices() .prepareCreate("test") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)) - .addMapping("_doc", "created_date", "type=date,format=yyyy-MM-dd") + .setMapping("created_date", "type=date,format=yyyy-MM-dd") ); client().prepareIndex("test").setId("1").setSource("created_date", "2020-01-01").get(); client().prepareIndex("test").setId("2").setSource("created_date", "2020-01-02").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java index aae6c1dec48b3..926e21294ffc8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java @@ -59,13 +59,10 @@ public class SearchAfterIT extends OpenSearchIntegTestCase { private static final String INDEX_NAME = "test"; - private static final String TYPE_NAME = "type1"; private static final int NUM_DOCS = 100; public void testsShouldFail() throws Exception { - assertAcked( - client().admin().indices().prepareCreate("test").addMapping("type1", "field1", "type=long", "field2", "type=keyword").get() - ); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=long", "field2", "type=keyword").get()); ensureGreen(); indexRandom(true, client().prepareIndex("test").setId("0").setSource("field1", 0, "field2", "toto")); { @@ -159,7 +156,7 @@ public void testsShouldFail() throws Exception { } public void testWithNullStrings() throws InterruptedException { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", "field2", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field2", "type=keyword").get()); ensureGreen(); indexRandom( true, @@ -219,7 +216,7 @@ public void testWithSimpleTypes() throws Exception { if (reqSize == 0) { reqSize = 1; } - assertSearchFromWithSortValues(INDEX_NAME, TYPE_NAME, documents, reqSize); + assertSearchFromWithSortValues(INDEX_NAME, documents, reqSize); } private static class ListComparator implements Comparator { @@ -250,10 +247,10 @@ public int compare(List o1, List o2) { private ListComparator LST_COMPARATOR = new ListComparator(); - private void assertSearchFromWithSortValues(String indexName, String typeName, List documents, int reqSize) throws Exception { + private void assertSearchFromWithSortValues(String indexName, List documents, int reqSize) throws Exception { int numFields = documents.get(0).size(); { - createIndexMappingsFromObjectType(indexName, typeName, documents.get(0)); + createIndexMappingsFromObjectType(indexName, documents.get(0)); List requests = new ArrayList<>(); for (int i = 0; i < documents.size(); i++) { XContentBuilder builder = jsonBuilder(); @@ -289,7 +286,7 @@ private void assertSearchFromWithSortValues(String indexName, String typeName, L } } - private void createIndexMappingsFromObjectType(String indexName, String typeName, List types) { + private void createIndexMappingsFromObjectType(String indexName, List types) { CreateIndexRequestBuilder indexRequestBuilder = client().admin().indices().prepareCreate(indexName); List mappings = new ArrayList<>(); int numFields = types.size(); @@ -323,7 +320,7 @@ private void createIndexMappingsFromObjectType(String indexName, String typeName fail("Can't match type [" + type + "]"); } } - indexRequestBuilder.addMapping(typeName, mappings.toArray(new String[0])).get(); + indexRequestBuilder.setMapping(mappings.toArray(new String[0])).get(); ensureGreen(); } 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 0652b38228ec5..7382d4e157bc4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java @@ -295,7 +295,7 @@ public void testSimpleTerminateAfterCount() throws Exception { 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(MapperService.SINGLE_MAPPING_NAME, "rank", "type=integer").get(); + ).setMapping("rank", "type=integer").get(); ensureGreen(); int max = randomIntBetween(3, 29); List docbuilders = new ArrayList<>(max); @@ -498,7 +498,7 @@ public void testTooLargeRescoreOkByDynamicResultWindowSetting() throws Exception } public void testQueryNumericFieldWithRegex() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "num", "type=integer")); + assertAcked(prepareCreate("idx").setMapping("num", "type=integer")); ensureGreen("idx"); try { @@ -510,7 +510,7 @@ public void testQueryNumericFieldWithRegex() throws Exception { } public void testTermQueryBigInt() throws Exception { - prepareCreate("idx").addMapping("type", "field", "type=keyword").get(); + prepareCreate("idx").setMapping("field", "type=keyword").get(); ensureGreen("idx"); client().prepareIndex("idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java index 3d1d407b386e1..4bf4cd138cbd1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java @@ -137,7 +137,7 @@ public void testIssue8226() { final boolean useMapping = randomBoolean(); for (int i = 0; i < numIndices; i++) { if (useMapping) { - assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test")).addMapping("foo", "entry", "type=long")); + assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test")).setMapping("entry", "type=long")); } else { assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test"))); } @@ -243,7 +243,7 @@ public void testIssue6614() throws ExecutionException, InterruptedException { } public void testTrackScores() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", "svalue", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("svalue", "type=keyword").get()); ensureGreen(); index( "test", @@ -354,7 +354,7 @@ public void testRandomSorting() throws IOException, InterruptedException, Execut } public void test3078() { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "field", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field", "type=keyword").get()); ensureGreen(); for (int i = 1; i < 101; i++) { @@ -492,7 +492,7 @@ public void testScoreSortDirectionWithFunctionScore() throws Exception { } public void testIssue2986() { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("post", "field1", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=keyword").get()); client().prepareIndex("test").setId("1").setSource("{\"field1\":\"value1\"}", XContentType.JSON).get(); client().prepareIndex("test").setId("2").setSource("{\"field1\":\"value2\"}", XContentType.JSON).get(); @@ -516,7 +516,7 @@ public void testIssue2991() { } catch (Exception e) { // ignore } - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("tag", "type=keyword").get()); ensureGreen(); client().prepareIndex("test").setId("1").setSource("tag", "alpha").get(); refresh(); @@ -1610,11 +1610,11 @@ public void testSortDuelBetweenSingleShardAndMultiShardIndex() throws Exception assertAcked( prepareCreate("test1").setSettings( Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(2, maximumNumberOfShards())) - ).addMapping("type", sortField, "type=long").get() + ).setMapping(sortField, "type=long").get() ); assertAcked( prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) - .addMapping("type", sortField, "type=long") + .setMapping(sortField, "type=long") .get() ); @@ -1650,7 +1650,7 @@ public void testCustomFormat() throws Exception { // Use an ip field, which uses different internal/external // representations of values, to make sure values are both correctly // rendered and parsed (search_after) - assertAcked(prepareCreate("test").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("test").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("test").setId("1").setSource("ip", "192.168.1.7"), @@ -1671,7 +1671,7 @@ public void testCustomFormat() throws Exception { } public void testScriptFieldSort() throws Exception { - assertAcked(prepareCreate("test").addMapping("t", "keyword", "type=keyword", "number", "type=integer")); + assertAcked(prepareCreate("test").setMapping("keyword", "type=keyword", "number", "type=integer")); ensureGreen(); final int numDocs = randomIntBetween(10, 20); IndexRequestBuilder[] indexReqs = new IndexRequestBuilder[numDocs]; @@ -1721,10 +1721,8 @@ public void testScriptFieldSort() throws Exception { public void testFieldAlias() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - assertAcked( - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance") - ); - assertAcked(prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double")); + assertAcked(prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance")); + assertAcked(prepareCreate("new_index").setMapping("route_length_miles", "type=double")); ensureGreen("old_index", "new_index"); List builders = new ArrayList<>(); @@ -1749,10 +1747,8 @@ public void testFieldAlias() throws Exception { public void testFieldAliasesWithMissingValues() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - assertAcked( - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance") - ); - assertAcked(prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double")); + assertAcked(prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance")); + assertAcked(prepareCreate("new_index").setMapping("route_length_miles", "type=double")); ensureGreen("old_index", "new_index"); List builders = new ArrayList<>(); @@ -1775,9 +1771,9 @@ public void testFieldAliasesWithMissingValues() throws Exception { } public void testCastNumericType() throws Exception { - assertAcked(prepareCreate("index_double").addMapping("_doc", "field", "type=double")); - assertAcked(prepareCreate("index_long").addMapping("_doc", "field", "type=long")); - assertAcked(prepareCreate("index_float").addMapping("_doc", "field", "type=float")); + assertAcked(prepareCreate("index_double").setMapping("field", "type=double")); + assertAcked(prepareCreate("index_long").setMapping("field", "type=long")); + assertAcked(prepareCreate("index_float").setMapping("field", "type=float")); ensureGreen("index_double", "index_long", "index_float"); List builders = new ArrayList<>(); @@ -1821,8 +1817,8 @@ public void testCastNumericType() throws Exception { } public void testCastDate() throws Exception { - assertAcked(prepareCreate("index_date").addMapping("_doc", "field", "type=date")); - assertAcked(prepareCreate("index_date_nanos").addMapping("_doc", "field", "type=date_nanos")); + assertAcked(prepareCreate("index_date").setMapping("field", "type=date")); + assertAcked(prepareCreate("index_date_nanos").setMapping("field", "type=date_nanos")); ensureGreen("index_date", "index_date_nanos"); List builders = new ArrayList<>(); @@ -1937,7 +1933,7 @@ public void testCastDate() throws Exception { } public void testCastNumericTypeExceptions() throws Exception { - assertAcked(prepareCreate("index").addMapping("_doc", "keyword", "type=keyword", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("keyword", "type=keyword", "ip", "type=ip")); ensureGreen("index"); for (String invalidField : new String[] { "keyword", "ip" }) { for (String numericType : new String[] { "long", "double", "date", "date_nanos" }) { @@ -1957,7 +1953,7 @@ public void testCastNumericTypeExceptions() throws Exception { public void testLongSortOptimizationCorrectResults() { assertAcked( prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2)) - .addMapping("_doc", "long_field", "type=long") + .setMapping("long_field", "type=long") .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java index c283444666f0b..aebd83592e793 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java @@ -83,7 +83,7 @@ public void testManyToManyGeoPoints() throws ExecutionException, InterruptedExce */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(3, 2), new GeoPoint(4, 1) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -174,7 +174,7 @@ public void testSingeToManyAvgMedian() throws ExecutionException, InterruptedExc */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(0, 1), new GeoPoint(0, 4), new GeoPoint(0, 10) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -248,7 +248,7 @@ public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionExcept */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(2.5, 1), new GeoPoint(2.75, 2), new GeoPoint(3, 3), new GeoPoint(3.25, 4) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -306,7 +306,7 @@ public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionExcept } public void testSinglePointGeoDistanceSort() throws ExecutionException, InterruptedException, IOException { - assertAcked(prepareCreate("index").addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setMapping(LOCATION_FIELD, "type=geo_point")); indexRandom( true, client().prepareIndex("index") @@ -382,8 +382,7 @@ private static void checkCorrectSortOrderForGeoSort(SearchResponse searchRespons public void testCrossIndexIgnoreUnmapped() throws Exception { assertAcked( - prepareCreate("test1").addMapping("type", "str_field", "type=keyword", "long_field", "type=long", "double_field", "type=double") - .get() + prepareCreate("test1").setMapping("str_field", "type=keyword", "long_field", "type=long", "double_field", "type=double").get() ); assertAcked(prepareCreate("test2").get()); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java index 758d749f0be8e..4f6dd89285bee 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java @@ -69,7 +69,7 @@ public void testSimple() { } public void testInnerHits() { - assertAcked(prepareCreate("test").addMapping("_doc", "nested", "type=nested")); + assertAcked(prepareCreate("test").setMapping("nested", "type=nested")); ensureGreen(); client().prepareIndex("test").setId("1").setSource("field", "value", "nested", Collections.singletonMap("title", "foo")).get(); refresh(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java index cd3921d91a3ed..07e58db836740 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java @@ -97,7 +97,7 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase { // see #3196 public void testSuggestAcrossMultipleIndices() throws IOException { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "abcd"); @@ -111,7 +111,7 @@ public void testSuggestAcrossMultipleIndices() throws IOException { .text("abcd"); logger.info("--> run suggestions with one index"); searchSuggest("test", termSuggest); - assertAcked(prepareCreate("test_1").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test_1").setMapping("text", "type=text")); ensureGreen(); index("test_1", "type1", "1", "text", "ab cd"); @@ -342,7 +342,7 @@ public void testUnmappedField() throws IOException, InterruptedException, Execut } public void testSimple() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "abcd"); @@ -367,7 +367,7 @@ public void testSimple() throws Exception { } public void testEmpty() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "bar"); @@ -386,7 +386,7 @@ public void testEmpty() throws Exception { } public void testEmptyIndex() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); // use SuggestMode.ALWAYS, otherwise the results can vary between requests. @@ -412,7 +412,7 @@ public void testEmptyIndex() throws Exception { } public void testWithMultipleCommands() throws Exception { - assertAcked(prepareCreate("test").addMapping("typ1", "field1", "type=text", "field2", "type=text")); + assertAcked(prepareCreate("test").setMapping("field1", "type=text", "field2", "type=text")); ensureGreen(); index("test", "typ1", "1", "field1", "prefix_abcd", "field2", "prefix_efgh"); @@ -516,7 +516,7 @@ public void testSizeAndSort() throws Exception { // see #2817 public void testStopwordsOnlyPhraseSuggest() throws IOException { assertAcked( - prepareCreate("test").addMapping("typ1", "body", "type=text,analyzer=stopwd") + prepareCreate("test").setMapping("body", "type=text,analyzer=stopwd") .setSettings( Settings.builder() .put("index.analysis.analyzer.stopwd.tokenizer", "standard") diff --git a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java index c6ec91a6ab078..16b0e8829b1a7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java @@ -542,7 +542,7 @@ public void testUpdateRequestWithScriptAndShouldUpsertDoc() throws Exception { } public void testContextVariables() throws Exception { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias"))); ensureGreen(); // Index some documents diff --git a/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java index a97c4a0d13f12..86a51e7367ade 100644 --- a/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java @@ -297,7 +297,7 @@ public void testExplainNoQuery() { public void testExplainFilteredAlias() { assertAcked( - prepareCreate("test").addMapping("test", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .addAlias(new Alias("alias").filter(QueryBuilders.termQuery("field", "value1"))) ); ensureGreen(); @@ -318,7 +318,7 @@ public void testExplainWithRewriteValidateQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping(MapperService.SINGLE_MAPPING_NAME, "field", "type=text,analyzer=whitespace") + .setMapping("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(); @@ -380,7 +380,7 @@ public void testExplainWithRewriteValidateQueryAllShards() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping(MapperService.SINGLE_MAPPING_NAME, "field", "type=text,analyzer=whitespace") + .setMapping("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 @@ -484,7 +484,7 @@ public void testExplainTermsQueryWithLookup() throws Exception { client().admin() .indices() .prepareCreate("twitter") - .addMapping("_doc", "user", "type=integer", "followers", "type=integer") + .setMapping("user", "type=integer", "followers", "type=integer") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put("index.number_of_routing_shards", 2)) .get(); client().prepareIndex("twitter").setId("1").setSource("followers", new int[] { 1, 2, 3 }).get(); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java index ac80b3eb6a155..cc99f63c6a844 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -141,10 +141,8 @@ public CreateIndexRequestBuilder setMapping(Map source) { /** * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). - * @deprecated types are being removed */ - @Deprecated - public CreateIndexRequestBuilder addMapping(String type, String... source) { + public CreateIndexRequestBuilder setMapping(String... source) { request.simpleMapping(source); return this; } 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 94bf162303127..5388c0a866c5f 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.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; @@ -58,10 +57,7 @@ protected Collection> getPlugins() { } public void testMappingClusterStateUpdateDoesntChangeExistingIndices() throws Exception { - final IndexService indexService = createIndex( - "test", - client().admin().indices().prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME) - ); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").setMapping()); final CompressedXContent currentMapping = indexService.mapperService().documentMapper().mappingSource(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); @@ -86,7 +82,7 @@ public void testMappingClusterStateUpdateDoesntChangeExistingIndices() throws Ex } public void testClusterStateIsNotChangedWithIdenticalMappings() throws Exception { - createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + createIndex("test", client().admin().indices().prepareCreate("test")); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); @@ -106,7 +102,7 @@ public void testClusterStateIsNotChangedWithIdenticalMappings() throws Exception } public void testMappingVersion() throws Exception { - final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test")); final long previousVersion = indexService.getMetadata().getMappingVersion(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); @@ -122,7 +118,7 @@ public void testMappingVersion() throws Exception { } public void testMappingVersionUnchanged() throws Exception { - final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").setMapping()); final long previousVersion = indexService.getMetadata().getMappingVersion(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); diff --git a/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java b/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java index d7cf873e133df..35c16c9954622 100644 --- a/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java +++ b/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java @@ -55,7 +55,7 @@ public void testQueryRewriteOnRefresh() throws Exception { client().admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=text") + .setMapping("s", "type=text") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) 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 80fd4edc6ac78..0349307ad20ea 100644 --- a/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java @@ -259,7 +259,7 @@ public void testRejectFieldDefinedTwice() throws IOException { } public void testMappingVersion() { - createIndex("test", client().admin().indices().prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME)); + createIndex("test", client().admin().indices().prepareCreate("test")); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); { final long previousVersion = clusterService.state().metadata().index("test").getMappingVersion(); diff --git a/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java b/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java index 1dcda74308f45..61ef0c746995a 100644 --- a/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java +++ b/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java @@ -38,8 +38,7 @@ public class CommonTermsQueryParserTests extends OpenSearchSingleNodeTestCase { public void testWhenParsedQueryIsNullNoNullPointerExceptionIsThrown() { final String index = "test-index"; - final String type = "test-type"; - client().admin().indices().prepareCreate(index).addMapping(type, "name", "type=text,analyzer=stop").execute().actionGet(); + client().admin().indices().prepareCreate(index).setMapping("name", "type=text,analyzer=stop").execute().actionGet(); ensureGreen(); CommonTermsQueryBuilder commonTermsQueryBuilder = new CommonTermsQueryBuilder("name", "the").queryName("query-name"); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java index bf16f70d400fc..d6981d1c34652 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java @@ -55,7 +55,7 @@ protected int numberOfShards() { } protected void createIdx(String keyFieldMapping) { - assertAcked(prepareCreate("idx").addMapping("type", "key", keyFieldMapping)); + assertAcked(prepareCreate("idx").setMapping("key", keyFieldMapping)); } protected static String routing1; // routing key to shard 1 diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java index 9243a1ccd517e..5dd8421bf5fc1 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java @@ -87,8 +87,7 @@ public abstract class AbstractGeoTestCase extends OpenSearchIntegTestCase { public void setupSuiteScopeCluster() throws Exception { createIndex(UNMAPPED_IDX_NAME); assertAcked( - prepareCreate(IDX_NAME).addMapping( - "type", + prepareCreate(IDX_NAME).setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -168,11 +167,10 @@ public void setupSuiteScopeCluster() throws Exception { ); } - assertAcked(prepareCreate(EMPTY_IDX_NAME).addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=geo_point")); + assertAcked(prepareCreate(EMPTY_IDX_NAME).setMapping(SINGLE_VALUED_FIELD_NAME, "type=geo_point")); assertAcked( - prepareCreate(DATELINE_IDX_NAME).addMapping( - "type", + prepareCreate(DATELINE_IDX_NAME).setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -205,8 +203,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( prepareCreate(HIGH_CARD_IDX_NAME).setSettings(Settings.builder().put("number_of_shards", 2)) - .addMapping( - "type", + .setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -247,7 +244,7 @@ public void setupSuiteScopeCluster() throws Exception { client().prepareIndex(IDX_ZERO_NAME) .setSource(jsonBuilder().startObject().array(SINGLE_VALUED_FIELD_NAME, 0.0, 1.0).endObject()) ); - assertAcked(prepareCreate(IDX_ZERO_NAME).addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=geo_point")); + assertAcked(prepareCreate(IDX_ZERO_NAME).setMapping(SINGLE_VALUED_FIELD_NAME, "type=geo_point")); indexRandom(true, builders); ensureSearchable(); diff --git a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java index 4247a2ccabff2..d6c5e4f9a6083 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java @@ -148,7 +148,7 @@ protected XContentBuilder createRandomMapping() throws Exception { public void testShapeFetchingPath() throws Exception { createIndex("shapes"); - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").get(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").get(); String location = "\"geo\" : {\"type\":\"polygon\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}"; @@ -538,14 +538,9 @@ public void testPointQuery() throws Exception { PointBuilder pb = new PointBuilder(pt[0], pt[1]); gcb.shape(pb); if (randomBoolean()) { - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").execute().actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").execute().actionGet(); } else { - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type", "geo", "type=geo_shape,tree=quadtree") - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").execute().actionGet(); } XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); client().prepareIndex("test").setId("1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); @@ -578,14 +573,9 @@ public void testContainsShapeQuery() throws Exception { } if (usePrefixTrees) { - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type", "geo", "type=geo_shape,tree=quadtree") - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").execute().actionGet(); } else { - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").execute().actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").execute().actionGet(); } XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); @@ -805,7 +795,7 @@ public void testQueryRandomGeoCollection() throws Exception { public void testShapeFilterWithDefinedGeoCollection() throws Exception { createIndex("shapes"); - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape,tree=quadtree").get(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").get(); XContentBuilder docSource = jsonBuilder().startObject() .startObject("geo") diff --git a/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java b/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java index c2c2728a348f5..1092bc4f8f47c 100644 --- a/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java +++ b/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java @@ -100,7 +100,7 @@ public static void index01Docs(String type, String settings, OpenSearchIntegTest assertAcked( testCase.prepareCreate(INDEX_NAME) .setSettings(settings, XContentType.JSON) - .addMapping("_doc", "text", textMappings, CLASS_FIELD, "type=keyword") + .setMapping("text", textMappings, CLASS_FIELD, "type=keyword") ); String[] gb = { "0", "1" }; List indexRequestBuilderList = new ArrayList<>(); diff --git a/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java b/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java index 495eb73e3f39a..a4f6b97115bb0 100644 --- a/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java +++ b/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java @@ -76,7 +76,7 @@ public void setupSuiteScopeCluster() throws Exception { // two docs {value: 0} and {value : 2}, then building a histogram agg with interval 1 and with empty // buckets computed.. the empty bucket is the one associated with key "1". then each test will have // to check that this bucket exists with the appropriate sub aggregations. - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").execute().actionGet(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").execute().actionGet(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java index fe65d14bbcd0f..3fe26d92bd17f 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java @@ -322,8 +322,8 @@ protected IndexService createIndex(String index, Settings settings, String type, @Deprecated protected IndexService createIndex(String index, Settings settings, String type, String... mappings) { CreateIndexRequestBuilder createIndexRequestBuilder = client().admin().indices().prepareCreate(index).setSettings(settings); - if (type != null) { - createIndexRequestBuilder.addMapping(type, mappings); + if (mappings != null) { + createIndexRequestBuilder.setMapping(mappings); } return createIndex(index, createIndexRequestBuilder); }