[Remove] type from CIR.mapping and CIRB.mapping (#2478)
First pass to remove types from CreateIndexRequest and CreateIndexRequestBuilder mapping method. This method is overloaded several times so the most widely used methods in the RequestBuilder are refactored from mapping to setMapping to avoid confusion, conflicts, and to be consistent with other method names (e.g., setSettings, setCause, setAlias). Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
This commit is contained in:
parent
05a5819243
commit
3675400b92
|
@ -70,10 +70,8 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testNgramHighlightingWithBrokenPositions() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"test",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("test")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "text")
|
||||
|
@ -88,7 +86,6 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.setSettings(
|
||||
Settings.builder()
|
||||
|
@ -260,7 +257,7 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
|
|||
.put("index.analysis.filter.synonym.type", "synonym")
|
||||
.putList("index.analysis.filter.synonym.synonyms", "quick => fast");
|
||||
|
||||
assertAcked(prepareCreate("first_test_index").setSettings(builder.build()).addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("first_test_index").setSettings(builder.build()).setMapping(type1TermVectorMapping()));
|
||||
|
||||
ensureGreen();
|
||||
|
||||
|
@ -421,7 +418,6 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
|
|||
public static XContentBuilder type1TermVectorMapping() throws IOException {
|
||||
return XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -432,7 +428,6 @@ public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
|
|||
.field("term_vector", "with_positions_offsets")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -641,12 +641,11 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
|
|||
public void testGeo() throws Exception {
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("location")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type1", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
client().prepareIndex("test")
|
||||
.setId("1")
|
||||
|
@ -687,12 +686,11 @@ public class MoreExpressionIT extends OpenSearchIntegTestCase {
|
|||
public void testBoolean() throws Exception {
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("doc")
|
||||
.startObject("properties")
|
||||
.startObject("vip")
|
||||
.field("type", "boolean");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("doc", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
indexRandom(
|
||||
true,
|
||||
|
|
|
@ -128,10 +128,8 @@ public class TokenCountFieldMapperIntegrationIT extends OpenSearchIntegTestCase
|
|||
settings.put("index.analysis.analyzer.mock_english.tokenizer", "standard");
|
||||
settings.put("index.analysis.analyzer.mock_english.filter", "stop");
|
||||
prepareCreate("test").setSettings(settings)
|
||||
.addMapping(
|
||||
"test",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("test")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "text")
|
||||
|
@ -162,7 +160,6 @@ public class TokenCountFieldMapperIntegrationIT extends OpenSearchIntegTestCase
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.get();
|
||||
ensureGreen();
|
||||
|
|
|
@ -55,8 +55,7 @@ public abstract class AbstractParentChildTestCase extends ParentChildTestCase {
|
|||
@Before
|
||||
public void setupCluster() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
prepareCreate("test").setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "article", "comment"),
|
||||
"commenter",
|
||||
|
|
|
@ -174,8 +174,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
|||
public void testWithDeletes() throws Exception {
|
||||
String indexName = "xyz";
|
||||
assertAcked(
|
||||
prepareCreate(indexName).addMapping(
|
||||
"doc",
|
||||
prepareCreate(indexName).setMapping(
|
||||
addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"), "name", "keyword")
|
||||
)
|
||||
);
|
||||
|
@ -234,8 +233,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
|||
prepareCreate(indexName).setSettings(
|
||||
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||
)
|
||||
.addMapping(
|
||||
"doc",
|
||||
.setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, masterType, childType),
|
||||
"brand",
|
||||
|
@ -309,8 +307,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
|||
String parentType = "country";
|
||||
String childType = "city";
|
||||
assertAcked(
|
||||
prepareCreate(indexName).addMapping(
|
||||
"doc",
|
||||
prepareCreate(indexName).setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, grandParentType, parentType, parentType, childType),
|
||||
"name",
|
||||
|
@ -352,8 +349,7 @@ public class ChildrenIT extends AbstractParentChildTestCase {
|
|||
// Before we only evaluated segments that yielded matches in 'towns' and 'parent_names' aggs, which caused
|
||||
// us to miss to evaluate child docs in segments we didn't have parent matches for.
|
||||
assertAcked(
|
||||
prepareCreate("index").addMapping(
|
||||
"doc",
|
||||
prepareCreate("index").setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parentType", "childType"),
|
||||
"name",
|
||||
|
|
|
@ -102,8 +102,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
public void testMultiLevelChild() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
prepareCreate("test").setMapping(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child", "child", "grandchild")
|
||||
)
|
||||
);
|
||||
|
@ -166,9 +165,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
// see #2744
|
||||
public void test2744() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "foo", "test"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "foo", "test")));
|
||||
ensureGreen();
|
||||
|
||||
// index simple data
|
||||
|
@ -185,9 +182,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testSimpleChildQuery() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
// index simple data
|
||||
|
@ -251,9 +246,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
// Issue #3290
|
||||
public void testCachingBugWithFqueryFilter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
List<IndexRequestBuilder> builders = new ArrayList<>();
|
||||
// index simple data
|
||||
|
@ -290,9 +283,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testHasParentFilter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
Map<String, Set<String>> parentToChildren = new HashMap<>();
|
||||
// Childless parent
|
||||
|
@ -340,9 +331,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testSimpleChildQueryWithFlush() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
// index simple data with flushes, so we have many segments
|
||||
|
@ -408,8 +397,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
public void testScopedFacet() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
prepareCreate("test").setMapping(
|
||||
addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"), "c_field", "keyword")
|
||||
)
|
||||
);
|
||||
|
@ -459,9 +447,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testDeletedParent() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
// index simple data
|
||||
createIndexRequest("test", "parent", "p1", null, "p_field", "p_value1").get();
|
||||
|
@ -496,9 +482,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testDfsSearchType() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
// index simple data
|
||||
|
@ -526,9 +510,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testHasChildAndHasParentFailWhenSomeSegmentsDontContainAnyParentOrChildDocs() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
createIndexRequest("test", "parent", "1", null, "p_field", 1).get();
|
||||
|
@ -551,9 +533,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testCountApiUsage() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
String parentId = "p1";
|
||||
|
@ -584,9 +564,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testExplainUsage() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
String parentId = "p1";
|
||||
|
@ -650,10 +628,8 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
public void testScoreForParentChildQueriesWithFunctionScore() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("doc")
|
||||
.startObject("properties")
|
||||
.startObject("join_field")
|
||||
.field("type", "join")
|
||||
|
@ -663,7 +639,6 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -758,9 +733,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
// Issue #2536
|
||||
public void testParentChildQueriesCanHandleNoRelevantTypesInIndex() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
SearchResponse response = client().prepareSearch("test")
|
||||
|
@ -792,9 +765,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testHasChildAndHasParentFilter_withFilter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
createIndexRequest("test", "parent", "1", null, "p_field", 1).get();
|
||||
|
@ -820,9 +791,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testHasChildInnerHitsHighlighting() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
createIndexRequest("test", "parent", "1", null, "p_field", 1).get();
|
||||
|
@ -848,9 +817,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testHasChildAndHasParentWrappedInAQueryFilter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
// query filter in case for p/c shouldn't execute per segment, but rather
|
||||
|
@ -884,8 +851,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
public void testSimpleQueryRewrite() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
prepareCreate("test").setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"),
|
||||
"c_field",
|
||||
|
@ -945,9 +911,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
// Issue #3144
|
||||
public void testReIndexingParentAndChildDocuments() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
// index simple data
|
||||
|
@ -1004,9 +968,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
// Issue #3203
|
||||
public void testHasChildQueryWithMinimumScore() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
// index simple data
|
||||
|
@ -1031,7 +993,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
public void testParentFieldQuery() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(Settings.builder().put("index.refresh_interval", -1))
|
||||
.addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
.setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
ensureGreen();
|
||||
|
||||
|
@ -1063,7 +1025,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
public void testParentIdQuery() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.refresh_interval", -1))
|
||||
.addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
.setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
ensureGreen();
|
||||
|
||||
|
@ -1083,9 +1045,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testHasChildNotBeingCached() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
// index simple data
|
||||
|
@ -1146,10 +1106,8 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
// Issue #3818
|
||||
public void testHasChildQueryOnlyReturnsSingleChildType() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("grandissue").addMapping(
|
||||
"doc",
|
||||
prepareCreate("grandissue").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("doc")
|
||||
.startObject("properties")
|
||||
.startObject("join_field")
|
||||
.field("type", "join")
|
||||
|
@ -1160,7 +1118,6 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -1203,8 +1160,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
public void testHasChildQueryWithNestedInnerObjects() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
prepareCreate("test").setMapping(
|
||||
addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"), "objects", "nested")
|
||||
)
|
||||
);
|
||||
|
@ -1282,9 +1238,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testNamedFilters() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
String parentId = "p1";
|
||||
|
@ -1368,7 +1322,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
public void testParentChildCaching() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(Settings.builder().put("index.refresh_interval", -1))
|
||||
.addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
.setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
ensureGreen();
|
||||
|
||||
|
@ -1413,9 +1367,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testParentChildQueriesViaScrollApi() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
createIndexRequest("test", "parent", "p" + i, null).get();
|
||||
|
@ -1496,9 +1448,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testMinMaxChildren() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(true, createMinMaxDocBuilders().toArray(new IndexRequestBuilder[0]));
|
||||
|
@ -1811,10 +1761,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
public void testHasParentInnerQueryType() {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent-type", "child-type")
|
||||
)
|
||||
prepareCreate("test").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent-type", "child-type"))
|
||||
);
|
||||
createIndexRequest("test", "child-type", "child-id", "parent-id").get();
|
||||
createIndexRequest("test", "parent-type", "parent-id", null).get();
|
||||
|
@ -1834,8 +1781,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
public void testHighlightersIgnoreParentChild() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
.startObject("join_field")
|
||||
|
@ -1888,7 +1834,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
|
|||
|
||||
public void testAliasesFilterWithHasChildQuery() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("my-index").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
prepareCreate("my-index").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
createIndexRequest("my-index", "parent", "1", null).get();
|
||||
createIndexRequest("my-index", "child", "2", "1").get();
|
||||
|
|
|
@ -103,10 +103,8 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testSimpleParentChild() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("articles").addMapping(
|
||||
"doc",
|
||||
prepareCreate("articles").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("doc")
|
||||
.startObject("properties")
|
||||
.startObject("join_field")
|
||||
.field("type", "join")
|
||||
|
@ -123,7 +121,6 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -223,10 +220,8 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testRandomParentChild() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("idx").addMapping(
|
||||
"doc",
|
||||
prepareCreate("idx").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("doc")
|
||||
.startObject("properties")
|
||||
.startObject("id")
|
||||
.field("type", "keyword")
|
||||
|
@ -239,7 +234,6 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
int numDocs = scaledRandomIntBetween(5, 50);
|
||||
|
@ -323,8 +317,7 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testInnerHitsOnHasParent() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("stack").addMapping(
|
||||
"doc",
|
||||
prepareCreate("stack").setMapping(
|
||||
addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "question", "answer"), "body", "text")
|
||||
)
|
||||
);
|
||||
|
@ -379,8 +372,7 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testParentChildMultipleLayers() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("articles").addMapping(
|
||||
"doc",
|
||||
prepareCreate("articles").setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "article", "comment", "comment", "remark"),
|
||||
"title",
|
||||
|
@ -449,8 +441,7 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testRoyals() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("royals").addMapping(
|
||||
"doc",
|
||||
prepareCreate("royals").setMapping(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef(
|
||||
"join_field",
|
||||
true,
|
||||
|
@ -536,9 +527,7 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
}
|
||||
|
||||
public void testMatchesQueriesParentChildInnerHits() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("index").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
assertAcked(prepareCreate("index").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child")));
|
||||
List<IndexRequestBuilder> requests = new ArrayList<>();
|
||||
requests.add(createIndexRequest("index", "parent", "1", null));
|
||||
requests.add(createIndexRequest("index", "child", "3", "1", "field", "value1"));
|
||||
|
@ -577,7 +566,7 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testUseMaxDocInsteadOfSize() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("index1").addMapping("doc", buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
prepareCreate("index1").setMapping(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"))
|
||||
);
|
||||
client().admin()
|
||||
.indices()
|
||||
|
@ -599,8 +588,7 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testNestedInnerHitWrappedInParentChildInnerhit() {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"doc",
|
||||
prepareCreate("test").setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent_type", "child_type"),
|
||||
"nested_type",
|
||||
|
@ -632,8 +620,7 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testInnerHitsWithIgnoreUnmapped() {
|
||||
assertAcked(
|
||||
prepareCreate("index1").addMapping(
|
||||
"doc",
|
||||
prepareCreate("index1").setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent_type", "child_type"),
|
||||
"nested_type",
|
||||
|
@ -662,8 +649,7 @@ public class InnerHitsIT extends ParentChildTestCase {
|
|||
|
||||
public void testTooHighResultWindow() {
|
||||
assertAcked(
|
||||
prepareCreate("index1").addMapping(
|
||||
"doc",
|
||||
prepareCreate("index1").setMapping(
|
||||
addFieldMappings(
|
||||
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent_type", "child_type"),
|
||||
"nested_type",
|
||||
|
|
|
@ -844,10 +844,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test3")
|
||||
.addMapping(
|
||||
"type",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field")
|
||||
.field("type", "keyword")
|
||||
|
@ -862,7 +860,6 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -876,10 +873,8 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test2")
|
||||
.addMapping(
|
||||
"type",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field")
|
||||
.field("type", "keyword")
|
||||
|
@ -894,7 +889,6 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -977,7 +971,7 @@ public class PercolatorQuerySearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(client().admin().indices().prepareCreate("test").addMapping("employee", mapping));
|
||||
assertAcked(client().admin().indices().prepareCreate("test").setMapping(mapping));
|
||||
client().prepareIndex("test")
|
||||
.setId("q1")
|
||||
.setSource(
|
||||
|
|
|
@ -150,7 +150,7 @@ public class PercolatorQuerySearchTests extends OpenSearchSingleNodeTestCase {
|
|||
.prepareCreate("test")
|
||||
// to avoid normal document from being cached by BitsetFilterCache
|
||||
.setSettings(Settings.builder().put(BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING.getKey(), false))
|
||||
.addMapping("employee", mapping)
|
||||
.setMapping(mapping)
|
||||
);
|
||||
client().prepareIndex("test")
|
||||
.setId("q1")
|
||||
|
@ -238,7 +238,7 @@ public class PercolatorQuerySearchTests extends OpenSearchSingleNodeTestCase {
|
|||
mapping.endObject();
|
||||
}
|
||||
mapping.endObject();
|
||||
createIndex("test", client().admin().indices().prepareCreate("test").addMapping("employee", mapping));
|
||||
createIndex("test", client().admin().indices().prepareCreate("test").setMapping(mapping));
|
||||
Script script = new Script(ScriptType.INLINE, MockScriptPlugin.NAME, "use_fielddata_please", Collections.emptyMap());
|
||||
client().prepareIndex("test")
|
||||
.setId("q1")
|
||||
|
|
|
@ -71,8 +71,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testBasicUsage() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
String[] equivalent = { "I WİLL USE TURKİSH CASING", "ı will use turkish casıng" };
|
||||
|
||||
XContentBuilder builder = jsonBuilder().startObject()
|
||||
|
@ -88,7 +86,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
// both values should collate to same value
|
||||
indexRandom(
|
||||
|
@ -114,7 +112,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testMultipleValues() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
String[] equivalent = { "a", "C", "a", "B" };
|
||||
|
||||
|
@ -130,7 +127,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
// everything should be indexed fine, no exceptions
|
||||
indexRandom(
|
||||
|
@ -177,7 +174,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testNormalization() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
String[] equivalent = { "I W\u0049\u0307LL USE TURKİSH CASING", "ı will use turkish casıng" };
|
||||
|
||||
|
@ -195,7 +191,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
indexRandom(
|
||||
true,
|
||||
|
@ -223,7 +219,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testSecondaryStrength() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
String[] equivalent = { "TESTING", "testing" };
|
||||
|
||||
|
@ -241,7 +236,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
indexRandom(
|
||||
true,
|
||||
|
@ -269,7 +264,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testIgnorePunctuation() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
String[] equivalent = { "foo-bar", "foo bar" };
|
||||
|
||||
|
@ -287,7 +281,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
indexRandom(
|
||||
true,
|
||||
|
@ -315,7 +309,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testIgnoreWhitespace() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
XContentBuilder builder = jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
|
@ -333,7 +326,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
indexRandom(
|
||||
true,
|
||||
|
@ -363,7 +356,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testNumerics() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
XContentBuilder builder = jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
|
@ -376,7 +368,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
indexRandom(
|
||||
true,
|
||||
|
@ -399,7 +391,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testIgnoreAccentsButNotCase() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
XContentBuilder builder = jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
|
@ -416,7 +407,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
indexRandom(
|
||||
true,
|
||||
|
@ -441,7 +432,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testUpperCaseFirst() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
XContentBuilder builder = jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
|
@ -455,7 +445,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
indexRandom(
|
||||
true,
|
||||
|
@ -481,7 +471,6 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testCustomRules() throws Exception {
|
||||
String index = "foo";
|
||||
String type = "mytype";
|
||||
|
||||
RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new ULocale("de_DE"));
|
||||
String DIN5007_2_tailorings = "& ae , a\u0308 & AE , A\u0308" + "& oe , o\u0308 & OE , O\u0308" + "& ue , u\u0308 & UE , u\u0308";
|
||||
|
@ -504,7 +493,7 @@ public class ICUCollationKeywordFieldMapperIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
indexRandom(
|
||||
true,
|
||||
|
|
|
@ -63,10 +63,9 @@ public class SizeMappingIT extends OpenSearchIntegTestCase {
|
|||
// issue 5053
|
||||
public void testThatUpdatingMappingShouldNotRemoveSizeMappingConfiguration() throws Exception {
|
||||
String index = "foo";
|
||||
String type = MapperService.SINGLE_MAPPING_NAME;
|
||||
|
||||
XContentBuilder builder = jsonBuilder().startObject().startObject("_size").field("enabled", true).endObject().endObject();
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
// check mapping again
|
||||
assertSizeMappingEnabled(index, true);
|
||||
|
@ -88,10 +87,9 @@ public class SizeMappingIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testThatSizeCanBeSwitchedOnAndOff() throws Exception {
|
||||
String index = "foo";
|
||||
String type = MapperService.SINGLE_MAPPING_NAME;
|
||||
|
||||
XContentBuilder builder = jsonBuilder().startObject().startObject("_size").field("enabled", true).endObject().endObject();
|
||||
assertAcked(client().admin().indices().prepareCreate(index).addMapping(type, builder));
|
||||
assertAcked(client().admin().indices().prepareCreate(index).setMapping(builder));
|
||||
|
||||
// check mapping again
|
||||
assertSizeMappingEnabled(index, true);
|
||||
|
|
|
@ -110,8 +110,7 @@ public class CreateIndexIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testNonNestedMappings() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"_doc",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("properties")
|
||||
|
@ -131,7 +130,7 @@ public class CreateIndexIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyNestedMappings() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("_doc", XContentFactory.jsonBuilder().startObject().endObject()));
|
||||
assertAcked(prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().endObject()));
|
||||
|
||||
GetMappingsResponse response = client().admin().indices().prepareGetMappings("test").get();
|
||||
|
||||
|
@ -144,10 +143,8 @@ public class CreateIndexIT extends OpenSearchIntegTestCase {
|
|||
public void testMappingParamAndNestedMismatch() throws Exception {
|
||||
MapperParsingException e = expectThrows(
|
||||
MapperParsingException.class,
|
||||
() -> prepareCreate("test").addMapping(
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
XContentFactory.jsonBuilder().startObject().startObject("type2").endObject().endObject()
|
||||
).get()
|
||||
() -> prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().startObject("type2").endObject().endObject())
|
||||
.get()
|
||||
);
|
||||
assertThat(
|
||||
e.getMessage(),
|
||||
|
@ -159,10 +156,7 @@ public class CreateIndexIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testEmptyMappings() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"_doc",
|
||||
XContentFactory.jsonBuilder().startObject().startObject("_doc").endObject().endObject()
|
||||
)
|
||||
prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().startObject("_doc").endObject().endObject())
|
||||
);
|
||||
|
||||
GetMappingsResponse response = client().admin().indices().prepareGetMappings("test").get();
|
||||
|
|
|
@ -88,7 +88,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping(mapping));
|
||||
|
||||
client().prepareIndex("test").setId("667").setSource("field", "foo bar").execute().actionGet();
|
||||
refresh();
|
||||
|
@ -105,16 +105,14 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
|
||||
public void testExistingFieldWithNoTermVectorsNoNPE() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("existingfield")
|
||||
.field("type", "text")
|
||||
.field("term_vector", "with_positions_offsets_payloads")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping(mapping));
|
||||
|
||||
// when indexing a field that simply has a question mark, the term vectors will be null
|
||||
client().prepareIndex("test").setId("0").setSource("existingfield", "?").execute().actionGet();
|
||||
|
@ -133,16 +131,14 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
|
||||
public void testExistingFieldButNotInDocNPE() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("existingfield")
|
||||
.field("type", "text")
|
||||
.field("term_vector", "with_positions_offsets_payloads")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping(mapping));
|
||||
|
||||
// when indexing a field that simply has a question mark, the term vectors will be null
|
||||
client().prepareIndex("test").setId("0").setSource("anotherexistingfield", 1).execute().actionGet();
|
||||
|
@ -205,7 +201,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
|
||||
public void testSimpleTermVectors() throws IOException {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field")
|
||||
.field("type", "text")
|
||||
|
@ -213,10 +208,9 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
.field("analyzer", "tv_test")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("type1", mapping)
|
||||
prepareCreate("test").setMapping(mapping)
|
||||
.addAlias(new Alias("alias"))
|
||||
.setSettings(
|
||||
Settings.builder()
|
||||
|
@ -316,7 +310,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
|
||||
String optionString = termVectorOptionsToString(ft);
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("_doc")
|
||||
.startObject("properties")
|
||||
.startObject("field")
|
||||
.field("type", "text")
|
||||
|
@ -324,10 +317,9 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
.field("analyzer", "tv_test")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("_doc", mapping)
|
||||
prepareCreate("test").setMapping(mapping)
|
||||
.setSettings(
|
||||
Settings.builder()
|
||||
.put("index.analysis.analyzer.tv_test.tokenizer", "standard")
|
||||
|
@ -466,7 +458,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
fieldNames[i] = "field" + String.valueOf(i);
|
||||
}
|
||||
|
||||
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1").startObject("properties");
|
||||
XContentBuilder mapping = jsonBuilder().startObject().startObject("properties");
|
||||
XContentBuilder source = jsonBuilder().startObject();
|
||||
for (String field : fieldNames) {
|
||||
mapping.startObject(field)
|
||||
|
@ -476,11 +468,11 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
.endObject();
|
||||
source.field(field, "the quick brown fox jumps over the lazy dog");
|
||||
}
|
||||
mapping.endObject().endObject().endObject();
|
||||
mapping.endObject().endObject();
|
||||
source.endObject();
|
||||
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping("type1", mapping)
|
||||
prepareCreate("test").setMapping(mapping)
|
||||
.setSettings(
|
||||
Settings.builder()
|
||||
.put(indexSettings())
|
||||
|
@ -640,16 +632,16 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
public void testSimpleWildCards() throws IOException {
|
||||
int numFields = 25;
|
||||
|
||||
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1").startObject("properties");
|
||||
XContentBuilder mapping = jsonBuilder().startObject().startObject("properties");
|
||||
XContentBuilder source = jsonBuilder().startObject();
|
||||
for (int i = 0; i < numFields; i++) {
|
||||
mapping.startObject("field" + i).field("type", "text").field("term_vector", randomBoolean() ? "yes" : "no").endObject();
|
||||
source.field("field" + i, "some text here");
|
||||
}
|
||||
source.endObject();
|
||||
mapping.endObject().endObject().endObject();
|
||||
mapping.endObject().endObject();
|
||||
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test").setId("0").setSource(source).get();
|
||||
|
@ -744,7 +736,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
|
||||
// setup mapping and document source
|
||||
Set<String> withTermVectors = new HashSet<>();
|
||||
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1").startObject("properties");
|
||||
XContentBuilder mapping = jsonBuilder().startObject().startObject("properties");
|
||||
XContentBuilder source = jsonBuilder().startObject();
|
||||
for (int i = 0; i < numFields; i++) {
|
||||
String fieldName = "field" + i;
|
||||
|
@ -758,11 +750,11 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
|
|||
source.field(fieldName, "some text here");
|
||||
}
|
||||
source.endObject();
|
||||
mapping.endObject().endObject().endObject();
|
||||
mapping.endObject().endObject();
|
||||
|
||||
// setup indices with mapping
|
||||
Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard");
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSettings(settings).addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setSettings(settings).setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
// index a single document with prepared source
|
||||
|
|
|
@ -261,7 +261,7 @@ public class SimpleClusterStateIT extends OpenSearchIntegTestCase {
|
|||
ByteSizeValue.parseBytesSizeValue("10k", "estimatedBytesSize").bytesAsInt(),
|
||||
ByteSizeValue.parseBytesSizeValue("256k", "estimatedBytesSize").bytesAsInt()
|
||||
);
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties");
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties");
|
||||
int counter = 0;
|
||||
int numberOfFields = 0;
|
||||
while (true) {
|
||||
|
@ -273,7 +273,7 @@ public class SimpleClusterStateIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
}
|
||||
logger.info("number of fields [{}], estimated bytes [{}]", numberOfFields, estimatedBytesSize);
|
||||
mapping.endObject().endObject().endObject();
|
||||
mapping.endObject().endObject();
|
||||
|
||||
int numberOfShards = scaledRandomIntBetween(1, cluster().numDataNodes());
|
||||
// if the create index is ack'ed, then all nodes have successfully processed the cluster state
|
||||
|
@ -287,7 +287,7 @@ public class SimpleClusterStateIT extends OpenSearchIntegTestCase {
|
|||
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||
.put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), Long.MAX_VALUE)
|
||||
)
|
||||
.addMapping("type", mapping)
|
||||
.setMapping(mapping)
|
||||
.setTimeout("60s")
|
||||
.get()
|
||||
);
|
||||
|
|
|
@ -105,10 +105,7 @@ public class GatewayIndexStateIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addMapping(
|
||||
"type1",
|
||||
XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject()
|
||||
)
|
||||
.setMapping(XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject())
|
||||
.execute()
|
||||
.actionGet();
|
||||
|
||||
|
|
|
@ -541,10 +541,8 @@ public class GetActionIT extends OpenSearchIntegTestCase {
|
|||
public void testGetFieldsNonLeafField() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addAlias(new Alias("alias"))
|
||||
.addMapping(
|
||||
"my-type1",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("my-type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.startObject("properties")
|
||||
|
@ -555,7 +553,6 @@ public class GetActionIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.setSettings(Settings.builder().put("index.refresh_interval", -1))
|
||||
);
|
||||
|
@ -582,10 +579,8 @@ public class GetActionIT extends OpenSearchIntegTestCase {
|
|||
prepareCreate("my-index")
|
||||
// multi types in 5.6
|
||||
.setSettings(Settings.builder().put("index.refresh_interval", -1))
|
||||
.addMapping(
|
||||
"my-type",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("my-type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "object")
|
||||
|
@ -608,7 +603,6 @@ public class GetActionIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public class IndexSortIT extends OpenSearchIntegTestCase {
|
|||
.put("index.number_of_shards", "1")
|
||||
.put("index.number_of_replicas", "1")
|
||||
.putList("index.sort.field", "date", "numeric_dv", "keyword_dv")
|
||||
).addMapping("test", TEST_MAPPING).get();
|
||||
).setMapping(TEST_MAPPING).get();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
client().prepareIndex("test")
|
||||
.setId(Integer.toString(i))
|
||||
|
@ -108,7 +108,7 @@ public class IndexSortIT extends OpenSearchIntegTestCase {
|
|||
IllegalArgumentException exc = expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).putList("index.sort.field", "invalid_field"))
|
||||
.addMapping("test", TEST_MAPPING)
|
||||
.setMapping(TEST_MAPPING)
|
||||
.get()
|
||||
);
|
||||
assertThat(exc.getMessage(), containsString("unknown index sort field:[invalid_field]"));
|
||||
|
@ -116,7 +116,7 @@ public class IndexSortIT extends OpenSearchIntegTestCase {
|
|||
exc = expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).putList("index.sort.field", "numeric"))
|
||||
.addMapping("test", TEST_MAPPING)
|
||||
.setMapping(TEST_MAPPING)
|
||||
.get()
|
||||
);
|
||||
assertThat(exc.getMessage(), containsString("docvalues not found for index sort field:[numeric]"));
|
||||
|
@ -124,7 +124,7 @@ public class IndexSortIT extends OpenSearchIntegTestCase {
|
|||
exc = expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).putList("index.sort.field", "keyword"))
|
||||
.addMapping("test", TEST_MAPPING)
|
||||
.setMapping(TEST_MAPPING)
|
||||
.get()
|
||||
);
|
||||
assertThat(exc.getMessage(), containsString("docvalues not found for index sort field:[keyword]"));
|
||||
|
|
|
@ -43,10 +43,8 @@ public class FieldDataLoadingIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testEagerGlobalOrdinalsFieldDataLoading() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "text")
|
||||
|
@ -55,7 +53,6 @@ public class FieldDataLoadingIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
|
|
@ -50,7 +50,7 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
|
||||
public class CopyToMapperIntegrationIT extends OpenSearchIntegTestCase {
|
||||
public void testDynamicTemplateCopyTo() throws Exception {
|
||||
assertAcked(client().admin().indices().prepareCreate("test-idx").addMapping("_doc", createDynamicTemplateMapping()));
|
||||
assertAcked(client().admin().indices().prepareCreate("test-idx").setMapping(createDynamicTemplateMapping()));
|
||||
|
||||
int recordCount = between(1, 200);
|
||||
|
||||
|
@ -98,7 +98,6 @@ public class CopyToMapperIntegrationIT extends OpenSearchIntegTestCase {
|
|||
private XContentBuilder createDynamicTemplateMapping() throws IOException {
|
||||
return XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("_doc")
|
||||
.startArray("dynamic_templates")
|
||||
|
||||
.startObject()
|
||||
|
@ -124,7 +123,6 @@ public class CopyToMapperIntegrationIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
|
||||
.endArray()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,18 +55,15 @@ public class ExternalValuesMapperIntegrationIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testHighlightingOnCustomString() throws Exception {
|
||||
prepareCreate("test-idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("test-idx").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field")
|
||||
.field("type", FakeStringFieldMapper.CONTENT_TYPE)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).execute().get();
|
||||
|
||||
index(
|
||||
|
@ -118,11 +115,9 @@ public class ExternalValuesMapperIntegrationIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testExternalValues() throws Exception {
|
||||
prepareCreate("test-idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("test-idx").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject(ExternalMetadataMapper.CONTENT_TYPE)
|
||||
.endObject()
|
||||
.startObject("properties")
|
||||
|
@ -131,7 +126,6 @@ public class ExternalValuesMapperIntegrationIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).execute().get();
|
||||
|
||||
index("test-idx", "type", "1", XContentFactory.jsonBuilder().startObject().field("field", "1234").endObject());
|
||||
|
@ -166,11 +160,9 @@ public class ExternalValuesMapperIntegrationIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testExternalValuesWithMultifield() throws Exception {
|
||||
prepareCreate("test-idx").addMapping(
|
||||
"_doc",
|
||||
prepareCreate("test-idx").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("_doc")
|
||||
.startObject("properties")
|
||||
.startObject("f")
|
||||
.field("type", ExternalMapperPlugin.EXTERNAL_UPPER)
|
||||
|
@ -189,7 +181,6 @@ public class ExternalValuesMapperIntegrationIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).execute().get();
|
||||
|
||||
index("test-idx", "_doc", "1", "f", "This is my text");
|
||||
|
|
|
@ -58,7 +58,7 @@ import static org.hamcrest.Matchers.nullValue;
|
|||
public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMultiFields() throws Exception {
|
||||
assertAcked(client().admin().indices().prepareCreate("my-index").addMapping("my-type", createTypeSource()));
|
||||
assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createTypeSource()));
|
||||
|
||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
||||
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||
|
@ -98,7 +98,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGeoPointMultiField() throws Exception {
|
||||
assertAcked(client().admin().indices().prepareCreate("my-index").addMapping("my-type", createMappingSource("geo_point")));
|
||||
assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("geo_point")));
|
||||
|
||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
||||
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||
|
@ -127,7 +127,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testCompletionMultiField() throws Exception {
|
||||
assertAcked(client().admin().indices().prepareCreate("my-index").addMapping("my-type", createMappingSource("completion")));
|
||||
assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("completion")));
|
||||
|
||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
||||
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||
|
@ -149,7 +149,7 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testIpMultiField() throws Exception {
|
||||
assertAcked(client().admin().indices().prepareCreate("my-index").addMapping("my-type", createMappingSource("ip")));
|
||||
assertAcked(client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("ip")));
|
||||
|
||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("my-index").get();
|
||||
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
|
||||
|
@ -172,7 +172,6 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
|
|||
private XContentBuilder createMappingSource(String fieldType) throws IOException {
|
||||
return XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("my-type")
|
||||
.startObject("properties")
|
||||
.startObject("a")
|
||||
.field("type", fieldType)
|
||||
|
@ -183,14 +182,12 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
private XContentBuilder createTypeSource() throws IOException {
|
||||
return XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("my-type")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
|
@ -201,7 +198,6 @@ public class MultiFieldsIntegrationIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -78,18 +78,16 @@ public class PreBuiltAnalyzerIntegrationIT extends OpenSearchIntegTestCase {
|
|||
loadedAnalyzers.get(preBuiltAnalyzer).add(randomVersion);
|
||||
|
||||
final XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "text")
|
||||
.field("analyzer", name)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
Settings versionSettings = settings(randomVersion).build();
|
||||
client().admin().indices().prepareCreate(indexName).addMapping("type", mapping).setSettings(versionSettings).get();
|
||||
client().admin().indices().prepareCreate(indexName).setMapping(mapping).setSettings(versionSettings).get();
|
||||
}
|
||||
|
||||
ensureGreen();
|
||||
|
|
|
@ -80,9 +80,8 @@ public class SimpleGetFieldMappingsIT extends OpenSearchIntegTestCase {
|
|||
assertThat(response.fieldMappings("index", "field"), nullValue());
|
||||
}
|
||||
|
||||
private XContentBuilder getMappingForType(String type) throws IOException {
|
||||
private XContentBuilder getMappingForType() throws IOException {
|
||||
return jsonBuilder().startObject()
|
||||
.startObject(type)
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -99,14 +98,13 @@ public class SimpleGetFieldMappingsIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
public void testGetFieldMappings() throws Exception {
|
||||
|
||||
assertAcked(prepareCreate("indexa").addMapping("typeA", getMappingForType("typeA")));
|
||||
assertAcked(client().admin().indices().prepareCreate("indexb").addMapping("typeB", getMappingForType("typeB")));
|
||||
assertAcked(prepareCreate("indexa").setMapping(getMappingForType()));
|
||||
assertAcked(client().admin().indices().prepareCreate("indexb").setMapping(getMappingForType()));
|
||||
|
||||
// Get mappings by full name
|
||||
GetFieldMappingsResponse response = client().admin()
|
||||
|
@ -136,7 +134,7 @@ public class SimpleGetFieldMappingsIT extends OpenSearchIntegTestCase {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSimpleGetFieldMappingsWithDefaults() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type", getMappingForType("type")));
|
||||
assertAcked(prepareCreate("test").setMapping(getMappingForType()));
|
||||
client().admin().indices().preparePutMapping("test").setSource("num", "type=long").get();
|
||||
client().admin().indices().preparePutMapping("test").setSource("field2", "type=text,index=false").get();
|
||||
|
||||
|
@ -163,7 +161,7 @@ public class SimpleGetFieldMappingsIT extends OpenSearchIntegTestCase {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetFieldMappingsWithFieldAlias() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type", getMappingForType("type")));
|
||||
assertAcked(prepareCreate("test").setMapping(getMappingForType()));
|
||||
|
||||
GetFieldMappingsResponse response = client().admin().indices().prepareGetFieldMappings().setFields("alias", "field1").get();
|
||||
|
||||
|
@ -179,7 +177,7 @@ public class SimpleGetFieldMappingsIT extends OpenSearchIntegTestCase {
|
|||
|
||||
// fix #6552
|
||||
public void testSimpleGetFieldMappingsWithPretty() throws Exception {
|
||||
assertAcked(prepareCreate("index").addMapping("type", getMappingForType("type")));
|
||||
assertAcked(prepareCreate("index").setMapping(getMappingForType()));
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("pretty", "true");
|
||||
GetFieldMappingsResponse response = client().admin()
|
||||
|
@ -209,7 +207,7 @@ public class SimpleGetFieldMappingsIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testGetFieldMappingsWithBlocks() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("_doc", getMappingForType("_doc")));
|
||||
assertAcked(prepareCreate("test").setMapping(getMappingForType()));
|
||||
|
||||
for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY)) {
|
||||
try {
|
||||
|
|
|
@ -70,21 +70,19 @@ public class SimpleGetMappingsIT extends OpenSearchIntegTestCase {
|
|||
assertEquals(MappingMetadata.EMPTY_MAPPINGS, response.mappings().get("index"));
|
||||
}
|
||||
|
||||
private XContentBuilder getMappingForType(String type) throws IOException {
|
||||
private XContentBuilder getMappingForType() throws IOException {
|
||||
return jsonBuilder().startObject()
|
||||
.startObject(type)
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
public void testSimpleGetMappings() throws Exception {
|
||||
client().admin().indices().prepareCreate("indexa").addMapping("typeA", getMappingForType("typeA")).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("indexb").addMapping("typeA", getMappingForType("typeA")).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("indexa").setMapping(getMappingForType()).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("indexb").setMapping(getMappingForType()).execute().actionGet();
|
||||
|
||||
ClusterHealthResponse clusterHealth = client().admin()
|
||||
.cluster()
|
||||
|
@ -114,7 +112,7 @@ public class SimpleGetMappingsIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testGetMappingsWithBlocks() throws IOException {
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", getMappingForType("_doc")).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("test").setMapping(getMappingForType()).execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY)) {
|
||||
|
|
|
@ -129,16 +129,7 @@ public class SimpleMgetIT extends OpenSearchIntegTestCase {
|
|||
public void testThatMgetShouldWorkWithAliasRouting() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addAlias(new Alias("alias1").routing("abc"))
|
||||
.addMapping(
|
||||
"test",
|
||||
jsonBuilder().startObject()
|
||||
.startObject("test")
|
||||
.startObject("_routing")
|
||||
.field("required", true)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.setMapping(jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject())
|
||||
);
|
||||
|
||||
client().prepareIndex("alias1")
|
||||
|
|
|
@ -351,17 +351,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
|
|||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addAlias(new Alias("alias"))
|
||||
.addMapping(
|
||||
"type1",
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("_routing")
|
||||
.field("required", true)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.setMapping(XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject())
|
||||
.execute()
|
||||
.actionGet();
|
||||
ensureGreen();
|
||||
|
@ -450,17 +440,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
|
|||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addAlias(new Alias("alias"))
|
||||
.addMapping(
|
||||
"type1",
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("_routing")
|
||||
.field("required", true)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.setMapping(XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject())
|
||||
.execute()
|
||||
.actionGet();
|
||||
ensureGreen();
|
||||
|
@ -544,17 +524,7 @@ public class SimpleRoutingIT extends OpenSearchIntegTestCase {
|
|||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addAlias(new Alias("alias"))
|
||||
.addMapping(
|
||||
"type1",
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("_routing")
|
||||
.field("required", true)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.setMapping(XContentFactory.jsonBuilder().startObject().startObject("_routing").field("required", true).endObject().endObject())
|
||||
.execute()
|
||||
.actionGet();
|
||||
ensureGreen();
|
||||
|
|
|
@ -115,10 +115,8 @@ public class CombiIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testSubAggregationForTopAggregationOnUnmappedField() throws Exception {
|
||||
|
||||
prepareCreate("idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "keyword")
|
||||
|
@ -128,7 +126,6 @@ public class CombiIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get();
|
||||
|
||||
ensureSearchable("idx");
|
||||
|
|
|
@ -133,17 +133,14 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
prepareCreate("idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("values")
|
||||
.field("type", "double")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get();
|
||||
|
||||
for (int i = 0; i < docs.length; ++i) {
|
||||
|
@ -235,10 +232,8 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
|
|||
|
||||
final IntHashSet valuesSet = new IntHashSet();
|
||||
cluster().wipeIndices("idx");
|
||||
prepareCreate("idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("num")
|
||||
.field("type", "double")
|
||||
|
@ -260,7 +255,6 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get();
|
||||
|
||||
List<IndexRequestBuilder> indexingRequests = new ArrayList<>();
|
||||
|
@ -358,17 +352,14 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
|
|||
|
||||
// Duel between histograms and scripted terms
|
||||
public void testDuelTermsHistogram() throws Exception {
|
||||
prepareCreate("idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("num")
|
||||
.field("type", "double")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get();
|
||||
|
||||
final int numDocs = scaledRandomIntBetween(500, 5000);
|
||||
|
@ -422,17 +413,14 @@ public class EquivalenceIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testLargeNumbersOfPercentileBuckets() throws Exception {
|
||||
// test high numbers of percentile buckets to make sure paging and release work correctly
|
||||
prepareCreate("idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("double_value")
|
||||
.field("type", "double")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get();
|
||||
|
||||
final int numDocs = scaledRandomIntBetween(2500, 5000);
|
||||
|
|
|
@ -158,10 +158,8 @@ public class NestedIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
assertAcked(
|
||||
prepareCreate("idx_nested_nested_aggs").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx_nested_nested_aggs").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("nested1")
|
||||
.field("type", "nested")
|
||||
|
@ -173,7 +171,6 @@ public class NestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen("idx_nested_nested_aggs");
|
||||
|
@ -400,7 +397,6 @@ public class NestedIT extends OpenSearchIntegTestCase {
|
|||
// Test based on: https://github.com/elastic/elasticsearch/issues/9280
|
||||
public void testParentFilterResolvedCorrectly() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("provider")
|
||||
.startObject("properties")
|
||||
.startObject("comments")
|
||||
.field("type", "nested")
|
||||
|
@ -450,11 +446,10 @@ public class NestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(
|
||||
prepareCreate("idx2").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
|
||||
.addMapping("provider", mapping)
|
||||
.setMapping(mapping)
|
||||
);
|
||||
ensureGreen("idx2");
|
||||
|
||||
|
@ -649,10 +644,8 @@ public class NestedIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testFilterAggInsideNestedAgg() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("classes").addMapping(
|
||||
"class",
|
||||
prepareCreate("classes").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("class")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "text")
|
||||
|
@ -681,7 +674,6 @@ public class NestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@ public class ReverseNestedIT extends OpenSearchIntegTestCase {
|
|||
@Override
|
||||
public void setupSuiteScopeCluster() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("idx1").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx1").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
|
@ -99,8 +98,7 @@ public class ReverseNestedIT extends OpenSearchIntegTestCase {
|
|||
)
|
||||
);
|
||||
assertAcked(
|
||||
prepareCreate("idx2").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx2").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
.startObject("nested1")
|
||||
|
@ -531,7 +529,6 @@ public class ReverseNestedIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSameParentDocHavingMultipleBuckets() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("product")
|
||||
.field("dynamic", "strict")
|
||||
.startObject("properties")
|
||||
.startObject("id")
|
||||
|
@ -562,11 +559,10 @@ public class ReverseNestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(
|
||||
prepareCreate("idx3").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0))
|
||||
.addMapping("product", mapping)
|
||||
.setMapping(mapping)
|
||||
);
|
||||
|
||||
client().prepareIndex("idx3")
|
||||
|
|
|
@ -128,10 +128,8 @@ public class CardinalityIT extends OpenSearchIntegTestCase {
|
|||
@Override
|
||||
public void setupSuiteScopeCluster() throws Exception {
|
||||
|
||||
prepareCreate("idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("str_value")
|
||||
.field("type", "keyword")
|
||||
|
@ -153,7 +151,6 @@ public class CardinalityIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get();
|
||||
|
||||
numDocs = randomIntBetween(2, 100);
|
||||
|
|
|
@ -139,10 +139,8 @@ public class TopHitsIT extends OpenSearchIntegTestCase {
|
|||
assertAcked(prepareCreate("field-collapsing").addMapping("type", "group", "type=keyword"));
|
||||
createIndex("empty");
|
||||
assertAcked(
|
||||
prepareCreate("articles").addMapping(
|
||||
"article",
|
||||
prepareCreate("articles").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("article")
|
||||
.startObject("properties")
|
||||
.startObject(TERMS_AGGS_FIELD)
|
||||
.field("type", "keyword")
|
||||
|
@ -174,7 +172,6 @@ public class TopHitsIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen("idx", "empty", "articles");
|
||||
|
|
|
@ -556,7 +556,7 @@ public class MaxBucketIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(client().admin().indices().prepareCreate("foo_2").addMapping("doc", builder).get());
|
||||
assertAcked(client().admin().indices().prepareCreate("foo_2").setMapping(builder).get());
|
||||
|
||||
XContentBuilder docBuilder = jsonBuilder().startObject()
|
||||
.startObject("license")
|
||||
|
|
|
@ -130,18 +130,15 @@ public class MovAvgIT extends OpenSearchIntegTestCase {
|
|||
|
||||
@Override
|
||||
public void setupSuiteScopeCluster() throws Exception {
|
||||
prepareCreate("idx").addMapping(
|
||||
"type",
|
||||
prepareCreate("idx").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject(VALUE_FIELD)
|
||||
.field("type", "double")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).execute().get();
|
||||
createIndex("idx_unmapped");
|
||||
List<IndexRequestBuilder> builders = new ArrayList<>();
|
||||
|
|
|
@ -79,10 +79,8 @@ public class FetchSubPhasePluginIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addMapping(
|
||||
"type1",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -90,7 +88,6 @@ public class FetchSubPhasePluginIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.get();
|
||||
|
||||
|
|
|
@ -100,10 +100,8 @@ public class InnerHitsIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSimpleNested() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("articles").addMapping(
|
||||
"article",
|
||||
prepareCreate("articles").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("article")
|
||||
.startObject("properties")
|
||||
.startObject("comments")
|
||||
.field("type", "nested")
|
||||
|
@ -119,7 +117,6 @@ public class InnerHitsIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -313,10 +310,8 @@ public class InnerHitsIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testNestedMultipleLayers() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("articles").addMapping(
|
||||
"article",
|
||||
prepareCreate("articles").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("article")
|
||||
.startObject("properties")
|
||||
.startObject("comments")
|
||||
.field("type", "nested")
|
||||
|
@ -339,7 +334,6 @@ public class InnerHitsIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -583,8 +577,7 @@ public class InnerHitsIT extends OpenSearchIntegTestCase {
|
|||
// number_of_shards = 1, because then we catch the expected exception in the same way.
|
||||
// (See expectThrows(...) below)
|
||||
.setSettings(Settings.builder().put("index.number_of_shards", 1))
|
||||
.addMapping(
|
||||
"article",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
.startObject("comments")
|
||||
|
@ -741,7 +734,6 @@ public class InnerHitsIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testMatchesQueriesNestedInnerHits() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("nested1")
|
||||
.field("type", "nested")
|
||||
|
@ -755,9 +747,8 @@ public class InnerHitsIT extends OpenSearchIntegTestCase {
|
|||
.field("type", "long")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type1", builder));
|
||||
assertAcked(prepareCreate("test").setMapping(builder));
|
||||
ensureGreen();
|
||||
|
||||
List<IndexRequestBuilder> requests = new ArrayList<>();
|
||||
|
|
|
@ -139,18 +139,16 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testHighlightingWithKeywordIgnoreBoundaryScanner() throws IOException {
|
||||
XContentBuilder mappings = jsonBuilder();
|
||||
mappings.startObject();
|
||||
mappings.startObject("type")
|
||||
.startObject("properties")
|
||||
mappings.startObject("properties")
|
||||
.startObject("tags")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject("sort")
|
||||
.field("type", "long")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
mappings.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
client().prepareIndex("test")
|
||||
.setId("1")
|
||||
.setSource(jsonBuilder().startObject().array("tags", "foo bar", "foo bar", "foo bar", "foo baz").field("sort", 1).endObject())
|
||||
|
@ -176,16 +174,9 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testHighlightingWithStoredKeyword() throws IOException {
|
||||
XContentBuilder mappings = jsonBuilder();
|
||||
mappings.startObject();
|
||||
mappings.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "keyword")
|
||||
.field("store", true)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
mappings.startObject("properties").startObject("text").field("type", "keyword").field("store", true).endObject().endObject();
|
||||
mappings.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("text", "foo").endObject()).get();
|
||||
refresh();
|
||||
SearchResponse search = client().prepareSearch()
|
||||
|
@ -199,18 +190,16 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
// test the kibana case with * as fieldname that will try highlight all fields including meta fields
|
||||
XContentBuilder mappings = jsonBuilder();
|
||||
mappings.startObject();
|
||||
mappings.startObject("type")
|
||||
.startObject("properties")
|
||||
mappings.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "keyword")
|
||||
.field("index_options", "offsets")
|
||||
.field("term_vector", "with_positions_offsets")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
mappings.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("text", "text").endObject()).get();
|
||||
refresh();
|
||||
for (String type : ALL_TYPES) {
|
||||
|
@ -224,7 +213,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testFieldAlias() throws IOException {
|
||||
XContentBuilder mappings = jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
|
@ -236,9 +224,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
|
||||
client().prepareIndex("test").setId("1").setSource("text", "foo").get();
|
||||
refresh();
|
||||
|
@ -253,7 +240,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testFieldAliasWithSourceLookup() throws IOException {
|
||||
XContentBuilder mappings = jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
|
@ -266,9 +252,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
|
||||
client().prepareIndex("test").setId("1").setSource("text", "foo bar").get();
|
||||
refresh();
|
||||
|
@ -283,7 +268,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testFieldAliasWithWildcardField() throws IOException {
|
||||
XContentBuilder mappings = jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("keyword")
|
||||
.field("type", "keyword")
|
||||
|
@ -293,9 +277,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
|
||||
client().prepareIndex("test").setId("1").setSource("keyword", "foo").get();
|
||||
refresh();
|
||||
|
@ -308,8 +291,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOException {
|
||||
XContentBuilder mappings = jsonBuilder();
|
||||
mappings.startObject();
|
||||
mappings.startObject("type")
|
||||
.startObject("_source")
|
||||
mappings.startObject("_source")
|
||||
.field("enabled", false)
|
||||
.endObject()
|
||||
.startObject("properties")
|
||||
|
@ -325,10 +307,9 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("type", "text")
|
||||
.field("store", true)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
mappings.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
client().prepareIndex("test")
|
||||
.setId("1")
|
||||
.setSource(jsonBuilder().startObject().field("unstored_text", "text").field("text", "text").endObject())
|
||||
|
@ -410,10 +391,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSourceLookupHighlightingUsingPlainHighlighter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
// we don't store title and don't use term vector, now lets see if it works...
|
||||
.startObject("title")
|
||||
|
@ -432,7 +411,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -480,10 +458,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSourceLookupHighlightingUsingFastVectorHighlighter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
// we don't store title, now lets see if it works...
|
||||
.startObject("title")
|
||||
|
@ -502,7 +478,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -550,10 +525,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSourceLookupHighlightingUsingPostingsHighlighter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
// we don't store title, now lets see if it works...
|
||||
.startObject("title")
|
||||
|
@ -572,7 +545,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -771,10 +743,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testForceSourceWithSourceDisabled() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("_source")
|
||||
.field("enabled", false)
|
||||
.endObject()
|
||||
|
@ -790,7 +760,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -852,7 +821,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testFastVectorHighlighter() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(
|
||||
|
@ -886,7 +855,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testHighlighterWithSentenceBoundaryScanner() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(
|
||||
|
@ -927,7 +896,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testHighlighterWithSentenceBoundaryScannerAndLocale() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(
|
||||
|
@ -970,7 +939,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testHighlighterWithWordBoundaryScanner() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(true, client().prepareIndex("test").setSource("field1", "some quick and hairy brown:fox jumped over the lazy dog"));
|
||||
|
@ -1000,7 +969,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testHighlighterWithWordBoundaryScannerAndLocale() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(true, client().prepareIndex("test").setSource("field1", "some quick and hairy brown:fox jumped over the lazy dog"));
|
||||
|
@ -1034,7 +1003,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
* phraseLimit is not set. Its default is now reasonably low.
|
||||
*/
|
||||
public void testFVHManyMatches() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
|
||||
// Index one megabyte of "t " over and over and over again
|
||||
|
@ -1085,11 +1054,9 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
settings.put("index.analysis.analyzer.mock_english.filter", "mock_snowball");
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(settings)
|
||||
.addMapping(
|
||||
"type1",
|
||||
.setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "text")
|
||||
|
@ -1119,7 +1086,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1270,7 +1236,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testFastVectorHighlighterManyDocs() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
|
||||
int COUNT = between(20, 100);
|
||||
|
@ -1297,7 +1263,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
public XContentBuilder type1TermVectorMapping() throws IOException {
|
||||
return XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -1308,7 +1273,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("term_vector", "with_positions_offsets")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
|
@ -1406,10 +1370,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testMultiMapperVectorWithStore() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
|
@ -1427,7 +1389,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1453,10 +1414,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testMultiMapperVectorFromSource() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
|
@ -1474,7 +1433,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1501,10 +1459,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testMultiMapperNoVectorWithStore() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
|
@ -1522,7 +1478,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -1549,10 +1504,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testMultiMapperNoVectorFromSource() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
|
@ -1570,7 +1523,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1739,7 +1691,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testBoostingQueryTermVector() throws IOException {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
client().prepareIndex("test").setSource("field1", "this is a test", "field2", "The quick brown fox jumps over the lazy dog").get();
|
||||
refresh();
|
||||
|
@ -1770,7 +1722,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testCommonTermsTermVector() throws IOException {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test").setSource("field1", "this is a test", "field2", "The quick brown fox jumps over the lazy dog").get();
|
||||
|
@ -2278,7 +2230,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighter() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2349,7 +2301,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterMultipleFields() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()).get());
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()).get());
|
||||
ensureGreen();
|
||||
|
||||
index(
|
||||
|
@ -2371,7 +2323,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterNumberOfFragments() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2457,7 +2409,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testMultiMatchQueryHighlight() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -2470,9 +2421,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("term_vector", "with_positions_offsets")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
ensureGreen();
|
||||
client().prepareIndex("test")
|
||||
.setSource("field1", "The quick brown fox jumps over", "field2", "The quick brown fox jumps over")
|
||||
|
@ -2507,7 +2457,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterOrderByScore() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2585,10 +2535,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testPostingsHighlighterMultiMapperWithStore() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
|
@ -2606,7 +2554,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -2645,10 +2592,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testPostingsHighlighterMultiMapperFromSource() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
|
@ -2666,7 +2611,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -2693,10 +2637,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testPostingsHighlighterShouldFailIfNoOffsets() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
|
@ -2705,7 +2647,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -2726,7 +2667,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterBoostingQuery() throws IOException {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
client().prepareIndex("test")
|
||||
.setSource("field1", "this is a test", "field2", "The quick brown fox jumps over the lazy dog! Second sentence.")
|
||||
|
@ -2743,7 +2684,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterCommonTermsQuery() throws IOException {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2770,7 +2711,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
private static XContentBuilder type1PostingsffsetsMapping() throws IOException {
|
||||
return XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -2781,12 +2721,11 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("index_options", "offsets")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
public void testPostingsHighlighterPrefixQuery() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2808,7 +2747,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterFuzzyQuery() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2831,7 +2770,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterRegexpQuery() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2854,7 +2793,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterWildcardQuery() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2890,7 +2829,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterTermRangeQuery() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test").setSource("field1", "this is a test", "field2", "aaab").get();
|
||||
|
@ -2905,7 +2844,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterQueryString() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -2928,7 +2867,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterRegexpQueryWithinConstantScoreQuery() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test").setSource("field1", "The photography word will get highlighted").get();
|
||||
|
@ -2942,7 +2881,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterMultiTermQueryMultipleLevels() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test").setSource("field1", "The photography word will get highlighted").get();
|
||||
|
@ -2959,7 +2898,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterPrefixQueryWithinBooleanQuery() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test").setSource("field1", "The photography word will get highlighted").get();
|
||||
|
@ -2974,7 +2913,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterQueryStringWithinFilteredQuery() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test").setSource("field1", "The photography word will get highlighted").get();
|
||||
|
@ -2989,7 +2928,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testPostingsHighlighterManyDocs() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1PostingsffsetsMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1PostingsffsetsMapping()));
|
||||
ensureGreen();
|
||||
|
||||
int COUNT = between(20, 100);
|
||||
|
@ -3025,7 +2964,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testDoesNotHighlightTypeName() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("typename")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "text")
|
||||
|
@ -3033,9 +2971,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("term_vector", "with_positions_offsets")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("typename", mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(true, client().prepareIndex("test").setSource("foo", "test typename"));
|
||||
|
@ -3052,7 +2989,6 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testDoesNotHighlightAliasFilters() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("typename")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "text")
|
||||
|
@ -3060,9 +2996,8 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("term_vector", "with_positions_offsets")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("typename", mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
assertAcked(client().admin().indices().prepareAliases().addAlias("test", "filtered_alias", matchQuery("foo", "japanese")));
|
||||
ensureGreen();
|
||||
|
||||
|
@ -3078,7 +3013,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
public void testFastVectorHighlighterPhraseBoost() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));
|
||||
assertAcked(prepareCreate("test").setMapping(type1TermVectorMapping()));
|
||||
phraseBoostTestCase("fvh");
|
||||
}
|
||||
|
||||
|
@ -3174,8 +3109,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
// see https://github.com/elastic/elasticsearch/issues/17537
|
||||
XContentBuilder mappings = jsonBuilder();
|
||||
mappings.startObject();
|
||||
mappings.startObject("type")
|
||||
.startObject("properties")
|
||||
mappings.startObject("properties")
|
||||
.startObject("geo_point")
|
||||
.field("type", "geo_point")
|
||||
.endObject()
|
||||
|
@ -3184,10 +3118,9 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("term_vector", "with_positions_offsets_payloads")
|
||||
.field("index_options", "offsets")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
mappings.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
|
||||
client().prepareIndex("test")
|
||||
.setId("1")
|
||||
|
@ -3216,18 +3149,16 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
// see https://github.com/elastic/elasticsearch/issues/17537#issuecomment-244939633
|
||||
XContentBuilder mappings = jsonBuilder();
|
||||
mappings.startObject();
|
||||
mappings.startObject("jobs")
|
||||
.startObject("properties")
|
||||
mappings.startObject("properties")
|
||||
.startObject("loc")
|
||||
.field("type", "geo_point")
|
||||
.endObject()
|
||||
.startObject("jd")
|
||||
.field("type", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
mappings.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("jobs", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
ensureYellow();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -3259,15 +3190,9 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
// check that keyword highlighting works
|
||||
XContentBuilder mappings = jsonBuilder();
|
||||
mappings.startObject();
|
||||
mappings.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("keyword_field")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
mappings.startObject("properties").startObject("keyword_field").field("type", "keyword").endObject().endObject();
|
||||
mappings.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mappings));
|
||||
assertAcked(prepareCreate("test").setMapping(mappings));
|
||||
|
||||
client().prepareIndex("test")
|
||||
.setId("1")
|
||||
|
@ -3299,7 +3224,7 @@ public class HighlighterSearchIT extends OpenSearchIntegTestCase {
|
|||
// If field is not stored, it is looked up in source (but source has only 'foo'
|
||||
b.startObject("foo_copy").field("type", "text").field("store", true).endObject();
|
||||
b.endObject().endObject();
|
||||
prepareCreate("test").addMapping("type", b).get();
|
||||
prepareCreate("test").setMapping(b).get();
|
||||
|
||||
client().prepareIndex("test")
|
||||
.setId("1")
|
||||
|
|
|
@ -88,7 +88,7 @@ public class FieldCapabilitiesIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("old_index").addMapping("_doc", oldIndexMapping));
|
||||
assertAcked(prepareCreate("old_index").setMapping(oldIndexMapping));
|
||||
|
||||
XContentBuilder newIndexMapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -106,7 +106,7 @@ public class FieldCapabilitiesIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("new_index").addMapping("_doc", newIndexMapping));
|
||||
assertAcked(prepareCreate("new_index").setMapping(newIndexMapping));
|
||||
assertAcked(client().admin().indices().prepareAliases().addAlias("new_index", "current"));
|
||||
}
|
||||
|
||||
|
|
|
@ -774,10 +774,8 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
.indices()
|
||||
.prepareCreate("my-index")
|
||||
.setSettings(Settings.builder().put("index.refresh_interval", -1))
|
||||
.addMapping(
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "object")
|
||||
|
@ -800,7 +798,6 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.get();
|
||||
|
||||
|
@ -1181,7 +1178,6 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
public void testDocValueFieldsWithFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("_source")
|
||||
.field("enabled", false)
|
||||
.endObject()
|
||||
|
@ -1203,9 +1199,8 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "date_field")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
ensureGreen("test");
|
||||
|
||||
DateTime date = new DateTime(1990, 12, 29, 0, 0, DateTimeZone.UTC);
|
||||
|
@ -1244,7 +1239,6 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
public void testWildcardDocValueFieldsWithFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("_source")
|
||||
.field("enabled", false)
|
||||
.endObject()
|
||||
|
@ -1266,9 +1260,8 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "date_field")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
ensureGreen("test");
|
||||
|
||||
DateTime date = new DateTime(1990, 12, 29, 0, 0, DateTimeZone.UTC);
|
||||
|
@ -1306,7 +1299,6 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
public void testStoredFieldsWithFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -1325,9 +1317,8 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "field2")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
|
||||
index("test", MapperService.SINGLE_MAPPING_NAME, "1", "field1", "value1", "field2", "value2");
|
||||
refresh("test");
|
||||
|
@ -1350,7 +1341,6 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
public void testWildcardStoredFieldsWithFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -1369,9 +1359,8 @@ public class SearchFieldsIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "field2")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
|
||||
index("test", MapperService.SINGLE_MAPPING_NAME, "1", "field1", "value1", "field2", "value2");
|
||||
refresh("test");
|
||||
|
|
|
@ -96,10 +96,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testDistanceScoreGeoLinGaussExp() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -109,7 +107,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -223,10 +220,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testDistanceScoreGeoLinGaussExpWithOffset() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -236,7 +231,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -337,10 +331,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1).build();
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(settings)
|
||||
.addMapping(
|
||||
"type1",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -350,7 +342,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -436,10 +427,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testParseGeoPoint() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -449,7 +438,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -504,10 +492,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testCombineModes() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -517,7 +503,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -621,10 +606,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testCombineModesExplain() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -634,7 +617,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -691,10 +673,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testExceptionThrownIfScaleLE0() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -704,7 +684,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
client().index(
|
||||
|
@ -731,10 +710,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testParseDateMath() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -745,7 +722,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
client().index(
|
||||
|
@ -785,10 +761,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testValueMissingLin() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -801,7 +775,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -854,10 +827,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
ZonedDateTime dt = ZonedDateTime.now(ZoneOffset.UTC);
|
||||
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -867,7 +838,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -933,7 +903,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
Version version = VersionUtils.randomIndexCompatibleVersion(random());
|
||||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -949,8 +918,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.startObject("geo")
|
||||
.field("type", "geo_point")
|
||||
.field("ignore_malformed", true);
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder));
|
||||
int numDocs = 200;
|
||||
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
|
||||
|
||||
|
@ -1013,10 +982,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testParsingExceptionIfFieldDoesNotExist() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -1026,7 +993,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
int numDocs = 2;
|
||||
|
@ -1066,10 +1032,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -1079,7 +1043,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
client().index(
|
||||
|
@ -1105,10 +1068,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testNoQueryGiven() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -1118,7 +1079,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
client().index(indexRequest("test").source(jsonBuilder().startObject().field("test", "value").field("num", 1.0).endObject()))
|
||||
|
@ -1138,10 +1098,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testMultiFieldOptions() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -1154,7 +1112,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -1271,10 +1228,8 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testDistanceScoreGeoLinGaussExplain() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -1284,7 +1239,6 @@ public class DecayFunctionScoreIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -57,10 +57,8 @@ import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertOrderedSea
|
|||
public class FunctionScoreFieldValueIT extends OpenSearchIntegTestCase {
|
||||
public void testFieldValueFactor() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", randomFrom(new String[] { "short", "float", "long", "integer", "double" }))
|
||||
|
@ -70,7 +68,6 @@ public class FunctionScoreFieldValueIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get()
|
||||
);
|
||||
|
||||
|
@ -169,10 +166,8 @@ public class FunctionScoreFieldValueIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testFieldValueFactorExplain() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", randomFrom(new String[] { "short", "float", "long", "integer", "double" }))
|
||||
|
@ -182,7 +177,6 @@ public class FunctionScoreFieldValueIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get()
|
||||
);
|
||||
|
||||
|
|
|
@ -76,10 +76,8 @@ public class FunctionScorePluginIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addMapping(
|
||||
"type1",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("test")
|
||||
.field("type", "text")
|
||||
|
@ -89,7 +87,6 @@ public class FunctionScorePluginIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.get();
|
||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().get();
|
||||
|
|
|
@ -127,10 +127,8 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testRescorePhrase() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("analyzer", "whitespace")
|
||||
|
@ -138,7 +136,6 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", 1))
|
||||
);
|
||||
|
||||
|
@ -190,22 +187,16 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "whitespace")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(
|
||||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addMapping("type1", mapping)
|
||||
.setSettings(builder.put("index.number_of_shards", 1))
|
||||
client().admin().indices().prepareCreate("test").setMapping(mapping).setSettings(builder.put("index.number_of_shards", 1))
|
||||
);
|
||||
|
||||
client().prepareIndex("test").setId("1").setSource("field1", "massachusetts avenue boston massachusetts").get();
|
||||
|
@ -285,22 +276,16 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "whitespace")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(
|
||||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addMapping("type1", mapping)
|
||||
.setSettings(builder.put("index.number_of_shards", 1))
|
||||
client().admin().indices().prepareCreate("test").setMapping(mapping).setSettings(builder.put("index.number_of_shards", 1))
|
||||
);
|
||||
|
||||
client().prepareIndex("test").setId("3").setSource("field1", "massachusetts").get();
|
||||
|
@ -371,22 +356,16 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "whitespace")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(
|
||||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addMapping("type1", mapping)
|
||||
.setSettings(builder.put("index.number_of_shards", 1))
|
||||
client().admin().indices().prepareCreate("test").setMapping(mapping).setSettings(builder.put("index.number_of_shards", 1))
|
||||
);
|
||||
|
||||
client().prepareIndex("test").setId("3").setSource("field1", "massachusetts").get();
|
||||
|
@ -524,10 +503,8 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testExplain() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("analyzer", "whitespace")
|
||||
|
@ -535,7 +512,6 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -785,10 +761,8 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("analyzer", analyzer)
|
||||
|
@ -796,7 +770,6 @@ public class QueryRescorerIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).setSettings(builder)
|
||||
);
|
||||
int numDocs = randomIntBetween(100, 150);
|
||||
|
|
|
@ -64,12 +64,11 @@ public class GeoBoundingBoxQueryIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("location")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -195,12 +194,11 @@ public class GeoBoundingBoxQueryIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("location")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -275,12 +273,11 @@ public class GeoBoundingBoxQueryIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("location")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
|
|
@ -124,12 +124,11 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("location")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
}
|
||||
|
||||
|
|
|
@ -393,7 +393,6 @@ public class GeoFilterIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("country")
|
||||
.startObject("properties")
|
||||
.startObject("pin")
|
||||
.field("type", "geo_point");
|
||||
|
@ -404,10 +403,9 @@ public class GeoFilterIT extends OpenSearchIntegTestCase {
|
|||
.field("ignore_malformed", true)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
client().admin().indices().prepareCreate("countries").setSettings(settings).addMapping("country", xContentBuilder).get();
|
||||
client().admin().indices().prepareCreate("countries").setSettings(settings).setMapping(xContentBuilder).get();
|
||||
BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, xContentBuilder.contentType()).get();
|
||||
|
||||
for (BulkItemResponse item : bulk.getItems()) {
|
||||
|
|
|
@ -86,17 +86,14 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
public void testSimpleMoreLikeThis() throws Exception {
|
||||
logger.info("Creating index test");
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -119,17 +116,14 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
public void testSimpleMoreLikeThisWithTypes() throws Exception {
|
||||
logger.info("Creating index test");
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -151,10 +145,8 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
|
||||
// Issue #30148
|
||||
public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Exception {
|
||||
CreateIndexRequestBuilder createIndexRequestBuilder = prepareCreate("test").addMapping(
|
||||
"type",
|
||||
CreateIndexRequestBuilder createIndexRequestBuilder = prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("myField")
|
||||
.field("type", "text")
|
||||
|
@ -164,7 +156,6 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
assertAcked(createIndexRequestBuilder);
|
||||
|
@ -214,17 +205,14 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
public void testMoreLikeThisWithAliases() throws Exception {
|
||||
logger.info("Creating index test");
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
logger.info("Creating aliases alias release");
|
||||
|
@ -370,10 +358,8 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
// Issue #3252
|
||||
public void testNumericField() throws Exception {
|
||||
final String[] numericTypes = new String[] { "byte", "short", "integer", "long" };
|
||||
prepareCreate("test").addMapping(
|
||||
"type",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("int_value")
|
||||
.field("type", randomFrom(numericTypes))
|
||||
|
@ -383,7 +369,6 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
).get();
|
||||
ensureGreen();
|
||||
client().prepareIndex("test")
|
||||
|
@ -486,7 +471,6 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
public void testMoreLikeThisWithFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("_doc")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
|
@ -496,10 +480,9 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(prepareCreate("test").addMapping("_doc", mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
index("test", "_doc", "1", "text", "lucene");
|
||||
|
@ -517,17 +500,14 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
public void testSimpleMoreLikeInclude() throws Exception {
|
||||
logger.info("Creating index test");
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -584,17 +564,14 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
public void testSimpleMoreLikeThisIds() throws Exception {
|
||||
logger.info("Creating index test");
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -867,10 +844,8 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
public void testWithMissingRouting() throws IOException {
|
||||
logger.info("Creating index test with routing required for type1");
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
|
@ -880,7 +855,6 @@ public class MoreLikeThisIT extends OpenSearchIntegTestCase {
|
|||
.field("required", true)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -213,10 +213,8 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testMultiNested() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("nested1")
|
||||
.field("type", "nested")
|
||||
|
@ -228,7 +226,6 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -371,10 +368,8 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
public void testDeleteNestedDocsWithAlias() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.refresh_interval", -1).build())
|
||||
.addMapping(
|
||||
"type1",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -384,7 +379,6 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -437,17 +431,14 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testExplain() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("nested1")
|
||||
.field("type", "nested")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -485,10 +476,8 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
public void testSimpleNestedSorting() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.refresh_interval", -1))
|
||||
.addMapping(
|
||||
"type1",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("nested1")
|
||||
.field("type", "nested")
|
||||
|
@ -501,7 +490,6 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -586,10 +574,8 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
public void testSimpleNestedSortingWithNestedFilterMissing() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.refresh_interval", -1))
|
||||
.addMapping(
|
||||
"type1",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("nested1")
|
||||
.field("type", "nested")
|
||||
|
@ -604,7 +590,6 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1048,11 +1033,9 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSortNestedWithNestedFilter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("grand_parent_values")
|
||||
.field("type", "long")
|
||||
|
@ -1075,7 +1058,6 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1448,8 +1430,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase {
|
|||
// Issue #9305
|
||||
public void testNestedSortingWithNestedFilterAsFilter() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
.startObject("officelocation")
|
||||
|
|
|
@ -70,7 +70,6 @@ public class ExistsIT extends OpenSearchIntegTestCase {
|
|||
public void testExists() throws Exception {
|
||||
XContentBuilder mapping = XContentBuilder.builder(JsonXContent.jsonXContent)
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "text")
|
||||
|
@ -95,10 +94,9 @@ public class ExistsIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", mapping));
|
||||
assertAcked(client().admin().indices().prepareCreate("idx").setMapping(mapping));
|
||||
Map<String, Object> barObject = new HashMap<>();
|
||||
barObject.put("foo", "bar");
|
||||
barObject.put("bar", singletonMap("bar", "foo"));
|
||||
|
@ -176,7 +174,6 @@ public class ExistsIT extends OpenSearchIntegTestCase {
|
|||
public void testFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("bar")
|
||||
.field("type", "long")
|
||||
|
@ -194,9 +191,8 @@ public class ExistsIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "foo.bar")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("idx").addMapping("type", mapping));
|
||||
assertAcked(prepareCreate("idx").setMapping(mapping));
|
||||
ensureGreen("idx");
|
||||
|
||||
List<IndexRequestBuilder> indexRequests = new ArrayList<>();
|
||||
|
@ -226,7 +222,6 @@ public class ExistsIT extends OpenSearchIntegTestCase {
|
|||
public void testFieldAliasWithNoDocValues() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "long")
|
||||
|
@ -237,9 +232,8 @@ public class ExistsIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "foo")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("idx").addMapping("type", mapping));
|
||||
assertAcked(prepareCreate("idx").setMapping(mapping));
|
||||
ensureGreen("idx");
|
||||
|
||||
List<IndexRequestBuilder> indexRequests = new ArrayList<>();
|
||||
|
|
|
@ -109,7 +109,7 @@ public class MultiMatchQueryIT extends OpenSearchIntegTestCase {
|
|||
.put("index.analysis.analyzer.category.tokenizer", "standard")
|
||||
.put("index.analysis.analyzer.category.filter", "lowercase")
|
||||
);
|
||||
assertAcked(builder.addMapping("test", createMapping()));
|
||||
assertAcked(builder.setMapping(createMapping()));
|
||||
ensureGreen();
|
||||
int numDocs = scaledRandomIntBetween(50, 100);
|
||||
List<IndexRequestBuilder> builders = new ArrayList<>();
|
||||
|
@ -259,7 +259,6 @@ public class MultiMatchQueryIT extends OpenSearchIntegTestCase {
|
|||
private XContentBuilder createMapping() throws IOException {
|
||||
return XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("test")
|
||||
.startObject("properties")
|
||||
.startObject("id")
|
||||
.field("type", "keyword")
|
||||
|
@ -287,7 +286,6 @@ public class MultiMatchQueryIT extends OpenSearchIntegTestCase {
|
|||
.field("type", "date")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -278,16 +278,14 @@ public class QueryStringIT extends OpenSearchIntegTestCase {
|
|||
public void testLimitOnExpandedFieldsButIgnoreUnmappedFields() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.startObject("_doc");
|
||||
builder.startObject("properties");
|
||||
for (int i = 0; i < CLUSTER_MAX_CLAUSE_COUNT; i++) {
|
||||
builder.startObject("field" + i).field("type", "text").endObject();
|
||||
}
|
||||
builder.endObject(); // properties
|
||||
builder.endObject(); // type1
|
||||
builder.endObject();
|
||||
|
||||
assertAcked(prepareCreate("ignoreunmappedfields").addMapping("_doc", builder));
|
||||
assertAcked(prepareCreate("ignoreunmappedfields").setMapping(builder));
|
||||
|
||||
client().prepareIndex("ignoreunmappedfields").setId("1").setSource("field1", "foo bar baz").get();
|
||||
refresh();
|
||||
|
@ -303,25 +301,19 @@ public class QueryStringIT extends OpenSearchIntegTestCase {
|
|||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject();
|
||||
{
|
||||
builder.startObject("_doc");
|
||||
{
|
||||
builder.startObject("properties");
|
||||
{
|
||||
for (int i = 0; i < CLUSTER_MAX_CLAUSE_COUNT; i++) {
|
||||
builder.startObject("field_A" + i).field("type", "text").endObject();
|
||||
builder.startObject("field_B" + i).field("type", "text").endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
builder.startObject("properties");
|
||||
for (int i = 0; i < CLUSTER_MAX_CLAUSE_COUNT; i++) {
|
||||
builder.startObject("field_A" + i).field("type", "text").endObject();
|
||||
builder.startObject("field_B" + i).field("type", "text").endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
|
||||
assertAcked(
|
||||
prepareCreate("testindex").setSettings(
|
||||
Settings.builder().put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), CLUSTER_MAX_CLAUSE_COUNT + 100)
|
||||
).addMapping("_doc", builder)
|
||||
).setMapping(builder)
|
||||
);
|
||||
|
||||
client().prepareIndex("testindex").setId("1").setSource("field_A0", "foo bar baz").get();
|
||||
|
|
|
@ -1119,10 +1119,8 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
public void testTermsLookupFilter() throws Exception {
|
||||
assertAcked(prepareCreate("lookup").addMapping("type", "terms", "type=text", "other", "type=text"));
|
||||
assertAcked(
|
||||
prepareCreate("lookup2").addMapping(
|
||||
"type",
|
||||
prepareCreate("lookup2").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("arr")
|
||||
.startObject("properties")
|
||||
|
@ -1133,7 +1131,6 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
assertAcked(prepareCreate("lookup3").addMapping("type", "_source", "enabled=false", "terms", "type=text"));
|
||||
|
@ -1600,10 +1597,8 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSimpleDFSQuery() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"_doc",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("_doc")
|
||||
.startObject("_routing")
|
||||
.field("required", true)
|
||||
.endObject()
|
||||
|
@ -1621,7 +1616,6 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -1876,8 +1870,7 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
assert ("SPI,COMPAT".equals(System.getProperty("java.locale.providers"))) : "`-Djava.locale.providers=SPI,COMPAT` needs to be set";
|
||||
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("properties")
|
||||
.startObject("date_field")
|
||||
|
@ -1978,7 +1971,6 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
public void testNestedQueryWithFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("_doc")
|
||||
.startObject("properties")
|
||||
.startObject("section")
|
||||
.field("type", "nested")
|
||||
|
@ -1993,9 +1985,8 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("index").addMapping("_doc", mapping));
|
||||
assertAcked(prepareCreate("index").setMapping(mapping));
|
||||
|
||||
XContentBuilder source = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
|
@ -2019,7 +2010,6 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
public void testFieldAliasesForMetaFields() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("id-alias")
|
||||
.field("type", "alias")
|
||||
|
@ -2030,9 +2020,8 @@ public class SearchQueryIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "_routing")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
|
||||
IndexRequestBuilder indexRequest = client().prepareIndex("test").setId("1").setRouting("custom").setSource("field", "value");
|
||||
indexRandom(true, false, indexRequest);
|
||||
|
|
|
@ -239,10 +239,8 @@ public class SimpleQueryStringIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testNestedFieldSimpleQueryString() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("body")
|
||||
.field("type", "text")
|
||||
|
@ -253,7 +251,6 @@ public class SimpleQueryStringIT extends OpenSearchIntegTestCase {
|
|||
.endObject() // fields
|
||||
.endObject() // body
|
||||
.endObject() // properties
|
||||
.endObject() // type1
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
@ -607,19 +604,17 @@ public class SimpleQueryStringIT extends OpenSearchIntegTestCase {
|
|||
public void testLimitOnExpandedFields() throws Exception {
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.startObject("type1");
|
||||
builder.startObject("properties");
|
||||
for (int i = 0; i < CLUSTER_MAX_CLAUSE_COUNT + 1; i++) {
|
||||
builder.startObject("field" + i).field("type", "text").endObject();
|
||||
}
|
||||
builder.endObject(); // properties
|
||||
builder.endObject(); // type1
|
||||
builder.endObject();
|
||||
|
||||
assertAcked(
|
||||
prepareCreate("toomanyfields").setSettings(
|
||||
Settings.builder().put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), CLUSTER_MAX_CLAUSE_COUNT + 100)
|
||||
).addMapping("type1", builder)
|
||||
).setMapping(builder)
|
||||
);
|
||||
|
||||
client().prepareIndex("toomanyfields").setId("1").setSource("field1", "foo bar baz").get();
|
||||
|
|
|
@ -127,11 +127,7 @@ public class ScriptQuerySearchIT extends OpenSearchIntegTestCase {
|
|||
final byte[] randomBytesDoc2 = getRandomBytes(16);
|
||||
|
||||
assertAcked(
|
||||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("my-index")
|
||||
.addMapping("my-type", createMappingSource("binary"))
|
||||
.setSettings(indexSettings())
|
||||
client().admin().indices().prepareCreate("my-index").setMapping(createMappingSource("binary")).setSettings(indexSettings())
|
||||
);
|
||||
client().prepareIndex("my-index")
|
||||
.setId("1")
|
||||
|
@ -170,14 +166,12 @@ public class ScriptQuerySearchIT extends OpenSearchIntegTestCase {
|
|||
private XContentBuilder createMappingSource(String fieldType) throws IOException {
|
||||
return XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("my-type")
|
||||
.startObject("properties")
|
||||
.startObject("binaryData")
|
||||
.field("type", fieldType)
|
||||
.field("doc_values", "true")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -115,10 +115,8 @@ public class DuelScrollIT extends OpenSearchIntegTestCase {
|
|||
|
||||
private TestContext create(SearchType... searchTypes) throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("index").addMapping(
|
||||
"type",
|
||||
prepareCreate("index").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "long")
|
||||
|
@ -139,7 +137,6 @@ public class DuelScrollIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -276,11 +276,9 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
public void testRandomSorting() throws IOException, InterruptedException, ExecutionException {
|
||||
Random random = random();
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("sparse_bytes")
|
||||
.field("type", "keyword")
|
||||
|
@ -290,7 +288,6 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -558,11 +555,9 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
public void testSimpleSorts() throws Exception {
|
||||
Random random = random();
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("str_value")
|
||||
.field("type", "keyword")
|
||||
|
@ -590,7 +585,6 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -801,11 +795,9 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSortMissingNumbers() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("i_value")
|
||||
.field("type", "integer")
|
||||
|
@ -815,7 +807,6 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -873,18 +864,15 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSortMissingStrings() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("value")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1009,11 +997,9 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSortMVField() throws Exception {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("long_values")
|
||||
.field("type", "long")
|
||||
|
@ -1038,7 +1024,6 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1345,18 +1330,15 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testSortOnRareField() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("string_values")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -1494,11 +1476,9 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
*/
|
||||
public void testNestedSort() throws IOException, InterruptedException, ExecutionException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type",
|
||||
prepareCreate("test").setMapping(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("nested")
|
||||
.field("type", "nested")
|
||||
|
@ -1530,7 +1510,6 @@ public class FieldSortIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
|
|
@ -72,12 +72,11 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("locations")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.field("ignore_malformed", true).endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder));
|
||||
xContentBuilder.field("ignore_malformed", true).endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -268,12 +267,11 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("locations")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test")
|
||||
|
@ -333,7 +331,6 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
|
|||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("company")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "text")
|
||||
|
@ -346,9 +343,9 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.startObject("location")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject().endObject().endObject();
|
||||
xContentBuilder.endObject().endObject().endObject().endObject().endObject();
|
||||
|
||||
assertAcked(prepareCreate("companies").setSettings(settings).addMapping("company", xContentBuilder));
|
||||
assertAcked(prepareCreate("companies").setSettings(settings).setMapping(xContentBuilder));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(
|
||||
|
@ -590,15 +587,14 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = JsonXContent.contentBuilder()
|
||||
.startObject()
|
||||
.startObject("location")
|
||||
.startObject("properties")
|
||||
.startObject("pin")
|
||||
.field("type", "geo_point");
|
||||
mapping.endObject().endObject().endObject().endObject();
|
||||
mapping.endObject().endObject().endObject();
|
||||
|
||||
XContentBuilder source = JsonXContent.contentBuilder().startObject().field("pin", Geohash.stringEncode(lon, lat)).endObject();
|
||||
|
||||
assertAcked(prepareCreate("locations").setSettings(settings).addMapping("location", mapping));
|
||||
assertAcked(prepareCreate("locations").setSettings(settings).setMapping(mapping));
|
||||
client().prepareIndex("locations").setId("1").setCreate(true).setSource(source).get();
|
||||
refresh();
|
||||
client().prepareGet("locations", "1").get();
|
||||
|
@ -614,12 +610,11 @@ public class GeoDistanceIT extends OpenSearchIntegTestCase {
|
|||
public void testDistanceSortingWithUnmappedField() throws Exception {
|
||||
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("locations")
|
||||
.field("type", "geo_point");
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test1").addMapping("type1", xContentBuilder));
|
||||
xContentBuilder.endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test1").setMapping(xContentBuilder));
|
||||
assertAcked(prepareCreate("test2"));
|
||||
ensureGreen();
|
||||
|
||||
|
|
|
@ -134,10 +134,8 @@ public class SimpleSortIT extends OpenSearchIntegTestCase {
|
|||
public void testSimpleSorts() throws Exception {
|
||||
Random random = random();
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"type1",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("str_value")
|
||||
.field("type", "keyword")
|
||||
|
@ -165,7 +163,6 @@ public class SimpleSortIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
@ -446,17 +443,14 @@ public class SimpleSortIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void test2920() throws IOException {
|
||||
assertAcked(
|
||||
prepareCreate("test").addMapping(
|
||||
"test",
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("test")
|
||||
.startObject("properties")
|
||||
.startObject("value")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
);
|
||||
ensureGreen();
|
||||
|
|
|
@ -682,15 +682,13 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
public void testThatUpgradeToMultiFieldsWorks() throws Exception {
|
||||
final XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject(FIELD)
|
||||
.field("type", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate(INDEX).addMapping(MapperService.SINGLE_MAPPING_NAME, mapping));
|
||||
assertAcked(prepareCreate(INDEX).setMapping(mapping));
|
||||
client().prepareIndex(INDEX)
|
||||
.setId("1")
|
||||
.setRefreshPolicy(IMMEDIATE)
|
||||
|
@ -1328,7 +1326,7 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.indices()
|
||||
.prepareCreate(INDEX)
|
||||
.setSettings(Settings.builder().put(indexSettings()).put(settings))
|
||||
.addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)
|
||||
.setMapping(mapping)
|
||||
.get()
|
||||
);
|
||||
}
|
||||
|
@ -1376,17 +1374,14 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate(INDEX)
|
||||
.addMapping(
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject(FIELD)
|
||||
.field("type", "completion")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.get()
|
||||
);
|
||||
|
@ -1408,17 +1403,14 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate(INDEX)
|
||||
.addMapping(
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject(FIELD)
|
||||
.field("type", "completion")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.get()
|
||||
);
|
||||
|
@ -1449,17 +1441,14 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate(INDEX)
|
||||
.addMapping(
|
||||
MapperService.SINGLE_MAPPING_NAME,
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject(FIELD)
|
||||
.field("type", "completion")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.get()
|
||||
);
|
||||
|
@ -1508,7 +1497,6 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testSuggestWithFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject(FIELD)
|
||||
.field("type", "completion")
|
||||
|
@ -1518,9 +1506,8 @@ public class CompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("path", FIELD)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate(INDEX).addMapping(MapperService.SINGLE_MAPPING_NAME, mapping));
|
||||
assertAcked(prepareCreate(INDEX).setMapping(mapping));
|
||||
|
||||
List<IndexRequestBuilder> builders = new ArrayList<>();
|
||||
builders.add(client().prepareIndex(INDEX).setSource(FIELD, "apple"));
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.opensearch.common.settings.Settings;
|
|||
import org.opensearch.common.unit.Fuzziness;
|
||||
import org.opensearch.common.xcontent.ToXContent;
|
||||
import org.opensearch.common.xcontent.XContentBuilder;
|
||||
import org.opensearch.index.mapper.MapperService;
|
||||
import org.opensearch.rest.RestStatus;
|
||||
import org.opensearch.search.suggest.CompletionSuggestSearchIT.CompletionMappingBuilder;
|
||||
import org.opensearch.search.suggest.completion.CompletionSuggestionBuilder;
|
||||
|
@ -608,7 +607,7 @@ public class ContextCompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
mapping.endObject();
|
||||
mapping.endObject();
|
||||
|
||||
assertAcked(prepareCreate(INDEX).addMapping(MapperService.SINGLE_MAPPING_NAME, mapping));
|
||||
assertAcked(prepareCreate(INDEX).setMapping(mapping));
|
||||
|
||||
XContentBuilder source1 = jsonBuilder().startObject()
|
||||
.startObject("location")
|
||||
|
@ -754,7 +753,7 @@ public class ContextCompletionSuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.indices()
|
||||
.prepareCreate(INDEX)
|
||||
.setSettings(Settings.builder().put(indexSettings()).put(settings))
|
||||
.addMapping(MapperService.SINGLE_MAPPING_NAME, mapping)
|
||||
.setMapping(mapping)
|
||||
.get()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -127,16 +127,14 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test_2").addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test_2").setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
index("test_2", "type1", "1", "text", "ab cd");
|
||||
|
@ -217,7 +215,6 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "text")
|
||||
|
@ -230,9 +227,8 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type1", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
index("test", "type1", "1", "name", "I like iced tea");
|
||||
|
@ -300,7 +296,6 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "text")
|
||||
|
@ -313,9 +308,8 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type1", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
indexRandom(
|
||||
|
@ -558,7 +552,6 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("body")
|
||||
.field("type", "text")
|
||||
|
@ -569,9 +562,8 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("analyzer", "bigram")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type1", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
index("test", "type1", "1", "body", "hello world");
|
||||
|
@ -614,7 +606,6 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
);
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("body")
|
||||
.field("type", "text")
|
||||
|
@ -625,9 +616,8 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("analyzer", "bigram")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type1", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
String[] strings = new String[] {
|
||||
|
@ -758,7 +748,6 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("body")
|
||||
.field("type", "text")
|
||||
|
@ -769,9 +758,8 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("analyzer", "bigram")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type1", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
String line = "xorr the god jewel";
|
||||
|
@ -833,16 +821,14 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type2")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "suggest")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type2", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
index("test", "type2", "1", "foo", "bar");
|
||||
|
@ -880,14 +866,12 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testEmptyShards() throws IOException, InterruptedException {
|
||||
XContentBuilder mappingBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "suggest")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(
|
||||
|
@ -901,7 +885,7 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.put("index.analysis.filter.shingler.min_shingle_size", 2)
|
||||
.put("index.analysis.filter.shingler.max_shingle_size", 5)
|
||||
.put("index.analysis.filter.shingler.output_unigrams", true)
|
||||
).addMapping("type1", mappingBuilder)
|
||||
).setMapping(mappingBuilder)
|
||||
);
|
||||
ensureGreen();
|
||||
|
||||
|
@ -978,16 +962,14 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("body")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "body")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type1", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
NumShards test = getNumShards("test");
|
||||
|
@ -1039,16 +1021,14 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type1", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
List<String> titles = new ArrayList<>();
|
||||
|
@ -1166,7 +1146,6 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testSuggestWithFieldAlias() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "keyword")
|
||||
|
@ -1176,9 +1155,8 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
.field("path", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate("test").addMapping("type", mapping));
|
||||
assertAcked(prepareCreate("test").setMapping(mapping));
|
||||
|
||||
List<IndexRequestBuilder> builders = new ArrayList<>();
|
||||
builders.add(client().prepareIndex("test").setSource("text", "apple"));
|
||||
|
@ -1195,17 +1173,13 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
public void testPhraseSuggestMinDocFreq() throws Exception {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(
|
||||
prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 1).build()).addMapping("type", mapping)
|
||||
);
|
||||
assertAcked(prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 1).build()).setMapping(mapping));
|
||||
|
||||
List<IndexRequestBuilder> builders = new ArrayList<>();
|
||||
builders.add(client().prepareIndex("test").setSource("text", "apple"));
|
||||
|
@ -1298,16 +1272,14 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title")
|
||||
.field("type", "text")
|
||||
.field("analyzer", "text")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(builder.addMapping("type1", mapping));
|
||||
assertAcked(builder.setMapping(mapping));
|
||||
ensureGreen();
|
||||
|
||||
List<String> titles = new ArrayList<>();
|
||||
|
|
|
@ -53,10 +53,8 @@ public class SimilarityIT extends OpenSearchIntegTestCase {
|
|||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addMapping(
|
||||
"type1",
|
||||
.setMapping(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("similarity", "custom")
|
||||
|
@ -68,7 +66,6 @@ public class SimilarityIT extends OpenSearchIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
)
|
||||
.setSettings(
|
||||
Settings.builder()
|
||||
|
|
|
@ -248,16 +248,33 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param type The mapping type
|
||||
* @param source The mapping source
|
||||
* @param xContentType the content type of the mapping source
|
||||
* @deprecated types are being removed
|
||||
*/
|
||||
@Deprecated
|
||||
private CreateIndexRequest mapping(String type, BytesReference source, XContentType xContentType) {
|
||||
private CreateIndexRequest mapping(BytesReference source, XContentType xContentType) {
|
||||
Objects.requireNonNull(xContentType);
|
||||
Map<String, Object> mappingAsMap = XContentHelper.convertToMap(source, false, xContentType).v2();
|
||||
return mapping(type, mappingAsMap);
|
||||
return mapping(MapperService.SINGLE_MAPPING_NAME, mappingAsMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param source The mapping source
|
||||
*/
|
||||
public CreateIndexRequest mapping(XContentBuilder source) {
|
||||
return mapping(BytesReference.bytes(source), source.contentType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mapping for this index
|
||||
*
|
||||
* @param source The mapping source
|
||||
*/
|
||||
public CreateIndexRequest mapping(Map<String, ?> source) {
|
||||
return mapping(MapperService.SINGLE_MAPPING_NAME, source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,19 +285,7 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
* @deprecated types are being removed
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest mapping(String type, XContentBuilder source) {
|
||||
return mapping(type, BytesReference.bytes(source), source.contentType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param type The mapping type
|
||||
* @param source The mapping source
|
||||
* @deprecated types are being removed
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest mapping(String type, Map<String, ?> source) {
|
||||
private CreateIndexRequest mapping(String type, Map<String, ?> source) {
|
||||
// wrap it in a type map if its not
|
||||
if (source.size() != 1 || !source.containsKey(type)) {
|
||||
source = Collections.singletonMap(MapperService.SINGLE_MAPPING_NAME, source);
|
||||
|
@ -304,7 +309,7 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest mapping(String type, Object... source) {
|
||||
mapping(type, PutMappingRequest.buildFromSimplifiedDef(source));
|
||||
mapping(PutMappingRequest.buildFromSimplifiedDef(source));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,43 +113,28 @@ public class CreateIndexRequestBuilder extends AcknowledgedRequestBuilder<
|
|||
*
|
||||
* @param source The mapping source
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequestBuilder setMapping(String source) {
|
||||
request.mapping(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The cause for this index creation.
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param source The mapping source
|
||||
*/
|
||||
public CreateIndexRequestBuilder setCause(String cause) {
|
||||
request.cause(cause);
|
||||
public CreateIndexRequestBuilder setMapping(XContentBuilder source) {
|
||||
request.mapping(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param type The mapping type
|
||||
* @param source The mapping source
|
||||
* @deprecated types are being removed
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequestBuilder addMapping(String type, XContentBuilder source) {
|
||||
request.mapping(type, source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param type The mapping type
|
||||
* @param source The mapping source
|
||||
* @deprecated types are being removed
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequestBuilder addMapping(String type, Map<String, Object> source) {
|
||||
request.mapping(type, source);
|
||||
public CreateIndexRequestBuilder setMapping(Map<String, Object> source) {
|
||||
request.mapping(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -164,6 +149,14 @@ public class CreateIndexRequestBuilder extends AcknowledgedRequestBuilder<
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The cause for this index creation.
|
||||
*/
|
||||
public CreateIndexRequestBuilder setCause(String cause) {
|
||||
request.cause(cause);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the aliases that will be associated with the index when it gets created
|
||||
*/
|
||||
|
|
|
@ -101,7 +101,7 @@ public class RolloverRequest extends AcknowledgedRequest<RolloverRequest> implem
|
|||
if (MapperService.isMappingSourceTyped(MapperService.SINGLE_MAPPING_NAME, mappings)) {
|
||||
throw new IllegalArgumentException("The mapping definition cannot be nested under a type");
|
||||
}
|
||||
request.createIndexRequest.mapping(MapperService.SINGLE_MAPPING_NAME, mappings);
|
||||
request.createIndexRequest.mapping(mappings);
|
||||
}, CreateIndexRequest.MAPPINGS, ObjectParser.ValueType.OBJECT);
|
||||
PARSER.declareField(
|
||||
(parser, request, context) -> request.createIndexRequest.aliases(parser.map()),
|
||||
|
|
|
@ -116,10 +116,10 @@ public class CreateIndexRequestTests extends OpenSearchTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
request1.mapping("type1", builder);
|
||||
request1.mapping(builder);
|
||||
builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));
|
||||
builder.startObject()
|
||||
.startObject("type1")
|
||||
.startObject(MapperService.SINGLE_MAPPING_NAME)
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -134,7 +134,7 @@ public class CreateIndexRequestTests extends OpenSearchTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
request2.mapping("type1", builder);
|
||||
request2.mapping(builder);
|
||||
assertEquals(request1.mappings(), request2.mappings());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class PutMappingRequestTests extends OpenSearchTestCase {
|
|||
String index = randomAlphaOfLength(5);
|
||||
|
||||
PutMappingRequest request = new PutMappingRequest(index);
|
||||
request.source(RandomCreateIndexGenerator.randomMapping("_doc"));
|
||||
request.source(RandomCreateIndexGenerator.randomMapping());
|
||||
|
||||
return request;
|
||||
}
|
||||
|
|
|
@ -218,8 +218,7 @@ public class RolloverRequestTests extends OpenSearchTestCase {
|
|||
private static RolloverRequest createTestItem() throws IOException {
|
||||
RolloverRequest rolloverRequest = new RolloverRequest();
|
||||
if (randomBoolean()) {
|
||||
rolloverRequest.getCreateIndexRequest()
|
||||
.mapping(MapperService.SINGLE_MAPPING_NAME, RandomCreateIndexGenerator.randomMapping(MapperService.SINGLE_MAPPING_NAME));
|
||||
rolloverRequest.getCreateIndexRequest().mapping(RandomCreateIndexGenerator.randomMapping());
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
RandomCreateIndexGenerator.randomAliases(rolloverRequest.getCreateIndexRequest());
|
||||
|
|
|
@ -67,7 +67,6 @@ public class IndicesStatsTests extends OpenSearchSingleNodeTestCase {
|
|||
IndexModule.Type storeType = IndexModule.defaultStoreType(true);
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("doc")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "keyword")
|
||||
|
@ -82,13 +81,12 @@ public class IndicesStatsTests extends OpenSearchSingleNodeTestCase {
|
|||
.field("type", "long")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(
|
||||
client().admin()
|
||||
.indices()
|
||||
.prepareCreate("test")
|
||||
.addMapping("doc", mapping)
|
||||
.setMapping(mapping)
|
||||
.setSettings(Settings.builder().put("index.store.type", storeType.getSettingsKey()))
|
||||
);
|
||||
ensureGreen("test");
|
||||
|
|
|
@ -219,16 +219,16 @@ public abstract class AbstractTermVectorsTestCase extends OpenSearchIntegTestCas
|
|||
|
||||
protected void createIndexBasedOnFieldSettings(String index, String alias, TestFieldSetting[] fieldSettings) throws IOException {
|
||||
XContentBuilder mappingBuilder = jsonBuilder();
|
||||
mappingBuilder.startObject().startObject("type1").startObject("properties");
|
||||
mappingBuilder.startObject().startObject("properties");
|
||||
for (TestFieldSetting field : fieldSettings) {
|
||||
field.addToMappings(mappingBuilder);
|
||||
}
|
||||
mappingBuilder.endObject().endObject().endObject();
|
||||
mappingBuilder.endObject().endObject();
|
||||
Settings.Builder settings = Settings.builder()
|
||||
.put(indexSettings())
|
||||
.put("index.analysis.analyzer.tv_test.tokenizer", "standard")
|
||||
.putList("index.analysis.analyzer.tv_test.filter", "lowercase");
|
||||
assertAcked(prepareCreate(index).addMapping("type1", mappingBuilder).setSettings(settings).addAlias(new Alias(alias)));
|
||||
assertAcked(prepareCreate(index).setMapping(mappingBuilder).setSettings(settings).addAlias(new Alias(alias)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -169,7 +169,6 @@ public class GetTermVectorsTests extends OpenSearchSingleNodeTestCase {
|
|||
String queryString = createString(tokens, payloads, encoding, delimiter.charAt(0));
|
||||
// create the mapping
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field")
|
||||
.field("type", "text")
|
||||
|
@ -177,7 +176,6 @@ public class GetTermVectorsTests extends OpenSearchSingleNodeTestCase {
|
|||
.field("analyzer", "payload_test")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
Settings setting = Settings.builder()
|
||||
.put("index.analysis.analyzer.payload_test.tokenizer", "mock-whitespace")
|
||||
|
|
|
@ -114,14 +114,12 @@ public class PreBuiltAnalyzerTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field")
|
||||
.field("type", "text")
|
||||
.field("analyzer", analyzerName)
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
MapperService mapperService = createIndex("test", indexSettings, "type", mapping).mapperService();
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class FieldFilterMapperPluginTests extends OpenSearchSingleNodeTestCase {
|
|||
// as the one coming from a filtered index with same mappings
|
||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("filtered").get();
|
||||
MappingMetadata filtered = getMappingsResponse.getMappings().get("filtered");
|
||||
assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", filtered.getSourceAsMap()));
|
||||
assertAcked(client().admin().indices().prepareCreate("test").setMapping(filtered.getSourceAsMap()));
|
||||
GetFieldMappingsResponse response = client().admin().indices().prepareGetFieldMappings("test").setFields("*").get();
|
||||
assertEquals(1, response.mappings().size());
|
||||
assertFieldMappings(response.mappings().get("test"), FILTERED_FLAT_FIELDS);
|
||||
|
@ -128,7 +128,7 @@ public class FieldFilterMapperPluginTests extends OpenSearchSingleNodeTestCase {
|
|||
// as the one coming from a filtered index with same mappings
|
||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("filtered").get();
|
||||
MappingMetadata filteredMapping = getMappingsResponse.getMappings().get("filtered");
|
||||
assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", filteredMapping.getSourceAsMap()));
|
||||
assertAcked(client().admin().indices().prepareCreate("test").setMapping(filteredMapping.getSourceAsMap()));
|
||||
FieldCapabilitiesResponse test = client().fieldCaps(new FieldCapabilitiesRequest().fields("*").indices("test")).actionGet();
|
||||
// properties.value is an object field in the new mapping
|
||||
filteredFields.add("properties.value");
|
||||
|
@ -176,7 +176,7 @@ public class FieldFilterMapperPluginTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
private void assertMappingsAreValid(Map<String, Object> sourceAsMap) {
|
||||
// check that the returned filtered mappings are still valid mappings by submitting them and retrieving them back
|
||||
assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", sourceAsMap));
|
||||
assertAcked(client().admin().indices().prepareCreate("test").setMapping(sourceAsMap));
|
||||
GetMappingsResponse testMappingsResponse = client().admin().indices().prepareGetMappings("test").get();
|
||||
assertEquals(1, testMappingsResponse.getMappings().size());
|
||||
// the mappings are returned unfiltered for this index, yet they are the same as the previous ones that were returned filtered
|
||||
|
|
|
@ -66,7 +66,6 @@ public class NestedHelperTests extends OpenSearchSingleNodeTestCase {
|
|||
super.setUp();
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "keyword")
|
||||
|
@ -110,7 +109,6 @@ public class NestedHelperTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
indexService = createIndex("index", Settings.EMPTY, "type", mapping);
|
||||
mapperService = indexService.mapperService();
|
||||
|
|
|
@ -100,14 +100,12 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testResolveSimilaritiesFromMapping_bm25() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("similarity", "my_similarity")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
Settings indexSettings = Settings.builder()
|
||||
|
@ -131,14 +129,12 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testResolveSimilaritiesFromMapping_boolean() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("similarity", "boolean")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
MapperService mapperService = createIndex("foo", Settings.EMPTY, "type", mapping).mapperService();
|
||||
|
@ -148,14 +144,12 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testResolveSimilaritiesFromMapping_DFR() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("similarity", "my_similarity")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
Settings indexSettings = Settings.builder()
|
||||
|
@ -178,14 +172,12 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testResolveSimilaritiesFromMapping_IB() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("similarity", "my_similarity")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
Settings indexSettings = Settings.builder()
|
||||
|
@ -208,14 +200,12 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testResolveSimilaritiesFromMapping_DFI() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("similarity", "my_similarity")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
Settings indexSettings = Settings.builder()
|
||||
|
@ -233,14 +223,12 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testResolveSimilaritiesFromMapping_LMDirichlet() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("similarity", "my_similarity")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
Settings indexSettings = Settings.builder()
|
||||
|
@ -261,14 +249,12 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testResolveSimilaritiesFromMapping_LMJelinekMercer() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
.field("similarity", "my_similarity")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
Settings indexSettings = Settings.builder()
|
||||
|
@ -292,7 +278,6 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
String mapping = Strings.toString(
|
||||
XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("field1")
|
||||
.field("type", "text")
|
||||
|
@ -300,7 +285,6 @@ public class SimilarityTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
IndexService indexService = createIndex("foo");
|
||||
|
|
|
@ -60,14 +60,12 @@ public class TermVectorsServiceTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testTook() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("field")
|
||||
.field("type", "text")
|
||||
.field("term_vector", "with_positions_offsets_payloads")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
createIndex("test", Settings.EMPTY, "type1", mapping);
|
||||
ensureGreen();
|
||||
|
@ -90,14 +88,12 @@ public class TermVectorsServiceTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testDocFreqs() throws IOException {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("_doc")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
.field("term_vector", "with_positions_offsets_payloads")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
Settings settings = Settings.builder().put("number_of_shards", 1).build();
|
||||
createIndex("test", settings, "_doc", mapping);
|
||||
|
@ -130,7 +126,6 @@ public class TermVectorsServiceTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testWithIndexedPhrases() throws IOException {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("_doc")
|
||||
.startObject("properties")
|
||||
.startObject("text")
|
||||
.field("type", "text")
|
||||
|
@ -138,7 +133,6 @@ public class TermVectorsServiceTests extends OpenSearchSingleNodeTestCase {
|
|||
.field("term_vector", "with_positions_offsets_payloads")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
Settings settings = Settings.builder().put("number_of_shards", 1).build();
|
||||
createIndex("test", settings, "_doc", mapping);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class GeoPointShapeQueryTests extends GeoQueryTests {
|
|||
|
||||
public void testProcessRelationSupport() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
Rectangle rectangle = new Rectangle(-35, -25, -25, -35);
|
||||
|
@ -112,7 +112,7 @@ public class GeoPointShapeQueryTests extends GeoQueryTests {
|
|||
|
||||
public void testQueryLine() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
Line line = new Line(new double[] { -25, -25 }, new double[] { -35, -35 });
|
||||
|
@ -126,7 +126,7 @@ public class GeoPointShapeQueryTests extends GeoQueryTests {
|
|||
|
||||
public void testQueryLinearRing() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
LinearRing linearRing = new LinearRing(new double[] { -25, -35, -25 }, new double[] { -25, -35, -25 });
|
||||
|
@ -148,7 +148,7 @@ public class GeoPointShapeQueryTests extends GeoQueryTests {
|
|||
|
||||
public void testQueryMultiLine() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
CoordinatesBuilder coords1 = new CoordinatesBuilder().coordinate(-35, -35).coordinate(-25, -25);
|
||||
|
@ -167,7 +167,7 @@ public class GeoPointShapeQueryTests extends GeoQueryTests {
|
|||
|
||||
public void testQueryMultiPoint() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
MultiPointBuilder mpb = new MultiPointBuilder().coordinate(-35, -25).coordinate(-15, -5);
|
||||
|
@ -182,7 +182,7 @@ public class GeoPointShapeQueryTests extends GeoQueryTests {
|
|||
|
||||
public void testQueryPoint() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
PointBuilder pb = new PointBuilder().coordinate(-35, -25);
|
||||
|
|
|
@ -82,7 +82,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testNullShape() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -96,7 +96,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testIndexPointsFilterRectangle() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -134,7 +134,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testIndexPointsCircle() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -167,7 +167,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testIndexPointsPolygon() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -203,7 +203,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testIndexPointsMultiPolygon() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -257,7 +257,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testIndexPointsRectangle() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -285,7 +285,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testIndexPointsIndexedRectangle() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).addMapping(defaultIndexName, xcb).get();
|
||||
client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -310,7 +310,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
client().admin().indices().prepareCreate(indexedShapeIndex).addMapping(defaultIndexName, xcb).get();
|
||||
client().admin().indices().prepareCreate(indexedShapeIndex).setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(indexedShapeIndex)
|
||||
|
@ -352,7 +352,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testRectangleSpanningDateline() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -385,7 +385,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testPolygonSpanningDateline() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
@ -429,7 +429,7 @@ public abstract class GeoQueryTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testMultiPolygonSpanningDateline() throws Exception {
|
||||
XContentBuilder xcb = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(xcb).get();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(defaultIndexName)
|
||||
|
|
|
@ -262,7 +262,7 @@ public class GeoShapeQueryTests extends GeoQueryTests {
|
|||
|
||||
XContentBuilder mapping = createRandomMapping();
|
||||
Settings settings = Settings.builder().put("index.number_of_shards", 1).build();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", mapping).setSettings(settings).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(mapping).setSettings(settings).get();
|
||||
ensureGreen();
|
||||
|
||||
XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject();
|
||||
|
@ -282,7 +282,7 @@ public class GeoShapeQueryTests extends GeoQueryTests {
|
|||
// Test for issue #34418
|
||||
public void testEnvelopeSpanningDateline() throws Exception {
|
||||
XContentBuilder mapping = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("_doc", mapping).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(mapping).get();
|
||||
ensureGreen();
|
||||
|
||||
String doc1 = "{\"geo\": {\r\n"
|
||||
|
@ -488,7 +488,7 @@ public class GeoShapeQueryTests extends GeoQueryTests {
|
|||
|
||||
public void testIndexedShapeReferenceSourceDisabled() throws Exception {
|
||||
XContentBuilder mapping = createDefaultMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(mapping).get();
|
||||
createIndex("shapes", Settings.EMPTY, "shape_type", "_source", "enabled=false");
|
||||
ensureGreen();
|
||||
|
||||
|
@ -612,7 +612,7 @@ public class GeoShapeQueryTests extends GeoQueryTests {
|
|||
GeometryCollectionBuilder gcb = RandomShapeGenerator.createGeometryCollection(random());
|
||||
|
||||
XContentBuilder builder = createRandomMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type", builder).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("test").setMapping(builder).execute().actionGet();
|
||||
|
||||
XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject();
|
||||
client().prepareIndex("test").setId("1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get();
|
||||
|
@ -748,7 +748,6 @@ public class GeoShapeQueryTests extends GeoQueryTests {
|
|||
public void testFieldAlias() throws IOException {
|
||||
XContentBuilder mapping = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("type")
|
||||
.startObject("properties")
|
||||
.startObject("location")
|
||||
.field("type", "geo_shape")
|
||||
|
@ -759,7 +758,6 @@ public class GeoShapeQueryTests extends GeoQueryTests {
|
|||
.field("path", "location")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
createIndex("test", Settings.EMPTY, "type", mapping);
|
||||
|
@ -786,7 +784,7 @@ public class GeoShapeQueryTests extends GeoQueryTests {
|
|||
gcb.shape(new PolygonBuilder(cb));
|
||||
|
||||
XContentBuilder builder = createRandomMapping();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type", builder).get();
|
||||
client().admin().indices().prepareCreate("test").setMapping(builder).get();
|
||||
|
||||
XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject();
|
||||
client().prepareIndex("test").setId("1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get();
|
||||
|
|
|
@ -77,7 +77,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithNoContexts() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -90,7 +89,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -129,7 +127,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithSimpleContexts() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -142,7 +139,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -176,7 +172,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithSimpleNumberContexts() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -189,7 +184,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -223,7 +217,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithSimpleBooleanContexts() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -236,7 +229,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -270,7 +262,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithSimpleNULLContexts() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -283,7 +274,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -314,7 +304,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithContextList() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -327,7 +316,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -359,7 +347,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithMixedTypeContextList() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -372,7 +359,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -404,7 +390,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithMixedTypeContextListHavingNULL() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -417,7 +402,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -443,7 +427,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testIndexingWithMultipleContexts() throws Exception {
|
||||
String mapping = Strings.toString(
|
||||
jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -460,7 +443,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
);
|
||||
|
||||
DocumentMapper defaultMapper = createIndex("test").mapperService()
|
||||
|
@ -798,7 +780,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
public void testUnknownQueryContextParsing() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder().startObject()
|
||||
.startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("completion")
|
||||
.field("type", "completion")
|
||||
|
@ -814,7 +795,6 @@ public class CategoryContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
.endArray()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
||||
MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService();
|
||||
|
|
|
@ -245,7 +245,6 @@ public class GeoContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testMalformedGeoField() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder();
|
||||
mapping.startObject();
|
||||
mapping.startObject("type1");
|
||||
mapping.startObject("properties");
|
||||
mapping.startObject("pin");
|
||||
String type = randomFrom("text", "keyword", "long");
|
||||
|
@ -266,7 +265,6 @@ public class GeoContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
mapping.endObject();
|
||||
|
||||
mapping.endObject();
|
||||
mapping.endObject();
|
||||
mapping.endObject();
|
||||
|
||||
|
@ -281,7 +279,6 @@ public class GeoContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
public void testMissingGeoField() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder();
|
||||
mapping.startObject();
|
||||
mapping.startObject("type1");
|
||||
mapping.startObject("properties");
|
||||
mapping.startObject("suggestion");
|
||||
mapping.field("type", "completion");
|
||||
|
@ -298,7 +295,6 @@ public class GeoContextMappingTests extends OpenSearchSingleNodeTestCase {
|
|||
|
||||
mapping.endObject();
|
||||
|
||||
mapping.endObject();
|
||||
mapping.endObject();
|
||||
mapping.endObject();
|
||||
|
||||
|
|
|
@ -63,8 +63,7 @@ public final class RandomCreateIndexGenerator {
|
|||
CreateIndexRequest request = new CreateIndexRequest(index);
|
||||
randomAliases(request);
|
||||
if (randomBoolean()) {
|
||||
String type = randomAlphaOfLength(5);
|
||||
request.mapping(type, randomMapping(type));
|
||||
request.mapping(randomMapping());
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
request.settings(randomIndexSettings());
|
||||
|
@ -94,16 +93,15 @@ public final class RandomCreateIndexGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a random mapping, with the mapping definition nested
|
||||
* under the given type name.
|
||||
* Creates a random mapping
|
||||
*/
|
||||
public static XContentBuilder randomMapping(String type) throws IOException {
|
||||
public static XContentBuilder randomMapping() throws IOException {
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));
|
||||
builder.startObject().startObject(type);
|
||||
builder.startObject();
|
||||
|
||||
randomMappingFields(builder, true);
|
||||
|
||||
builder.endObject().endObject();
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ public abstract class OpenSearchSingleNodeTestCase extends OpenSearchTestCase {
|
|||
protected IndexService createIndex(String index, Settings settings, String type, XContentBuilder mappings) {
|
||||
CreateIndexRequestBuilder createIndexRequestBuilder = client().admin().indices().prepareCreate(index).setSettings(settings);
|
||||
if (type != null && mappings != null) {
|
||||
createIndexRequestBuilder.addMapping(type, mappings);
|
||||
createIndexRequestBuilder.setMapping(mappings);
|
||||
}
|
||||
return createIndex(index, createIndexRequestBuilder);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue