From 068c788ec86bdf0682f87180909a5444d6a85e76 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 29 Mar 2016 11:37:53 +0200 Subject: [PATCH] Disable fielddata on text fields by defaults. #17386 `text` fields will have fielddata disabled by default. Fielddata can still be enabled on an existing index by setting `fielddata=true` in the mappings. --- .../index/mapper/core/TextFieldMapper.java | 6 ++---- .../elasticsearch/aliases/IndexAliasesIT.java | 2 +- .../index/fielddata/FieldDataLoadingIT.java | 1 + .../index/fielddata/FilterFieldDataTests.java | 4 ++++ .../copyto/CopyToMapperIntegrationIT.java | 3 ++- .../mapper/core/TextFieldMapperTests.java | 21 ++++++++++++++----- .../breaker/CircuitBreakerServiceIT.java | 8 ++++--- .../indices/stats/IndexStatsIT.java | 16 +++++++------- .../percolator/PercolatorAggregationsIT.java | 6 +++--- .../AggregationsIntegrationIT.java | 2 +- .../search/aggregations/CombiIT.java | 2 +- .../search/aggregations/MetaDataIT.java | 4 +++- .../search/aggregations/MissingValueIT.java | 2 +- .../aggregations/bucket/ChildrenIT.java | 10 ++++----- .../search/aggregations/bucket/MissingIT.java | 4 +++- .../aggregations/bucket/NaNSortingIT.java | 4 +++- .../search/aggregations/bucket/NestedIT.java | 4 ++-- .../aggregations/bucket/ReverseNestedIT.java | 14 ++++++------- .../aggregations/bucket/ShardReduceIT.java | 3 ++- .../bucket/SignificantTermsIT.java | 2 +- .../SignificantTermsSignificanceScoreIT.java | 13 +++++++----- .../bucket/TermsDocCountErrorIT.java | 7 +++++-- .../bucket/TermsShardMinDocCountIT.java | 16 +++++++++----- .../aggregations/metrics/TopHitsIT.java | 8 ++++++- .../aggregations/pipeline/AvgBucketIT.java | 3 ++- .../pipeline/ExtendedStatsBucketIT.java | 3 ++- .../aggregations/pipeline/MaxBucketIT.java | 3 ++- .../aggregations/pipeline/MinBucketIT.java | 3 ++- .../pipeline/PercentilesBucketIT.java | 3 ++- .../aggregations/pipeline/StatsBucketIT.java | 3 ++- .../aggregations/pipeline/SumBucketIT.java | 3 ++- .../search/child/ChildQuerySearchIT.java | 6 +++--- .../search/innerhits/InnerHitsIT.java | 10 +++++++-- .../search/nested/SimpleNestedIT.java | 4 ++-- .../search/query/SearchQueryIT.java | 2 +- .../search/scroll/DuelScrollIT.java | 4 ++-- .../search/scroll/SearchScrollIT.java | 2 +- .../search/searchafter/SearchAfterIT.java | 7 +++++-- .../search/sort/FieldSortIT.java | 13 ++++++++---- .../search/sort/GeoDistanceSortBuilderIT.java | 2 +- .../suggest/CompletionSuggestSearchIT.java | 10 +++++++-- .../SharedSignificantTermsTestMethods.java | 8 +++++-- .../expression/MoreExpressionTests.java | 4 +++- .../messy/tests/MinDocCountTests.java | 4 +++- .../messy/tests/SearchFieldsTests.java | 5 +++-- .../messy/tests/SimpleSortTests.java | 1 + .../messy/tests/StringTermsTests.java | 11 ++++++++-- .../test/plan_a/20_scriptfield.yaml | 9 ++++++++ .../reindex/UpdateByQueryBasicTests.java | 2 +- .../test/lang_javascript/10_basic.yaml | 2 +- .../test/lang_python/10_basic.yaml | 2 +- .../test/cat.fielddata/10_basic.yaml | 13 ++++++++++++ .../test/indices.stats/13_fields.yaml | 2 ++ .../test/search/test_sig_terms.yaml | 8 +++++++ .../test/suggest/20_completion.yaml | 2 ++ 55 files changed, 219 insertions(+), 97 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/TextFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/TextFieldMapper.java index 0baa4564b69..3cfd1096c32 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/TextFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/TextFieldMapper.java @@ -43,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import static org.elasticsearch.index.mapper.core.TypeParsers.parseMultiField; import static org.elasticsearch.index.mapper.core.TypeParsers.parseTextField; /** A {@link FieldMapper} for full-text fields. */ @@ -60,7 +59,6 @@ public class TextFieldMapper extends FieldMapper implements AllFieldMapper.Inclu public static final MappedFieldType FIELD_TYPE = new TextFieldType(); static { - FIELD_TYPE.setTokenized(true); FIELD_TYPE.freeze(); } @@ -177,8 +175,8 @@ public class TextFieldMapper extends FieldMapper implements AllFieldMapper.Inclu private int fielddataMinSegmentSize; public TextFieldType() { - // TODO: change the default to false - fielddata = true; + setTokenized(true); + fielddata = false; fielddataMinFrequency = Defaults.FIELDDATA_MIN_FREQUENCY; fielddataMaxFrequency = Defaults.FIELDDATA_MAX_FREQUENCY; fielddataMinSegmentSize = Defaults.FIELDDATA_MIN_SEGMENT_SIZE; diff --git a/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java b/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java index 2cc8f852760..539c65c6193 100644 --- a/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java +++ b/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java @@ -163,7 +163,7 @@ public class IndexAliasesIT extends ESIntegTestCase { public void testSearchingFilteringAliasesSingleIndex() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type1", "id", "type=text", "name", "type=text")); + assertAcked(prepareCreate("test").addMapping("type1", "id", "type=text", "name", "type=text,fielddata=true")); ensureGreen(); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java index 7b69afa16b5..bbc3a03f0a3 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java @@ -35,6 +35,7 @@ public class FieldDataLoadingIT extends ESIntegTestCase { .addMapping("type", jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("name") .field("type", "text") + .field("fielddata", true) .field("eager_global_ordinals", true) .endObject() .endObject().endObject().endObject())); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java index 14278e1f557..9895acdc75d 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/FilterFieldDataTests.java @@ -64,6 +64,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase { { ifdService.clear(); MappedFieldType ft = new TextFieldMapper.Builder("high_freq") + .fielddata(true) .fielddataFrequencyFilter(0, random.nextBoolean() ? 100 : 0.5d, 0) .build(builderCtx).fieldType(); IndexOrdinalsFieldData fieldData = ifdService.getForField(ft); @@ -76,6 +77,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase { { ifdService.clear(); MappedFieldType ft = new TextFieldMapper.Builder("high_freq") + .fielddata(true) .fielddataFrequencyFilter(random.nextBoolean() ? 101 : 101d/200.0d, 201, 100) .build(builderCtx).fieldType(); IndexOrdinalsFieldData fieldData = ifdService.getForField(ft); @@ -88,6 +90,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase { { ifdService.clear(); // test # docs with value MappedFieldType ft = new TextFieldMapper.Builder("med_freq") + .fielddata(true) .fielddataFrequencyFilter(random.nextBoolean() ? 101 : 101d/200.0d, Integer.MAX_VALUE, 101) .build(builderCtx).fieldType(); IndexOrdinalsFieldData fieldData = ifdService.getForField(ft); @@ -101,6 +104,7 @@ public class FilterFieldDataTests extends AbstractFieldDataTestCase { { ifdService.clear(); MappedFieldType ft = new TextFieldMapper.Builder("med_freq") + .fielddata(true) .fielddataFrequencyFilter(random.nextBoolean() ? 101 : 101d/200.0d, Integer.MAX_VALUE, 101) .build(builderCtx).fieldType(); IndexOrdinalsFieldData fieldData = ifdService.getForField(ft); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java index 75807ae9c2e..fa98f2a45c4 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperIntegrationIT.java @@ -102,7 +102,8 @@ public class CopyToMapperIntegrationIT extends ESIntegTestCase { .startObject().startObject("template_all") .field("match", "*") .field("match_mapping_type", "string") - .startObject("mapping").field("type", "text").field("copy_to", "{name}_raw").endObject() + .startObject("mapping").field("type", "text").field("fielddata", true) + .field("copy_to", "{name}_raw").endObject() .endObject().endObject() .endArray(); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java index 1581727937a..a0e3fd69f6b 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java @@ -405,22 +405,33 @@ public class TextFieldMapperTests extends ESSingleNodeTestCase { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("field") .field("type", "text") - .field("fielddata", false) .endObject().endObject() .endObject().endObject().string(); - DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); - - assertEquals(mapping, mapper.mappingSource().toString()); + DocumentMapper disabledMapper = parser.parse("type", new CompressedXContent(mapping)); + assertEquals(mapping, disabledMapper.mappingSource().toString()); IllegalStateException e = expectThrows(IllegalStateException.class, - () -> mapper.mappers().getMapper("field").fieldType().fielddataBuilder()); + () -> disabledMapper.mappers().getMapper("field").fieldType().fielddataBuilder()); assertThat(e.getMessage(), containsString("Fielddata is disabled")); + + mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties").startObject("field") + .field("type", "text") + .field("fielddata", true) + .endObject().endObject() + .endObject().endObject().string(); + + DocumentMapper enabledMapper = parser.parse("type", new CompressedXContent(mapping)); + + assertEquals(mapping, enabledMapper.mappingSource().toString()); + enabledMapper.mappers().getMapper("field").fieldType().fielddataBuilder(); // no exception this time } public void testFrequencyFilter() throws IOException { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties").startObject("field") .field("type", "text") + .field("fielddata", true) .startObject("fielddata_frequency_filter") .field("min", 2d) .field("min_segment_size", 1000) diff --git a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java index a7cc93f75c7..b6bdbf968ba 100644 --- a/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java +++ b/core/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java @@ -103,7 +103,8 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase { logger.info("--> noop breakers used, skipping test"); return; } - assertAcked(prepareCreate("cb-test", 1, settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1)))); + assertAcked(prepareCreate("cb-test", 1, settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))) + .addMapping("type", "test", "type=text,fielddata=true")); final Client client = client(); // index some different terms so we have some field data for loading @@ -148,7 +149,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase { // Create an index where the mappings have a field data filter assertAcked(prepareCreate("ramtest").setSource("{\"mappings\": {\"type\": {\"properties\": {\"test\": " + - "{\"type\": \"text\",\"fielddata_frequency_filter\": {\"max\": 10000}}}}}}")); + "{\"type\": \"text\",\"fielddata\": true,\"fielddata_frequency_filter\": {\"max\": 10000}}}}}}")); ensureGreen("ramtest"); @@ -197,7 +198,8 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase { logger.info("--> noop breakers used, skipping test"); return; } - assertAcked(prepareCreate("cb-test", 1, settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1)))); + assertAcked(prepareCreate("cb-test", 1, settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))) + .addMapping("type", "test", "type=text,fielddata=true")); Client client = client(); // index some different terms so we have some field data for loading diff --git a/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java b/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java index 12e6d2b4799..5fca4fa37ec 100644 --- a/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java +++ b/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java @@ -58,10 +58,7 @@ import java.io.IOException; import java.util.EnumSet; import java.util.Random; -import static org.elasticsearch.cluster.metadata.IndexMetaData.PROTO; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; -import static org.elasticsearch.common.settings.Settings.settingsBuilder; -import static org.elasticsearch.common.xcontent.XContentFactory.contentBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; @@ -97,7 +94,10 @@ public class IndexStatsIT extends ESIntegTestCase { } public void testFieldDataStats() { - client().admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("index.number_of_shards", 2)).execute().actionGet(); + assertAcked(client().admin().indices().prepareCreate("test") + .setSettings(settingsBuilder().put("index.number_of_shards", 2)) + .addMapping("type", "field", "type=text,fielddata=true", + "field2", "type=text,fielddata=true").get()); ensureGreen(); client().prepareIndex("test", "type", "1").setSource("field", "value1", "field2", "value1").execute().actionGet(); client().prepareIndex("test", "type", "2").setSource("field", "value2", "field2", "value2").execute().actionGet(); @@ -141,9 +141,9 @@ public class IndexStatsIT extends ESIntegTestCase { } public void testClearAllCaches() throws Exception { - client().admin().indices().prepareCreate("test") + assertAcked(client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) - .execute().actionGet(); + .addMapping("type", "field", "type=text,fielddata=true").get()); ensureGreen(); client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); client().prepareIndex("test", "type", "1").setSource("field", "value1").execute().actionGet(); @@ -719,7 +719,9 @@ public class IndexStatsIT extends ESIntegTestCase { } public void testFieldDataFieldsParam() throws Exception { - createIndex("test1"); + assertAcked(client().admin().indices().prepareCreate("test1") + .addMapping("type", "bar", "type=text,fielddata=true", + "baz", "type=text,fielddata=true").get()); ensureGreen(); diff --git a/core/src/test/java/org/elasticsearch/percolator/PercolatorAggregationsIT.java b/core/src/test/java/org/elasticsearch/percolator/PercolatorAggregationsIT.java index 8393c80786c..8cf529a130a 100644 --- a/core/src/test/java/org/elasticsearch/percolator/PercolatorAggregationsIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/PercolatorAggregationsIT.java @@ -54,7 +54,7 @@ public class PercolatorAggregationsIT extends ESIntegTestCase { // Just test the integration with facets and aggregations, not the facet and aggregation functionality! public void testAggregations() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "field1", "type=text", "field2", "type=text")); + assertAcked(prepareCreate("test").addMapping("type", "field1", "type=text", "field2", "type=keyword")); ensureGreen(); int numQueries = scaledRandomIntBetween(250, 500); @@ -119,7 +119,7 @@ public class PercolatorAggregationsIT extends ESIntegTestCase { // Just test the integration with facets and aggregations, not the facet and aggregation functionality! public void testAggregationsAndPipelineAggregations() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "field1", "type=text", "field2", "type=text")); + assertAcked(prepareCreate("test").addMapping("type", "field1", "type=text", "field2", "type=keyword")); ensureGreen(); int numQueries = scaledRandomIntBetween(250, 500); @@ -204,7 +204,7 @@ public class PercolatorAggregationsIT extends ESIntegTestCase { public void testSingleShardAggregations() throws Exception { assertAcked(prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", 1)) - .addMapping("type", "field1", "type=text", "field2", "type=text")); + .addMapping("type", "field1", "type=text", "field2", "type=keyword")); ensureGreen(); int numQueries = scaledRandomIntBetween(250, 500); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsIntegrationIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsIntegrationIT.java index fd1bf634a85..c7384c5aa2d 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/AggregationsIntegrationIT.java @@ -40,7 +40,7 @@ public class AggregationsIntegrationIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "f", "type=text").get()); + assertAcked(prepareCreate("index").addMapping("type", "f", "type=keyword").get()); ensureYellow("index"); numDocs = randomIntBetween(1, 20); List docs = new ArrayList<>(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java index 25fb756d125..f72ecdb8b1c 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java @@ -117,7 +117,7 @@ public class CombiIT extends ESIntegTestCase { prepareCreate("idx").addMapping("type", jsonBuilder() .startObject() .startObject("type").startObject("properties") - .startObject("name").field("type", "text").endObject() + .startObject("name").field("type", "keyword").endObject() .startObject("value").field("type", "integer").endObject() .endObject().endObject() .endObject()).execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java index 347c4684c11..dfdaa7d9fb2 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/MetaDataIT.java @@ -34,13 +34,15 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.maxBucket; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; public class MetaDataIT extends ESIntegTestCase { public void testMetaDataSetOnAggregationResult() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "name", "type=keyword").get()); IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)]; for (int i = 0; i < builders.length; i++) { String name = "name_" + randomIntBetween(1, 10); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/MissingValueIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/MissingValueIT.java index 1821d09fc85..b675c14a488 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/MissingValueIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/MissingValueIT.java @@ -54,7 +54,7 @@ public class MissingValueIT extends ESIntegTestCase { @Override protected void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "date", "type=date", "location", "type=geo_point").get()); + assertAcked(prepareCreate("idx").addMapping("type", "date", "type=date", "location", "type=geo_point", "str", "type=keyword").get()); indexRandom(true, client().prepareIndex("idx", "type", "1").setSource(), client().prepareIndex("idx", "type", "2").setSource("str", "foo", "long", 3L, "double", 5.5, "date", "2015-05-07", "location", "1,2")); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java index 4e4b54d91f6..a6670c61d2e 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java @@ -66,8 +66,8 @@ public class ChildrenIT extends ESIntegTestCase { public void setupSuiteScopeCluster() throws Exception { assertAcked( prepareCreate("test") - .addMapping("article") - .addMapping("comment", "_parent", "type=article") + .addMapping("article", "category", "type=keyword") + .addMapping("comment", "_parent", "type=article", "commenter", "type=keyword") ); List requests = new ArrayList<>(); @@ -295,8 +295,8 @@ children("non-existing", "xyz") String childType = "variantsku"; assertAcked( prepareCreate(indexName) - .addMapping(masterType, "brand", "type=text", "name", "type=text", "material", "type=text") - .addMapping(childType, "_parent", "type=masterprod", "color", "type=text", "size", "type=text") + .addMapping(masterType, "brand", "type=text", "name", "type=keyword", "material", "type=text") + .addMapping(childType, "_parent", "type=masterprod", "color", "type=keyword", "size", "type=keyword") ); List requests = new ArrayList<>(); @@ -358,7 +358,7 @@ children("non-existing", "xyz") .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) ) - .addMapping(grandParentType) + .addMapping(grandParentType, "name", "type=keyword") .addMapping(parentType, "_parent", "type=" + grandParentType) .addMapping(childType, "_parent", "type=" + parentType) ); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java index 97eaf2f2c12..c1baf8b3678 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java @@ -34,6 +34,7 @@ import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.search.aggregations.AggregationBuilders.avg; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.missing; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -49,7 +50,8 @@ public class MissingIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "tag", "type=keyword").get()); List builders = new ArrayList<>(); numDocs = randomIntBetween(5, 20); numDocsMissing = randomIntBetween(1, numDocs - 1); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java index 7b055a3de5f..84edfbfe359 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NaNSortingIT.java @@ -39,6 +39,7 @@ import static org.elasticsearch.search.aggregations.AggregationBuilders.avg; import static org.elasticsearch.search.aggregations.AggregationBuilders.extendedStats; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.core.IsNull.notNullValue; @@ -108,7 +109,8 @@ public class NaNSortingIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "string_value", "type=keyword").get()); final int numDocs = randomIntBetween(2, 10); for (int i = 0; i < numDocs; ++i) { final long value = randomInt(5); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java index 11d838d43c4..b3241fc608c 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java @@ -297,7 +297,7 @@ public class NestedIT extends ESIntegTestCase { public void testNestNestedAggs() throws Exception { SearchResponse response = client().prepareSearch("idx_nested_nested_aggs") .addAggregation(nested("level1", "nested1") - .subAggregation(terms("a").field("nested1.a") + .subAggregation(terms("a").field("nested1.a.keyword") .collectMode(aggCollectionMode) .subAggregation(nested("level2", "nested1.nested2") .subAggregation(sum("sum").field("nested1.nested2.b"))))) @@ -463,7 +463,7 @@ public class NestedIT extends ESIntegTestCase { assertAcked( prepareCreate("idx4") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("product", "categories", "type=text", "name", "type=text", "property", "type=nested") + .addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idx4"); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java index 71b64ceaa58..93e6536e47c 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java @@ -66,9 +66,9 @@ public class ReverseNestedIT extends ESIntegTestCase { .addMapping( "type1", jsonBuilder().startObject().startObject("properties") - .startObject("field1").field("type", "text").endObject() + .startObject("field1").field("type", "keyword").endObject() .startObject("nested1").field("type", "nested").startObject("properties") - .startObject("field2").field("type", "text").endObject() + .startObject("field2").field("type", "keyword").endObject() .endObject().endObject() .endObject().endObject() ) @@ -76,9 +76,9 @@ public class ReverseNestedIT extends ESIntegTestCase { "type2", jsonBuilder().startObject().startObject("properties") .startObject("nested1").field("type", "nested").startObject("properties") - .startObject("field1").field("type", "text").endObject() + .startObject("field1").field("type", "keyword").endObject() .startObject("nested2").field("type", "nested").startObject("properties") - .startObject("field2").field("type", "text").endObject() + .startObject("field2").field("type", "keyword").endObject() .endObject().endObject() .endObject().endObject() .endObject().endObject() @@ -487,17 +487,17 @@ public class ReverseNestedIT extends ESIntegTestCase { .startObject("category") .field("type", "nested") .startObject("properties") - .startObject("name").field("type", "text").endObject() + .startObject("name").field("type", "keyword").endObject() .endObject() .endObject() .startObject("sku") .field("type", "nested") .startObject("properties") - .startObject("sku_type").field("type", "text").endObject() + .startObject("sku_type").field("type", "keyword").endObject() .startObject("colors") .field("type", "nested") .startObject("properties") - .startObject("name").field("type", "text").endObject() + .startObject("name").field("type", "keyword").endObject() .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java index 3a0e8de1c36..89554fd033e 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardReduceIT.java @@ -78,7 +78,8 @@ public class ShardReduceIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { assertAcked(prepareCreate("idx") - .addMapping("type", "nested", "type=nested", "ip", "type=ip", "location", "type=geo_point")); + .addMapping("type", "nested", "type=nested", "ip", "type=ip", + "location", "type=geo_point", "term-s", "type=keyword")); indexRandom(true, indexDoc("2014-01-01", 1), diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java index 0fd1ab15d7b..676761d6825 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsIT.java @@ -77,7 +77,7 @@ public class SignificantTermsIT extends ESIntegTestCase { public void setupSuiteScopeCluster() throws Exception { assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, 5, SETTING_NUMBER_OF_REPLICAS, 0).addMapping("fact", "_routing", "required=true", "routing_id", "type=keyword", "fact_category", - "type=integer,index=true", "description", "type=text,index=true")); + "type=integer,index=true", "description", "type=text,fielddata=true")); createIndex("idx_unmapped"); ensureGreen(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java index 86d429a444b..c9cd332ec33 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java @@ -291,8 +291,8 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase { public void testDeletesIssue7951() throws Exception { String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}"; - String mappings = "{\"doc\": {\"properties\":{\"text\": {\"type\":\"keyword\"}}}}"; - assertAcked(prepareCreate(INDEX_NAME).setSettings(settings).addMapping("doc", mappings)); + assertAcked(prepareCreate(INDEX_NAME).setSettings(settings) + .addMapping("doc", "text", "type=keyword", CLASS_FIELD, "type=keyword")); String[] cat1v1 = {"constant", "one"}; String[] cat1v2 = {"constant", "uno"}; String[] cat2v1 = {"constant", "two"}; @@ -427,7 +427,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase { private void indexEqualTestData() throws ExecutionException, InterruptedException { assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0).addMapping("doc", - "text", "type=text", "class", "type=text")); + "text", "type=text,fielddata=true", "class", "type=keyword")); createIndex("idx_unmapped"); ensureGreen(); @@ -496,8 +496,11 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase { } private void indexRandomFrequencies01(String type) throws ExecutionException, InterruptedException { - String mappings = "{\"" + DOC_TYPE + "\": {\"properties\":{\"" + TEXT_FIELD + "\": {\"type\":\"" + type + "\"}}}}"; - assertAcked(prepareCreate(INDEX_NAME).addMapping(DOC_TYPE, mappings)); + String textMappings = "type=" + type; + if (type.equals("text")) { + textMappings += ",fielddata=true"; + } + assertAcked(prepareCreate(INDEX_NAME).addMapping(DOC_TYPE, TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword")); String[] gb = {"0", "1"}; List indexRequestBuilderList = new ArrayList<>(); for (int i = 0; i < randomInt(20); i++) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java index 1780911ccfd..e112e6d44b4 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java @@ -60,7 +60,8 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", STRING_FIELD_NAME, "type=keyword").get()); List builders = new ArrayList<>(); int numDocs = between(10, 200); int numUniqueTerms = between(2,numDocs/2); @@ -72,7 +73,9 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { .field(DOUBLE_FIELD_NAME, 1.0 * randomInt(numUniqueTerms)) .endObject())); } - assertAcked(prepareCreate("idx_single_shard").setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1))); + assertAcked(prepareCreate("idx_single_shard") + .addMapping("type", STRING_FIELD_NAME, "type=keyword") + .setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1))); for (int i = 0; i < numDocs; i++) { builders.add(client().prepareIndex("idx_single_shard", "type", ""+i).setSource(jsonBuilder() .startObject() diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java index 870569c2002..dad55a20828 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsShardMinDocCountIT.java @@ -51,11 +51,14 @@ public class TermsShardMinDocCountIT extends ESIntegTestCase { // see https://github.com/elastic/elasticsearch/issues/5998 public void testShardMinDocCountSignificantTermsTest() throws Exception { - String termtype = "text"; + String textMappings; if (randomBoolean()) { - termtype = "long"; + textMappings = "type=long"; + } else { + textMappings = "type=text,fielddata=true"; } - assertAcked(prepareCreate(index).setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(type, "{\"properties\":{\"text\": {\"type\": \"" + termtype + "\"}}}")); + assertAcked(prepareCreate(index).setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0) + .addMapping(type, "text", textMappings)); ensureYellow(index); List indexBuilders = new ArrayList<>(); @@ -111,8 +114,11 @@ public class TermsShardMinDocCountIT extends ESIntegTestCase { public void testShardMinDocCountTermsTest() throws Exception { final String [] termTypes = {"text", "long", "integer", "float", "double"}; String termtype = termTypes[randomInt(termTypes.length - 1)]; - - assertAcked(prepareCreate(index).setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(type, "{\"properties\":{\"text\": {\"type\": \"" + termtype + "\"}}}")); + String termMappings = "type=" + termtype; + if (termtype.equals("text")) { + termMappings += ",fielddata=true"; + } + assertAcked(prepareCreate(index).setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(type, "text", termMappings)); ensureYellow(index); List indexBuilders = new ArrayList<>(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java index 3d1e33fa444..3a0a0f25a62 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java @@ -101,12 +101,18 @@ public class TopHitsIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(prepareCreate("idx").addMapping("type", TERMS_AGGS_FIELD, "type=keyword", "group", "type=keyword")); createIndex("empty"); assertAcked(prepareCreate("articles").addMapping("article", jsonBuilder().startObject().startObject("article").startObject("properties") + .startObject(TERMS_AGGS_FIELD) + .field("type", "keyword") + .endObject() .startObject("comments") .field("type", "nested") .startObject("properties") + .startObject("user") + .field("type", "keyword") + .endObject() .startObject("date") .field("type", "long") .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java index 17f06bec2be..51f405fcc97 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java @@ -59,7 +59,8 @@ public class AvgBucketIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java index f9b80620c54..b1888303a1d 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java @@ -62,7 +62,8 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java index 434c45da2a3..af60a44fd1b 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java @@ -63,7 +63,8 @@ public class MaxBucketIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java index 55d4cb08b0b..c3b7cd375ed 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java @@ -60,7 +60,8 @@ public class MinBucketIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java index 0e256a86863..64dd0f87caa 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java @@ -64,7 +64,8 @@ public class PercentilesBucketIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java index a16a430343e..8c6479ef6bf 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java @@ -60,7 +60,8 @@ public class StatsBucketIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java index e372f667b43..2a9be035ca1 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java @@ -59,7 +59,8 @@ public class SumBucketIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); diff --git a/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java b/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java index 87d5a00d2a2..2cc16ef14cb 100644 --- a/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java @@ -413,7 +413,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { public void testScopedFacet() throws Exception { assertAcked(prepareCreate("test") .addMapping("parent") - .addMapping("child", "_parent", "type=parent")); + .addMapping("child", "_parent", "type=parent", "c_field", "type=keyword")); ensureGreen(); // index simple data @@ -825,8 +825,8 @@ public class ChildQuerySearchIT extends ESIntegTestCase { public void testSimpleQueryRewrite() throws Exception { assertAcked(prepareCreate("test") - .addMapping("parent", "p_field", "type=text") - .addMapping("child", "_parent", "type=parent", "c_field", "type=text")); + .addMapping("parent", "p_field", "type=keyword") + .addMapping("child", "_parent", "type=parent", "c_field", "type=keyword")); ensureGreen(); // index simple data diff --git a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java index d545479c00b..fe7aa4e9613 100644 --- a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java +++ b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java @@ -81,6 +81,7 @@ public class InnerHitsIT extends ESIntegTestCase { .startObject("properties") .startObject("message") .field("type", "text") + .field("fielddata", true) .endObject() .endObject() .endObject() @@ -282,7 +283,7 @@ public class InnerHitsIT extends ESIntegTestCase { public void testSimpleParentChild() throws Exception { assertAcked(prepareCreate("articles") .addMapping("article", "title", "type=text") - .addMapping("comment", "_parent", "type=article", "message", "type=text") + .addMapping("comment", "_parent", "type=article", "message", "type=text,fielddata=true") ); List requests = new ArrayList<>(); @@ -903,9 +904,14 @@ public class InnerHitsIT extends ESIntegTestCase { .startObject("properties") .startObject("nested1") .field("type", "nested") + .startObject("properties") + .startObject("n_field1") + .field("type", "keyword") + .endObject() + .endObject() .endObject() .startObject("field1") - .field("type", "long") + .field("type", "long") .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java index e38ac0ca76e..b5658adff39 100644 --- a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java @@ -872,8 +872,8 @@ public class SimpleNestedIT extends ESIntegTestCase { .startObject("users") .field("type", "nested") .startObject("properties") - .startObject("first").field("type", "text").endObject() - .startObject("last").field("type", "text").endObject() + .startObject("first").field("type", "keyword").endObject() + .startObject("last").field("type", "keyword").endObject() .startObject("workstations") .field("type", "nested") .startObject("properties") diff --git a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java index 891911b6202..271d1f4aadf 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java @@ -792,7 +792,7 @@ public class SearchQueryIT extends ESIntegTestCase { MultiMatchQueryBuilder builder = multiMatchQuery("value1 value2 value4", "field1", "field2"); SearchResponse searchResponse = client().prepareSearch().setQuery(builder) - .addAggregation(AggregationBuilders.terms("field1").field("field1")).get(); + .addAggregation(AggregationBuilders.terms("field1").field("field1.keyword")).get(); assertHitCount(searchResponse, 2L); // this uses dismax so scores are equal and the order can be arbitrary diff --git a/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java b/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java index 6c0b9963940..ed7ee493c31 100644 --- a/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java +++ b/core/src/test/java/org/elasticsearch/search/scroll/DuelScrollIT.java @@ -138,7 +138,7 @@ public class DuelScrollIT extends ESIntegTestCase { .field("type", "long") .endObject() .startObject("field2") - .field("type", "text") + .field("type", "keyword") .endObject() .startObject("nested") .field("type", "nested") @@ -147,7 +147,7 @@ public class DuelScrollIT extends ESIntegTestCase { .field("type", "long") .endObject() .startObject("field4") - .field("type", "text") + .field("type", "keyword") .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java index 6aa7652e3a5..4ab11d538fd 100644 --- a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java +++ b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java @@ -465,7 +465,7 @@ public class SearchScrollIT extends ESIntegTestCase { public void testStringSortMissingAscTerminates() throws Exception { assertAcked(prepareCreate("test") .setSettings(Settings.settingsBuilder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("test", "no_field", "type=text", "some_field", "type=text")); + .addMapping("test", "no_field", "type=keyword", "some_field", "type=keyword")); client().prepareIndex("test", "test", "1").setSource("some_field", "test").get(); refresh(); diff --git a/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java b/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java index 0274143a6ad..a115567059d 100644 --- a/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java +++ b/core/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java @@ -41,6 +41,7 @@ import java.util.Collections; import java.util.Arrays; import java.util.concurrent.ExecutionException; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.hamcrest.Matchers.equalTo; @@ -51,7 +52,8 @@ public class SearchAfterIT extends ESIntegTestCase { private static final int NUM_DOCS = 100; public void testsShouldFail() throws Exception { - createIndex("test"); + assertAcked(client().admin().indices().prepareCreate("test") + .addMapping("type1", "field2", "type=keyword").get()); ensureGreen(); indexRandom(true, client().prepareIndex("test", "type1", "0").setSource("field1", 0, "field2", "toto")); try { @@ -139,7 +141,8 @@ public class SearchAfterIT extends ESIntegTestCase { } public void testWithNullStrings() throws ExecutionException, InterruptedException { - createIndex("test"); + assertAcked(client().admin().indices().prepareCreate("test") + .addMapping("type1", "field2", "type=keyword").get()); ensureGreen(); indexRandom(true, client().prepareIndex("test", "type1", "0").setSource("field1", 0), diff --git a/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java b/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java index 2419dd2c508..445f2a66e0f 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java +++ b/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java @@ -180,7 +180,8 @@ public class FieldSortIT extends ESIntegTestCase { } public void testTrackScores() throws Exception { - createIndex("test"); + assertAcked(client().admin().indices().prepareCreate("test") + .addMapping("type", "svalue", "type=keyword").get()); ensureGreen(); index("test", "type1", jsonBuilder().startObject() .field("id", "1") @@ -294,7 +295,8 @@ public class FieldSortIT extends ESIntegTestCase { } public void test3078() { - createIndex("test"); + assertAcked(client().admin().indices().prepareCreate("test") + .addMapping("type", "field", "type=keyword").get()); ensureGreen(); for (int i = 1; i < 101; i++) { @@ -423,7 +425,8 @@ public class FieldSortIT extends ESIntegTestCase { } public void testIssue2986() { - createIndex("test"); + assertAcked(client().admin().indices().prepareCreate("test") + .addMapping("type", "field1", "type=keyword").get()); client().prepareIndex("test", "post", "1").setSource("{\"field1\":\"value1\"}").execute().actionGet(); client().prepareIndex("test", "post", "2").setSource("{\"field1\":\"value2\"}").execute().actionGet(); @@ -444,7 +447,8 @@ public class FieldSortIT extends ESIntegTestCase { } catch (Exception e) { // ignore } - createIndex("test"); + assertAcked(client().admin().indices().prepareCreate("test") + .addMapping("type", "tag", "type=keyword").get()); ensureGreen(); client().prepareIndex("test", "type", "1").setSource("tag", "alpha").execute().actionGet(); refresh(); @@ -1414,6 +1418,7 @@ public class FieldSortIT extends ESIntegTestCase { .startObject("properties") .startObject("foo") .field("type", "text") + .field("fielddata", true) .startObject("fields") .startObject("sub") .field("type", "keyword") diff --git a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java index a88c977cce6..831db7ea3fc 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java +++ b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java @@ -333,7 +333,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase { public void testCrossIndexIgnoreUnmapped() throws Exception { assertAcked(prepareCreate("test1").addMapping( - "type", "str_field1", "type=keyword", + "type", "str_field", "type=keyword", "long_field", "type=long", "double_field", "type=double").get()); assertAcked(prepareCreate("test2").get()); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java index 152c450f6ec..2e2040e0572 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java @@ -308,7 +308,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { int numRequestedPayloadFields = randomIntBetween(2, numPayloadFields); List payloadFields = new ArrayList<>(numRequestedPayloadFields); for (int i = 0; i < numRequestedPayloadFields; i++) { - payloadFields.add("test_field" + i); + payloadFields.add("test_field" + i + ".keyword"); } CompletionSuggestionBuilder prefix = SuggestBuilders.completionSuggestion(FIELD).prefix("sugg") @@ -324,7 +324,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { assertThat(option.getText().toString(), equalTo("suggestion" + id)); assertThat(option.getPayload().size(), equalTo(numRequestedPayloadFields)); for (int i = 0; i < numRequestedPayloadFields; i++) { - List fieldValue = option.getPayload().get("test_field" + i); + List fieldValue = option.getPayload().get("test_field" + i + ".keyword"); assertNotNull(fieldValue); assertThat(fieldValue.size(), equalTo(1)); assertThat((String)fieldValue.get(0), equalTo(i + "value" + id)); @@ -961,6 +961,12 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { private void createIndexAndMappingAndSettings(Settings settings, CompletionMappingBuilder completionMappingBuilder) throws IOException { XContentBuilder mapping = jsonBuilder().startObject() .startObject(TYPE).startObject("properties") + .startObject("test_field") + .field("type", "keyword") + .endObject() + .startObject("title") + .field("type", "keyword") + .endObject() .startObject(FIELD) .field("type", "completion") .field("analyzer", completionMappingBuilder.indexAnalyzer) diff --git a/core/src/test/java/org/elasticsearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java b/core/src/test/java/org/elasticsearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java index e3af1c296ba..e37de0e6746 100644 --- a/core/src/test/java/org/elasticsearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java +++ b/core/src/test/java/org/elasticsearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java @@ -76,8 +76,12 @@ public class SharedSignificantTermsTestMethods { } public static void index01Docs(String type, String settings, ESIntegTestCase testCase) throws ExecutionException, InterruptedException { - String mappings = "{\"doc\": {\"properties\":{\"text\": {\"type\":\"" + type + "\"}}}}"; - assertAcked(testCase.prepareCreate(INDEX_NAME).setSettings(settings).addMapping("doc", mappings)); + String textMappings = "type=" + type; + if (type.equals("text")) { + textMappings += ",fielddata=true"; + } + assertAcked(testCase.prepareCreate(INDEX_NAME).setSettings(settings) + .addMapping("doc", "text", textMappings, CLASS_FIELD, "type=keyword")); String[] gb = {"0", "1"}; List indexRequestBuilderList = new ArrayList<>(); indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "1") diff --git a/modules/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java b/modules/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java index a8856ea78b5..9d31088517f 100644 --- a/modules/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java +++ b/modules/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java @@ -56,6 +56,7 @@ import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.bucketScript; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; @@ -408,7 +409,8 @@ public class MoreExpressionTests extends ESIntegTestCase { public void testStringSpecialValueVariable() throws Exception { // i.e. expression script for term aggregations, which is not allowed - createIndex("test"); + assertAcked(client().admin().indices().prepareCreate("test") + .addMapping("doc", "text", "type=keyword").get()); ensureGreen("test"); indexRandom(true, client().prepareIndex("test", "doc", "1").setSource("text", "hello"), diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinDocCountTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinDocCountTests.java index 9a92a6180e2..738b4c4a844 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinDocCountTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinDocCountTests.java @@ -56,6 +56,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.dateHistogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; @@ -73,7 +74,8 @@ public class MinDocCountTests extends AbstractTermsTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", "s", "type=keyword").get()); cardinality = randomIntBetween(8, 30); final List indexRequests = new ArrayList<>(); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java index 9d31274be81..279a5149679 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java @@ -539,7 +539,8 @@ public class SearchFieldsTests extends ESIntegTestCase { // see #8203 public void testSingleValueFieldDatatField() throws ExecutionException, InterruptedException { - createIndex("test"); + assertAcked(client().admin().indices().prepareCreate("test") + .addMapping("type", "test_field", "type=keyword").get()); indexRandom(true, client().prepareIndex("test", "type", "1").setSource("test_field", "foobar")); refresh(); SearchResponse searchResponse = client().prepareSearch("test").setTypes("type").setSource( @@ -554,7 +555,7 @@ public class SearchFieldsTests extends ESIntegTestCase { client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("_source").field("enabled", false).endObject().startObject("properties") - .startObject("text_field").field("type", "text").endObject() + .startObject("text_field").field("type", "text").field("fielddata", true).endObject() .startObject("keyword_field").field("type", "keyword").endObject() .startObject("byte_field").field("type", "byte").endObject() .startObject("short_field").field("type", "short").endObject() diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java index 3aa3f1422ec..11f0e4c191a 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java @@ -227,6 +227,7 @@ public class SimpleSortTests extends ESIntegTestCase { // We have to specify mapping explicitly because by the time search is performed dynamic mapping might not // be propagated to all nodes yet and sort operation fail when the sort field is not defined String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties") + .startObject("id").field("type", "keyword").endObject() .startObject("svalue").field("type", "keyword").endObject() .endObject().endObject().endObject().string(); assertAcked(prepareCreate("test").addMapping("type1", mapping)); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java index 606b26f193d..deeeb2911b6 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java @@ -68,6 +68,7 @@ import static org.elasticsearch.search.aggregations.AggregationBuilders.histogra import static org.elasticsearch.search.aggregations.AggregationBuilders.stats; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -90,7 +91,10 @@ public class StringTermsTests extends AbstractTermsTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - createIndex("idx"); + assertAcked(client().admin().indices().prepareCreate("idx") + .addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=keyword", + MULTI_VALUED_FIELD_NAME, "type=keyword", + "tag", "type=keyword").get()); List builders = new ArrayList<>(); for (int i = 0; i < 5; i++) { builders.add(client().prepareIndex("idx", "type").setSource( @@ -163,7 +167,10 @@ public class StringTermsTests extends AbstractTermsTestCase { bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((String) bucketProps.get("_term"), bucketProps); - createIndex("sort_idx"); + assertAcked(client().admin().indices().prepareCreate("sort_idx") + .addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=keyword", + MULTI_VALUED_FIELD_NAME, "type=keyword", + "tag", "type=keyword").get()); for (int i = 1; i <= 3; i++) { builders.add(client().prepareIndex("sort_idx", "multi_sort_type").setSource( jsonBuilder().startObject().field(SINGLE_VALUED_FIELD_NAME, "val1").field("l", 1).field("d", i).endObject())); diff --git a/modules/lang-painless/src/test/resources/rest-api-spec/test/plan_a/20_scriptfield.yaml b/modules/lang-painless/src/test/resources/rest-api-spec/test/plan_a/20_scriptfield.yaml index df1ce6cfe74..66cff5df792 100644 --- a/modules/lang-painless/src/test/resources/rest-api-spec/test/plan_a/20_scriptfield.yaml +++ b/modules/lang-painless/src/test/resources/rest-api-spec/test/plan_a/20_scriptfield.yaml @@ -1,6 +1,15 @@ # Integration tests for using a scripted field # setup: + - do: + indices.create: + index: test + body: + mappings: + test: + properties: + foo: + type: keyword - do: index: index: test diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryBasicTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryBasicTests.java index 096967149fb..75a7ee2284b 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryBasicTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryBasicTests.java @@ -53,7 +53,7 @@ public class UpdateByQueryBasicTests extends UpdateByQueryTestCase { // Limit with size UpdateByQueryRequestBuilder request = request().source("test").size(3).refresh(true); - request.source().addSort("foo", SortOrder.ASC); + request.source().addSort("foo.keyword", SortOrder.ASC); assertThat(request.get(), responseMatcher().updated(3)); // Only the first three documents are updated because of sort assertEquals(4, client().prepareGet("test", "test", "1").get().getVersion()); diff --git a/plugins/lang-javascript/src/test/resources/rest-api-spec/test/lang_javascript/10_basic.yaml b/plugins/lang-javascript/src/test/resources/rest-api-spec/test/lang_javascript/10_basic.yaml index 6d1625a9494..021e17e4a83 100644 --- a/plugins/lang-javascript/src/test/resources/rest-api-spec/test/lang_javascript/10_basic.yaml +++ b/plugins/lang-javascript/src/test/resources/rest-api-spec/test/lang_javascript/10_basic.yaml @@ -19,7 +19,7 @@ setup: script_fields: bar: script: - inline: "doc['foo'].value + x" + inline: "doc['foo.keyword'].value + x" lang: javascript params: x: "bbb" diff --git a/plugins/lang-python/src/test/resources/rest-api-spec/test/lang_python/10_basic.yaml b/plugins/lang-python/src/test/resources/rest-api-spec/test/lang_python/10_basic.yaml index 4a811d1f26a..c915411f1d4 100644 --- a/plugins/lang-python/src/test/resources/rest-api-spec/test/lang_python/10_basic.yaml +++ b/plugins/lang-python/src/test/resources/rest-api-spec/test/lang_python/10_basic.yaml @@ -19,7 +19,7 @@ setup: script_fields: bar: script: - inline: "doc['foo'].value + x" + inline: "doc['foo.keyword'].value + x" lang: python params: x: "bbb" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.fielddata/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.fielddata/10_basic.yaml index dfc580da1dd..cd3a53a103c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.fielddata/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.fielddata/10_basic.yaml @@ -19,6 +19,19 @@ - do: cat.fielddata: {} + - do: + indices.create: + index: index + body: + settings: + number_of_shards: "1" + mappings: + type: + properties: + foo: + type: text + fielddata: true + - do: index: index: index diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/13_fields.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/13_fields.yaml index 72fc228004e..7f9396b8565 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/13_fields.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/13_fields.yaml @@ -10,11 +10,13 @@ setup: properties: bar: type: text + fielddata: true fields: completion: type: completion baz: type: text + fielddata: true fields: completion: type: completion diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/test_sig_terms.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/test_sig_terms.yaml index 58346d01c45..9c01bbc2b5d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/test_sig_terms.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/test_sig_terms.yaml @@ -6,6 +6,14 @@ body: settings: number_of_shards: "1" + mappings: + doc: + properties: + text: + type: text + fielddata: true + class: + type: keyword - do: index: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/suggest/20_completion.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/suggest/20_completion.yaml index 8eb01023e08..3bf0a7cd91b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/suggest/20_completion.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/suggest/20_completion.yaml @@ -24,6 +24,8 @@ setup: "type" : "completion" "suggest_6": "type" : "completion" + title: + type: keyword --- "Simple suggestion should work":