Skip to content

Commit

Permalink
Remove type parameter from `CreateIndexRequest.mapping(type, XContent…
Browse files Browse the repository at this point in the history
…Builder)` (#50586)

This continues the removal of type parameters from CreateIndexRequest.mapping
methods started in #50419. Here the removed methods are almost entirely in test
code, with the exception of a change to TransformIndex in the transform plugin.

Relates to #41059
  • Loading branch information
romseygeek committed Jan 8, 2020
1 parent 7e12d5a commit a59b065
Show file tree
Hide file tree
Showing 108 changed files with 581 additions and 669 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {

public void testNgramHighlightingWithBrokenPositions() throws IOException {
assertAcked(prepareCreate("test")
.addMapping("test", jsonBuilder()
.setMapping(jsonBuilder()
.startObject()
.startObject("test")
.startObject("_doc")
.startObject("properties")
.startObject("name")
.field("type", "text")
Expand Down Expand Up @@ -213,7 +213,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 @@ -317,7 +317,7 @@ public void testPhrasePrefix() throws IOException {
}

public static XContentBuilder type1TermVectorMapping() throws IOException {
return XContentFactory.jsonBuilder().startObject().startObject("type1")
return XContentFactory.jsonBuilder().startObject().startObject("_doc")
.startObject("properties")
.startObject("field1").field("type", "text").field("term_vector", "with_positions_offsets").endObject()
.startObject("field2").field("type", "text").field("term_vector", "with_positions_offsets").endObject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,10 @@ public void testPipelineAggregationScript() throws Exception {
}

public void testGeo() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1")
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("_doc")
.startObject("properties").startObject("location").field("type", "geo_point");
xContentBuilder.endObject().endObject().endObject().endObject();
assertAcked(prepareCreate("test").addMapping("type1", xContentBuilder));
assertAcked(prepareCreate("test").setMapping(xContentBuilder));
ensureGreen();
client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject()
.field("name", "test")
Expand Down Expand Up @@ -621,10 +621,10 @@ public void testGeo() throws Exception {
}

public void testBoolean() throws Exception {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("doc")
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));
assertAcked(prepareCreate("test").setMapping(xContentBuilder));
ensureGreen();
indexRandom(true,
client().prepareIndex("test").setId("1").setSource("id", 1, "price", 1.0, "vip", true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void testMultiFields() throws IOException {
List<String> fields = new ArrayList<>();
fields.add(path);
final MapperService mapperService =
createIndex(index, Settings.EMPTY, "_doc", mapping).mapperService();
createIndex(index, Settings.EMPTY, mapping).mapperService();
FieldType fieldType = mapperService.fullName(path + "._index_prefix");
assertThat(fieldType, instanceOf(PrefixFieldType.class));
PrefixFieldType prefixFieldType = (PrefixFieldType) fieldType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ private void init() throws IOException {
settings.put("index.analysis.analyzer.mock_english.filter", "stop");
prepareCreate("test")
.setSettings(settings)
.addMapping("test", jsonBuilder().startObject()
.startObject("test")
.setMapping(jsonBuilder().startObject()
.startObject("_doc")
.startObject("properties")
.startObject("foo")
.field("type", "text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

package org.elasticsearch.join.aggregations;

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.join.query.ParentChildTestCase;
import org.junit.Before;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -28,9 +30,7 @@
import java.util.Map;
import java.util.Set;

import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.join.query.ParentChildTestCase;
import org.junit.Before;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;

/**
* Small base test-class which combines stuff used for Children and Parent aggregation tests
Expand All @@ -43,7 +43,7 @@ public abstract class AbstractParentChildTestCase extends ParentChildTestCase {
public void setupCluster() throws Exception {
assertAcked(
prepareCreate("test")
.addMapping("doc",
.setMapping(
addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "article", "comment"),
"commenter", "keyword", "category", "keyword"))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void testWithDeletes() throws Exception {
String indexName = "xyz";
assertAcked(
prepareCreate(indexName)
.addMapping("doc",
.setMapping(
addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true, "parent", "child"),
"name", "keyword"))
);
Expand Down Expand Up @@ -222,7 +222,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", "text", "name", "keyword", "material", "text", "color", "keyword", "size", "keyword"))
Expand Down Expand Up @@ -285,7 +285,7 @@ public void testHierarchicalChildrenAggs() {
String childType = "city";
assertAcked(
prepareCreate(indexName)
.addMapping("doc",
.setMapping(
addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true,
grandParentType, parentType, parentType, childType),
"name", "keyword"))
Expand Down Expand Up @@ -328,7 +328,7 @@ public void testPostCollectAllLeafReaders() throws Exception {
// us to miss to evaluate child docs in segments we didn't have parent matches for.
assertAcked(
prepareCreate("index")
.addMapping("doc",
.setMapping(
addFieldMappings(buildParentJoinFieldMappingFromSimplifiedDef("join_field", true,
"parentType", "childType"),
"name", "keyword", "town", "keyword", "age", "integer"))
Expand Down
Loading

0 comments on commit a59b065

Please sign in to comment.