Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove type parameter from CreateIndexRequest.mapping(type, XContentBuilder) #50586

Merged
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To double-check I understand -- we could already remove the mentions to _doc in mapping definitions, but we'll postpone that for another PR? This approach makes sense to me, as it helps keep the current PR focused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct - there's also still a bit of inconsistency as to when things need to be wrapped and when not, which this PR moves us one more step towards resolving.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.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