Skip to content

Commit

Permalink
[Remove] type from CIR.mapping and CIRB.mapping (#2478)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nknize authored Mar 16, 2022
1 parent 05a5819 commit 3675400
Show file tree
Hide file tree
Showing 83 changed files with 392 additions and 1,026 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {

public void testNgramHighlightingWithBrokenPositions() throws IOException {
assertAcked(
prepareCreate("test").addMapping(
"test",
prepareCreate("test").setMapping(
jsonBuilder().startObject()
.startObject("test")
.startObject("properties")
.startObject("name")
.field("type", "text")
Expand All @@ -88,7 +86,6 @@ public void testNgramHighlightingWithBrokenPositions() throws IOException {
.endObject()
.endObject()
.endObject()
.endObject()
)
.setSettings(
Settings.builder()
Expand Down Expand Up @@ -260,7 +257,7 @@ public void testPhrasePrefix() throws IOException {
.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();

Expand Down Expand Up @@ -421,7 +418,6 @@ public void testPhrasePrefix() throws IOException {
public static XContentBuilder type1TermVectorMapping() throws IOException {
return XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("field1")
.field("type", "text")
Expand All @@ -432,7 +428,6 @@ public static XContentBuilder type1TermVectorMapping() throws IOException {
.field("term_vector", "with_positions_offsets")
.endObject()
.endObject()
.endObject()
.endObject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,11 @@ public void testPipelineAggregationScript() throws Exception {
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")
Expand Down Expand Up @@ -687,12 +686,11 @@ public void testGeo() throws Exception {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ private void init() throws IOException {
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")
Expand Down Expand Up @@ -162,7 +160,6 @@ private void init() throws IOException {
.endObject()
.endObject()
.endObject()
.endObject()
)
.get();
ensureGreen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ public void testParentWithMultipleBuckets() throws Exception {
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")
)
);
Expand Down Expand Up @@ -234,8 +233,7 @@ public void testPostCollection() throws Exception {
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",
Expand Down Expand Up @@ -309,8 +307,7 @@ public void testHierarchicalChildrenAggs() {
String parentType = "country";
String childType = "city";
assertAcked(
prepareCreate(indexName).addMapping(
"doc",
prepareCreate(indexName).setMapping(
addFieldMappings(
buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, grandParentType, parentType, parentType, childType),
"name",
Expand Down Expand Up @@ -352,8 +349,7 @@ public void testPostCollectAllLeafReaders() throws Exception {
// 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",
Expand Down
Loading

0 comments on commit 3675400

Please sign in to comment.