From 4f8895eae33c4efd9d5058a608b4a654bda42a33 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Fri, 12 Feb 2016 14:27:19 +0100 Subject: [PATCH] Add a text field. This new field is intended to replace analyzed string fields. --- .../index/analysis/AnalysisService.java | 4 +- .../analysis/CustomAnalyzerProvider.java | 4 +- .../fielddata/IndexFieldDataService.java | 5 + .../index/mapper/DocumentParser.java | 14 + .../index/mapper/FieldMapper.java | 9 +- .../index/mapper/core/KeywordFieldMapper.java | 8 + .../index/mapper/core/StringFieldMapper.java | 34 +- .../index/mapper/core/TextFieldMapper.java | 267 ++++++++++++ .../index/mapper/core/TypeParsers.java | 42 +- .../index/query/QueryShardContext.java | 3 +- .../index/termvectors/TermVectorsService.java | 4 +- .../elasticsearch/indices/IndicesModule.java | 2 + .../admin/indices/create/CreateIndexIT.java | 4 +- .../indices/stats/IndicesStatsTests.java | 2 +- .../GetTermVectorsCheckDocFreqIT.java | 2 +- .../action/termvectors/GetTermVectorsIT.java | 40 +- .../elasticsearch/aliases/IndexAliasesIT.java | 26 +- .../BasicAnalysisBackwardCompatibilityIT.java | 2 +- .../BasicBackwardsCompatibilityIT.java | 4 +- .../cluster/SimpleClusterStateIT.java | 6 +- .../explain/ExplainActionIT.java | 4 +- .../fieldstats/FieldStatsIntegrationIT.java | 4 +- .../fieldstats/FieldStatsTests.java | 6 +- .../gateway/RecoveryFromGatewayIT.java | 6 +- .../org/elasticsearch/get/GetActionIT.java | 8 +- .../index/IndexWithShadowReplicasIT.java | 18 +- .../index/analysis/PreBuiltAnalyzerTests.java | 2 +- .../FieldDataFilterIntegrationIT.java | 4 +- .../index/fielddata/FieldDataLoadingIT.java | 4 +- .../index/mapper/DynamicMappingTests.java | 26 +- .../index/mapper/MapperServiceTests.java | 4 +- .../mapper/all/SimpleAllMapperTests.java | 8 +- .../copyto/CopyToMapperIntegrationIT.java | 4 +- .../mapper/copyto/CopyToMapperTests.java | 28 +- .../mapper/core/BooleanFieldMapperTests.java | 3 +- .../core/MultiFieldCopyToMapperTests.java | 6 +- .../mapper/core/TextFieldMapperTests.java | 389 ++++++++++++++++++ .../index/mapper/core/TextFieldTypeTests.java | 29 ++ .../mapper/externalvalues/ExternalMapper.java | 5 +- .../ExternalValuesMapperIntegrationIT.java | 2 +- .../SimpleExternalMappingTests.java | 14 +- .../mapper/merge/TestMergeMapperTests.java | 16 +- .../mapper/multifield/MultiFieldTests.java | 32 +- .../multifield/MultiFieldsIntegrationIT.java | 6 +- .../mapper/nested/NestedMappingTests.java | 2 +- .../object/SimpleObjectMappingTests.java | 9 +- .../mapper/simple/SimpleMapperTests.java | 8 +- .../string/SimpleStringMappingTests.java | 13 +- .../index/mapper/ttl/TTLMappingTests.java | 20 +- .../update/UpdateMappingOnClusterIT.java | 8 +- .../mapper/update/UpdateMappingTests.java | 22 +- .../PercolatorFieldMapperTests.java | 2 +- .../index/query/AbstractQueryTestCase.java | 4 +- .../query/CommonTermsQueryParserTests.java | 2 +- .../query/HasChildQueryBuilderTests.java | 4 +- .../query/HasParentQueryBuilderTests.java | 4 +- .../index/query/NestedQueryBuilderTests.java | 2 +- .../query/ParentIdQueryBuilderTests.java | 4 +- .../index/query/QueryShardContextTests.java | 6 +- .../index/shard/IndexShardTests.java | 6 +- .../index/similarity/SimilarityTests.java | 18 +- .../index/suggest/stats/SuggestStatsIT.java | 4 +- .../indices/IndicesOptionsIntegrationIT.java | 16 +- .../PreBuiltAnalyzerIntegrationIT.java | 6 +- .../indices/analyze/AnalyzeActionIT.java | 8 +- .../mapping/SimpleGetFieldMappingsIT.java | 6 +- .../indices/mapping/SimpleGetMappingsIT.java | 2 +- .../mapping/UpdateMappingIntegrationIT.java | 8 +- .../recovery/IndexPrimaryRelocationIT.java | 2 +- .../template/IndexTemplateBlocksIT.java | 2 +- .../template/IndexTemplateFilteringIT.java | 6 +- .../template/SimpleIndexTemplateIT.java | 28 +- .../percolator/ConcurrentPercolatorIT.java | 6 +- .../percolator/MultiPercolatorIT.java | 8 +- .../percolator/PercolatorAggregationsIT.java | 6 +- .../percolator/PercolatorIT.java | 22 +- .../percolator/RecoveryPercolatorIT.java | 6 +- .../percolator/TTLPercolatorIT.java | 2 +- .../recovery/TruncatedRecoveryIT.java | 2 +- .../AggregationsIntegrationIT.java | 2 +- .../search/aggregations/CombiIT.java | 2 +- .../aggregations/bucket/ChildrenIT.java | 4 +- .../search/aggregations/bucket/NestedIT.java | 2 +- .../aggregations/bucket/ReverseNestedIT.java | 14 +- .../search/aggregations/bucket/SamplerIT.java | 4 +- .../bucket/SignificantTermsIT.java | 2 +- .../SignificantTermsSignificanceScoreIT.java | 2 +- .../aggregations/metrics/TopHitsIT.java | 2 +- .../search/basic/SearchWhileRelocatingIT.java | 2 +- .../search/child/ChildQuerySearchIT.java | 4 +- .../search/fetch/FetchSubPhasePluginIT.java | 2 +- .../functionscore/DecayFunctionScoreIT.java | 28 +- .../FunctionScoreBackwardCompatibilityIT.java | 2 +- .../FunctionScoreFieldValueIT.java | 2 +- .../functionscore/FunctionScorePluginIT.java | 2 +- .../search/functionscore/QueryRescorerIT.java | 12 +- .../highlight/HighlightBuilderTests.java | 4 +- .../search/highlight/HighlighterSearchIT.java | 138 +++---- .../search/innerhits/InnerHitsIT.java | 34 +- .../search/morelikethis/MoreLikeThisIT.java | 20 +- .../search/nested/SimpleNestedIT.java | 12 +- .../elasticsearch/search/query/ExistsIT.java | 6 +- .../search/query/MultiMatchQueryIT.java | 8 +- .../search/query/SearchQueryIT.java | 32 +- .../search/query/SimpleQueryStringIT.java | 6 +- .../rescore/QueryRescoreBuilderTests.java | 3 +- .../search/scroll/DuelScrollIT.java | 4 +- .../search/scroll/SearchScrollIT.java | 2 +- .../search/sort/FieldSortIT.java | 2 +- .../search/sort/GeoDistanceIT.java | 4 +- .../search/sort/GeoDistanceSortBuilderIT.java | 2 +- .../suggest/CompletionSuggestSearchIT.java | 4 +- .../phrase/DirectCandidateGeneratorTests.java | 3 +- .../similarity/SimilarityIT.java | 4 +- .../SharedClusterSnapshotRestoreIT.java | 6 +- .../timestamp/SimpleTimestampIT.java | 2 +- .../ContextAndHeaderTransportIT.java | 2 +- .../org/elasticsearch/ttl/SimpleTTLIT.java | 2 +- .../validate/SimpleValidateQueryIT.java | 12 +- .../index/mapper/all/mapping.json | 11 +- .../mapping_boost_omit_positions_on_all.json | 9 +- .../mapper/all/mapping_offsets_on_all.json | 9 +- .../all/mapping_omit_positions_on_all.json | 11 +- .../all/misplaced_mapping_key_in_root.json | 2 +- .../mapper/all/misplaced_type_in_root.json | 4 +- .../mapper/all/mistyped_type_in_root.json | 2 +- .../all/multifield-mapping_default.json | 7 +- ...d-mapping_include_in_all_set_to_false.json | 7 +- .../index/mapper/all/noboost-mapping.json | 11 +- .../index/mapper/all/store-mapping.json | 11 +- .../all/type_date_detection_mapping.json | 2 +- .../type_dynamic_date_formats_mapping.json | 2 +- .../all/type_dynamic_template_mapping.json | 2 +- .../all/type_numeric_detection_mapping.json | 2 +- .../pathmatch/test-mapping.json | 2 +- .../dynamictemplate/simple/test-mapping.json | 5 +- .../multifield/merge/test-mapping1.json | 5 +- .../multifield/merge/test-mapping2.json | 15 +- .../multifield/merge/test-mapping3.json | 19 +- .../multifield/merge/test-mapping4.json | 9 +- .../mapper/multifield/merge/upgrade1.json | 10 +- .../mapper/multifield/merge/upgrade2.json | 14 +- .../mapper/multifield/merge/upgrade3.json | 8 +- .../test-multi-field-type-completion.json | 8 +- .../test-multi-field-type-geo_point.json | 9 +- ...est-multi-field-type-no-default-field.json | 7 +- .../mapper/multifield/test-multi-fields.json | 16 +- .../index/mapper/path/test-mapping.json | 8 +- .../index/mapper/simple/test-mapping.json | 21 +- .../mapper/attachments/AttachmentMapper.java | 16 +- .../DateAttachmentMapperTests.java | 4 +- ...anguageDetectionAttachmentMapperTests.java | 3 +- .../MultifieldAttachmentMapperTests.java | 27 +- .../test/unit/date/date-mapping.json | 2 +- .../test/unit/language/language-mapping.json | 2 +- .../unit/multifield/multifield-mapping.json | 26 +- .../test/cat.aliases/10_basic.yaml | 2 +- .../test/indices.analyze/10_analyze.yaml | 2 +- .../test/indices.create/10_basic.yaml | 2 +- .../indices.get_field_mapping/10_basic.yaml | 14 +- .../20_missing_field.yaml | 2 +- .../30_missing_type.yaml | 2 +- .../50_field_wildcards.yaml | 20 +- .../indices.get_mapping/20_missing_type.yaml | 2 +- .../test/indices.get_mapping/40_aliases.yaml | 4 +- .../test/indices.put_mapping/10_basic.yaml | 12 +- .../indices.put_mapping/all_path_options.yaml | 52 ++- .../test/indices.stats/13_fields.yaml | 4 +- .../20_query_string.yaml | 2 +- .../rest-api-spec/test/mlt/10_basic.yaml | 4 +- .../test/mtermvectors/10_basic.yaml | 2 +- .../percolate/18_highligh_with_query.yaml | 2 +- .../test/percolate/19_nested.yaml | 4 +- .../test/termvectors/10_basic.yaml | 2 +- .../test/termvectors/20_issue7121.yaml | 2 +- 175 files changed, 1465 insertions(+), 783 deletions(-) create mode 100644 core/src/main/java/org/elasticsearch/index/mapper/core/TextFieldMapper.java create mode 100644 core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java create mode 100644 core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldTypeTests.java diff --git a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java index a042bbcb9f3..22a560dc372 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import java.io.Closeable; import java.util.HashMap; @@ -78,7 +78,7 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable * and 100 afterwards so we override the positionIncrementGap if it * doesn't match here. */ - int overridePositionIncrementGap = StringFieldMapper.Defaults.POSITION_INCREMENT_GAP; + int overridePositionIncrementGap = TextFieldMapper.Defaults.POSITION_INCREMENT_GAP; if (analyzerFactory instanceof CustomAnalyzerProvider) { ((CustomAnalyzerProvider) analyzerFactory).build(this); /* diff --git a/core/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java index 3c4768279f2..a8bfd996a3e 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/CustomAnalyzerProvider.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import java.util.ArrayList; import java.util.List; @@ -74,7 +74,7 @@ public class CustomAnalyzerProvider extends AbstractIndexAnalyzerProvider buildersByTypeBuilder = new HashMap<>(); buildersByTypeBuilder.put("string", new PagedBytesIndexFieldData.Builder()); + buildersByTypeBuilder.put(TextFieldMapper.CONTENT_TYPE, new PagedBytesIndexFieldData.Builder()); buildersByTypeBuilder.put(KeywordFieldMapper.CONTENT_TYPE, MISSING_DOC_VALUES_BUILDER); buildersByTypeBuilder.put("float", MISSING_DOC_VALUES_BUILDER); buildersByTypeBuilder.put("double", MISSING_DOC_VALUES_BUILDER); @@ -129,6 +131,9 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Clo .put(Tuple.tuple("string", DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder()) .put(Tuple.tuple("string", DISABLED_FORMAT), DISABLED_BUILDER) + .put(Tuple.tuple(TextFieldMapper.CONTENT_TYPE, PAGED_BYTES_FORMAT), new PagedBytesIndexFieldData.Builder()) + .put(Tuple.tuple(TextFieldMapper.CONTENT_TYPE, DISABLED_FORMAT), DISABLED_BUILDER) + .put(Tuple.tuple(KeywordFieldMapper.CONTENT_TYPE, DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder()) .put(Tuple.tuple(KeywordFieldMapper.CONTENT_TYPE, DISABLED_FORMAT), DISABLED_BUILDER) diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java index ac7240495bd..b0cdb993b78 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java @@ -35,9 +35,13 @@ import org.elasticsearch.index.mapper.core.DateFieldMapper.DateFieldType; import org.elasticsearch.index.mapper.core.DoubleFieldMapper; import org.elasticsearch.index.mapper.core.FloatFieldMapper; import org.elasticsearch.index.mapper.core.IntegerFieldMapper; +import org.elasticsearch.index.mapper.core.KeywordFieldMapper; +import org.elasticsearch.index.mapper.core.KeywordFieldMapper.KeywordFieldType; import org.elasticsearch.index.mapper.core.LongFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper.StringFieldType; +import org.elasticsearch.index.mapper.core.TextFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper.TextFieldType; import org.elasticsearch.index.mapper.internal.TypeFieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.mapper.object.ArrayValueMapperParser; @@ -452,6 +456,16 @@ class DocumentParser implements Closeable { if (builder == null) { builder = new StringFieldMapper.Builder(currentFieldName); } + } else if (fieldType instanceof TextFieldType) { + builder = context.root().findTemplateBuilder(context, currentFieldName, "string"); + if (builder == null) { + builder = new TextFieldMapper.Builder(currentFieldName); + } + } else if (fieldType instanceof KeywordFieldType) { + builder = context.root().findTemplateBuilder(context, currentFieldName, "string"); + if (builder == null) { + builder = new KeywordFieldMapper.Builder(currentFieldName); + } } else if (fieldType instanceof DateFieldType) { builder = context.root().findTemplateBuilder(context, currentFieldName, "date"); if (builder == null) { diff --git a/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index fd35398a9dc..1436fd9a48a 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -185,6 +185,11 @@ public abstract class FieldMapper extends Mapper implements Cloneable { return builder; } + public T searchQuoteAnalyzer(NamedAnalyzer searchQuoteAnalyzer) { + this.fieldType.setSearchQuoteAnalyzer(searchQuoteAnalyzer); + return builder; + } + public T includeInAll(Boolean includeInAll) { this.includeInAll = includeInAll; return builder; @@ -293,7 +298,9 @@ public abstract class FieldMapper extends Mapper implements Cloneable { try { parseCreateField(context, fields); for (Field field : fields) { - if (!customBoost()) { + if (!customBoost() + // don't set boosts eg. on dv fields + && field.fieldType().indexOptions() != IndexOptions.NONE) { field.setBoost(fieldType().boost()); } context.doc().add(field); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/KeywordFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/KeywordFieldMapper.java index 35f1ee7ad58..171bc8de794 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/KeywordFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/KeywordFieldMapper.java @@ -92,6 +92,14 @@ public final class KeywordFieldMapper extends FieldMapper implements AllFieldMap return super.indexOptions(indexOptions); } + @Override + protected void setupFieldType(BuilderContext context) { + if (!omitNormsSet && fieldType.boost() != 1.0f) { + fieldType.setOmitNorms(false); + } + super.setupFieldType(context); + } + @Override public KeywordFieldMapper build(BuilderContext context) { setupFieldType(context); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java index 6812fa520aa..343d3a407d0 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java @@ -31,7 +31,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.analysis.NamedAnalyzer; -import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; @@ -63,13 +62,6 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc // NOTE, when adding defaults here, make sure you add them in the builder public static final String NULL_VALUE = null; - /** - * Post 2.0 default for position_increment_gap. Set to 100 so that - * phrase queries of reasonably high slop will not match across field - * values. - */ - public static final int POSITION_INCREMENT_GAP = 100; - public static final int IGNORE_ABOVE = -1; } @@ -102,11 +94,6 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc return this; } - public Builder searchQuotedAnalyzer(NamedAnalyzer analyzer) { - this.fieldType.setSearchQuoteAnalyzer(analyzer); - return builder; - } - public Builder ignoreAbove(int ignoreAbove) { this.ignoreAbove = ignoreAbove; return this; @@ -167,6 +154,9 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc throw new IllegalArgumentException("Can't parse [index] value [" + index + "] for field [" + fieldName + "], expected [true], [false], [no], [not_analyzed] or [analyzed]"); } } + builder.fieldType().setIndexAnalyzer(parserContext.analysisService().defaultIndexAnalyzer()); + builder.fieldType().setSearchAnalyzer(parserContext.analysisService().defaultSearchAnalyzer()); + builder.fieldType().setSearchQuoteAnalyzer(parserContext.analysisService().defaultSearchQuoteAnalyzer()); parseTextField(builder, fieldName, node, parserContext); for (Iterator> iterator = node.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = iterator.next(); @@ -178,30 +168,12 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc } builder.nullValue(propNode.toString()); iterator.remove(); - } else if (propName.equals("search_quote_analyzer")) { - NamedAnalyzer analyzer = parserContext.analysisService().analyzer(propNode.toString()); - if (analyzer == null) { - throw new MapperParsingException("Analyzer [" + propNode.toString() + "] not found for field [" + fieldName + "]"); - } - builder.searchQuotedAnalyzer(analyzer); - iterator.remove(); } else if (propName.equals("position_increment_gap")) { int newPositionIncrementGap = XContentMapValues.nodeIntegerValue(propNode, -1); if (newPositionIncrementGap < 0) { throw new MapperParsingException("positions_increment_gap less than 0 aren't allowed."); } builder.positionIncrementGap(newPositionIncrementGap); - // we need to update to actual analyzers if they are not set in this case... - // so we can inject the position increment gap... - if (builder.fieldType().indexAnalyzer() == null) { - builder.fieldType().setIndexAnalyzer(parserContext.analysisService().defaultIndexAnalyzer()); - } - if (builder.fieldType().searchAnalyzer() == null) { - builder.fieldType().setSearchAnalyzer(parserContext.analysisService().defaultSearchAnalyzer()); - } - if (builder.fieldType().searchQuoteAnalyzer() == null) { - builder.fieldType().setSearchQuoteAnalyzer(parserContext.analysisService().defaultSearchQuoteAnalyzer()); - } iterator.remove(); } else if (propName.equals("ignore_above")) { builder.ignoreAbove(XContentMapValues.nodeIntegerValue(propNode, -1)); 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 new file mode 100644 index 00000000000..1ec093ec8e0 --- /dev/null +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/TextFieldMapper.java @@ -0,0 +1,267 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.index.mapper.core; + +import org.apache.lucene.document.Field; +import org.apache.lucene.index.IndexOptions; +import org.apache.lucene.search.Query; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.support.XContentMapValues; +import org.elasticsearch.index.analysis.NamedAnalyzer; +import org.elasticsearch.index.mapper.FieldMapper; +import org.elasticsearch.index.mapper.MappedFieldType; +import org.elasticsearch.index.mapper.Mapper; +import org.elasticsearch.index.mapper.MapperParsingException; +import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.internal.AllFieldMapper; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +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. */ +public class TextFieldMapper extends FieldMapper implements AllFieldMapper.IncludeInAll { + + public static final String CONTENT_TYPE = "text"; + private static final int POSITION_INCREMENT_GAP_USE_ANALYZER = -1; + + public static class Defaults { + public static final MappedFieldType FIELD_TYPE = new TextFieldType(); + + static { + FIELD_TYPE.setTokenized(true); + FIELD_TYPE.freeze(); + } + + /** + * The default position_increment_gap is set to 100 so that phrase + * queries of reasonably high slop will not match across field values. + */ + public static final int POSITION_INCREMENT_GAP = 100; + } + + public static class Builder extends FieldMapper.Builder { + + private int positionIncrementGap = POSITION_INCREMENT_GAP_USE_ANALYZER; + + public Builder(String name) { + super(name, Defaults.FIELD_TYPE, Defaults.FIELD_TYPE); + builder = this; + } + + public Builder positionIncrementGap(int positionIncrementGap) { + if (positionIncrementGap < 0) { + throw new MapperParsingException("[positions_increment_gap] must be positive, got " + positionIncrementGap); + } + this.positionIncrementGap = positionIncrementGap; + return this; + } + + @Override + public Builder docValues(boolean docValues) { + if (docValues) { + throw new IllegalArgumentException("[text] fields do not support doc values"); + } + return super.docValues(docValues); + } + + @Override + public TextFieldMapper build(BuilderContext context) { + if (positionIncrementGap != POSITION_INCREMENT_GAP_USE_ANALYZER) { + fieldType.setIndexAnalyzer(new NamedAnalyzer(fieldType.indexAnalyzer(), positionIncrementGap)); + fieldType.setSearchAnalyzer(new NamedAnalyzer(fieldType.searchAnalyzer(), positionIncrementGap)); + fieldType.setSearchQuoteAnalyzer(new NamedAnalyzer(fieldType.searchQuoteAnalyzer(), positionIncrementGap)); + } + setupFieldType(context); + TextFieldMapper fieldMapper = new TextFieldMapper( + name, fieldType, defaultFieldType, positionIncrementGap, + context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo); + return fieldMapper.includeInAll(includeInAll); + } + } + + public static class TypeParser implements Mapper.TypeParser { + @Override + public Mapper.Builder parse(String fieldName, Map node, ParserContext parserContext) throws MapperParsingException { + TextFieldMapper.Builder builder = new TextFieldMapper.Builder(fieldName); + builder.fieldType().setIndexAnalyzer(parserContext.analysisService().defaultIndexAnalyzer()); + builder.fieldType().setSearchAnalyzer(parserContext.analysisService().defaultSearchAnalyzer()); + builder.fieldType().setSearchQuoteAnalyzer(parserContext.analysisService().defaultSearchQuoteAnalyzer()); + parseTextField(builder, fieldName, node, parserContext); + for (Iterator> iterator = node.entrySet().iterator(); iterator.hasNext();) { + Map.Entry entry = iterator.next(); + String propName = Strings.toUnderscoreCase(entry.getKey()); + Object propNode = entry.getValue(); + if (propName.equals("position_increment_gap")) { + int newPositionIncrementGap = XContentMapValues.nodeIntegerValue(propNode, -1); + builder.positionIncrementGap(newPositionIncrementGap); + iterator.remove(); + } else if (parseMultiField(builder, fieldName, parserContext, propName, propNode)) { + iterator.remove(); + } + } + return builder; + } + } + + public static final class TextFieldType extends MappedFieldType { + + public TextFieldType() {} + + protected TextFieldType(TextFieldType ref) { + super(ref); + } + + public TextFieldType clone() { + return new TextFieldType(this); + } + + @Override + public String typeName() { + return CONTENT_TYPE; + } + + @Override + public String value(Object value) { + if (value == null) { + return null; + } + return value.toString(); + } + + @Override + public Query nullValueQuery() { + if (nullValue() == null) { + return null; + } + return termQuery(nullValue(), null); + } + } + + private Boolean includeInAll; + private int positionIncrementGap; + + protected TextFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, + int positionIncrementGap, + Settings indexSettings, MultiFields multiFields, CopyTo copyTo) { + super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo); + assert fieldType.tokenized(); + assert fieldType.hasDocValues() == false; + this.positionIncrementGap = positionIncrementGap; + } + + @Override + protected TextFieldMapper clone() { + return (TextFieldMapper) super.clone(); + } + + @Override + public TextFieldMapper includeInAll(Boolean includeInAll) { + if (includeInAll != null) { + TextFieldMapper clone = clone(); + clone.includeInAll = includeInAll; + return clone; + } else { + return this; + } + } + + @Override + public TextFieldMapper includeInAllIfNotSet(Boolean includeInAll) { + if (includeInAll != null && this.includeInAll == null) { + TextFieldMapper clone = clone(); + clone.includeInAll = includeInAll; + return clone; + } else { + return this; + } + } + + @Override + public TextFieldMapper unsetIncludeInAll() { + if (includeInAll != null) { + TextFieldMapper clone = clone(); + clone.includeInAll = null; + return clone; + } else { + return this; + } + } + + public int getPositionIncrementGap() { + return this.positionIncrementGap; + } + + @Override + protected void parseCreateField(ParseContext context, List fields) throws IOException { + final String value; + if (context.externalValueSet()) { + value = context.externalValue().toString(); + } else { + value = context.parser().textOrNull(); + } + + if (value == null) { + return; + } + + if (context.includeInAll(includeInAll, this)) { + context.allEntries().addText(fieldType().name(), value, fieldType().boost()); + } + + if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { + Field field = new Field(fieldType().name(), value, fieldType()); + fields.add(field); + } + } + + @Override + protected String contentType() { + return CONTENT_TYPE; + } + + @Override + protected void doMerge(Mapper mergeWith, boolean updateAllTypes) { + super.doMerge(mergeWith, updateAllTypes); + this.includeInAll = ((TextFieldMapper) mergeWith).includeInAll; + } + + @Override + protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { + super.doXContentBody(builder, includeDefaults, params); + doXContentAnalyzers(builder, includeDefaults); + + if (includeInAll != null) { + builder.field("include_in_all", includeInAll); + } else if (includeDefaults) { + builder.field("include_in_all", true); + } + + if (includeDefaults || positionIncrementGap != POSITION_INCREMENT_GAP_USE_ANALYZER) { + builder.field("position_increment_gap", positionIncrementGap); + } + } +} diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java b/core/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java index 6f83b7d75d4..375dcee527b 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java @@ -100,8 +100,9 @@ public class TypeParsers { } private static void parseAnalyzersAndTermVectors(FieldMapper.Builder builder, String name, Map fieldNode, Mapper.TypeParser.ParserContext parserContext) { - NamedAnalyzer indexAnalyzer = builder.fieldType().indexAnalyzer(); - NamedAnalyzer searchAnalyzer = builder.fieldType().searchAnalyzer(); + NamedAnalyzer indexAnalyzer = null; + NamedAnalyzer searchAnalyzer = null; + NamedAnalyzer searchQuoteAnalyzer = null; for (Iterator> iterator = fieldNode.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = iterator.next(); @@ -136,18 +137,41 @@ public class TypeParsers { } searchAnalyzer = analyzer; iterator.remove(); + } else if (propName.equals("search_quote_analyzer")) { + NamedAnalyzer analyzer = parserContext.analysisService().analyzer(propNode.toString()); + if (analyzer == null) { + throw new MapperParsingException("analyzer [" + propNode.toString() + "] not found for field [" + name + "]"); + } + searchQuoteAnalyzer = analyzer; + iterator.remove(); } } - if (indexAnalyzer == null) { - if (searchAnalyzer != null) { - throw new MapperParsingException("analyzer on field [" + name + "] must be set when search_analyzer is set"); - } - } else if (searchAnalyzer == null) { + if (indexAnalyzer == null && searchAnalyzer != null) { + throw new MapperParsingException("analyzer on field [" + name + "] must be set when search_analyzer is set"); + } + + if (searchAnalyzer == null && searchQuoteAnalyzer != null) { + throw new MapperParsingException("analyzer and search_analyzer on field [" + name + "] must be set when search_quote_analyzer is set"); + } + + if (searchAnalyzer == null) { searchAnalyzer = indexAnalyzer; } - builder.indexAnalyzer(indexAnalyzer); - builder.searchAnalyzer(searchAnalyzer); + + if (searchQuoteAnalyzer == null) { + searchQuoteAnalyzer = searchAnalyzer; + } + + if (indexAnalyzer != null) { + builder.indexAnalyzer(indexAnalyzer); + } + if (searchAnalyzer != null) { + builder.searchAnalyzer(searchAnalyzer); + } + if (searchQuoteAnalyzer != null) { + builder.searchQuoteAnalyzer(searchQuoteAnalyzer); + } } /** diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java b/core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java index 83066fba7bc..6acd5272f89 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryShardContext.java @@ -45,6 +45,7 @@ import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.mapper.object.ObjectMapper; import org.elasticsearch.index.query.support.InnerHitsQueryParserHelper; import org.elasticsearch.index.query.support.NestedScope; @@ -254,7 +255,7 @@ public class QueryShardContext extends QueryRewriteContext { if (fieldMapping != null || allowUnmappedFields) { return fieldMapping; } else if (mapUnmappedFieldAsString) { - StringFieldMapper.Builder builder = new StringFieldMapper.Builder(name); + TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); return builder.build(new Mapper.BuilderContext(indexSettings.getSettings(), new ContentPath(1))).fieldType(); } else { throw new QueryShardException(this, "No field mapping can be found for the field with name [{}]", name); diff --git a/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java b/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java index e3885816cd2..be48a2f0c31 100644 --- a/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java +++ b/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java @@ -46,6 +46,7 @@ import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.mapper.core.KeywordFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.search.dfs.AggregatedDfs; @@ -160,7 +161,8 @@ public class TermVectorsService { private static boolean isValidField(MappedFieldType fieldType) { // must be a string if (fieldType instanceof StringFieldMapper.StringFieldType == false - && fieldType instanceof KeywordFieldMapper.KeywordFieldType == false) { + && fieldType instanceof KeywordFieldMapper.KeywordFieldType == false + && fieldType instanceof TextFieldMapper.TextFieldType == false) { return false; } // and must be indexed diff --git a/core/src/main/java/org/elasticsearch/indices/IndicesModule.java b/core/src/main/java/org/elasticsearch/indices/IndicesModule.java index 955a95676bd..e1330f02544 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndicesModule.java +++ b/core/src/main/java/org/elasticsearch/indices/IndicesModule.java @@ -38,6 +38,7 @@ import org.elasticsearch.index.mapper.core.KeywordFieldMapper; import org.elasticsearch.index.mapper.core.LongFieldMapper; import org.elasticsearch.index.mapper.core.ShortFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.mapper.core.TokenCountFieldMapper; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper; @@ -97,6 +98,7 @@ public class IndicesModule extends AbstractModule { registerMapper(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser()); registerMapper(IpFieldMapper.CONTENT_TYPE, new IpFieldMapper.TypeParser()); registerMapper(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser()); + registerMapper(TextFieldMapper.CONTENT_TYPE, new TextFieldMapper.TypeParser()); registerMapper(KeywordFieldMapper.CONTENT_TYPE, new KeywordFieldMapper.TypeParser()); registerMapper(TokenCountFieldMapper.CONTENT_TYPE, new TokenCountFieldMapper.TypeParser()); registerMapper(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser()); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java index 5cf9d858016..1eeba76dbca 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java @@ -247,13 +247,13 @@ public class CreateIndexIT extends ESIntegTestCase { CreateIndexRequestBuilder b = prepareCreate("test"); b.addMapping("type1", jsonBuilder().startObject().startObject("properties") .startObject("text") - .field("type", "string") + .field("type", "text") .field("analyzer", "standard") .field("search_analyzer", "whitespace") .endObject().endObject().endObject()); b.addMapping("type2", jsonBuilder().humanReadable(true).startObject().startObject("properties") .startObject("text") - .field("type", "string") + .field("type", "text") .endObject().endObject().endObject()); try { b.get(); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java index 13e973504a3..13a2bb29981 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java @@ -55,7 +55,7 @@ public class IndicesStatsTests extends ESSingleNodeTestCase { .field("store", true) .endObject() .startObject("bar") - .field("type", "string") + .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java index 4928cc66081..37a1bc92e9c 100644 --- a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java +++ b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java @@ -61,7 +61,7 @@ public class GetTermVectorsCheckDocFreqIT extends ESIntegTestCase { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("field") - .field("type", "string") + .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .field("analyzer", "tv_test") .endObject() diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java index d4f61393010..c637e49bae0 100644 --- a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java +++ b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java @@ -66,7 +66,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { XContentBuilder mapping = jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("field") - .field("type", "string") + .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() @@ -92,7 +92,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { XContentBuilder mapping = jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("existingfield") - .field("type", "string") + .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() @@ -119,7 +119,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { XContentBuilder mapping = jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("existingfield") - .field("type", "string") + .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .endObject() .endObject() @@ -150,11 +150,11 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { .addAlias(new Alias("alias")) .addMapping("type1", "field0", "type=integer,", // no tvs - "field1", "type=string,index=no", // no tvs - "field2", "type=string,index=no,store=true", // no tvs - "field3", "type=string,index=no,term_vector=yes", // no tvs + "field1", "type=text,index=false", // no tvs + "field2", "type=text,index=false,store=true", // no tvs + "field3", "type=text,index=false,term_vector=yes", // no tvs "field4", "type=keyword", // yes tvs - "field5", "type=string,index=analyzed")); // yes tvs + "field5", "type=text,index=true")); // yes tvs ensureYellow(); @@ -190,7 +190,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { XContentBuilder mapping = jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("field") - .field("type", "string") + .field("type", "text") .field("term_vector", "with_positions_offsets_payloads") .field("analyzer", "tv_test") .endObject() @@ -278,7 +278,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { XContentBuilder mapping = jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("field") - .field("type", "string") + .field("type", "text") .field("term_vector", optionString) .field("analyzer", "tv_test") .endObject() @@ -428,7 +428,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { String queryString = createString(tokens, payloads, encoding, delimiter.charAt(0)); //create the mapping XContentBuilder mapping = jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field").field("type", "string").field("term_vector", "with_positions_offsets_payloads") + .startObject("field").field("type", "text").field("term_vector", "with_positions_offsets_payloads") .field("analyzer", "payload_test").endObject().endObject().endObject().endObject(); assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings( settingsBuilder() @@ -586,7 +586,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { XContentBuilder source = jsonBuilder().startObject(); for (String field : fieldNames) { mapping.startObject(field) - .field("type", "string") + .field("type", "text") .field("term_vector", randomBoolean() ? "with_positions_offsets_payloads" : "no") .field("analyzer", "tv_test") .endObject(); @@ -672,9 +672,9 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { // setup indices String[] indexNames = new String[] {"with_tv", "without_tv"}; assertAcked(prepareCreate(indexNames[0]) - .addMapping("type1", "field1", "type=string,term_vector=with_positions_offsets,analyzer=keyword")); + .addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets,analyzer=keyword")); assertAcked(prepareCreate(indexNames[1]) - .addMapping("type1", "field1", "type=string,term_vector=no,analyzer=keyword")); + .addMapping("type1", "field1", "type=text,term_vector=no,analyzer=keyword")); ensureGreen(); // index documents with and without term vectors @@ -763,7 +763,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { XContentBuilder source = jsonBuilder().startObject(); for (int i = 0; i < numFields; i++) { mapping.startObject("field" + i) - .field("type", "string") + .field("type", "text") .field("term_vector", randomBoolean() ? "yes" : "no") .endObject(); source.field("field" + i, "some text here"); @@ -790,7 +790,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { .put("index.analysis.analyzer", "standard"); assertAcked(prepareCreate("test") .setSettings(settings) - .addMapping("type1", "field1", "type=string,term_vector=with_positions_offsets")); + .addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets")); ensureGreen(); // index documents existing document @@ -848,7 +848,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { .put("index.analysis.analyzer", "standard"); assertAcked(prepareCreate("test") .setSettings(settings) - .addMapping("type1", "field1", "type=string")); + .addMapping("type1", "field1", "type=text")); ensureGreen(); // request tvs from artificial document @@ -882,7 +882,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { withTermVectors.add(fieldName); } mapping.startObject(fieldName) - .field("type", "string") + .field("type", "text") .field("term_vector", withTermVectors.contains(fieldName) ? "yes" : "no") .endObject(); source.field(fieldName, "some text here"); @@ -1090,7 +1090,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { .put("index.analysis.analyzer", "keyword"); assertAcked(prepareCreate("test") .setSettings(settings) - .addMapping("type1", "tags", "type=string")); + .addMapping("type1", "tags", "type=text")); ensureYellow(); int numTerms = scaledRandomIntBetween(10, 50); @@ -1128,7 +1128,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { .put("index.analysis.analyzer", "keyword"); assertAcked(prepareCreate("test") .setSettings(settings) - .addMapping("type1", "tags", "type=string")); + .addMapping("type1", "tags", "type=text")); ensureYellow(); logger.info("Indexing one document with tags of increasing frequencies ..."); @@ -1169,7 +1169,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { .put("index.number_of_shards", 1); // no dfs assertAcked(prepareCreate("test") .setSettings(settings) - .addMapping("type1", "tags", "type=string")); + .addMapping("type1", "tags", "type=text")); ensureYellow(); int numDocs = scaledRandomIntBetween(10, 50); // as many terms as there are docs diff --git a/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java b/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java index ef8247018bf..0846e0710a3 100644 --- a/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java +++ b/core/src/test/java/org/elasticsearch/aliases/IndexAliasesIT.java @@ -136,7 +136,7 @@ public class IndexAliasesIT extends ESIntegTestCase { public void testFilteringAliases() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type", "user", "type=string")); + assertAcked(prepareCreate("test").addMapping("type", "user", "type=text")); ensureGreen(); @@ -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=string", "name", "type=string")); + assertAcked(prepareCreate("test").addMapping("type1", "id", "type=text", "name", "type=text")); ensureGreen(); @@ -243,9 +243,9 @@ public class IndexAliasesIT extends ESIntegTestCase { public void testSearchingFilteringAliasesTwoIndices() throws Exception { logger.info("--> creating index [test1]"); - assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=string")); + assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=text")); logger.info("--> creating index [test2]"); - assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=string")); + assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -310,7 +310,7 @@ public class IndexAliasesIT extends ESIntegTestCase { assertAcked(client().admin().indices().preparePutMapping("test1", "test2", "test3") .setType("type1") - .setSource("name", "type=string")); + .setSource("name", "type=text")); ensureGreen(); @@ -370,8 +370,8 @@ public class IndexAliasesIT extends ESIntegTestCase { public void testDeletingByQueryFilteringAliases() throws Exception { logger.info("--> creating index [test1] and [test2"); - assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=string")); - assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=string")); + assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -407,8 +407,8 @@ public class IndexAliasesIT extends ESIntegTestCase { public void testDeleteAliases() throws Exception { logger.info("--> creating index [test1] and [test2]"); - assertAcked(prepareCreate("test1").addMapping("type", "name", "type=string")); - assertAcked(prepareCreate("test2").addMapping("type", "name", "type=string")); + assertAcked(prepareCreate("test1").addMapping("type", "name", "type=text")); + assertAcked(prepareCreate("test2").addMapping("type", "name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -486,7 +486,7 @@ public class IndexAliasesIT extends ESIntegTestCase { public void testSameAlias() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type", "name", "type=string")); + assertAcked(prepareCreate("test").addMapping("type", "name", "type=text")); ensureGreen(); logger.info("--> creating alias1 "); @@ -547,7 +547,7 @@ public class IndexAliasesIT extends ESIntegTestCase { createIndex("bazbar"); assertAcked(client().admin().indices().preparePutMapping("foobar", "test", "test123", "foobarbaz", "bazbar") - .setType("type").setSource("field", "type=string")); + .setType("type").setSource("field", "type=text")); ensureGreen(); logger.info("--> creating aliases [alias1, alias2]"); @@ -956,7 +956,7 @@ public class IndexAliasesIT extends ESIntegTestCase { public void testCreateIndexWithAliases() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type", "field", "type=string") + .addMapping("type", "field", "type=text") .addAlias(new Alias("alias1")) .addAlias(new Alias("alias2").filter(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("field")))) .addAlias(new Alias("alias3").indexRouting("index").searchRouting("search"))); @@ -978,7 +978,7 @@ public class IndexAliasesIT extends ESIntegTestCase { public void testCreateIndexWithAliasesSource() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type", "field", "type=string") + .addMapping("type", "field", "type=text") .setAliases("{\n" + " \"alias1\" : {},\n" + " \"alias2\" : {\"filter\" : {\"term\": {\"field\":\"value\"}}},\n" + diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java index fe025060a9d..9a0316050b1 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityIT.java @@ -54,7 +54,7 @@ public class BasicAnalysisBackwardCompatibilityIT extends ESBackcompatTestCase { for (int i = 0; i < fields.length; i++) { fields[i++] = "field_" + fieldId++; String analyzer = randomAnalyzer(); - fields[i] = "type=string,analyzer=" + analyzer; + fields[i] = "type=text,analyzer=" + analyzer; } assertAcked(prepareCreate("test") .addMapping("type", (Object[])fields) diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java index d5dcd142009..5b7c4fa37ba 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java @@ -561,7 +561,7 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase { public void testAnalyze() { createIndexWithAlias(); - assertAcked(client().admin().indices().preparePutMapping("test").setType("test").setSource("field", "type=string,analyzer=keyword")); + assertAcked(client().admin().indices().preparePutMapping("test").setType("test").setSource("field", "type=text,analyzer=keyword")); ensureYellow("test"); AnalyzeResponse analyzeResponse = client().admin().indices().prepareAnalyze("this is a test").setIndex(indexOrAlias()).setField("field").get(); assertThat(analyzeResponse.getTokens().size(), equalTo(1)); @@ -586,7 +586,7 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase { public void testGetTermVector() throws IOException { createIndexWithAlias(); - assertAcked(client().admin().indices().preparePutMapping("test").setType("type1").setSource("field", "type=string,term_vector=with_positions_offsets_payloads").get()); + assertAcked(client().admin().indices().preparePutMapping("test").setType("type1").setSource("field", "type=text,term_vector=with_positions_offsets_payloads").get()); ensureYellow("test"); client().prepareIndex(indexOrAlias(), "type1", "1") diff --git a/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java b/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java index 550891d4906..6916cfc4e31 100644 --- a/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java @@ -90,7 +90,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .get(); @@ -99,7 +99,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase { .setTemplate("test*") .setOrder(1) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field2").field("type", "string").field("store", "no").endObject() + .startObject("field2").field("type", "text").field("store", "no").endObject() .endObject().endObject().endObject()) .get(); @@ -132,7 +132,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase { int counter = 0; int numberOfFields = 0; while (true) { - mapping.startObject(Strings.randomBase64UUID()).field("type", "string").endObject(); + mapping.startObject(Strings.randomBase64UUID()).field("type", "text").endObject(); counter += 10; // each field is about 10 bytes, assuming compression in place numberOfFields++; if (counter > estimatedBytesSize) { diff --git a/core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java b/core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java index 54480e02b17..efe0b547416 100644 --- a/core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java +++ b/core/src/test/java/org/elasticsearch/explain/ExplainActionIT.java @@ -209,7 +209,7 @@ public class ExplainActionIT extends ESIntegTestCase { public void testExplainWithFilteredAlias() throws Exception { assertAcked(prepareCreate("test") - .addMapping("test", "field2", "type=string") + .addMapping("test", "field2", "type=text") .addAlias(new Alias("alias1").filter(QueryBuilders.termQuery("field2", "value2")))); ensureGreen("test"); @@ -225,7 +225,7 @@ public class ExplainActionIT extends ESIntegTestCase { public void testExplainWithFilteredAliasFetchSource() throws Exception { assertAcked(client().admin().indices().prepareCreate("test") - .addMapping("test", "field2", "type=string") + .addMapping("test", "field2", "type=text") .addAlias(new Alias("alias1").filter(QueryBuilders.termQuery("field2", "value2")))); ensureGreen("test"); diff --git a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsIntegrationIT.java b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsIntegrationIT.java index f5e99ab2561..07eac1d8cea 100644 --- a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsIntegrationIT.java @@ -47,7 +47,7 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { public void testRandom() throws Exception { assertAcked(prepareCreate("test").addMapping( - "test", "string", "type=string", "date", "type=date", "double", "type=double", "double", "type=double", + "test", "string", "type=text", "date", "type=date", "double", "type=double", "double", "type=double", "float", "type=float", "long", "type=long", "integer", "type=integer", "short", "type=short", "byte", "type=byte" )); ensureGreen("test"); @@ -185,7 +185,7 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { "test", "value", "type=long" )); assertAcked(prepareCreate("test2").addMapping( - "test", "value", "type=string" + "test", "value", "type=text" )); ensureGreen("test1", "test2"); diff --git a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java index 63437d4ebe0..4dbb0673b6d 100644 --- a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java +++ b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java @@ -72,7 +72,7 @@ public class FieldStatsTests extends ESSingleNodeTestCase { } public void testString() { - createIndex("test", Settings.EMPTY, "test", "field", "type=string"); + createIndex("test", Settings.EMPTY, "test", "field", "type=text"); for (int value = 0; value <= 10; value++) { client().prepareIndex("test", "test").setSource("field", String.format(Locale.ENGLISH, "%03d", value)).get(); } @@ -185,11 +185,11 @@ public class FieldStatsTests extends ESSingleNodeTestCase { } public void testInvalidField() { - createIndex("test1", Settings.EMPTY, "test", "field1", "type=string"); + createIndex("test1", Settings.EMPTY, "test", "field1", "type=text"); client().prepareIndex("test1", "test").setSource("field1", "a").get(); client().prepareIndex("test1", "test").setSource("field1", "b").get(); - createIndex("test2", Settings.EMPTY, "test", "field2", "type=string"); + createIndex("test2", Settings.EMPTY, "test", "field2", "type=text"); client().prepareIndex("test2", "test").setSource("field2", "a").get(); client().prepareIndex("test2", "test").setSource("field2", "b").get(); client().admin().indices().prepareRefresh().get(); diff --git a/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java b/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java index fc8452ba81d..dfff924f1a5 100644 --- a/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java +++ b/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java @@ -69,7 +69,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase { internalCluster().startNode(); String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1") - .startObject("properties").startObject("appAccountIds").field("type", "string").endObject().endObject() + .startObject("properties").startObject("appAccountIds").field("type", "text").endObject().endObject() .endObject().endObject().string(); assertAcked(prepareCreate("test").addMapping("type1", mapping)); @@ -109,7 +109,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase { internalCluster().startNode(); String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1") - .startObject("properties").startObject("field").field("type", "string").endObject().startObject("num").field("type", "integer").endObject().endObject() + .startObject("properties").startObject("field").field("type", "text").endObject().startObject("num").field("type", "integer").endObject().endObject() .endObject().endObject().string(); // note: default replica settings are tied to #data nodes-1 which is 0 here. We can do with 1 in this test. int numberOfShards = numberOfShards(); @@ -301,7 +301,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/get/GetActionIT.java b/core/src/test/java/org/elasticsearch/get/GetActionIT.java index f0f90311907..6b417ce25be 100644 --- a/core/src/test/java/org/elasticsearch/get/GetActionIT.java +++ b/core/src/test/java/org/elasticsearch/get/GetActionIT.java @@ -253,12 +253,12 @@ public class GetActionIT extends ESIntegTestCase { public void testGetDocWithMultivaluedFields() throws Exception { String mapping1 = XContentFactory.jsonBuilder().startObject().startObject("type1") .startObject("properties") - .startObject("field").field("type", "string").field("store", true).endObject() + .startObject("field").field("type", "text").field("store", true).endObject() .endObject() .endObject().endObject().string(); String mapping2 = XContentFactory.jsonBuilder().startObject().startObject("type2") .startObject("properties") - .startObject("field").field("type", "string").field("store", true).endObject() + .startObject("field").field("type", "text").field("store", true).endObject() .endObject() .endObject().endObject().string(); assertAcked(prepareCreate("test") @@ -718,7 +718,7 @@ public class GetActionIT extends ESIntegTestCase { assertAcked(prepareCreate("test").addAlias(new Alias("alias")) .addMapping("my-type1", jsonBuilder().startObject().startObject("my-type1").startObject("properties") .startObject("field1").startObject("properties") - .startObject("field2").field("type", "string").endObject() + .startObject("field2").field("type", "text").endObject() .endObject().endObject() .endObject().endObject().endObject()) .setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1))); @@ -846,7 +846,7 @@ public class GetActionIT extends ESIntegTestCase { .endObject() .startObject("properties") .startObject("some_field") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java b/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java index a052b1d898c..d4b46016125 100644 --- a/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java +++ b/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java @@ -188,7 +188,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true) .build(); - prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string").get(); + prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=text").get(); ensureGreen(IDX); // So basically, the primary should fail and the replica will need to @@ -265,7 +265,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true) .build(); - prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string").get(); + prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=text").get(); ensureYellow(IDX); client().prepareIndex(IDX, "doc", "1").setSource("foo", "bar").get(); client().prepareIndex(IDX, "doc", "2").setSource("foo", "bar").get(); @@ -323,7 +323,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true) .build(); - prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string").get(); + prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=text").get(); ensureYellow(IDX); client().prepareIndex(IDX, "doc", "1").setSource("foo", "bar").get(); client().prepareIndex(IDX, "doc", "2").setSource("foo", "bar").get(); @@ -383,7 +383,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true) .build(); - prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string").get(); + prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=text").get(); ensureYellow(IDX); // Node1 has the primary, now node2 has the replica String node2 = internalCluster().startNode(nodeSettings); @@ -458,7 +458,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true) .build(); - prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string").get(); + prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=text").get(); ensureYellow(IDX); // Node1 has the primary, now node2 has the replica String node2 = internalCluster().startNode(nodeSettings); @@ -551,7 +551,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true) .build(); - prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string").get(); + prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=text").get(); ensureGreen(IDX); client().prepareIndex(IDX, "doc", "1").setSource("foo", "bar").get(); client().prepareIndex(IDX, "doc", "2").setSource("foo", "bar").get(); @@ -590,7 +590,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true) .build(); - prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string").get(); + prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=text").get(); ensureGreen(IDX); int docCount = randomIntBetween(10, 100); @@ -797,8 +797,8 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase { .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true) .build(); - prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=string").get(); - prepareCreate(IDX2).setSettings(idx2Settings).addMapping("doc", "foo", "type=string").get(); + prepareCreate(IDX).setSettings(idxSettings).addMapping("doc", "foo", "type=text").get(); + prepareCreate(IDX2).setSettings(idx2Settings).addMapping("doc", "foo", "type=text").get(); ensureGreen(IDX, IDX2); int docCount = randomIntBetween(10, 100); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java index f4792f0bc37..fbb69ea1eb0 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java @@ -86,7 +86,7 @@ public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase { NamedAnalyzer namedAnalyzer = new PreBuiltAnalyzerProvider(analyzerName, AnalyzerScope.INDEX, randomPreBuiltAnalyzer.getAnalyzer(randomVersion)).get(); String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("field").field("type", "string").field("analyzer", analyzerName).endObject().endObject() + .startObject("properties").startObject("field").field("type", "text").field("analyzer", analyzerName).endObject().endObject() .endObject().endObject().string(); DocumentMapper docMapper = createIndex("test", indexSettings).mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping)); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java index adb511f1c89..82b6c995576 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataFilterIntegrationIT.java @@ -46,7 +46,7 @@ public class FieldDataFilterIntegrationIT extends ESIntegTestCase { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties") .startObject("name") - .field("type", "string") + .field("type", "text") .startObject("fielddata") .startObject("filter") .startObject("regex") @@ -56,7 +56,7 @@ public class FieldDataFilterIntegrationIT extends ESIntegTestCase { .endObject() .endObject() .startObject("not_filtered") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject().endObject(); 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 d88ef884eb9..8dc46df3405 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java @@ -33,7 +33,7 @@ public class FieldDataLoadingIT extends ESIntegTestCase { assertAcked(prepareCreate("test") .addMapping("type", jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("name") - .field("type", "string") + .field("type", "text") .startObject("fielddata").field("loading", "eager").endObject() .endObject() .endObject().endObject().endObject())); @@ -50,7 +50,7 @@ public class FieldDataLoadingIT extends ESIntegTestCase { assertAcked(prepareCreate("test") .addMapping("type", jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("name") - .field("type", "string") + .field("type", "text") .startObject("fielddata").field("loading", "eager_global_ordinals").endObject() .endObject() .endObject().endObject().endObject())); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java index 1a8ffd9e6f4..0931120c177 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java @@ -38,7 +38,7 @@ import org.elasticsearch.index.mapper.core.FloatFieldMapper; import org.elasticsearch.index.mapper.core.IntegerFieldMapper; import org.elasticsearch.index.mapper.core.LongFieldMapper; import org.elasticsearch.index.mapper.core.LongFieldMapper.LongFieldType; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.test.ESSingleNodeTestCase; import java.io.IOException; @@ -55,7 +55,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { String mapping = jsonBuilder().startObject().startObject("type") .field("dynamic", "true") .startObject("properties") - .startObject("field1").field("type", "string").endObject() + .startObject("field1").field("type", "text").endObject() .endObject() .endObject().endObject().string(); @@ -75,7 +75,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { String mapping = jsonBuilder().startObject().startObject("type") .field("dynamic", "false") .startObject("properties") - .startObject("field1").field("type", "string").endObject() + .startObject("field1").field("type", "text").endObject() .endObject() .endObject().endObject().string(); @@ -96,7 +96,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { String mapping = jsonBuilder().startObject().startObject("type") .field("dynamic", "strict") .startObject("properties") - .startObject("field1").field("type", "string").endObject() + .startObject("field1").field("type", "text").endObject() .endObject() .endObject().endObject().string(); @@ -130,7 +130,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { .field("dynamic", "false") .startObject("properties") .startObject("obj1").startObject("properties") - .startObject("field1").field("type", "string").endObject() + .startObject("field1").field("type", "text").endObject() .endObject().endObject() .endObject() .endObject().endObject().string(); @@ -153,7 +153,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { .field("dynamic", "strict") .startObject("properties") .startObject("obj1").startObject("properties") - .startObject("field1").field("type", "string").endObject() + .startObject("field1").field("type", "text").endObject() .endObject().endObject() .endObject() .endObject().endObject().string(); @@ -218,7 +218,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { IndexService indexService = createIndex("test"); DocumentMapperParser parser = indexService.mapperService().documentMapperParser(); String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("foo").field("type", "string").endObject().endObject() + .startObject("properties").startObject("foo").field("type", "text").endObject().endObject() .endObject().string(); DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); @@ -251,7 +251,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { // Make sure that mapping updates are incremental, this is important for performance otherwise // every new field introduction runs in linear time with the total number of fields String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("foo").field("type", "string").endObject().endObject() + .startObject("properties").startObject("foo").field("type", "text").endObject().endObject() .endObject().string(); DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); @@ -374,7 +374,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { public void testReuseExistingMappings() throws IOException, Exception { IndexService indexService = createIndex("test", Settings.EMPTY, "type", - "my_field1", "type=string,store=true", + "my_field1", "type=text,store=true", "my_field2", "type=integer,precision_step=10", "my_field3", "type=long,doc_values=false", "my_field4", "type=float,index_options=freqs", @@ -423,9 +423,9 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { } assertNotNull(myField1Mapper); // same type - assertTrue(myField1Mapper instanceof StringFieldMapper); + assertTrue(myField1Mapper instanceof TextFieldMapper); // and same option - assertTrue(((StringFieldMapper) myField1Mapper).fieldType().stored()); + assertTrue(((TextFieldMapper) myField1Mapper).fieldType().stored()); // Even if dynamic mappings would map a numeric field as a long, here it should map it as a integer // since we already have a mapping of type integer @@ -470,7 +470,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { .startObject("template1") .field("match_mapping_type", "string") .startObject("mapping") - .field("type", "string") + .field("type", "text") .startObject("fields") .startObject("raw") .field("type", "keyword") @@ -486,7 +486,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase { .startObject("type2") .startObject("properties") .startObject("field") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject().endObject(); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java b/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java index 7cc8e10bef7..58244ce7ad0 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java @@ -60,7 +60,7 @@ public class MapperServiceTests extends ESSingleNodeTestCase { .admin() .indices() .prepareCreate(index) - .addMapping(type, field, "type=string") + .addMapping(type, field, "type=text") .execute() .actionGet(); } @@ -76,7 +76,7 @@ public class MapperServiceTests extends ESSingleNodeTestCase { .admin() .indices() .prepareCreate(index) - .addMapping(type, field, "type=string") + .addMapping(type, field, "type=text") .execute() .actionGet(); } diff --git a/core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java index 642e35eef88..0ec3d7d7a58 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/all/SimpleAllMapperTests.java @@ -362,7 +362,7 @@ public class SimpleAllMapperTests extends ESSingleNodeTestCase { fail("Expected MapperParsingException"); } catch (MapperParsingException e) { assertThat(e.getMessage(), containsString("Root mapping definition has unsupported parameters")); - assertThat(e.getMessage(), containsString("[type : string]")); + assertThat(e.getMessage(), containsString("[type : text]")); } } @@ -374,7 +374,7 @@ public class SimpleAllMapperTests extends ESSingleNodeTestCase { fail("Expected MapperParsingException"); } catch (MapperParsingException e) { assertThat(e.getMessage(), containsString("Root mapping definition has unsupported parameters")); - assertThat(e.getMessage(), containsString("type=string")); + assertThat(e.getMessage(), containsString("type=text")); } } @@ -386,7 +386,7 @@ public class SimpleAllMapperTests extends ESSingleNodeTestCase { fail("Expected MapperParsingException"); } catch (MapperParsingException e) { assertThat(e.getMessage(), containsString("Root mapping definition has unsupported parameters")); - assertThat(e.getMessage(), containsString("type=string")); + assertThat(e.getMessage(), containsString("type=text")); } } @@ -451,7 +451,7 @@ public class SimpleAllMapperTests extends ESSingleNodeTestCase { public void testAutoBoost() throws Exception { for (boolean boost : new boolean[] {false, true}) { String index = "test_" + boost; - IndexService indexService = createIndex(index, client().admin().indices().prepareCreate(index).addMapping("type", "foo", "type=string" + (boost ? ",boost=2" : ""))); + IndexService indexService = createIndex(index, client().admin().indices().prepareCreate(index).addMapping("type", "foo", "type=text" + (boost ? ",boost=2" : ""))); client().prepareIndex(index, "type").setSource("foo", "bar").get(); client().admin().indices().prepareRefresh(index).get(); Query query = indexService.mapperService().documentMapper("type").allFieldMapper().fieldType().termQuery("bar", null); 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 8f1e61d8d5b..75807ae9c2e 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 @@ -72,7 +72,7 @@ public class CopyToMapperIntegrationIT extends ESIntegTestCase { public void testDynamicObjectCopyTo() throws Exception { String mapping = jsonBuilder().startObject().startObject("doc").startObject("properties") .startObject("foo") - .field("type", "string") + .field("type", "text") .field("copy_to", "root.top.child") .endObject() .endObject().endObject().endObject().string(); @@ -102,7 +102,7 @@ public class CopyToMapperIntegrationIT extends ESIntegTestCase { .startObject().startObject("template_all") .field("match", "*") .field("match_mapping_type", "string") - .startObject("mapping").field("type", "string").field("copy_to", "{name}_raw").endObject() + .startObject("mapping").field("type", "text").field("copy_to", "{name}_raw").endObject() .endObject().endObject() .endArray(); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java index d1de843e38f..0e4f0a34af6 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java @@ -37,7 +37,7 @@ import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.core.LongFieldMapper; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.test.ESSingleNodeTestCase; import java.util.Arrays; @@ -58,16 +58,16 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { public void testCopyToFieldsParsing() throws Exception { String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .array("copy_to", "another_field", "cyclic_test") .endObject() .startObject("another_field") - .field("type", "string") + .field("type", "text") .endObject() .startObject("cyclic_test") - .field("type", "string") + .field("type", "text") .array("copy_to", "copy_test") .endObject() @@ -84,7 +84,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { FieldMapper fieldMapper = docMapper.mappers().getMapper("copy_test"); // Check json serialization - StringFieldMapper stringFieldMapper = (StringFieldMapper) fieldMapper; + TextFieldMapper stringFieldMapper = (TextFieldMapper) fieldMapper; XContentBuilder builder = jsonBuilder().startObject(); stringFieldMapper.toXContent(builder, ToXContent.EMPTY_PARAMS).endObject(); builder.close(); @@ -93,7 +93,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { serializedMap = parser.map(); } Map copyTestMap = (Map) serializedMap.get("copy_test"); - assertThat(copyTestMap.get("type").toString(), is("string")); + assertThat(copyTestMap.get("type").toString(), is("text")); List copyToList = (List) copyTestMap.get("copy_to"); assertThat(copyToList.size(), equalTo(2)); assertThat(copyToList.get(0).toString(), equalTo("another_field")); @@ -138,7 +138,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .field("copy_to", "very.inner.field") .endObject() @@ -173,7 +173,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { String mapping = jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .field("copy_to", "very.inner.field") .endObject() .endObject() @@ -201,7 +201,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { String mapping = jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .field("copy_to", "very.far.inner.field") .endObject() .startObject("very") @@ -238,7 +238,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { .field("dynamic", "strict") .startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .field("copy_to", "very.inner.field") .endObject() .endObject() @@ -262,7 +262,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { String mapping = jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .field("copy_to", "very.far.field") .endObject() .startObject("very") @@ -296,7 +296,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { String mappingBefore = jsonBuilder().startObject().startObject("type1").startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .array("copy_to", "foo", "bar") .endObject() @@ -305,7 +305,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { String mappingAfter = jsonBuilder().startObject().startObject("type1").startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .array("copy_to", "baz", "bar") .endObject() @@ -438,7 +438,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase { .endArray() .startObject("properties") .startObject("copy_test") - .field("type", "string") + .field("type", "text") .field("copy_to", "very.inner.field") .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/index/mapper/core/BooleanFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/core/BooleanFieldMapperTests.java index d66b1508dc3..7bed3ce091f 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/core/BooleanFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/core/BooleanFieldMapperTests.java @@ -134,8 +134,7 @@ public class BooleanFieldMapperTests extends ESSingleNodeTestCase { .field("type", "boolean") .startObject("fields") .startObject("as_string") - .field("type", "string") - .field("index", "not_analyzed") + .field("type", "keyword") .endObject() .endObject() .endObject().endObject() diff --git a/core/src/test/java/org/elasticsearch/index/mapper/core/MultiFieldCopyToMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/core/MultiFieldCopyToMapperTests.java index b9bcaf2f1c5..0ac7945e327 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/core/MultiFieldCopyToMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/core/MultiFieldCopyToMapperTests.java @@ -69,13 +69,13 @@ public class MultiFieldCopyToMapperTests extends ESTestCase { .startObject("type") .startObject("properties") .startObject("a") - .field("type", "string") + .field("type", "text") .endObject() .startObject("b") - .field("type", "string") + .field("type", "text") .startObject("fields") .startObject("c") - .field("type", "string") + .field("type", "text") .field("copy_to", "a") .endObject() .endObject() 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 new file mode 100644 index 00000000000..3a9d5b46ab9 --- /dev/null +++ b/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldMapperTests.java @@ -0,0 +1,389 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.index.mapper.core; + +import org.apache.lucene.index.DocValuesType; +import org.apache.lucene.index.IndexOptions; +import org.apache.lucene.index.IndexableField; +import org.apache.lucene.index.IndexableFieldType; +import org.apache.lucene.index.LeafReader; +import org.apache.lucene.index.PostingsEnum; +import org.apache.lucene.index.Term; +import org.apache.lucene.index.TermsEnum; +import org.apache.lucene.util.BytesRef; +import org.elasticsearch.common.compress.CompressedXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.engine.Engine; +import org.elasticsearch.index.mapper.DocumentMapper; +import org.elasticsearch.index.mapper.DocumentMapperParser; +import org.elasticsearch.index.mapper.MapperService.MergeReason; +import org.elasticsearch.index.mapper.ParsedDocument; +import org.elasticsearch.index.shard.IndexShard; +import org.elasticsearch.test.ESSingleNodeTestCase; +import org.junit.Before; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import static org.hamcrest.Matchers.equalTo; + +public class TextFieldMapperTests extends ESSingleNodeTestCase { + + IndexService indexService; + DocumentMapperParser parser; + + @Before + public void before() { + indexService = createIndex("test"); + parser = indexService.mapperService().documentMapperParser(); + } + + public void testDefaults() throws Exception { + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties").startObject("field").field("type", "text").endObject().endObject() + .endObject().endObject().string(); + + DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); + + assertEquals(mapping, mapper.mappingSource().toString()); + + ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder() + .startObject() + .field("field", "1234") + .endObject() + .bytes()); + + IndexableField[] fields = doc.rootDoc().getFields("field"); + assertEquals(1, fields.length); + + assertEquals("1234", fields[0].stringValue()); + IndexableFieldType fieldType = fields[0].fieldType(); + assertThat(fieldType.omitNorms(), equalTo(false)); + assertTrue(fieldType.tokenized()); + assertFalse(fieldType.stored()); + assertThat(fieldType.indexOptions(), equalTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)); + assertThat(fieldType.storeTermVectors(), equalTo(false)); + assertThat(fieldType.storeTermVectorOffsets(), equalTo(false)); + assertThat(fieldType.storeTermVectorPositions(), equalTo(false)); + assertThat(fieldType.storeTermVectorPayloads(), equalTo(false)); + assertEquals(DocValuesType.NONE, fieldType.docValuesType()); + } + + public void testEnableStore() throws IOException { + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties").startObject("field").field("type", "text").field("store", true).endObject().endObject() + .endObject().endObject().string(); + + DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); + + assertEquals(mapping, mapper.mappingSource().toString()); + + ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder() + .startObject() + .field("field", "1234") + .endObject() + .bytes()); + + IndexableField[] fields = doc.rootDoc().getFields("field"); + assertEquals(1, fields.length); + assertTrue(fields[0].fieldType().stored()); + } + + public void testDisableIndex() throws IOException { + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties").startObject("field").field("type", "text").field("index", false).endObject().endObject() + .endObject().endObject().string(); + + DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); + + assertEquals(mapping, mapper.mappingSource().toString()); + + ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder() + .startObject() + .field("field", "1234") + .endObject() + .bytes()); + + IndexableField[] fields = doc.rootDoc().getFields("field"); + assertEquals(0, fields.length); + } + + public void testDisableNorms() throws IOException { + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties").startObject("field") + .field("type", "text") + .startObject("norms") + .field("enabled", false) + .endObject() + .endObject().endObject() + .endObject().endObject().string(); + + DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); + + assertEquals(mapping, mapper.mappingSource().toString()); + + ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder() + .startObject() + .field("field", "1234") + .endObject() + .bytes()); + + IndexableField[] fields = doc.rootDoc().getFields("field"); + assertEquals(1, fields.length); + assertTrue(fields[0].fieldType().omitNorms()); + } + + public void testIndexOptions() throws IOException { + Map supportedOptions = new HashMap<>(); + supportedOptions.put("docs", IndexOptions.DOCS); + supportedOptions.put("freqs", IndexOptions.DOCS_AND_FREQS); + supportedOptions.put("positions", IndexOptions.DOCS_AND_FREQS_AND_POSITIONS); + supportedOptions.put("offsets", IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS); + + XContentBuilder mappingBuilder = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties"); + for (String option : supportedOptions.keySet()) { + mappingBuilder.startObject(option).field("type", "text").field("index_options", option).endObject(); + } + String mapping = mappingBuilder.endObject().endObject().endObject().string(); + + DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); + + XContentBuilder jsonDoc = XContentFactory.jsonBuilder().startObject(); + for (String option : supportedOptions.keySet()) { + jsonDoc.field(option, "1234"); + } + ParsedDocument doc = mapper.parse("test", "type", "1", jsonDoc.endObject().bytes()); + + for (Map.Entry entry : supportedOptions.entrySet()) { + String field = entry.getKey(); + IndexOptions options = entry.getValue(); + IndexableField[] fields = doc.rootDoc().getFields(field); + assertEquals(1, fields.length); + assertEquals(options, fields[0].fieldType().indexOptions()); + } + } + + public void testDefaultPositionIncrementGap() throws IOException { + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties").startObject("field").field("type", "text").endObject().endObject() + .endObject().endObject().string(); + + DocumentMapper mapper = indexService.mapperService().merge("type", + new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE, false); + + assertEquals(mapping, mapper.mappingSource().toString()); + + ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder() + .startObject() + .field("field", new String[] {"a", "b"}) + .endObject() + .bytes()); + + IndexableField[] fields = doc.rootDoc().getFields("field"); + assertEquals(2, fields.length); + + assertEquals("a", fields[0].stringValue()); + assertEquals("b", fields[1].stringValue()); + + IndexShard shard = indexService.getShard(0); + shard.index(new Engine.Index(new Term("_uid", "1"), doc)); + shard.refresh("test"); + try (Engine.Searcher searcher = shard.acquireSearcher("test")) { + LeafReader leaf = searcher.getDirectoryReader().leaves().get(0).reader(); + TermsEnum terms = leaf.terms("field").iterator(); + assertTrue(terms.seekExact(new BytesRef("b"))); + PostingsEnum postings = terms.postings(null, PostingsEnum.POSITIONS); + assertEquals(0, postings.nextDoc()); + assertEquals(TextFieldMapper.Defaults.POSITION_INCREMENT_GAP + 1, postings.nextPosition()); + } + } + + public void testPositionIncrementGap() throws IOException { + final int positionIncrementGap = randomIntBetween(1, 1000); + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties").startObject("field") + .field("type", "text") + .field("position_increment_gap", positionIncrementGap) + .endObject().endObject() + .endObject().endObject().string(); + + DocumentMapper mapper = indexService.mapperService().merge("type", + new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE, false); + + assertEquals(mapping, mapper.mappingSource().toString()); + + ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder() + .startObject() + .field("field", new String[] {"a", "b"}) + .endObject() + .bytes()); + + IndexableField[] fields = doc.rootDoc().getFields("field"); + assertEquals(2, fields.length); + + assertEquals("a", fields[0].stringValue()); + assertEquals("b", fields[1].stringValue()); + + IndexShard shard = indexService.getShard(0); + shard.index(new Engine.Index(new Term("_uid", "1"), doc)); + shard.refresh("test"); + try (Engine.Searcher searcher = shard.acquireSearcher("test")) { + LeafReader leaf = searcher.getDirectoryReader().leaves().get(0).reader(); + TermsEnum terms = leaf.terms("field").iterator(); + assertTrue(terms.seekExact(new BytesRef("b"))); + PostingsEnum postings = terms.postings(null, PostingsEnum.POSITIONS); + assertEquals(0, postings.nextDoc()); + assertEquals(positionIncrementGap + 1, postings.nextPosition()); + } + } + + public void testSearchAnalyzerSerialization() throws IOException { + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties") + .startObject("field") + .field("type", "text") + .field("analyzer", "standard") + .field("search_analyzer", "keyword") + .endObject() + .endObject().endObject().endObject().string(); + + DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); + assertEquals(mapping, mapper.mappingSource().toString()); + + // special case: default index analyzer + mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties") + .startObject("field") + .field("type", "text") + .field("analyzer", "default") + .field("search_analyzer", "keyword") + .endObject() + .endObject().endObject().endObject().string(); + + mapper = parser.parse("type", new CompressedXContent(mapping)); + assertEquals(mapping, mapper.mappingSource().toString()); + } + + public void testSearchQuoteAnalyzerSerialization() throws IOException { + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties") + .startObject("field") + .field("type", "text") + .field("analyzer", "standard") + .field("search_analyzer", "standard") + .field("search_quote_analyzer", "keyword") + .endObject() + .endObject().endObject().endObject().string(); + + DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); + assertEquals(mapping, mapper.mappingSource().toString()); + + // special case: default index/search analyzer + mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties") + .startObject("field") + .field("type", "text") + .field("analyzer", "default") + .field("search_analyzer", "default") + .field("search_quote_analyzer", "keyword") + .endObject() + .endObject().endObject().endObject().string(); + + mapper = parser.parse("type", new CompressedXContent(mapping)); + assertEquals(mapping, mapper.mappingSource().toString()); + } + + public void testTermVectors() throws Exception { + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") + .startObject("properties") + .startObject("field1") + .field("type", "text") + .field("term_vector", "no") + .endObject() + .startObject("field2") + .field("type", "text") + .field("term_vector", "yes") + .endObject() + .startObject("field3") + .field("type", "text") + .field("term_vector", "with_offsets") + .endObject() + .startObject("field4") + .field("type", "text") + .field("term_vector", "with_positions") + .endObject() + .startObject("field5") + .field("type", "text") + .field("term_vector", "with_positions_offsets") + .endObject() + .startObject("field6") + .field("type", "text") + .field("term_vector", "with_positions_offsets_payloads") + .endObject() + .endObject() + .endObject().endObject().string(); + + DocumentMapper defaultMapper = parser.parse("type", new CompressedXContent(mapping)); + + ParsedDocument doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder() + .startObject() + .field("field1", "1234") + .field("field2", "1234") + .field("field3", "1234") + .field("field4", "1234") + .field("field5", "1234") + .field("field6", "1234") + .endObject() + .bytes()); + + assertThat(doc.rootDoc().getField("field1").fieldType().storeTermVectors(), equalTo(false)); + assertThat(doc.rootDoc().getField("field1").fieldType().storeTermVectorOffsets(), equalTo(false)); + assertThat(doc.rootDoc().getField("field1").fieldType().storeTermVectorPositions(), equalTo(false)); + assertThat(doc.rootDoc().getField("field1").fieldType().storeTermVectorPayloads(), equalTo(false)); + + assertThat(doc.rootDoc().getField("field2").fieldType().storeTermVectors(), equalTo(true)); + assertThat(doc.rootDoc().getField("field2").fieldType().storeTermVectorOffsets(), equalTo(false)); + assertThat(doc.rootDoc().getField("field2").fieldType().storeTermVectorPositions(), equalTo(false)); + assertThat(doc.rootDoc().getField("field2").fieldType().storeTermVectorPayloads(), equalTo(false)); + + assertThat(doc.rootDoc().getField("field3").fieldType().storeTermVectors(), equalTo(true)); + assertThat(doc.rootDoc().getField("field3").fieldType().storeTermVectorOffsets(), equalTo(true)); + assertThat(doc.rootDoc().getField("field3").fieldType().storeTermVectorPositions(), equalTo(false)); + assertThat(doc.rootDoc().getField("field3").fieldType().storeTermVectorPayloads(), equalTo(false)); + + assertThat(doc.rootDoc().getField("field4").fieldType().storeTermVectors(), equalTo(true)); + assertThat(doc.rootDoc().getField("field4").fieldType().storeTermVectorOffsets(), equalTo(false)); + assertThat(doc.rootDoc().getField("field4").fieldType().storeTermVectorPositions(), equalTo(true)); + assertThat(doc.rootDoc().getField("field4").fieldType().storeTermVectorPayloads(), equalTo(false)); + + assertThat(doc.rootDoc().getField("field5").fieldType().storeTermVectors(), equalTo(true)); + assertThat(doc.rootDoc().getField("field5").fieldType().storeTermVectorOffsets(), equalTo(true)); + assertThat(doc.rootDoc().getField("field5").fieldType().storeTermVectorPositions(), equalTo(true)); + assertThat(doc.rootDoc().getField("field5").fieldType().storeTermVectorPayloads(), equalTo(false)); + + assertThat(doc.rootDoc().getField("field6").fieldType().storeTermVectors(), equalTo(true)); + assertThat(doc.rootDoc().getField("field6").fieldType().storeTermVectorOffsets(), equalTo(true)); + assertThat(doc.rootDoc().getField("field6").fieldType().storeTermVectorPositions(), equalTo(true)); + assertThat(doc.rootDoc().getField("field6").fieldType().storeTermVectorPayloads(), equalTo(true)); + } +} diff --git a/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldTypeTests.java b/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldTypeTests.java new file mode 100644 index 00000000000..a6c453c4a3c --- /dev/null +++ b/core/src/test/java/org/elasticsearch/index/mapper/core/TextFieldTypeTests.java @@ -0,0 +1,29 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.index.mapper.core; + +import org.elasticsearch.index.mapper.FieldTypeTestCase; +import org.elasticsearch.index.mapper.MappedFieldType; + +public class TextFieldTypeTests extends FieldTypeTestCase { + @Override + protected MappedFieldType createDefaultFieldType() { + return new TextFieldMapper.TextFieldType(); + } +} diff --git a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java index 356a2c815fc..03c14ee1a45 100755 --- a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java @@ -36,6 +36,7 @@ import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.core.BinaryFieldMapper; import org.elasticsearch.index.mapper.core.BooleanFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.mapper.geo.BaseGeoPointFieldMapper; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapperLegacy; @@ -81,7 +82,7 @@ public class ExternalMapper extends FieldMapper { public Builder(String name, String generatedValue, String mapperName) { super(name, new ExternalFieldType(), new ExternalFieldType()); this.builder = this; - this.stringBuilder = new StringFieldMapper.Builder(name).store(false); + this.stringBuilder = new TextFieldMapper.Builder(name).store(false); this.generatedValue = generatedValue; this.mapperName = mapperName; } @@ -224,7 +225,7 @@ public class ExternalMapper extends FieldMapper { BooleanFieldMapper boolMapperUpdate = (BooleanFieldMapper) boolMapper.updateFieldType(fullNameToFieldType); GeoPointFieldMapper pointMapperUpdate = (GeoPointFieldMapper) pointMapper.updateFieldType(fullNameToFieldType); GeoShapeFieldMapper shapeMapperUpdate = (GeoShapeFieldMapper) shapeMapper.updateFieldType(fullNameToFieldType); - StringFieldMapper stringMapperUpdate = (StringFieldMapper) stringMapper.updateFieldType(fullNameToFieldType); + TextFieldMapper stringMapperUpdate = (TextFieldMapper) stringMapper.updateFieldType(fullNameToFieldType); if (update == this && multiFieldsUpdate == multiFields && binMapperUpdate == binMapper diff --git a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java index d90c39381f9..171245841a0 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalValuesMapperIntegrationIT.java @@ -88,7 +88,7 @@ public class ExternalValuesMapperIntegrationIT extends ESIntegTestCase { .field("type", ExternalMapperPlugin.EXTERNAL_UPPER) .startObject("fields") .startObject("g") - .field("type", "string") + .field("type", "text") .field("store", true) .startObject("fields") .startObject("raw") diff --git a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java index 11688152f94..558e3bc83fb 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/SimpleExternalMappingTests.java @@ -31,7 +31,7 @@ import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.core.KeywordFieldMapper; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.indices.mapper.MapperRegistry; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; @@ -106,7 +106,7 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase { IndexService indexService = createIndex("test", settings); Map mapperParsers = new HashMap<>(); mapperParsers.put(ExternalMapperPlugin.EXTERNAL, new ExternalMapper.TypeParser(ExternalMapperPlugin.EXTERNAL, "foo")); - mapperParsers.put(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser()); + mapperParsers.put(TextFieldMapper.CONTENT_TYPE, new TextFieldMapper.TypeParser()); mapperParsers.put(KeywordFieldMapper.CONTENT_TYPE, new KeywordFieldMapper.TypeParser()); MapperRegistry mapperRegistry = new MapperRegistry(mapperParsers, Collections.emptyMap()); @@ -119,7 +119,7 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase { .field("type", ExternalMapperPlugin.EXTERNAL) .startObject("fields") .startObject("field") - .field("type", "string") + .field("type", "text") .field("store", true) .startObject("fields") .startObject("raw") @@ -165,7 +165,7 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase { Map mapperParsers = new HashMap<>(); mapperParsers.put(ExternalMapperPlugin.EXTERNAL, new ExternalMapper.TypeParser(ExternalMapperPlugin.EXTERNAL, "foo")); mapperParsers.put(ExternalMapperPlugin.EXTERNAL_BIS, new ExternalMapper.TypeParser(ExternalMapperPlugin.EXTERNAL, "bar")); - mapperParsers.put(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser()); + mapperParsers.put(TextFieldMapper.CONTENT_TYPE, new TextFieldMapper.TypeParser()); MapperRegistry mapperRegistry = new MapperRegistry(mapperParsers, Collections.emptyMap()); DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(), @@ -177,18 +177,18 @@ public class SimpleExternalMappingTests extends ESSingleNodeTestCase { .field("type", ExternalMapperPlugin.EXTERNAL) .startObject("fields") .startObject("field") - .field("type", "string") + .field("type", "text") .startObject("fields") .startObject("generated") .field("type", ExternalMapperPlugin.EXTERNAL_BIS) .endObject() .startObject("raw") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() .startObject("raw") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java index 4614909568c..627f268545a 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java @@ -30,7 +30,6 @@ import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.Mapping; import org.elasticsearch.index.mapper.ParsedDocument; -import org.elasticsearch.index.mapper.core.StringFieldMapper; import org.elasticsearch.index.mapper.object.ObjectMapper; import org.elasticsearch.test.ESSingleNodeTestCase; @@ -49,12 +48,12 @@ public class TestMergeMapperTests extends ESSingleNodeTestCase { public void test1Merge() throws Exception { String stage1Mapping = XContentFactory.jsonBuilder().startObject().startObject("person").startObject("properties") - .startObject("name").field("type", "string").endObject() + .startObject("name").field("type", "text").endObject() .endObject().endObject().endObject().string(); DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser(); DocumentMapper stage1 = parser.parse("person", new CompressedXContent(stage1Mapping)); String stage2Mapping = XContentFactory.jsonBuilder().startObject().startObject("person").startObject("properties") - .startObject("name").field("type", "string").endObject() + .startObject("name").field("type", "text").endObject() .startObject("age").field("type", "integer").endObject() .startObject("obj1").startObject("properties").startObject("prop1").field("type", "integer").endObject().endObject().endObject() .endObject().endObject().endObject().string(); @@ -112,10 +111,10 @@ public class TestMergeMapperTests extends ESSingleNodeTestCase { public void testMergeSearchAnalyzer() throws Exception { DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser(); String mapping1 = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("field").field("type", "string").field("analyzer", "standard").field("search_analyzer", "whitespace").endObject().endObject() + .startObject("properties").startObject("field").field("type", "text").field("analyzer", "standard").field("search_analyzer", "whitespace").endObject().endObject() .endObject().endObject().string(); String mapping2 = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("field").field("type", "string").field("analyzer", "standard").field("search_analyzer", "keyword").endObject().endObject() + .startObject("properties").startObject("field").field("type", "text").field("analyzer", "standard").field("search_analyzer", "keyword").endObject().endObject() .endObject().endObject().string(); DocumentMapper existing = parser.parse("type", new CompressedXContent(mapping1)); @@ -130,10 +129,10 @@ public class TestMergeMapperTests extends ESSingleNodeTestCase { public void testChangeSearchAnalyzerToDefault() throws Exception { MapperService mapperService = createIndex("test").mapperService(); String mapping1 = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("field").field("type", "string").field("analyzer", "standard").field("search_analyzer", "whitespace").endObject().endObject() + .startObject("properties").startObject("field").field("type", "text").field("analyzer", "standard").field("search_analyzer", "whitespace").endObject().endObject() .endObject().endObject().string(); String mapping2 = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("field").field("type", "string").field("analyzer", "standard").field("ignore_above", 14).endObject().endObject() + .startObject("properties").startObject("field").field("type", "text").field("analyzer", "standard").endObject().endObject() .endObject().endObject().string(); DocumentMapper existing = mapperService.merge("type", new CompressedXContent(mapping1), MapperService.MergeReason.MAPPING_UPDATE, false); @@ -142,7 +141,6 @@ public class TestMergeMapperTests extends ESSingleNodeTestCase { assertThat(((NamedAnalyzer) existing.mappers().getMapper("field").fieldType().searchAnalyzer()).name(), equalTo("whitespace")); assertThat(((NamedAnalyzer) merged.mappers().getMapper("field").fieldType().searchAnalyzer()).name(), equalTo("standard")); - assertThat(((StringFieldMapper) (merged.mappers().getMapper("field"))).getIgnoreAbove(), equalTo(14)); } public void testConcurrentMergeTest() throws Throwable { @@ -219,7 +217,7 @@ public class TestMergeMapperTests extends ESSingleNodeTestCase { .startObject("type") .startObject("properties") .startObject("foo") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject().endObject().bytes()); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java index 29726efaad1..b165722bf2a 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java @@ -35,7 +35,9 @@ import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.index.mapper.core.DateFieldMapper; +import org.elasticsearch.index.mapper.core.KeywordFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.mapper.core.TokenCountFieldMapper; import org.elasticsearch.index.mapper.object.RootObjectMapper; import org.elasticsearch.test.ESSingleNodeTestCase; @@ -94,25 +96,25 @@ public class MultiFieldTests extends ESSingleNodeTestCase { assertThat(f.stringValue(), equalTo("2010-01-01")); assertThat(docMapper.mappers().getMapper("name"), notNullValue()); - assertThat(docMapper.mappers().getMapper("name"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("name"), instanceOf(TextFieldMapper.class)); assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("name").fieldType().indexOptions()); assertThat(docMapper.mappers().getMapper("name").fieldType().stored(), equalTo(true)); assertThat(docMapper.mappers().getMapper("name").fieldType().tokenized(), equalTo(true)); assertThat(docMapper.mappers().getMapper("name.indexed"), notNullValue()); - assertThat(docMapper.mappers().getMapper("name.indexed"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("name.indexed"), instanceOf(TextFieldMapper.class)); assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("name.indexed").fieldType().indexOptions()); assertThat(docMapper.mappers().getMapper("name.indexed").fieldType().stored(), equalTo(false)); assertThat(docMapper.mappers().getMapper("name.indexed").fieldType().tokenized(), equalTo(true)); assertThat(docMapper.mappers().getMapper("name.not_indexed"), notNullValue()); - assertThat(docMapper.mappers().getMapper("name.not_indexed"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("name.not_indexed"), instanceOf(TextFieldMapper.class)); assertEquals(IndexOptions.NONE, docMapper.mappers().getMapper("name.not_indexed").fieldType().indexOptions()); assertThat(docMapper.mappers().getMapper("name.not_indexed").fieldType().stored(), equalTo(true)); assertThat(docMapper.mappers().getMapper("name.not_indexed").fieldType().tokenized(), equalTo(true)); assertThat(docMapper.mappers().getMapper("name.test1"), notNullValue()); - assertThat(docMapper.mappers().getMapper("name.test1"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("name.test1"), instanceOf(TextFieldMapper.class)); assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("name.test1").fieldType().indexOptions()); assertThat(docMapper.mappers().getMapper("name.test1").fieldType().stored(), equalTo(true)); assertThat(docMapper.mappers().getMapper("name.test1").fieldType().tokenized(), equalTo(true)); @@ -129,7 +131,7 @@ public class MultiFieldTests extends ESSingleNodeTestCase { assertThat(docMapper.mappers().getMapper("object1.multi1"), notNullValue()); assertThat(docMapper.mappers().getMapper("object1.multi1"), instanceOf(DateFieldMapper.class)); assertThat(docMapper.mappers().getMapper("object1.multi1.string"), notNullValue()); - assertThat(docMapper.mappers().getMapper("object1.multi1.string"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("object1.multi1.string"), instanceOf(KeywordFieldMapper.class)); assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("object1.multi1.string").fieldType().indexOptions()); assertThat(docMapper.mappers().getMapper("object1.multi1.string").fieldType().tokenized(), equalTo(false)); } @@ -139,8 +141,8 @@ public class MultiFieldTests extends ESSingleNodeTestCase { DocumentMapper builderDocMapper = new DocumentMapper.Builder(new RootObjectMapper.Builder("person").add( new StringFieldMapper.Builder("name").store(true) - .addMultiField(new StringFieldMapper.Builder("indexed").index(true).tokenized(true)) - .addMultiField(new StringFieldMapper.Builder("not_indexed").index(false).store(true)) + .addMultiField(new TextFieldMapper.Builder("indexed").index(true).tokenized(true)) + .addMultiField(new TextFieldMapper.Builder("not_indexed").index(false).store(true)) ), indexService.mapperService()).build(indexService.mapperService()); String builtMapping = builderDocMapper.mappingSource().string(); @@ -181,9 +183,9 @@ public class MultiFieldTests extends ESSingleNodeTestCase { } XContentBuilder builder = jsonBuilder().startObject().startObject("type").startObject("properties") - .startObject("my_field").field("type", "string").startObject("fields"); + .startObject("my_field").field("type", "text").startObject("fields"); for (String multiFieldName : multiFieldNames) { - builder = builder.startObject(multiFieldName).field("type", "string").endObject(); + builder = builder.startObject(multiFieldName).field("type", "text").endObject(); } builder = builder.endObject().endObject().endObject().endObject().endObject(); String mapping = builder.string(); @@ -218,8 +220,8 @@ public class MultiFieldTests extends ESSingleNodeTestCase { // Generate a mapping with the a random subset of possible fielddata settings XContentBuilder builder = jsonBuilder().startObject().startObject("type").startObject("properties") - .startObject("my_field").field("type", "string").startObject("fields").startObject(MY_MULTI_FIELD) - .field("type", "string").startObject("fielddata"); + .startObject("my_field").field("type", "text").startObject("fields").startObject(MY_MULTI_FIELD) + .field("type", "text").startObject("fielddata"); String[] keys = possibleSettings.keySet().toArray(new String[]{}); Collections.shuffle(Arrays.asList(keys), random()); for(int i = randomIntBetween(0, possibleSettings.size()-1); i >= 0; --i) @@ -235,7 +237,7 @@ public class MultiFieldTests extends ESSingleNodeTestCase { public void testObjectFieldNotAllowed() throws Exception { String mapping = jsonBuilder().startObject().startObject("type").startObject("properties").startObject("my_field") - .field("type", "string").startObject("fields").startObject("multi").field("type", "object").endObject().endObject() + .field("type", "text").startObject("fields").startObject("multi").field("type", "object").endObject().endObject() .endObject().endObject().endObject().endObject().string(); final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser(); try { @@ -248,7 +250,7 @@ public class MultiFieldTests extends ESSingleNodeTestCase { public void testNestedFieldNotAllowed() throws Exception { String mapping = jsonBuilder().startObject().startObject("type").startObject("properties").startObject("my_field") - .field("type", "string").startObject("fields").startObject("multi").field("type", "nested").endObject().endObject() + .field("type", "text").startObject("fields").startObject("multi").field("type", "nested").endObject().endObject() .endObject().endObject().endObject().endObject().string(); final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser(); try { @@ -265,10 +267,10 @@ public class MultiFieldTests extends ESSingleNodeTestCase { .startObject("my_type") .startObject("properties") .startObject("city") - .field("type", "string") + .field("type", "text") .startObject("fields") .startObject("raw.foo") - .field("type", "string") + .field("type", "text") .field("index", "not_analyzed") .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java index bb24a41c445..6a82052bfa8 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java @@ -234,7 +234,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { return XContentFactory.jsonBuilder().startObject().startObject("my-type") .startObject("properties") .startObject("title") - .field("type", "string") + .field("type", "text") .startObject("fields") .startObject("not_analyzed") .field("type", "keyword") @@ -249,10 +249,10 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { return XContentFactory.jsonBuilder().startObject().startObject("my-type") .startObject("properties") .startObject("title") - .field("type", "string") + .field("type", "text") .startObject("fields") .startObject("uncased") - .field("type", "string") + .field("type", "text") .field("analyzer", "whitespace") .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java index 5c846b09ab9..1b5245624ce 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/nested/NestedMappingTests.java @@ -320,7 +320,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase { public void testNestedArrayStrict() throws Exception { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("nested1").field("type", "nested").field("dynamic", "strict").startObject("properties") - .startObject("field1").field("type", "string") + .startObject("field1").field("type", "text") .endObject().endObject() .endObject().endObject().endObject().string(); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java index 423c3e04343..96d5559f457 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java @@ -69,8 +69,7 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase { .startObject("tweet") .startObject("properties") .startObject("name") - .field("type", "string") - .field("index", "analyzed") + .field("type", "text") .startArray("fields") .endArray() .endObject() @@ -87,8 +86,7 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase { .startObject("tweet") .startObject("properties") .startObject("name") - .field("type", "string") - .field("index", "analyzed") + .field("type", "text") .startArray("fields") .startObject().field("test", "string").endObject() .startObject().field("test2", "string").endObject() @@ -148,8 +146,7 @@ public class SimpleObjectMappingTests extends ESSingleNodeTestCase { .startObject("tweet") .startObject("properties") .startObject("name") - .field("type", "string") - .field("index", "analyzed") + .field("type", "text") .startObject("fields") .startObject("raw") .field("type", "keyword") diff --git a/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java index 9280e5a297a..c6e6d69662a 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java @@ -28,7 +28,7 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.ParseContext.Document; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.mapper.object.ObjectMapper; import org.elasticsearch.index.mapper.object.RootObjectMapper; import org.elasticsearch.index.mapper.Uid; @@ -48,7 +48,7 @@ public class SimpleMapperTests extends ESSingleNodeTestCase { IndexService indexService = createIndex("test"); DocumentMapper docMapper = new DocumentMapper.Builder( new RootObjectMapper.Builder("person") - .add(new ObjectMapper.Builder("name").add(new StringFieldMapper.Builder("first").store(true).index(false))), + .add(new ObjectMapper.Builder("name").add(new TextFieldMapper.Builder("first").store(true).index(false))), indexService.mapperService()).build(indexService.mapperService()); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json")); @@ -108,7 +108,7 @@ public class SimpleMapperTests extends ESSingleNodeTestCase { IndexService indexService = createIndex("test"); DocumentMapper docMapper = new DocumentMapper.Builder( new RootObjectMapper.Builder("person") - .add(new ObjectMapper.Builder("name").add(new StringFieldMapper.Builder("first").store(true).index(false))), + .add(new ObjectMapper.Builder("name").add(new TextFieldMapper.Builder("first").store(true).index(false))), indexService.mapperService()).build(indexService.mapperService()); BytesReference json = new BytesArray("".getBytes(StandardCharsets.UTF_8)); @@ -124,7 +124,7 @@ public class SimpleMapperTests extends ESSingleNodeTestCase { IndexService indexService = createIndex("test"); DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser(); String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties") - .startObject("foo.bar").field("type", "string").endObject() + .startObject("foo.bar").field("type", "text").endObject() .endObject().endObject().string(); try { mapperParser.parse("type", new CompressedXContent(mapping)); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java index f100182ebf5..caeb321b8c6 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java @@ -259,12 +259,7 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase { // Cases where search_quote_analyzer should be present. mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties") - .startObject("field1") - .field("type", "string") - .field("position_increment_gap", 1000) - .field("search_quote_analyzer", "simple") - .endObject() - .startObject("field2") + .startObject("field") .field("type", "string") .field("position_increment_gap", 1000) .field("analyzer", "standard") @@ -275,10 +270,8 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase { .endObject().endObject().string(); mapper = parser.parse("type", new CompressedXContent(mapping)); - for (String fieldName : Arrays.asList("field1", "field2")) { - Map serializedMap = getSerializedMap(fieldName, mapper); - assertEquals(serializedMap.get("search_quote_analyzer"), "simple"); - } + Map serializedMap = getSerializedMap("field", mapper); + assertEquals(serializedMap.get("search_quote_analyzer"), "simple"); } public void testSearchAnalyzerSerialization() throws IOException { diff --git a/core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java index 335d3a06e32..ca99f74610c 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java @@ -84,14 +84,14 @@ public class TTLMappingTests extends ESSingleNodeTestCase { public void testThatEnablingTTLFieldOnMergeWorks() throws Exception { String mappingWithoutTtl = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").field("field").startObject().field("type", "string").endObject().endObject() + .startObject("properties").field("field").startObject().field("type", "text").endObject().endObject() .endObject().endObject().string(); String mappingWithTtl = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_ttl") .field("enabled", "yes") .endObject() - .startObject("properties").field("field").startObject().field("type", "string").endObject().endObject() + .startObject("properties").field("field").startObject().field("type", "text").endObject().endObject() .endObject().endObject().string(); MapperService mapperService = createIndex("test").mapperService(); @@ -107,14 +107,14 @@ public class TTLMappingTests extends ESSingleNodeTestCase { .startObject("_ttl") .field("enabled", "yes") .endObject() - .startObject("properties").field("field").startObject().field("type", "string").endObject().endObject() + .startObject("properties").field("field").startObject().field("type", "text").endObject().endObject() .endObject().endObject().string(); String updatedMapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_ttl") .field("default", "1w") .endObject() - .startObject("properties").field("field").startObject().field("type", "string").endObject().endObject() + .startObject("properties").field("field").startObject().field("type", "text").endObject().endObject() .endObject().endObject().string(); MapperService mapperService = createIndex("test").mapperService(); @@ -185,18 +185,18 @@ public class TTLMappingTests extends ESSingleNodeTestCase { XContentBuilder mappingWithOnlyDefaultSet = getMappingWithOnlyTtlDefaultSet("6m"); indexService.mapperService().merge("type", new CompressedXContent(mappingWithOnlyDefaultSet.string()), MapperService.MergeReason.MAPPING_UPDATE, false); CompressedXContent mappingAfterMerge = indexService.mapperService().documentMapper("type").mappingSource(); - assertThat(mappingAfterMerge, equalTo(new CompressedXContent("{\"type\":{\"_ttl\":{\"enabled\":true,\"default\":360000},\"properties\":{\"field\":{\"type\":\"string\"}}}}"))); + assertThat(mappingAfterMerge, equalTo(new CompressedXContent("{\"type\":{\"_ttl\":{\"enabled\":true,\"default\":360000},\"properties\":{\"field\":{\"type\":\"text\"}}}}"))); } public void testMergeWithOnlyDefaultSetTtlDisabled() throws Exception { XContentBuilder mappingWithTtlEnabled = getMappingWithTtlDisabled("7d"); IndexService indexService = createIndex("testindex", Settings.settingsBuilder().build(), "type", mappingWithTtlEnabled); CompressedXContent mappingAfterCreation = indexService.mapperService().documentMapper("type").mappingSource(); - assertThat(mappingAfterCreation, equalTo(new CompressedXContent("{\"type\":{\"_ttl\":{\"enabled\":false},\"properties\":{\"field\":{\"type\":\"string\"}}}}"))); + assertThat(mappingAfterCreation, equalTo(new CompressedXContent("{\"type\":{\"_ttl\":{\"enabled\":false},\"properties\":{\"field\":{\"type\":\"text\"}}}}"))); XContentBuilder mappingWithOnlyDefaultSet = getMappingWithOnlyTtlDefaultSet("6m"); indexService.mapperService().merge("type", new CompressedXContent(mappingWithOnlyDefaultSet.string()), MapperService.MergeReason.MAPPING_UPDATE, false); CompressedXContent mappingAfterMerge = indexService.mapperService().documentMapper("type").mappingSource(); - assertThat(mappingAfterMerge, equalTo(new CompressedXContent("{\"type\":{\"_ttl\":{\"enabled\":false},\"properties\":{\"field\":{\"type\":\"string\"}}}}"))); + assertThat(mappingAfterMerge, equalTo(new CompressedXContent("{\"type\":{\"_ttl\":{\"enabled\":false},\"properties\":{\"field\":{\"type\":\"text\"}}}}"))); } public void testIncludeInObjectNotAllowed() throws Exception { @@ -230,7 +230,7 @@ public class TTLMappingTests extends ESSingleNodeTestCase { mapping.field("default", defaultValue); } return mapping.endObject() - .startObject("properties").field("field").startObject().field("type", "string").endObject().endObject() + .startObject("properties").field("field").startObject().field("type", "text").endObject().endObject() .endObject().endObject(); } @@ -242,14 +242,14 @@ public class TTLMappingTests extends ESSingleNodeTestCase { mapping.field("default", defaultValue); } return mapping.endObject() - .startObject("properties").field("field").startObject().field("type", "string").endObject().endObject() + .startObject("properties").field("field").startObject().field("type", "text").endObject().endObject() .endObject().endObject(); } private org.elasticsearch.common.xcontent.XContentBuilder getMappingWithOnlyTtlDefaultSet(String defaultValue) throws IOException { return XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("_ttl").field("default", defaultValue).endObject() - .startObject("properties").field("field").startObject().field("type", "string").endObject().endObject() + .startObject("properties").field("field").startObject().field("type", "text").endObject().endObject() .endObject().endObject(); } } diff --git a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java index 8b6aa794062..a3d6a87c43f 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java @@ -40,7 +40,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase { public void testAllEnabled() throws Exception { XContentBuilder mapping = jsonBuilder().startObject().startObject("mappings").startObject(TYPE).startObject("_all").field("enabled", "false").endObject().endObject().endObject().endObject(); - XContentBuilder mappingUpdate = jsonBuilder().startObject().startObject("_all").field("enabled", "true").endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject(); + XContentBuilder mappingUpdate = jsonBuilder().startObject().startObject("_all").field("enabled", "true").endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject(); String errorMessage = "[_all] enabled is false now encountering true"; testConflict(mapping.string(), mappingUpdate.string(), errorMessage); } @@ -63,7 +63,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase { public void testAllDisabled() throws Exception { XContentBuilder mapping = jsonBuilder().startObject().startObject("mappings").startObject(TYPE).startObject("_all").field("enabled", true).endObject().endObject().endObject().endObject(); - XContentBuilder mappingUpdate = jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject(); + XContentBuilder mappingUpdate = jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject(); String errorMessage = "[_all] enabled is true now encountering false"; testConflict(mapping.string(), mappingUpdate.string(), errorMessage); } @@ -84,7 +84,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase { String docMappingUpdate = jsonBuilder().startObject().startObject("doc") .startObject("properties") .startObject("text") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() @@ -125,7 +125,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase { } public void testDocValuesInvalidMappingOnUpdate() throws Exception { - String mapping = jsonBuilder().startObject().startObject(TYPE).startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject().string(); + String mapping = jsonBuilder().startObject().startObject(TYPE).startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject().string(); prepareCreate(INDEX).addMapping(TYPE, mapping).get(); String mappingUpdate = jsonBuilder().startObject().startObject(TYPE).startObject("_all").startObject("fielddata").field("format", "doc_values").endObject().endObject().endObject().endObject().string(); GetMappingsResponse mappingsBeforeUpdateResponse = client().admin().indices().prepareGetMappings(INDEX).addTypes(TYPE).get(); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java index 4e65c4a5ab7..ab0182aa0ef 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java @@ -51,33 +51,33 @@ public class UpdateMappingTests extends ESSingleNodeTestCase { public void testAllEnabledAfterDisabled() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().endObject(); - XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject(); + XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject(); testConflictWhileMergingAndMappingUnchanged(mapping, mappingUpdate); } public void testAllDisabledAfterEnabled() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().endObject(); - XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject(); + XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject(); testConflictWhileMergingAndMappingUnchanged(mapping, mappingUpdate); } public void testAllDisabledAfterDefaultEnabled() throws Exception { - XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties").startObject("some_text").field("type", "string").endObject().endObject().endObject(); - XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject(); + XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties").startObject("some_text").field("type", "text").endObject().endObject().endObject(); + XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject(); testConflictWhileMergingAndMappingUnchanged(mapping, mappingUpdate); } public void testAllEnabledAfterEnabled() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().endObject(); - XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject(); - XContentBuilder expectedMapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject().endObject(); + XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject(); + XContentBuilder expectedMapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_all").field("enabled", true).endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject().endObject(); testNoConflictWhileMergingAndMappingChanged(mapping, mappingUpdate, expectedMapping); } public void testAllDisabledAfterDisabled() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().endObject(); - XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject(); - XContentBuilder expectedMapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "string").endObject().endObject().endObject().endObject(); + XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject(); + XContentBuilder expectedMapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_all").field("enabled", false).endObject().startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject().endObject(); testNoConflictWhileMergingAndMappingChanged(mapping, mappingUpdate, expectedMapping); } @@ -97,7 +97,7 @@ public class UpdateMappingTests extends ESSingleNodeTestCase { .endObject().endObject(); XContentBuilder mappingUpdate = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject(fieldName).field("enabled", true).field("store", "yes").endObject() - .startObject("properties").startObject("text").field("type", "string").endObject().endObject() + .startObject("properties").startObject("text").field("type", "text").endObject().endObject() .endObject().endObject(); testConflictWhileMergingAndMappingUnchanged(mapping, mappingUpdate); } @@ -212,7 +212,7 @@ public class UpdateMappingTests extends ESSingleNodeTestCase { public void testReuseMetaField() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("_id").field("type", "string").endObject() + .startObject("properties").startObject("_id").field("type", "text").endObject() .endObject().endObject().endObject(); MapperService mapperService = createIndex("test", Settings.settingsBuilder().build()).mapperService(); @@ -233,7 +233,7 @@ public class UpdateMappingTests extends ESSingleNodeTestCase { public void testReuseMetaFieldBackCompat() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("_id").field("type", "string").endObject() + .startObject("properties").startObject("_id").field("type", "text").endObject() .endObject().endObject().endObject(); // the logic is different for 2.x indices since they record some meta mappers (including _id) // in the root object diff --git a/core/src/test/java/org/elasticsearch/index/percolator/PercolatorFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/percolator/PercolatorFieldMapperTests.java index 9e46ce95041..074e64f8232 100644 --- a/core/src/test/java/org/elasticsearch/index/percolator/PercolatorFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/percolator/PercolatorFieldMapperTests.java @@ -44,7 +44,7 @@ public class PercolatorFieldMapperTests extends ESSingleNodeTestCase { mapperService = indexService.mapperService(); String mapper = XContentFactory.jsonBuilder().startObject().startObject("type") - .startObject("properties").startObject("field").field("type", "string").endObject().endObject() + .startObject("properties").startObject("field").field("type", "text").endObject().endObject() .endObject().endObject().string(); mapperService.merge("type", new CompressedXContent(mapper), MapperService.MergeReason.MAPPING_UPDATE, true); diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java index 26bededf685..53594f43080 100644 --- a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java @@ -293,8 +293,8 @@ public abstract class AbstractQueryTestCase> for (int i = 0; i < currentTypes.length; i++) { String type = randomAsciiOfLengthBetween(1, 10); mapperService.merge(type, new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef(type, - STRING_FIELD_NAME, "type=string", - STRING_FIELD_NAME_2, "type=string", + STRING_FIELD_NAME, "type=text", + STRING_FIELD_NAME_2, "type=text", INT_FIELD_NAME, "type=integer", DOUBLE_FIELD_NAME, "type=double", BOOLEAN_FIELD_NAME, "type=boolean", diff --git a/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java b/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java index 8430e11a967..6b217f68eea 100644 --- a/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/CommonTermsQueryParserTests.java @@ -32,7 +32,7 @@ public class CommonTermsQueryParserTests extends ESSingleNodeTestCase { .admin() .indices() .prepareCreate(index) - .addMapping(type, "name", "type=string,analyzer=stop") + .addMapping(type, "name", "type=text,analyzer=stop") .execute() .actionGet(); ensureGreen(); diff --git a/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java index fb618868417..b706a4ce5d8 100644 --- a/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java @@ -62,7 +62,7 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"), hasEntry("index", Boolean.TRUE)); assertThat((Map) response.fieldMappings("test", "type", "num").sourceAsMap().get("num"), hasEntry("type", (Object) "long")); - assertThat((Map) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"), hasEntry("index", (Object) "analyzed")); - assertThat((Map) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"), hasEntry("type", (Object) "string")); + assertThat((Map) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"), hasEntry("index", Boolean.TRUE)); + assertThat((Map) response.fieldMappings("test", "type", "field1").sourceAsMap().get("field1"), hasEntry("type", (Object) "text")); assertThat((Map) response.fieldMappings("test", "type", "obj.subfield").sourceAsMap().get("subfield"), hasEntry("type", (Object) "keyword")); diff --git a/core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java b/core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java index 2f4970ef4f8..8d319ae5b8d 100644 --- a/core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java +++ b/core/src/test/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java @@ -53,7 +53,7 @@ public class SimpleGetMappingsIT extends ESIntegTestCase { private XContentBuilder getMappingForType(String type) throws IOException { return jsonBuilder().startObject().startObject(type).startObject("properties") - .startObject("field1").field("type", "string").endObject() + .startObject("field1").field("type", "text").endObject() .endObject().endObject().endObject(); } diff --git a/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java index 3c4dc3186bc..a3169f08498 100644 --- a/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java @@ -220,7 +220,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase { logger.info("Creating _default_ mappings with an analyzed field"); putResponse = client().admin().indices().preparePutMapping("test").setType(MapperService.DEFAULT_MAPPING).setSource( JsonXContent.contentBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) - .startObject("properties").startObject("f").field("type", "string").field("index", "analyzed").endObject().endObject() + .startObject("properties").startObject("f").field("type", "text").field("index", true).endObject().endObject() .endObject().endObject() ).get(); assertThat(putResponse.isAcknowledged(), equalTo(true)); @@ -287,7 +287,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase { PutMappingResponse response = client1.admin().indices().preparePutMapping(indexName).setType(typeName).setSource( JsonXContent.contentBuilder().startObject().startObject(typeName) - .startObject("properties").startObject(fieldName).field("type", "string").endObject().endObject() + .startObject("properties").startObject(fieldName).field("type", "text").endObject().endObject() .endObject().endObject() ).get(); @@ -340,12 +340,12 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase { } public void testUpdateMappingOnAllTypes() throws IOException { - assertAcked(prepareCreate("index").addMapping("type1", "f", "type=string").addMapping("type2", "f", "type=string")); + assertAcked(prepareCreate("index").addMapping("type1", "f", "type=keyword").addMapping("type2", "f", "type=keyword")); assertAcked(client().admin().indices().preparePutMapping("index") .setType("type1") .setUpdateAllTypes(true) - .setSource("f", "type=string,analyzer=default,null_value=n/a") + .setSource("f", "type=keyword,null_value=n/a") .get()); GetMappingsResponse mappings = client().admin().indices().prepareGetMappings("index").setTypes("type2").get(); diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java index 727641eb224..d105c98f4ac 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -44,7 +44,7 @@ public class IndexPrimaryRelocationIT extends ESIntegTestCase { internalCluster().ensureAtLeastNumDataNodes(randomIntBetween(2, 3)); client().admin().indices().prepareCreate("test") .setSettings(Settings.settingsBuilder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) - .addMapping("type", "field", "type=string") + .addMapping("type", "field", "type=text") .get(); ensureGreen("test"); diff --git a/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java b/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java index 38269ebf8f1..a21624d6e92 100644 --- a/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java +++ b/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateBlocksIT.java @@ -38,7 +38,7 @@ public class IndexTemplateBlocksIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java b/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java index 8e0d5a882c3..47742969501 100644 --- a/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java +++ b/core/src/test/java/org/elasticsearch/indices/template/IndexTemplateFilteringIT.java @@ -47,15 +47,15 @@ public class IndexTemplateFilteringIT extends ESIntegTestCase { public void testTemplateFiltering() throws Exception { client().admin().indices().preparePutTemplate("template1") .setTemplate("test*") - .addMapping("type1", "field1", "type=string").get(); + .addMapping("type1", "field1", "type=text").get(); client().admin().indices().preparePutTemplate("template2") .setTemplate("test*") - .addMapping("type2", "field2", "type=string").get(); + .addMapping("type2", "field2", "type=text").get(); client().admin().indices().preparePutTemplate("template3") .setTemplate("no_match") - .addMapping("type3", "field3", "type=string").get(); + .addMapping("type3", "field3", "type=text").get(); assertAcked(prepareCreate("test")); diff --git a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java index 5df1b2311ca..9fe8995e65f 100644 --- a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java +++ b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java @@ -78,7 +78,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setSettings(indexSettings()) .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .get(); @@ -88,7 +88,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setSettings(indexSettings()) .setOrder(1) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field2").field("type", "string").field("store", false).endObject() + .startObject("field2").field("type", "text").field("store", false).endObject() .endObject().endObject().endObject()) .get(); @@ -99,7 +99,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setCreate(true) .setOrder(1) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field2").field("type", "string").field("store", false).endObject() + .startObject("field2").field("type", "text").field("store", false).endObject() .endObject().endObject().endObject()) , IndexTemplateAlreadyExistsException.class ); @@ -145,8 +145,8 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() - .startObject("field2").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() + .startObject("field2").field("type", "text").field("store", true).endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -154,7 +154,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setTemplate("test*") .setOrder(1) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field2").field("type", "string").field("store", "no").endObject() + .startObject("field2").field("type", "text").field("store", "no").endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -170,7 +170,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -190,7 +190,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -213,7 +213,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -223,7 +223,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -233,7 +233,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { .setTemplate("te*") .setOrder(0) .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("store", true).endObject() + .startObject("field1").field("type", "text").field("store", true).endObject() .startObject("field2").field("type", "keyword").field("store", true).endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -599,20 +599,20 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { client().admin().indices().preparePutTemplate("template1") .setTemplate("a*") .setOrder(0) - .addMapping("test", "field", "type=string") + .addMapping("test", "field", "type=text") .addAlias(new Alias("alias1").filter(termQuery("field", "value"))).get(); // Indexing into b should succeed, because the field mapping for field 'field' is defined in the _default_ mapping and the test type exists. client().admin().indices().preparePutTemplate("template2") .setTemplate("b*") .setOrder(0) - .addMapping("_default_", "field", "type=string") + .addMapping("_default_", "field", "type=text") .addMapping("test") .addAlias(new Alias("alias2").filter(termQuery("field", "value"))).get(); // Indexing into c should succeed, because the field mapping for field 'field' is defined in the _default_ mapping. client().admin().indices().preparePutTemplate("template3") .setTemplate("c*") .setOrder(0) - .addMapping("_default_", "field", "type=string") + .addMapping("_default_", "field", "type=text") .addAlias(new Alias("alias3").filter(termQuery("field", "value"))).get(); // Indexing into d index should fail, since there is field with name 'field' in the mapping client().admin().indices().preparePutTemplate("template4") diff --git a/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java index 42750a7f1d4..e99cf51758b 100644 --- a/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java @@ -58,7 +58,7 @@ public class ConcurrentPercolatorIT extends ESIntegTestCase { // We need to index a document / define mapping, otherwise field1 doesn't get recognized as number field. // If we don't do this, then 'test2' percolate query gets parsed as a TermQuery and not a RangeQuery. // The percolate api doesn't parse the doc if no queries have registered, so it can't lazily create a mapping - assertAcked(prepareCreate("index").addMapping("type", "field1", "type=long", "field2", "type=string")); // random # shards better has a mapping! + assertAcked(prepareCreate("index").addMapping("type", "field1", "type=long", "field2", "type=text")); // random # shards better has a mapping! ensureGreen(); final BytesReference onlyField1 = XContentFactory.jsonBuilder().startObject().startObject("doc") @@ -149,7 +149,7 @@ public class ConcurrentPercolatorIT extends ESIntegTestCase { } public void testConcurrentAddingAndPercolating() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "field1", "type=string", "field2", "type=string")); + assertAcked(prepareCreate("index").addMapping("type", "field1", "type=text", "field2", "type=text")); ensureGreen(); final int numIndexThreads = scaledRandomIntBetween(1, 3); final int numPercolateThreads = scaledRandomIntBetween(2, 6); @@ -298,7 +298,7 @@ public class ConcurrentPercolatorIT extends ESIntegTestCase { } public void testConcurrentAddingAndRemovingWhilePercolating() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "field1", "type=string")); + assertAcked(prepareCreate("index").addMapping("type", "field1", "type=text")); ensureGreen(); final int numIndexThreads = scaledRandomIntBetween(1, 3); final int numberPercolateOperation = scaledRandomIntBetween(10, 100); diff --git a/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java index 31115a2565b..6dfcc5a878a 100644 --- a/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java @@ -56,7 +56,7 @@ import static org.hamcrest.Matchers.nullValue; */ public class MultiPercolatorIT extends ESIntegTestCase { public void testBasics() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "field1", "type=string")); + assertAcked(prepareCreate("test").addMapping("type", "field1", "type=text")); ensureGreen(); logger.info("--> register a queries"); @@ -126,7 +126,7 @@ public class MultiPercolatorIT extends ESIntegTestCase { } public void testWithRouting() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "field1", "type=string")); + assertAcked(prepareCreate("test").addMapping("type", "field1", "type=text")); ensureGreen(); logger.info("--> register a queries"); @@ -394,9 +394,9 @@ public class MultiPercolatorIT extends ESIntegTestCase { void initNestedIndexAndPercolation() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder(); - mapping.startObject().startObject("properties").startObject("companyname").field("type", "string").endObject() + mapping.startObject().startObject("properties").startObject("companyname").field("type", "text").endObject() .startObject("employee").field("type", "nested").startObject("properties") - .startObject("name").field("type", "string").endObject().endObject().endObject().endObject() + .startObject("name").field("type", "text").endObject().endObject().endObject().endObject() .endObject(); assertAcked(client().admin().indices().prepareCreate("nestedindex").addMapping("company", mapping)); diff --git a/core/src/test/java/org/elasticsearch/percolator/PercolatorAggregationsIT.java b/core/src/test/java/org/elasticsearch/percolator/PercolatorAggregationsIT.java index b8ed2cc0e28..a5bc1a89c64 100644 --- a/core/src/test/java/org/elasticsearch/percolator/PercolatorAggregationsIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/PercolatorAggregationsIT.java @@ -53,7 +53,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=string", "field2", "type=string")); + assertAcked(prepareCreate("test").addMapping("type", "field1", "type=text", "field2", "type=text")); ensureGreen(); int numQueries = scaledRandomIntBetween(250, 500); @@ -118,7 +118,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=string", "field2", "type=string")); + assertAcked(prepareCreate("test").addMapping("type", "field1", "type=text", "field2", "type=text")); ensureGreen(); int numQueries = scaledRandomIntBetween(250, 500); @@ -203,7 +203,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=string", "field2", "type=string")); + .addMapping("type", "field1", "type=text", "field2", "type=text")); ensureGreen(); int numQueries = scaledRandomIntBetween(250, 500); diff --git a/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java index 6d187147f2b..f9eba5fc7dd 100644 --- a/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java @@ -178,7 +178,7 @@ public class PercolatorIT extends ESIntegTestCase { } public void testSimple2() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=long,doc_values=true", "field2", "type=string")); + assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=long,doc_values=true", "field2", "type=text")); ensureGreen(); // introduce the doc @@ -315,7 +315,7 @@ public class PercolatorIT extends ESIntegTestCase { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("doc") .startObject("properties") - .startObject("filingcategory").field("type", "string").field("analyzer", "lwhitespacecomma").endObject() + .startObject("filingcategory").field("type", "text").field("analyzer", "lwhitespacecomma").endObject() .endObject() .endObject().endObject(); @@ -346,7 +346,7 @@ public class PercolatorIT extends ESIntegTestCase { public void testCreateIndexAndThenRegisterPercolator() throws Exception { prepareCreate("test") - .addMapping("type1", "field1", "type=string") + .addMapping("type1", "field1", "type=text") .get(); ensureGreen(); @@ -394,7 +394,7 @@ public class PercolatorIT extends ESIntegTestCase { } public void testMultiplePercolators() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=string")); + assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=text")); ensureGreen(); logger.info("--> register a query 1"); @@ -436,7 +436,7 @@ public class PercolatorIT extends ESIntegTestCase { public void testDynamicAddingRemovingQueries() throws Exception { assertAcked( prepareCreate("test") - .addMapping("type1", "field1", "type=string") + .addMapping("type1", "field1", "type=text") ); ensureGreen(); @@ -1273,7 +1273,7 @@ public class PercolatorIT extends ESIntegTestCase { public void testPercolateSortingUnsupportedField() throws Exception { client().admin().indices().prepareCreate("my-index") - .addMapping("my-type", "field", "type=string") + .addMapping("my-type", "field", "type=text") .addMapping(PercolatorService.TYPE_NAME, "level", "type=integer", "query", "type=object,enabled=false") .get(); ensureGreen(); @@ -1312,7 +1312,7 @@ public class PercolatorIT extends ESIntegTestCase { } public void testPercolatorWithHighlighting() throws Exception { - StringBuilder fieldMapping = new StringBuilder("type=string") + StringBuilder fieldMapping = new StringBuilder("type=text") .append(",store=").append(randomBoolean()); if (randomBoolean()) { fieldMapping.append(",term_vector=with_positions_offsets"); @@ -1521,7 +1521,7 @@ public class PercolatorIT extends ESIntegTestCase { } public void testPercolateNonMatchingConstantScoreQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("doc", "message", "type=string")); + assertAcked(prepareCreate("test").addMapping("doc", "message", "type=text")); ensureGreen(); logger.info("--> register a query"); @@ -1646,9 +1646,9 @@ public class PercolatorIT extends ESIntegTestCase { void initNestedIndexAndPercolation() throws IOException { XContentBuilder mapping = XContentFactory.jsonBuilder(); - mapping.startObject().startObject("properties").startObject("companyname").field("type", "string").endObject() + mapping.startObject().startObject("properties").startObject("companyname").field("type", "text").endObject() .startObject("employee").field("type", "nested").startObject("properties") - .startObject("name").field("type", "string").endObject().endObject().endObject().endObject() + .startObject("name").field("type", "text").endObject().endObject().endObject().endObject() .endObject(); assertAcked(client().admin().indices().prepareCreate("nestedindex").addMapping("company", mapping)); @@ -1869,7 +1869,7 @@ public class PercolatorIT extends ESIntegTestCase { .field("type", "nested") .startObject("properties") .startObject("name") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java index 4005754f31f..a08eb41236d 100644 --- a/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java @@ -69,7 +69,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { public void testRestartNodePercolator1() throws Exception { internalCluster().startNode(); - assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=string").addMapping(PercolatorService.TYPE_NAME, "color", "type=string")); + assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=text").addMapping(PercolatorService.TYPE_NAME, "color", "type=text")); logger.info("--> register a query"); client().prepareIndex("test", PercolatorService.TYPE_NAME, "kuku") @@ -105,7 +105,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { public void testRestartNodePercolator2() throws Exception { internalCluster().startNode(); - assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=string").addMapping(PercolatorService.TYPE_NAME, "color", "type=string")); + assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=text").addMapping(PercolatorService.TYPE_NAME, "color", "type=text")); logger.info("--> register a query"); client().prepareIndex("test", PercolatorService.TYPE_NAME, "kuku") @@ -138,7 +138,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { DeleteIndexResponse actionGet = client().admin().indices().prepareDelete("test").get(); assertThat(actionGet.isAcknowledged(), equalTo(true)); - assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=string").addMapping(PercolatorService.TYPE_NAME, "color", "type=string")); + assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=text").addMapping(PercolatorService.TYPE_NAME, "color", "type=text")); clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForYellowStatus().waitForActiveShards(1)).actionGet(); logger.info("Done Cluster Health, status " + clusterHealth.getStatus()); assertThat(clusterHealth.isTimedOut(), equalTo(false)); diff --git a/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java index b1cd982e997..52f8ecb4b13 100644 --- a/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java @@ -73,7 +73,7 @@ public class TTLPercolatorIT extends ESIntegTestCase { String typeMapping = XContentFactory.jsonBuilder().startObject().startObject("type1") .startObject("_ttl").field("enabled", true).endObject() .startObject("_timestamp").field("enabled", true).endObject() - .startObject("properties").startObject("field1").field("type", "string").endObject().endObject() + .startObject("properties").startObject("field1").field("type", "text").endObject().endObject() .endObject().endObject().string(); client.admin().indices().prepareCreate("test") diff --git a/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java b/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java index 0b5c4a6bebf..16f27655055 100644 --- a/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java +++ b/core/src/test/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java @@ -92,7 +92,7 @@ public class TruncatedRecoveryIT extends ESIntegTestCase { // create the index and prevent allocation on any other nodes than the lucky one // we have no replicas so far and make sure that we allocate the primary on the lucky node assertAcked(prepareCreate("test") - .addMapping("type1", "field1", "type=string", "the_id", "type=string") + .addMapping("type1", "field1", "type=text", "the_id", "type=text") .setSettings(settingsBuilder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numberOfShards()) .put("index.routing.allocation.include._name", primariesNode.getNode().name()))); // only allocate on the lucky node 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 bdecb756126..fd1bf634a85 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=string").get()); + assertAcked(prepareCreate("index").addMapping("type", "f", "type=text").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 a07d0714b69..25fb756d125 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", "string").endObject() + .startObject("name").field("type", "text").endObject() .startObject("value").field("type", "integer").endObject() .endObject().endObject() .endObject()).execute().actionGet(); 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 8981a96facf..6b68fe1b29e 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 @@ -294,8 +294,8 @@ public class ChildrenIT extends ESIntegTestCase { String childType = "variantsku"; assertAcked( prepareCreate(indexName) - .addMapping(masterType, "brand", "type=string", "name", "type=string", "material", "type=string") - .addMapping(childType, "_parent", "type=masterprod", "color", "type=string", "size", "type=string") + .addMapping(masterType, "brand", "type=text", "name", "type=text", "material", "type=text") + .addMapping(childType, "_parent", "type=masterprod", "color", "type=text", "size", "type=text") ); List requests = new ArrayList<>(); 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 af17ca8e212..3c6365fd46a 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 @@ -462,7 +462,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=string", "name", "type=string", "property", "type=nested") + .addMapping("product", "categories", "type=text", "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 e82a7374b84..d4d304357cd 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", "string").endObject() + .startObject("field1").field("type", "text").endObject() .startObject("nested1").field("type", "nested").startObject("properties") - .startObject("field2").field("type", "string").endObject() + .startObject("field2").field("type", "text").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", "string").endObject() + .startObject("field1").field("type", "text").endObject() .startObject("nested2").field("type", "nested").startObject("properties") - .startObject("field2").field("type", "string").endObject() + .startObject("field2").field("type", "text").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", "string").endObject() + .startObject("name").field("type", "text").endObject() .endObject() .endObject() .startObject("sku") .field("type", "nested") .startObject("properties") - .startObject("sku_type").field("type", "string").endObject() + .startObject("sku_type").field("type", "text").endObject() .startObject("colors") .field("type", "nested") .startObject("properties") - .startObject("name").field("type", "string").endObject() + .startObject("name").field("type", "text").endObject() .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java index b6088c88784..6257d486955 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java @@ -61,12 +61,12 @@ public class SamplerIT extends ESIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0).addMapping( - "book", "author", "type=keyword", "name", "type=string,index=analyzed", "genre", + "book", "author", "type=keyword", "name", "type=text", "genre", "type=keyword", "price", "type=float")); createIndex("idx_unmapped"); // idx_unmapped_author is same as main index but missing author field assertAcked(prepareCreate("idx_unmapped_author").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0) - .addMapping("book", "name", "type=string,index=analyzed", "genre", "type=keyword", "price", "type=float")); + .addMapping("book", "name", "type=text", "genre", "type=keyword", "price", "type=float")); ensureGreen(); String data[] = { 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 450e029622f..b450c5b8277 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 @@ -76,7 +76,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=string,index=analyzed")); + "type=integer,index=true", "description", "type=text,index=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 6daa6f2dc28..cd5ac743cfe 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 @@ -419,7 +419,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=string", "class", "type=string")); + "text", "type=text", "class", "type=text")); createIndex("idx_unmapped"); ensureGreen(); 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 3d8259a6ed6..b3fcc9d159f 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 @@ -111,7 +111,7 @@ public class TopHitsIT extends ESIntegTestCase { .field("type", "long") .endObject() .startObject("message") - .field("type", "string") + .field("type", "text") .field("store", true) .field("term_vector", "with_positions_offsets") .field("index_options", "offsets") diff --git a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java index 1f421292371..beedd72c280 100644 --- a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java +++ b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java @@ -61,7 +61,7 @@ public class SearchWhileRelocatingIT extends ESIntegTestCase { final int numShards = between(1, 20); client().admin().indices().prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", numShards).put("index.number_of_replicas", numberOfReplicas)) - .addMapping("type", "loc", "type=geo_point", "test", "type=string").execute().actionGet(); + .addMapping("type", "loc", "type=geo_point", "test", "type=text").execute().actionGet(); ensureGreen(); List indexBuilders = new ArrayList<>(); final int numDocs = between(10, 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 67420bdf3b5..4d3e6413eee 100644 --- a/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java @@ -824,8 +824,8 @@ public class ChildQuerySearchIT extends ESIntegTestCase { public void testSimpleQueryRewrite() throws Exception { assertAcked(prepareCreate("test") - .addMapping("parent", "p_field", "type=string") - .addMapping("child", "_parent", "type=parent", "c_field", "type=string")); + .addMapping("parent", "p_field", "type=text") + .addMapping("child", "_parent", "type=parent", "c_field", "type=text")); ensureGreen(); // index simple data diff --git a/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java b/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java index f4323e26fbd..3159217f174 100644 --- a/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java +++ b/core/src/test/java/org/elasticsearch/search/fetch/FetchSubPhasePluginIT.java @@ -74,7 +74,7 @@ public class FetchSubPhasePluginIT extends ESIntegTestCase { .startObject().startObject("type1") .startObject("properties") .startObject("test") - .field("type", "string").field("term_vector", "yes") + .field("type", "text").field("term_vector", "yes") .endObject() .endObject() .endObject().endObject()).execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java index 695575d9d08..18a99411cf4 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java @@ -77,7 +77,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testDistanceScoreGeoLinGaussExp() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("loc").field("type", "geo_point").endObject().endObject().endObject().endObject())); ensureYellow(); @@ -175,7 +175,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testDistanceScoreGeoLinGaussExpWithOffset() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num").field("type", "double").endObject().endObject().endObject().endObject())); ensureYellow(); @@ -249,7 +249,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testBoostModeSettingWorks() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("loc").field("type", "geo_point").endObject().endObject().endObject().endObject())); ensureYellow(); @@ -303,7 +303,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testParseGeoPoint() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("loc").field("type", "geo_point").endObject().endObject().endObject().endObject())); ensureYellow(); @@ -343,7 +343,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testCombineModes() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num").field("type", "double").endObject().endObject().endObject().endObject())); ensureYellow(); @@ -424,7 +424,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testExceptionThrownIfScaleLE0() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num1").field("type", "date").endObject().endObject().endObject().endObject())); ensureYellow(); client().index( @@ -450,7 +450,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testParseDateMath() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num1").field("type", "date").field("format", "epoch_millis").endObject().endObject().endObject().endObject())); ensureYellow(); client().index( @@ -482,7 +482,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testValueMissingLin() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num1").field("type", "date").endObject().startObject("num2").field("type", "double") .endObject().endObject().endObject().endObject()) ); @@ -533,7 +533,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num1").field("type", "date").endObject().endObject().endObject().endObject())); ensureYellow(); @@ -581,7 +581,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT); Settings settings = Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = jsonBuilder().startObject().startObject("type").startObject("properties") - .startObject("test").field("type", "string").endObject().startObject("date").field("type", "date") + .startObject("test").field("type", "text").endObject().startObject("date").field("type", "date") .field("doc_values", true).endObject().startObject("num").field("type", "double") .field("doc_values", true).endObject().startObject("geo").field("type", "geo_point") .field("ignore_malformed", true); @@ -667,8 +667,8 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testParsingExceptionIfFieldTypeDoesNotMatch() throws Exception { assertAcked(prepareCreate("test").addMapping( "type", - jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "string") - .endObject().startObject("num").field("type", "string").endObject().endObject().endObject().endObject())); + jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "text") + .endObject().startObject("num").field("type", "text").endObject().endObject().endObject().endObject())); ensureYellow(); client().index( indexRequest("test").type("type").source( @@ -690,7 +690,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testNoQueryGiven() throws Exception { assertAcked(prepareCreate("test").addMapping( "type", - jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("num").field("type", "double").endObject().endObject().endObject().endObject())); ensureYellow(); client().index( @@ -709,7 +709,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { public void testMultiFieldOptions() throws Exception { assertAcked(prepareCreate("test").addMapping( "type1", - jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "string") + jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text") .endObject().startObject("loc").field("type", "geo_point").endObject().startObject("num").field("type", "float").endObject().endObject().endObject().endObject())); ensureYellow(); diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java index 2e7a0a2329d..343fc2c2c7d 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreBackwardCompatibilityIT.java @@ -56,7 +56,7 @@ public class FunctionScoreBackwardCompatibilityIT extends ESBackcompatTestCase { .startObject("type1") .startObject("properties") .startObject("text") - .field("type", "string") + .field("type", "text") .endObject() .startObject("loc") .field("type", "geo_point") diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java index 5331dfe6ff9..6c7bfdc85a2 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java @@ -50,7 +50,7 @@ public class FunctionScoreFieldValueIT extends ESIntegTestCase { .field("type", randomFrom(new String[]{"short", "float", "long", "integer", "double"})) .endObject() .startObject("body") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java index d1d8278b79b..18155ce91de 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java @@ -63,7 +63,7 @@ public class FunctionScorePluginIT extends ESIntegTestCase { .addMapping( "type1", jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test") - .field("type", "string").endObject().startObject("num1").field("type", "date").endObject().endObject() + .field("type", "text").endObject().startObject("num1").field("type", "date").endObject().endObject() .endObject().endObject()).execute().actionGet(); client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java index 959adac3daf..4ef80fcdf67 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java @@ -104,7 +104,7 @@ public class QueryRescorerIT extends ESIntegTestCase { .addMapping( "type1", jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1") - .field("analyzer", "whitespace").field("type", "string").endObject().endObject().endObject().endObject()) + .field("analyzer", "whitespace").field("type", "text").endObject().endObject().endObject().endObject()) .setSettings(Settings.settingsBuilder().put(indexSettings()).put("index.number_of_shards", 1))); client().prepareIndex("test", "type1", "1").setSource("field1", "the quick brown fox").execute().actionGet(); @@ -153,7 +153,7 @@ public class QueryRescorerIT extends ESIntegTestCase { builder.putArray("index.analysis.filter.synonym.synonyms", "ave => ave, avenue", "street => str, street"); XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("analyzer", "whitespace").field("search_analyzer", "synonym") + .startObject("field1").field("type", "text").field("analyzer", "whitespace").field("search_analyzer", "synonym") .endObject().endObject().endObject().endObject(); assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", mapping).setSettings(builder.put("index.number_of_shards", 1))); @@ -231,7 +231,7 @@ public class QueryRescorerIT extends ESIntegTestCase { builder.putArray("index.analysis.filter.synonym.synonyms", "ave => ave, avenue", "street => str, street"); XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("analyzer", "whitespace").field("search_analyzer", "synonym") + .startObject("field1").field("type", "text").field("analyzer", "whitespace").field("search_analyzer", "synonym") .endObject().endObject().endObject().endObject(); assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", mapping).setSettings(builder.put("index.number_of_shards", 1))); @@ -301,7 +301,7 @@ public class QueryRescorerIT extends ESIntegTestCase { builder.putArray("index.analysis.filter.synonym.synonyms", "ave => ave, avenue", "street => str, street"); XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("field1").field("type", "string").field("analyzer", "whitespace").field("search_analyzer", "synonym") + .startObject("field1").field("type", "text").field("analyzer", "whitespace").field("search_analyzer", "synonym") .endObject().endObject().endObject().endObject(); assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", mapping).setSettings(builder.put("index.number_of_shards", 1))); @@ -494,7 +494,7 @@ public class QueryRescorerIT extends ESIntegTestCase { .addMapping( "type1", jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1") - .field("analyzer", "whitespace").field("type", "string").endObject().endObject().endObject().endObject()) + .field("analyzer", "whitespace").field("type", "text").endObject().endObject().endObject().endObject()) ); ensureGreen(); client().prepareIndex("test", "type1", "1").setSource("field1", "the quick brown fox").execute().actionGet(); @@ -731,7 +731,7 @@ public class QueryRescorerIT extends ESIntegTestCase { .addMapping( "type1", jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1") - .field("analyzer", analyzer).field("type", "string").endObject().endObject().endObject().endObject()) + .field("analyzer", analyzer).field("type", "text").endObject().endObject().endObject().endObject()) .setSettings(builder)); int numDocs = randomIntBetween(100, 150); IndexRequestBuilder[] docs = new IndexRequestBuilder[numDocs]; diff --git a/core/src/test/java/org/elasticsearch/search/highlight/HighlightBuilderTests.java b/core/src/test/java/org/elasticsearch/search/highlight/HighlightBuilderTests.java index cc0afb83874..6d165f2d37c 100644 --- a/core/src/test/java/org/elasticsearch/search/highlight/HighlightBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/highlight/HighlightBuilderTests.java @@ -39,7 +39,7 @@ import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.mapper.ContentPath; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.query.IdsQueryBuilder; import org.elasticsearch.index.query.MatchAllQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; @@ -280,7 +280,7 @@ public class HighlightBuilderTests extends ESTestCase { QueryShardContext mockShardContext = new QueryShardContext(idxSettings, null, null, null, null, null, indicesQueriesRegistry) { @Override public MappedFieldType fieldMapper(String name) { - StringFieldMapper.Builder builder = new StringFieldMapper.Builder(name); + TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); return builder.build(new Mapper.BuilderContext(idxSettings.getSettings(), new ContentPath(1))).fieldType(); } }; diff --git a/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java b/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java index 25dd81aecd8..e2649b4ab94 100644 --- a/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java @@ -92,7 +92,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { mappings.startObject("type") .startObject("properties") .startObject("text") - .field("type", "string") + .field("type", "text") .field("analyzer", "keyword") .field("index_options", "offsets") .field("term_vector", "with_positions_offsets") @@ -126,7 +126,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { .field("ignore_above", 1) .endObject() .startObject("text") - .field("type", "string") + .field("type", "text") .field("analyzer", "keyword") .field("index_options", "offsets") .field("term_vector", "with_positions_offsets") @@ -173,13 +173,13 @@ public class HighlighterSearchIT extends ESIntegTestCase { .startObject("unstored_field") .field("index_options", "offsets") .field("term_vector", "with_positions_offsets") - .field("type", "string") + .field("type", "text") .field("store", false) .endObject() .startObject("text") .field("index_options", "offsets") .field("term_vector", "with_positions_offsets") - .field("type", "string") + .field("type", "text") .field("store", true) .endObject() .endObject() @@ -205,7 +205,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { // see #3486 public void testHighTermFrequencyDoc() throws IOException { assertAcked(prepareCreate("test") - .addMapping("test", "name", "type=string,term_vector=with_positions_offsets,store=" + randomBoolean())); + .addMapping("test", "name", "type=text,term_vector=with_positions_offsets,store=" + randomBoolean())); ensureYellow(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 6000; i++) { @@ -229,13 +229,13 @@ public class HighlighterSearchIT extends ESIntegTestCase { .startObject("name") .startObject("fields") .startObject("autocomplete") - .field("type", "string") + .field("type", "text") .field("analyzer", "autocomplete") .field("search_analyzer", "search_autocomplete") .field("term_vector", "with_positions_offsets") .endObject() .endObject() - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject()) @@ -280,7 +280,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { * query. We cut off and extract terms if there are more than 16 terms in the query */ assertAcked(prepareCreate("test") - .addMapping("test", "body", "type=string,analyzer=custom_analyzer,search_analyzer=custom_analyzer,term_vector=with_positions_offsets") + .addMapping("test", "body", "type=text,analyzer=custom_analyzer,search_analyzer=custom_analyzer,term_vector=with_positions_offsets") .setSettings( settingsBuilder().put(indexSettings()) .put("analysis.filter.wordDelimiter.type", "word_delimiter") @@ -320,8 +320,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testNgramHighlightingPreLucene42() throws IOException { assertAcked(prepareCreate("test") .addMapping("test", - "name", "type=string,analyzer=name_index_analyzer,search_analyzer=name_search_analyzer," + randomStoreField() + "term_vector=with_positions_offsets", - "name2", "type=string,analyzer=name2_index_analyzer,search_analyzer=name_search_analyzer," + randomStoreField() + "term_vector=with_positions_offsets") + "name", "type=text,analyzer=name_index_analyzer,search_analyzer=name_search_analyzer," + randomStoreField() + "term_vector=with_positions_offsets", + "name2", "type=text,analyzer=name2_index_analyzer,search_analyzer=name_search_analyzer," + randomStoreField() + "term_vector=with_positions_offsets") .setSettings(settingsBuilder() .put(indexSettings()) .put("analysis.filter.my_ngram.max_gram", 20) @@ -392,8 +392,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testNgramHighlighting() throws IOException { assertAcked(prepareCreate("test") .addMapping("test", - "name", "type=string,analyzer=name_index_analyzer,search_analyzer=name_search_analyzer,term_vector=with_positions_offsets", - "name2", "type=string,analyzer=name2_index_analyzer,search_analyzer=name_search_analyzer,term_vector=with_positions_offsets") + "name", "type=text,analyzer=name_index_analyzer,search_analyzer=name_search_analyzer,term_vector=with_positions_offsets", + "name2", "type=text,analyzer=name2_index_analyzer,search_analyzer=name_search_analyzer,term_vector=with_positions_offsets") .setSettings(settingsBuilder() .put(indexSettings()) .put("analysis.filter.my_ngram.max_gram", 20) @@ -437,8 +437,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testEnsureNoNegativeOffsets() throws Exception { assertAcked(prepareCreate("test") .addMapping("type1", - "no_long_term", "type=string,term_vector=with_positions_offsets", - "long_term", "type=string,term_vector=with_positions_offsets")); + "no_long_term", "type=text,term_vector=with_positions_offsets", + "long_term", "type=text,term_vector=with_positions_offsets")); ensureYellow(); client().prepareIndex("test", "type1", "1") @@ -471,8 +471,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { assertAcked(prepareCreate("test") .addMapping("type1", 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").field("type", "string").field("store", false).field("term_vector", "no").endObject() - .startObject("attachments").startObject("properties").startObject("body").field("type", "string").field("store", false).field("term_vector", "no").endObject().endObject().endObject() + .startObject("title").field("type", "text").field("store", false).field("term_vector", "no").endObject() + .startObject("attachments").startObject("properties").startObject("body").field("type", "text").field("store", false).field("term_vector", "no").endObject().endObject().endObject() .endObject().endObject().endObject())); ensureYellow(); @@ -510,8 +510,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") // we don't store title, now lets see if it works... - .startObject("title").field("type", "string").field("store", false).field("term_vector", "with_positions_offsets").endObject() - .startObject("attachments").startObject("properties").startObject("body").field("type", "string").field("store", false).field("term_vector", "with_positions_offsets").endObject().endObject().endObject() + .startObject("title").field("type", "text").field("store", false).field("term_vector", "with_positions_offsets").endObject() + .startObject("attachments").startObject("properties").startObject("body").field("type", "text").field("store", false).field("term_vector", "with_positions_offsets").endObject().endObject().endObject() .endObject().endObject().endObject())); ensureYellow(); @@ -549,8 +549,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") // we don't store title, now lets see if it works... - .startObject("title").field("type", "string").field("store", false).field("index_options", "offsets").endObject() - .startObject("attachments").startObject("properties").startObject("body").field("type", "string").field("store", false).field("index_options", "offsets").endObject().endObject().endObject() + .startObject("title").field("type", "text").field("store", false).field("index_options", "offsets").endObject() + .startObject("attachments").startObject("properties").startObject("body").field("type", "text").field("store", false).field("index_options", "offsets").endObject().endObject().endObject() .endObject().endObject().endObject())); ensureYellow(); @@ -598,7 +598,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testHighlightIssue1994() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "title", "type=string,store=false", "titleTV", "type=string,store=false,term_vector=with_positions_offsets")); + .addMapping("type1", "title", "type=text,store=false", "titleTV", "type=text,store=false,term_vector=with_positions_offsets")); ensureYellow(); indexRandom(false, client().prepareIndex("test", "type1", "1") @@ -654,9 +654,9 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testHighlightingOnWildcardFields() throws Exception { assertAcked(prepareCreate("test") .addMapping("type1", - "field-postings", "type=string,index_options=offsets", - "field-fvh", "type=string,term_vector=with_positions_offsets", - "field-plain", "type=string")); + "field-postings", "type=text,index_options=offsets", + "field-fvh", "type=text,term_vector=with_positions_offsets", + "field-plain", "type=text")); ensureGreen(); client().prepareIndex("test", "type1") @@ -683,7 +683,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { .addMapping("type1", jsonBuilder().startObject().startObject("type1") .startObject("_source").field("enabled", false).endObject() .startObject("properties") - .startObject("field1").field("type", "string").field("store", true).field("index_options", "offsets") + .startObject("field1").field("type", "text").field("store", true).field("index_options", "offsets") .field("term_vector", "with_positions_offsets").endObject() .endObject().endObject().endObject())); @@ -913,26 +913,26 @@ public class HighlighterSearchIT extends ESIntegTestCase { .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1") .startObject("properties") .startObject("foo") - .field("type", "string") + .field("type", "text") .field("termVector", "with_positions_offsets") .field("store", true) .field("analyzer", "english") .startObject("fields") .startObject("plain") - .field("type", "string") + .field("type", "text") .field("termVector", "with_positions_offsets") .field("analyzer", "standard") .endObject() .endObject() .endObject() .startObject("bar") - .field("type", "string") + .field("type", "text") .field("termVector", "with_positions_offsets") .field("store", true) .field("analyzer", "english") .startObject("fields") .startObject("plain") - .field("type", "string") + .field("type", "text") .field("termVector", "with_positions_offsets") .field("analyzer", "standard") .endObject() @@ -1103,15 +1103,15 @@ public class HighlighterSearchIT extends ESIntegTestCase { return XContentFactory.jsonBuilder().startObject().startObject("type1") .startObject("_all").field("store", true).field("termVector", "with_positions_offsets").endObject() .startObject("properties") - .startObject("field1").field("type", "string").field("termVector", "with_positions_offsets").endObject() - .startObject("field2").field("type", "string").field("termVector", "with_positions_offsets").endObject() + .startObject("field1").field("type", "text").field("termVector", "with_positions_offsets").endObject() + .startObject("field2").field("type", "text").field("termVector", "with_positions_offsets").endObject() .endObject() .endObject().endObject(); } public void testSameContent() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "title", "type=string,store=true,term_vector=with_positions_offsets")); + .addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets")); ensureYellow(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1133,7 +1133,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testFastVectorHighlighterOffsetParameter() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "title", "type=string,store=true,term_vector=with_positions_offsets").get()); + .addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets").get()); ensureYellow(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1156,7 +1156,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testEscapeHtml() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "title", "type=string,store=true")); + .addMapping("type1", "title", "type=text,store=true")); ensureYellow(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1178,7 +1178,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testEscapeHtmlVector() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "title", "type=string,store=true,term_vector=with_positions_offsets")); + .addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets")); ensureYellow(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1201,9 +1201,9 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testMultiMapperVectorWithStore() throws Exception { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("title").field("type", "string").field("store", true).field("term_vector", "with_positions_offsets").field("analyzer", "classic") + .startObject("title").field("type", "text").field("store", true).field("term_vector", "with_positions_offsets").field("analyzer", "classic") .startObject("fields") - .startObject("key").field("type", "string").field("store", true).field("term_vector", "with_positions_offsets").field("analyzer", "whitespace").endObject() + .startObject("key").field("type", "text").field("store", true).field("term_vector", "with_positions_offsets").field("analyzer", "whitespace").endObject() .endObject().endObject() .endObject().endObject().endObject())); ensureGreen(); @@ -1229,9 +1229,9 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testMultiMapperVectorFromSource() throws Exception { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("title").field("type", "string").field("store", false).field("term_vector", "with_positions_offsets").field("analyzer", "classic") + .startObject("title").field("type", "text").field("store", false).field("term_vector", "with_positions_offsets").field("analyzer", "classic") .startObject("fields") - .startObject("key").field("type", "string").field("store", false).field("term_vector", "with_positions_offsets").field("analyzer", "whitespace").endObject() + .startObject("key").field("type", "text").field("store", false).field("term_vector", "with_positions_offsets").field("analyzer", "whitespace").endObject() .endObject().endObject() .endObject().endObject().endObject())); ensureGreen(); @@ -1259,9 +1259,9 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testMultiMapperNoVectorWithStore() throws Exception { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("title").field("type", "string").field("store", true).field("term_vector", "no").field("analyzer", "classic") + .startObject("title").field("type", "text").field("store", true).field("term_vector", "no").field("analyzer", "classic") .startObject("fields") - .startObject("key").field("type", "string").field("store", true).field("term_vector", "no").field("analyzer", "whitespace").endObject() + .startObject("key").field("type", "text").field("store", true).field("term_vector", "no").field("analyzer", "whitespace").endObject() .endObject().endObject() .endObject().endObject().endObject())); @@ -1289,9 +1289,9 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testMultiMapperNoVectorFromSource() throws Exception { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("title").field("type", "string").field("store", false).field("term_vector", "no").field("analyzer", "classic") + .startObject("title").field("type", "text").field("store", false).field("term_vector", "no").field("analyzer", "classic") .startObject("fields") - .startObject("key").field("type", "string").field("store", false).field("term_vector", "no").field("analyzer", "whitespace").endObject() + .startObject("key").field("type", "text").field("store", false).field("term_vector", "no").field("analyzer", "whitespace").endObject() .endObject().endObject() .endObject().endObject().endObject())); ensureGreen(); @@ -1317,7 +1317,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testFastVectorHighlighterShouldFailIfNoTermVectors() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "title", "type=string,store=true,term_vector=no")); + .addMapping("type1", "title", "type=text,store=true,term_vector=no")); ensureGreen(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1347,7 +1347,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testDisableFastVectorHighlighter() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "title", "type=string,store=true,term_vector=with_positions_offsets,analyzer=classic")); + .addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets,analyzer=classic")); ensureGreen(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1392,7 +1392,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testFSHHighlightAllMvFragments() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "tags", "type=string,term_vector=with_positions_offsets")); + .addMapping("type1", "tags", "type=text,term_vector=with_positions_offsets")); ensureGreen(); client().prepareIndex("test", "type1", "1") .setSource("tags", new String[]{ @@ -1486,8 +1486,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { assertAcked(prepareCreate("test").setSettings(builder.build()).addMapping("type1", type1TermVectorMapping()) .addMapping("type2", "_all", "store=true,termVector=with_positions_offsets", - "field4", "type=string,term_vector=with_positions_offsets,analyzer=synonym", - "field3", "type=string,analyzer=synonym")); + "field4", "type=text,term_vector=with_positions_offsets,analyzer=synonym", + "field3", "type=text,analyzer=synonym")); ensureGreen(); client().prepareIndex("test", "type1", "0") @@ -1548,7 +1548,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testPlainHighlightDifferentFragmenter() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "tags", "type=string")); + .addMapping("type1", "tags", "type=text")); ensureGreen(); client().prepareIndex("test", "type1", "1") .setSource(jsonBuilder().startObject().field("tags", @@ -1603,7 +1603,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testFastVectorHighlighterMultipleFields() { assertAcked(prepareCreate("test") - .addMapping("type1", "field1", "type=string,term_vector=with_positions_offsets", "field2", "type=string,term_vector=with_positions_offsets")); + .addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets", "field2", "type=text,term_vector=with_positions_offsets")); ensureGreen(); index("test", "type1", "1", "field1", "The quick brown fox", "field2", "The slow brown fox"); @@ -1622,7 +1622,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testMissingStoredField() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "highlight_field", "type=string,store=true")); + .addMapping("type1", "highlight_field", "type=text,store=true")); ensureGreen(); client().prepareIndex("test", "type1", "1") .setSource(jsonBuilder().startObject() @@ -1642,7 +1642,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { // Issue #3211 public void testNumericHighlighting() throws Exception { assertAcked(prepareCreate("test") - .addMapping("test", "text", "type=string,index=analyzed", + .addMapping("test", "text", "type=text", "byte", "type=byte", "short", "type=short", "int", "type=integer", "long", "type=long", "float", "type=float", "double", "type=double")); ensureGreen(); @@ -1670,7 +1670,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { .put("analysis.analyzer.my_analyzer.type", "pattern") .put("analysis.analyzer.my_analyzer.pattern", "\\s+") .build()) - .addMapping("type", "text", "type=string,analyzer=my_analyzer")); + .addMapping("type", "text", "type=text,analyzer=my_analyzer")); ensureGreen(); client().prepareIndex("test", "type", "1") .setSource("text", "elasticsearch test").get(); @@ -1685,7 +1685,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testHighlightUsesHighlightQuery() throws IOException { assertAcked(prepareCreate("test") - .addMapping("type1", "text", "type=string," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets")); + .addMapping("type1", "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets")); ensureGreen(); index("test", "type1", "1", "text", "Testing the highlight query feature"); @@ -1751,7 +1751,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testHighlightNoMatchSize() throws IOException { assertAcked(prepareCreate("test") - .addMapping("type1", "text", "type=string," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets")); + .addMapping("type1", "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets")); ensureGreen(); String text = "I am pretty long so some of me should get cut off. Second sentence"; @@ -1859,7 +1859,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException { assertAcked(prepareCreate("test") - .addMapping("type1", "text", "type=string," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets")); + .addMapping("type1", "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets")); ensureGreen(); String text1 = "I am pretty long so some of me should get cut off. We'll see how that goes."; @@ -1971,7 +1971,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testHighlightNoMatchSizeNumberOfFragments() throws IOException { assertAcked(prepareCreate("test") - .addMapping("type1", "text", "type=string," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets")); + .addMapping("type1", "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets")); ensureGreen(); String text1 = "This is the first sentence. This is the second sentence." + HighlightUtils.PARAGRAPH_SEPARATOR; @@ -2138,8 +2138,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1") .startObject("_all").field("store", true).field("index_options", "offsets").endObject() .startObject("properties") - .startObject("field1").field("type", "string").field("index_options", "offsets").field("term_vector", "with_positions_offsets").endObject() - .startObject("field2").field("type", "string").field("index_options", "offsets").field("term_vector", "with_positions_offsets").endObject() + .startObject("field1").field("type", "text").field("index_options", "offsets").field("term_vector", "with_positions_offsets").endObject() + .startObject("field2").field("type", "text").field("index_options", "offsets").field("term_vector", "with_positions_offsets").endObject() .endObject() .endObject().endObject(); assertAcked(prepareCreate("test").addMapping("type1", mapping)); @@ -2203,7 +2203,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testPostingsHighlighterEscapeHtml() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "title", "type=string," + randomStoreField() + "index_options=offsets")); + .addMapping("type1", "title", "type=text," + randomStoreField() + "index_options=offsets")); ensureYellow(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -2226,9 +2226,9 @@ public class HighlighterSearchIT extends ESIntegTestCase { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1") .startObject("properties") - .startObject("title").field("type", "string").field("store", true).field("index_options", "offsets").field("analyzer", "classic") + .startObject("title").field("type", "text").field("store", true).field("index_options", "offsets").field("analyzer", "classic") .startObject("fields") - .startObject("key").field("type", "string").field("store", true).field("index_options", "offsets").field("analyzer", "whitespace").endObject() + .startObject("key").field("type", "text").field("store", true).field("index_options", "offsets").field("analyzer", "whitespace").endObject() .endObject().endObject() .endObject().endObject().endObject())); ensureGreen(); @@ -2258,9 +2258,9 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testPostingsHighlighterMultiMapperFromSource() throws Exception { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("title").field("type", "string").field("store", false).field("index_options", "offsets").field("analyzer", "classic") + .startObject("title").field("type", "text").field("store", false).field("index_options", "offsets").field("analyzer", "classic") .startObject("fields") - .startObject("key").field("type", "string").field("store", false).field("index_options", "offsets").field("analyzer", "whitespace").endObject() + .startObject("key").field("type", "text").field("store", false).field("index_options", "offsets").field("analyzer", "whitespace").endObject() .endObject().endObject() .endObject().endObject().endObject())); ensureGreen(); @@ -2287,7 +2287,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testPostingsHighlighterShouldFailIfNoOffsets() throws Exception { assertAcked(prepareCreate("test") .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("title").field("type", "string").field("store", true).field("index_options", "docs").endObject() + .startObject("title").field("type", "text").field("store", true).field("index_options", "docs").endObject() .endObject().endObject().endObject())); ensureGreen(); @@ -2357,8 +2357,8 @@ public class HighlighterSearchIT extends ESIntegTestCase { private static XContentBuilder type1PostingsffsetsMapping() throws IOException { return XContentFactory.jsonBuilder().startObject().startObject("type1") .startObject("properties") - .startObject("field1").field("type", "string").field("index_options", "offsets").endObject() - .startObject("field2").field("type", "string").field("index_options", "offsets").endObject() + .startObject("field1").field("type", "text").field("index_options", "offsets").endObject() + .startObject("field2").field("type", "text").field("index_options", "offsets").endObject() .endObject() .endObject().endObject(); } @@ -2552,7 +2552,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testDoesNotHighlightTypeName() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("typename").startObject("properties") - .startObject("foo").field("type", "string") + .startObject("foo").field("type", "text") .field("index_options", "offsets") .field("term_vector", "with_positions_offsets") .endObject().endObject().endObject().endObject(); @@ -2570,7 +2570,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { public void testDoesNotHighlightAliasFilters() throws Exception { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("typename").startObject("properties") - .startObject("foo").field("type", "string") + .startObject("foo").field("type", "text") .field("index_options", "offsets") .field("term_vector", "with_positions_offsets") .endObject().endObject().endObject().endObject(); 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 be0fd8a2d4e..fad1cc3a0ef 100644 --- a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java +++ b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java @@ -84,12 +84,12 @@ public class InnerHitsIT extends ESIntegTestCase { .field("type", "nested") .startObject("properties") .startObject("message") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() .startObject("title") - .field("type", "string") + .field("type", "text") .endObject() .endObject().endObject().endObject())); @@ -285,8 +285,8 @@ public class InnerHitsIT extends ESIntegTestCase { public void testSimpleParentChild() throws Exception { assertAcked(prepareCreate("articles") - .addMapping("article", "title", "type=string") - .addMapping("comment", "_parent", "type=article", "message", "type=string") + .addMapping("article", "title", "type=text") + .addMapping("comment", "_parent", "type=article", "message", "type=text") ); List requests = new ArrayList<>(); @@ -506,8 +506,8 @@ public class InnerHitsIT extends ESIntegTestCase { public void testInnerHitsOnHasParent() throws Exception { assertAcked(prepareCreate("stack") - .addMapping("question", "body", "type=string") - .addMapping("answer", "_parent", "type=question", "body", "type=string") + .addMapping("question", "body", "type=text") + .addMapping("answer", "_parent", "type=question", "body", "type=text") ); List requests = new ArrayList<>(); requests.add(client().prepareIndex("stack", "question", "1").setSource("body", "I'm using HTTPS + Basic authentication to protect a resource. How can I throttle authentication attempts to protect against brute force attacks?")); @@ -544,9 +544,9 @@ public class InnerHitsIT extends ESIntegTestCase { public void testParentChildMultipleLayers() throws Exception { assertAcked(prepareCreate("articles") - .addMapping("article", "title", "type=string") - .addMapping("comment", "_parent", "type=article", "message", "type=string") - .addMapping("remark", "_parent", "type=comment", "message", "type=string") + .addMapping("article", "title", "type=text") + .addMapping("comment", "_parent", "type=article", "message", "type=text") + .addMapping("remark", "_parent", "type=comment", "message", "type=text") ); List requests = new ArrayList<>(); @@ -617,18 +617,18 @@ public class InnerHitsIT extends ESIntegTestCase { .field("type", "nested") .startObject("properties") .startObject("message") - .field("type", "string") + .field("type", "text") .endObject() .startObject("remarks") .field("type", "nested") .startObject("properties") - .startObject("message").field("type", "string").endObject() + .startObject("message").field("type", "text").endObject() .endObject() .endObject() .endObject() .endObject() .startObject("title") - .field("type", "string") + .field("type", "text") .endObject() .endObject().endObject().endObject())); @@ -731,7 +731,7 @@ public class InnerHitsIT extends ESIntegTestCase { // Issue #9723 public void testNestedDefinedAsObject() throws Exception { - assertAcked(prepareCreate("articles").addMapping("article", "comments", "type=nested", "title", "type=string")); + assertAcked(prepareCreate("articles").addMapping("article", "comments", "type=nested", "title", "type=text")); List requests = new ArrayList<>(); requests.add(client().prepareIndex("articles", "article", "1").setSource(jsonBuilder().startObject() @@ -762,7 +762,7 @@ public class InnerHitsIT extends ESIntegTestCase { .startObject("comments") .field("type", "nested") .startObject("properties") - .startObject("message").field("type", "string").field("store", true).endObject() + .startObject("message").field("type", "text").field("store", true).endObject() .endObject() .endObject() .endObject() @@ -800,7 +800,7 @@ public class InnerHitsIT extends ESIntegTestCase { .startObject("comments") .field("type", "nested") .startObject("properties") - .startObject("message").field("type", "string").field("store", true).endObject() + .startObject("message").field("type", "text").field("store", true).endObject() .endObject() .endObject() .endObject() @@ -838,7 +838,7 @@ public class InnerHitsIT extends ESIntegTestCase { .startObject("comments") .field("type", "nested") .startObject("properties") - .startObject("message").field("type", "string").field("store", true).endObject() + .startObject("message").field("type", "text").field("store", true).endObject() .endObject() .endObject() .endObject() @@ -877,7 +877,7 @@ public class InnerHitsIT extends ESIntegTestCase { .startObject("comments") .field("type", "nested") .startObject("properties") - .startObject("message").field("type", "string").field("store", true).endObject() + .startObject("message").field("type", "text").field("store", true).endObject() .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java b/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java index 40608134fc6..8f0ef3c0fbe 100644 --- a/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java +++ b/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java @@ -65,7 +65,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { logger.info("Creating index test"); assertAcked(prepareCreate("test").addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("text").field("type", "string").endObject() + .startObject("text").field("type", "text").endObject() .endObject().endObject().endObject())); logger.info("Running Cluster Health"); @@ -105,7 +105,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { logger.info("Creating index test"); assertAcked(prepareCreate("test").addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("text").field("type", "string").endObject() + .startObject("text").field("type", "text").endObject() .endObject().endObject().endObject())); logger.info("Creating aliases alias release"); client().admin().indices().aliases(indexAliasesRequest().addAlias("release", termQuery("text", "release"), "test")).actionGet(); @@ -218,7 +218,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { .startObject().startObject("type") .startObject("properties") .startObject("int_value").field("type", randomFrom(numericTypes)).endObject() - .startObject("string_value").field("type", "string").endObject() + .startObject("string_value").field("type", "text").endObject() .endObject() .endObject().endObject()).execute().actionGet(); ensureGreen(); @@ -275,7 +275,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { logger.info("Creating index test"); assertAcked(prepareCreate("test").addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("text").field("type", "string").endObject() + .startObject("text").field("type", "text").endObject() .endObject().endObject().endObject())); logger.info("Running Cluster Health"); @@ -311,7 +311,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { logger.info("Creating index test"); assertAcked(prepareCreate("test").addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("text").field("type", "string").endObject() + .startObject("text").field("type", "text").endObject() .endObject().endObject().endObject())); logger.info("Running Cluster Health"); @@ -336,7 +336,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { CreateIndexRequestBuilder createRequestBuilder = prepareCreate("test"); for (int i = 0; i < numOfTypes; i++) { createRequestBuilder.addMapping("type" + i, jsonBuilder().startObject().startObject("type" + i).startObject("properties") - .startObject("text").field("type", "string").endObject() + .startObject("text").field("type", "text").endObject() .endObject().endObject().endObject()); } assertAcked(createRequestBuilder); @@ -365,7 +365,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { public void testMoreLikeThisMultiValueFields() throws Exception { logger.info("Creating the index ..."); assertAcked(prepareCreate("test") - .addMapping("type1", "text", "type=string,analyzer=keyword") + .addMapping("type1", "text", "type=text,analyzer=keyword") .setSettings(SETTING_NUMBER_OF_SHARDS, 1)); ensureGreen(); @@ -397,7 +397,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { public void testMinimumShouldMatch() throws ExecutionException, InterruptedException { logger.info("Creating the index ..."); assertAcked(prepareCreate("test") - .addMapping("type1", "text", "type=string,analyzer=whitespace") + .addMapping("type1", "text", "type=text,analyzer=whitespace") .setSettings(SETTING_NUMBER_OF_SHARDS, 1)); ensureGreen(); @@ -460,7 +460,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { public void testMoreLikeThisMalformedArtificialDocs() throws Exception { logger.info("Creating the index ..."); assertAcked(prepareCreate("test") - .addMapping("type1", "text", "type=string,analyzer=whitespace", "date", "type=date")); + .addMapping("type1", "text", "type=text,analyzer=whitespace", "date", "type=date")); ensureGreen("test"); logger.info("Creating an index with a single document ..."); @@ -572,7 +572,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { public void testSelectFields() throws IOException, ExecutionException, InterruptedException { assertAcked(prepareCreate("test") - .addMapping("type1", "text", "type=string,analyzer=whitespace", "text1", "type=string,analyzer=whitespace")); + .addMapping("type1", "text", "type=text,analyzer=whitespace", "text1", "type=text,analyzer=whitespace")); ensureGreen("test"); indexRandom(true, client().prepareIndex("test", "type1", "1").setSource(jsonBuilder() 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 f9bae6a1c90..2f932604145 100644 --- a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java @@ -238,7 +238,7 @@ public class SimpleNestedIT extends ESIntegTestCase { .setSettings(settingsBuilder().put(indexSettings()).put("index.refresh_interval", -1).build()) .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") .startObject("field1") - .field("type", "string") + .field("type", "text") .endObject() .startObject("nested1") .field("type", "nested") @@ -867,17 +867,17 @@ public class SimpleNestedIT extends ESIntegTestCase { // Issue #9305 public void testNestedSortingWithNestedFilterAsFilter() throws Exception { assertAcked(prepareCreate("test").addMapping("type", jsonBuilder().startObject().startObject("properties") - .startObject("officelocation").field("type", "string").endObject() + .startObject("officelocation").field("type", "text").endObject() .startObject("users") .field("type", "nested") .startObject("properties") - .startObject("first").field("type", "string").endObject() - .startObject("last").field("type", "string").endObject() + .startObject("first").field("type", "text").endObject() + .startObject("last").field("type", "text").endObject() .startObject("workstations") .field("type", "nested") .startObject("properties") - .startObject("stationid").field("type", "string").endObject() - .startObject("phoneid").field("type", "string").endObject() + .startObject("stationid").field("type", "text").endObject() + .startObject("phoneid").field("type", "text").endObject() .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/query/ExistsIT.java b/core/src/test/java/org/elasticsearch/search/query/ExistsIT.java index a508883e53a..6b226d2c569 100644 --- a/core/src/test/java/org/elasticsearch/search/query/ExistsIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/ExistsIT.java @@ -63,19 +63,19 @@ public class ExistsIT extends ESIntegTestCase { .endObject() .startObject("properties") .startObject("foo") - .field("type", "string") + .field("type", "text") .endObject() .startObject("bar") .field("type", "object") .startObject("properties") .startObject("foo") - .field("type", "string") + .field("type", "text") .endObject() .startObject("bar") .field("type", "object") .startObject("properties") .startObject("bar") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java index 6ad4d990dee..f65b17288ae 100644 --- a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java @@ -146,21 +146,21 @@ public class MultiMatchQueryIT extends ESIntegTestCase { return XContentFactory.jsonBuilder().startObject().startObject("test") .startObject("properties") .startObject("full_name") - .field("type", "string") + .field("type", "text") .field("copy_to", "full_name_phrase") .field("analyzer", "perfect_match") .endObject() .startObject("category") - .field("type", "string") + .field("type", "text") .field("analyzer", "category") .endObject() .startObject("first_name") - .field("type", "string") + .field("type", "text") .field("omit_norms", "true") .field("copy_to", "first_name_phrase") .endObject() .startObject("last_name") - .field("type", "string") + .field("type", "text") .field("omit_norms", "true") .field("copy_to", "last_name_phrase") .endObject() 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 2f856483cff..1f4919977bd 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java @@ -191,7 +191,7 @@ public class SearchQueryIT extends ESIntegTestCase { public void testIndexOptions() throws Exception { assertAcked(prepareCreate("test") - .addMapping("type1", "field1", "type=string,index_options=docs")); + .addMapping("type1", "field1", "type=text,index_options=docs")); indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("field1", "quick brown fox", "field2", "quick brown fox"), client().prepareIndex("test", "type1", "2").setSource("field1", "quick lazy huge brown fox", "field2", "quick lazy huge brown fox")); @@ -288,7 +288,7 @@ public class SearchQueryIT extends ESIntegTestCase { public void testCommonTermsQueryOnAllField() throws Exception { client().admin().indices().prepareCreate("test") - .addMapping("type1", "message", "type=string", "comment", "type=string,boost=5.0") + .addMapping("type1", "message", "type=text", "comment", "type=text,boost=5.0") .setSettings(SETTING_NUMBER_OF_SHARDS, 1).get(); indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("message", "test message", "comment", "whatever"), client().prepareIndex("test", "type1", "2").setSource("message", "hello world", "comment", "test comment")); @@ -302,7 +302,7 @@ public class SearchQueryIT extends ESIntegTestCase { public void testCommonTermsQuery() throws Exception { client().admin().indices().prepareCreate("test") - .addMapping("type1", "field1", "type=string,analyzer=whitespace") + .addMapping("type1", "field1", "type=text,analyzer=whitespace") .setSettings(SETTING_NUMBER_OF_SHARDS, 1).get(); indexRandom(true, client().prepareIndex("test", "type1", "3").setSource("field1", "quick lazy huge brown pidgin", "field2", "the quick lazy huge brown fox jumps over the tree"), client().prepareIndex("test", "type1", "1").setSource("field1", "the quick brown fox"), @@ -390,7 +390,7 @@ public class SearchQueryIT extends ESIntegTestCase { .put("index.analysis.analyzer.syns.tokenizer","whitespace") .put("index.analysis.analyzer.syns.filter","syns") ) - .addMapping("type1", "field1", "type=string,analyzer=syns", "field2", "type=string,analyzer=syns")); + .addMapping("type1", "field1", "type=text,analyzer=syns", "field2", "type=text,analyzer=syns")); indexRandom(true, client().prepareIndex("test", "type1", "3").setSource("field1", "quick lazy huge brown pidgin", "field2", "the quick lazy huge brown fox jumps over the tree"), client().prepareIndex("test", "type1", "1").setSource("field1", "the quick brown fox"), @@ -847,7 +847,7 @@ public class SearchQueryIT extends ESIntegTestCase { public void testMatchQueryZeroTermsQuery() { assertAcked(prepareCreate("test") - .addMapping("type1", "field1", "type=string,analyzer=classic", "field2", "type=string,analyzer=classic")); + .addMapping("type1", "field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic")); client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get(); client().prepareIndex("test", "type1", "2").setSource("field1", "value2").get(); refresh(); @@ -871,7 +871,7 @@ public class SearchQueryIT extends ESIntegTestCase { public void testMultiMatchQueryZeroTermsQuery() { assertAcked(prepareCreate("test") - .addMapping("type1", "field1", "type=string,analyzer=classic", "field2", "type=string,analyzer=classic")); + .addMapping("type1", "field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic")); client().prepareIndex("test", "type1", "1").setSource("field1", "value1", "field2", "value2").get(); client().prepareIndex("test", "type1", "2").setSource("field1", "value3", "field2", "value4").get(); refresh(); @@ -1066,7 +1066,7 @@ public class SearchQueryIT extends ESIntegTestCase { } public void testEmptytermsQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "term", "type=string")); + assertAcked(prepareCreate("test").addMapping("type", "term", "type=text")); indexRandom(true, client().prepareIndex("test", "type", "1").setSource("term", "1"), client().prepareIndex("test", "type", "2").setSource("term", "2"), @@ -1082,7 +1082,7 @@ public class SearchQueryIT extends ESIntegTestCase { } public void testTermsQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "str", "type=string", "lng", "type=long", "dbl", "type=double")); + assertAcked(prepareCreate("test").addMapping("type", "str", "type=text", "lng", "type=long", "dbl", "type=double")); indexRandom(true, client().prepareIndex("test", "type", "1").setSource("str", "1", "lng", 1L, "dbl", 1.0d), @@ -1149,12 +1149,12 @@ public class SearchQueryIT extends ESIntegTestCase { } public void testTermsLookupFilter() throws Exception { - assertAcked(prepareCreate("lookup").addMapping("type", "terms","type=string", "other", "type=string")); + assertAcked(prepareCreate("lookup").addMapping("type", "terms","type=text", "other", "type=text")); assertAcked(prepareCreate("lookup2").addMapping("type", jsonBuilder().startObject().startObject("type").startObject("properties") - .startObject("arr").startObject("properties").startObject("term").field("type", "string") + .startObject("arr").startObject("properties").startObject("term").field("type", "text") .endObject().endObject().endObject().endObject().endObject().endObject())); - assertAcked(prepareCreate("test").addMapping("type", "term", "type=string")); + assertAcked(prepareCreate("test").addMapping("type", "term", "type=text")); indexRandom(true, client().prepareIndex("lookup", "type", "1").setSource("terms", new String[]{"1", "3"}), @@ -1587,7 +1587,7 @@ public class SearchQueryIT extends ESIntegTestCase { .putArray("index.analysis.analyzer.search.filter", "lowercase", "synonym") .put("index.analysis.filter.synonym.type", "synonym") .putArray("index.analysis.filter.synonym.synonyms", "fast, quick")); - assertAcked(builder.addMapping("test", "text", "type=string,analyzer=index,search_analyzer=search")); + assertAcked(builder.addMapping("test", "text", "type=text,analyzer=index,search_analyzer=search")); client().prepareIndex("test", "test", "1").setSource("text", "quick brown fox").get(); refresh(); @@ -1617,7 +1617,7 @@ public class SearchQueryIT extends ESIntegTestCase { .putArray("index.analysis.analyzer.search.filter", "lowercase", "keyword_repeat", "porterStem", "unique_stem") .put("index.analysis.filter.unique_stem.type", "unique") .put("index.analysis.filter.unique_stem.only_on_same_position", true)); - assertAcked(builder.addMapping("test", "text", "type=string,analyzer=index,search_analyzer=search")); + assertAcked(builder.addMapping("test", "text", "type=text,analyzer=index,search_analyzer=search")); client().prepareIndex("test", "test", "1").setSource("text", "the fox runs across the street").get(); refresh(); @@ -1641,7 +1641,7 @@ public class SearchQueryIT extends ESIntegTestCase { .putArray("index.analysis.analyzer.search.filter", "lowercase", "synonym") .put("index.analysis.filter.synonym.type", "synonym") .putArray("index.analysis.filter.synonym.synonyms", "fast, quick")); - assertAcked(builder.addMapping("test", "text", "type=string,analyzer=index,search_analyzer=search")); + assertAcked(builder.addMapping("test", "text", "type=text,analyzer=index,search_analyzer=search")); client().prepareIndex("test", "test", "1").setSource("text", "quick brown fox").get(); refresh(); @@ -1676,7 +1676,7 @@ public class SearchQueryIT extends ESIntegTestCase { "analysis.filter.custom_word_delimiter.split_on_case_change", "false", "analysis.filter.custom_word_delimiter.split_on_numerics", "false", "analysis.filter.custom_word_delimiter.stem_english_possessive", "false") - .addMapping("type1", "field1", "type=string,analyzer=my_analyzer", "field2", "type=string,analyzer=my_analyzer")); + .addMapping("type1", "field1", "type=text,analyzer=my_analyzer", "field2", "type=text,analyzer=my_analyzer")); client().prepareIndex("test", "type1", "1").setSource("field1", "foo bar baz", "field2", "not needed").get(); refresh(); @@ -2026,7 +2026,7 @@ public class SearchQueryIT extends ESIntegTestCase { .put("index.analysis.tokenizer.my_ngram_tokenizer.min_gram", "1") .put("index.analysis.tokenizer.my_ngram_tokenizer.max_gram", "10") .putArray("index.analysis.tokenizer.my_ngram_tokenizer.token_chars", new String[0])); - assertAcked(builder.addMapping("test", "origin", "type=string,copy_to=meta", "meta", "type=string,analyzer=my_ngram_analyzer")); + assertAcked(builder.addMapping("test", "origin", "type=text,copy_to=meta", "meta", "type=text,analyzer=my_ngram_analyzer")); // we only have ngrams as the index analyzer so searches will get standard analyzer diff --git a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java index 1a585db3934..6608e341362 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java @@ -207,9 +207,9 @@ public class SimpleQueryStringIT extends ESIntegTestCase { .startObject() .startObject("type1") .startObject("properties") - .startObject("body").field("type", "string") + .startObject("body").field("type", "text") .startObject("fields") - .startObject("sub").field("type", "string") + .startObject("sub").field("type", "text") .endObject() // sub .endObject() // fields .endObject() // body @@ -329,7 +329,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase { .startObject("type1") .startObject("properties") .startObject("location") - .field("type", "string") + .field("type", "text") .field("analyzer", "german") .endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java b/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java index 0784e3e88f9..a39c618fe9d 100644 --- a/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/rescore/QueryRescoreBuilderTests.java @@ -40,6 +40,7 @@ import org.elasticsearch.index.mapper.ContentPath; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.query.MatchAllQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryParseContext; @@ -162,7 +163,7 @@ public class QueryRescoreBuilderTests extends ESTestCase { QueryShardContext mockShardContext = new QueryShardContext(idxSettings, null, null, null, null, null, indicesQueriesRegistry) { @Override public MappedFieldType fieldMapper(String name) { - StringFieldMapper.Builder builder = new StringFieldMapper.Builder(name); + TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); return builder.build(new Mapper.BuilderContext(idxSettings.getSettings(), new ContentPath(1))).fieldType(); } }; 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 ac723778abb..292f9a495dc 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", "string") + .field("type", "text") .endObject() .startObject("nested") .field("type", "nested") @@ -147,7 +147,7 @@ public class DuelScrollIT extends ESIntegTestCase { .field("type", "long") .endObject() .startObject("field4") - .field("type", "string") + .field("type", "text") .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 6341be8037e..6aa7652e3a5 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=string", "some_field", "type=string")); + .addMapping("test", "no_field", "type=text", "some_field", "type=text")); client().prepareIndex("test", "test", "1").setSource("some_field", "test").get(); refresh(); 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 cdceb9e9951..35608b9e38f 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java +++ b/core/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java @@ -1430,7 +1430,7 @@ public class FieldSortIT extends ESIntegTestCase { .field("type", "nested") .startObject("properties") .startObject("foo") - .field("type", "string") + .field("type", "text") .startObject("fields") .startObject("sub") .field("type", "keyword") diff --git a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceIT.java b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceIT.java index 5b0bc4d9ffe..28994042084 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceIT.java +++ b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceIT.java @@ -393,8 +393,8 @@ public class GeoDistanceIT extends ESIntegTestCase { Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT); Settings settings = Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("company").startObject("properties") - .startObject("name").field("type", "string").endObject().startObject("branches").field("type", "nested") - .startObject("properties").startObject("name").field("type", "string").endObject().startObject("location") + .startObject("name").field("type", "text").endObject().startObject("branches").field("type", "nested") + .startObject("properties").startObject("name").field("type", "text").endObject().startObject("location") .field("type", "geo_point"); if (version.before(Version.V_2_2_0)) { xContentBuilder.field("lat_lon", true); 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 69f7431e371..42a3a8dc7c0 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java +++ b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java @@ -280,7 +280,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase { public void testCrossIndexIgnoreUnmapped() throws Exception { assertAcked(prepareCreate("test1").addMapping( - "type", "str_field1", "type=string", + "type", "str_field1", "type=text", "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 c910e46cbd2..04369348b6f 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java @@ -607,7 +607,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { .startObject(TYPE) .startObject("properties") .startObject(FIELD) - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject() @@ -619,7 +619,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject() .startObject(TYPE).startObject("properties") .startObject(FIELD) - .field("type", "string") + .field("type", "text") .startObject("fields") .startObject("suggest").field("type", "completion").field("analyzer", "simple").endObject() .endObject() diff --git a/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java b/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java index acd475f2f0f..ba3c3492476 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java @@ -40,6 +40,7 @@ import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.core.StringFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper.StringFieldType; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.indices.IndicesModule; @@ -173,7 +174,7 @@ public class DirectCandidateGeneratorTests extends ESTestCase{ QueryShardContext mockShardContext = new QueryShardContext(idxSettings, null, null, mockMapperService, null, null, null) { @Override public MappedFieldType fieldMapper(String name) { - StringFieldMapper.Builder builder = new StringFieldMapper.Builder(name); + TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); return builder.build(new Mapper.BuilderContext(idxSettings.getSettings(), new ContentPath(1))).fieldType(); } }; diff --git a/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java b/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java index f6fa1fc621f..58fc257244f 100644 --- a/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java +++ b/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java @@ -42,11 +42,11 @@ public class SimilarityIT extends ESIntegTestCase { .startObject("properties") .startObject("field1") .field("similarity", "custom") - .field("type", "string") + .field("type", "text") .endObject() .startObject("field2") .field("similarity", "classic") - .field("type", "string") + .field("type", "text") .endObject() .endObject() .endObject()) diff --git a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java index 02db67cd153..65337d4b632 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java @@ -305,7 +305,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas NumShards numShards = getNumShards("test-idx"); - assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("foo").setSource("baz", "type=string")); + assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("foo").setSource("baz", "type=text")); ensureGreen(); logger.info("--> snapshot it"); @@ -317,7 +317,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas cluster().wipeIndices("test-idx"); assertAcked(prepareCreate("test-idx", 2, Settings.builder() .put(SETTING_NUMBER_OF_SHARDS, numShards.numPrimaries).put(SETTING_NUMBER_OF_REPLICAS, between(0, 1)).put("refresh_interval", 5, TimeUnit.SECONDS))); - assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("bar").setSource("baz", "type=string")); + assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("bar").setSource("baz", "type=text")); ensureGreen(); logger.info("--> close index"); @@ -1635,7 +1635,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas assertAcked(prepareCreate("test-idx", 2, indexSettings)); int numberOfShards = getNumShards("test-idx").numPrimaries; - assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("type1").setSource("field1", "type=string,analyzer=standard,search_analyzer=my_analyzer")); + assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("type1").setSource("field1", "type=text,analyzer=standard,search_analyzer=my_analyzer")); final int numdocs = randomIntBetween(10, 100); IndexRequestBuilder[] builders = new IndexRequestBuilder[numdocs]; for (int i = 0; i < builders.length; i++) { diff --git a/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java b/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java index 1bb51fab09d..6742d1b0bfb 100644 --- a/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java +++ b/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java @@ -102,7 +102,7 @@ public class SimpleTimestampIT extends ESIntegTestCase { assertTimestampMappingEnabled(index, type, true); // update some field in the mapping - XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "string").endObject().endObject(); + XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").endObject().endObject(); PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get(); assertAcked(putMappingResponse); diff --git a/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java b/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java index 451f844344f..36c75c3a13e 100644 --- a/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java +++ b/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java @@ -105,7 +105,7 @@ public class ContextAndHeaderTransportIT extends ESIntegTestCase { String mapping = jsonBuilder().startObject().startObject("type") .startObject("properties") .startObject("location").field("type", "geo_shape").endObject() - .startObject("name").field("type", "string").endObject() + .startObject("name").field("type", "text").endObject() .endObject() .endObject().endObject().string(); diff --git a/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java b/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java index cb8165b4aac..9678504f4f3 100644 --- a/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java +++ b/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java @@ -215,7 +215,7 @@ public class SimpleTTLIT extends ESIntegTestCase { assertTTLMappingEnabled(index, type); // update some field in the mapping - XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "string").endObject().endObject(); + XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").endObject().endObject(); PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get(); assertAcked(putMappingResponse); diff --git a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java index 8bc69d4c17a..5e9bc80b9a9 100644 --- a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java +++ b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java @@ -59,7 +59,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { ensureGreen(); client().admin().indices().preparePutMapping("test").setType("type1") .setSource(XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("foo").field("type", "string").endObject() + .startObject("foo").field("type", "text").endObject() .startObject("bar").field("type", "integer").endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -83,9 +83,9 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { ensureGreen(); client().admin().indices().preparePutMapping("test").setType("type1") .setSource(XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") - .startObject("foo").field("type", "string").endObject() + .startObject("foo").field("type", "text").endObject() .startObject("bar").field("type", "integer").endObject() - .startObject("baz").field("type", "string").field("analyzer", "snowball").endObject() + .startObject("baz").field("type", "text").field("analyzer", "snowball").endObject() .startObject("pin").startObject("properties").startObject("location").field("type", "geo_point").endObject().endObject().endObject() .endObject().endObject().endObject()) .execute().actionGet(); @@ -164,7 +164,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { public void testExplainFilteredAlias() { assertAcked(prepareCreate("test") - .addMapping("test", "field", "type=string") + .addMapping("test", "field", "type=text") .addAlias(new Alias("alias").filter(QueryBuilders.termQuery("field", "value1")))); ensureGreen(); @@ -183,7 +183,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { .putArray("index.analysis.filter.syns.synonyms", "one,two") .put("index.analysis.analyzer.syns.tokenizer", "standard") .putArray("index.analysis.analyzer.syns.filter", "syns") - ).addMapping("test", "field","type=string,analyzer=syns")); + ).addMapping("test", "field","type=text,analyzer=syns")); ensureGreen(); ValidateQueryResponse validateQueryResponse = client().admin().indices().prepareValidateQuery("test") @@ -215,7 +215,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { @SuppressWarnings("deprecation") // fuzzy queries will be removed in 4.0 public void testExplainWithRewriteValidateQuery() throws Exception { client().admin().indices().prepareCreate("test") - .addMapping("type1", "field", "type=string,analyzer=whitespace") + .addMapping("type1", "field", "type=text,analyzer=whitespace") .setSettings(SETTING_NUMBER_OF_SHARDS, 1).get(); client().prepareIndex("test", "type1", "1").setSource("field", "quick lazy huge brown pidgin").get(); client().prepareIndex("test", "type1", "2").setSource("field", "the quick brown fox").get(); diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping.json index eb9b7833c68..e0a7bfeba89 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping.json @@ -10,13 +10,12 @@ "dynamic":false, "properties":{ "first":{ - "type":"string", + "type":"text", "store":true, "include_in_all":false }, "last":{ - "type":"string", - "index":"not_analyzed", + "type":"keyword", "boost":2.0 } } @@ -28,7 +27,7 @@ "first":{ "properties":{ "location":{ - "type":"string", + "type":"text", "store":true } } @@ -36,7 +35,7 @@ "last":{ "properties":{ "location":{ - "type":"string", + "type":"text", "include_in_all":true } } @@ -53,4 +52,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_boost_omit_positions_on_all.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_boost_omit_positions_on_all.json index 42bba4354c6..dbdb78d9c21 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_boost_omit_positions_on_all.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_boost_omit_positions_on_all.json @@ -10,13 +10,12 @@ "dynamic":false, "properties":{ "first":{ - "type":"string", + "type":"text", "store":true, "include_in_all":false }, "last":{ - "type":"string", - "index":"not_analyzed", + "type":"keyword", "boost": 2.0 } } @@ -28,7 +27,7 @@ "first":{ "properties":{ "location":{ - "type":"string", + "type":"text", "store":true } } @@ -36,7 +35,7 @@ "last":{ "properties":{ "location":{ - "type":"string", + "type":"text", "include_in_all":true } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_offsets_on_all.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_offsets_on_all.json index 388ac13e9e6..0f4541d4ffc 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_offsets_on_all.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_offsets_on_all.json @@ -10,13 +10,12 @@ "dynamic":false, "properties":{ "first":{ - "type":"string", + "type":"text", "store":true, "include_in_all":false }, "last":{ - "type":"string", - "index":"not_analyzed", + "type":"keyword", "boost": 2.0 } } @@ -28,7 +27,7 @@ "first":{ "properties":{ "location":{ - "type":"string", + "type":"text", "store":true } } @@ -36,7 +35,7 @@ "last":{ "properties":{ "location":{ - "type":"string", + "type":"text", "include_in_all":true } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_omit_positions_on_all.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_omit_positions_on_all.json index 57aad9e8fab..f34e8374b54 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_omit_positions_on_all.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/mapping_omit_positions_on_all.json @@ -10,13 +10,12 @@ "dynamic":false, "properties":{ "first":{ - "type":"string", + "type":"text", "store":true, "include_in_all":false }, "last":{ - "type":"string", - "index":"not_analyzed" + "type":"keyword" } } }, @@ -27,7 +26,7 @@ "first":{ "properties":{ "location":{ - "type":"string", + "type":"text", "store":true } } @@ -35,7 +34,7 @@ "last":{ "properties":{ "location":{ - "type":"string", + "type":"text", "include_in_all":true } } @@ -52,4 +51,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/misplaced_mapping_key_in_root.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/misplaced_mapping_key_in_root.json index f08757a9e9d..1fb35fad833 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/misplaced_mapping_key_in_root.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/misplaced_mapping_key_in_root.json @@ -3,7 +3,7 @@ "test": { "properties": { "foo": { - "type": "string" + "type": "text" } } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/misplaced_type_in_root.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/misplaced_type_in_root.json index f4b325c6c1a..0cff175bff4 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/misplaced_type_in_root.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/misplaced_type_in_root.json @@ -1,8 +1,8 @@ { - "type": "string", + "type": "text", "properties": { "foo": { - "type": "string" + "type": "text" } } } \ No newline at end of file diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/mistyped_type_in_root.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/mistyped_type_in_root.json index 19edf597670..0373bd28c41 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/mistyped_type_in_root.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/mistyped_type_in_root.json @@ -2,7 +2,7 @@ "testX": { "properties": { "foo": { - "type": "string" + "type": "text" } } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/multifield-mapping_default.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/multifield-mapping_default.json index 6a5f044b123..9dfd924803f 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/multifield-mapping_default.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/multifield-mapping_default.json @@ -5,12 +5,11 @@ "type": "nested", "properties": { "bar": { - "type": "string", - "index": "not_analyzed", + "type": "keyword", "fields": { "lower": { "analyzer": "standard", - "type": "string" + "type": "text" } } } @@ -18,4 +17,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/multifield-mapping_include_in_all_set_to_false.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/multifield-mapping_include_in_all_set_to_false.json index 5a0ad92afad..8d9f8036499 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/multifield-mapping_include_in_all_set_to_false.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/multifield-mapping_include_in_all_set_to_false.json @@ -6,13 +6,12 @@ "include_in_all": false, "properties": { "bar": { - "type": "string", - "index": "not_analyzed", + "type": "keyword", "include_in_all": false, "fields": { "lower": { "analyzer": "standard", - "type": "string" + "type": "text" } } } @@ -20,4 +19,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/noboost-mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/noboost-mapping.json index 9b1119f1a2e..3f9a14ccdd6 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/noboost-mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/noboost-mapping.json @@ -9,13 +9,12 @@ "dynamic":false, "properties":{ "first":{ - "type":"string", + "type":"text", "store":true, "include_in_all":false }, "last":{ - "type":"string", - "index":"not_analyzed" + "type":"keyword" } } }, @@ -26,7 +25,7 @@ "first":{ "properties":{ "location":{ - "type":"string", + "type":"text", "store":true } } @@ -34,7 +33,7 @@ "last":{ "properties":{ "location":{ - "type":"string", + "type":"text", "include_in_all":true } } @@ -51,4 +50,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/store-mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/store-mapping.json index 66fed5928ad..20b10f4b919 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/store-mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/store-mapping.json @@ -10,13 +10,12 @@ "dynamic":false, "properties":{ "first":{ - "type":"string", + "type":"text", "store":true, "include_in_all":false }, "last":{ - "type":"string", - "index":"not_analyzed", + "type":"keyword", "boost":2.0 } } @@ -28,7 +27,7 @@ "first":{ "properties":{ "location":{ - "type":"string", + "type":"text", "store":true } } @@ -36,7 +35,7 @@ "last":{ "properties":{ "location":{ - "type":"string" + "type":"text" } } } @@ -52,4 +51,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/type_date_detection_mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/type_date_detection_mapping.json index c2db712ced5..0e78d9f2ad1 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/type_date_detection_mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/type_date_detection_mapping.json @@ -2,7 +2,7 @@ "date_detection" : false, "properties": { "foo": { - "type": "string" + "type": "text" } } } \ No newline at end of file diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/type_dynamic_date_formats_mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/type_dynamic_date_formats_mapping.json index 7e6afd397c4..7c519db65c0 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/type_dynamic_date_formats_mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/type_dynamic_date_formats_mapping.json @@ -2,7 +2,7 @@ "dynamic_date_formats" : ["yyyy-MM-dd", "dd-MM-yyyy"], "properties": { "foo": { - "type": "string" + "type": "text" } } } \ No newline at end of file diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/type_dynamic_template_mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/type_dynamic_template_mapping.json index b155fb7204b..295beaa7e57 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/type_dynamic_template_mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/type_dynamic_template_mapping.json @@ -11,7 +11,7 @@ ], "properties": { "foo": { - "type": "string" + "type": "text" } } } \ No newline at end of file diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/all/type_numeric_detection_mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/all/type_numeric_detection_mapping.json index 47293546007..fba7a393c77 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/all/type_numeric_detection_mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/all/type_numeric_detection_mapping.json @@ -2,7 +2,7 @@ "numeric_detection" : false, "properties": { "foo": { - "type": "string" + "type": "text" } } } \ No newline at end of file diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json index 3c273e6ed9e..ad461063426 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json @@ -21,7 +21,7 @@ "template_3":{ "path_match":"*.obj4.*", "mapping":{ - "type":"string" + "type":"text" } } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json index 7a7e96d12a3..7993934c34d 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json @@ -23,11 +23,10 @@ "match":"*", "match_mapping_type":"string", "mapping":{ - "type":"string", - "index":"not_analyzed" + "type":"keyword" } } } ] } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json index 0c2f9ab3f81..a276c0bf236 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping1.json @@ -2,10 +2,9 @@ person:{ properties:{ "name":{ - type:"string", - index:"analyzed", + "type": "text", store:true } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json index 37064a038b1..b4d18439288 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json @@ -2,26 +2,23 @@ "person" :{ "properties" :{ "name":{ - "type" :"string", - "index" :"analyzed", + "type": "text", "store" :true, "fields":{ "name":{ - "type" :"string", - "index" :"analyzed", + "type": "text", "store" :true }, "indexed":{ - "type" :"string", - "index" :"analyzed" + "type": "text" }, "not_indexed":{ - "type" :"string", - "index" :"no", + "type": "text", + "index" :false, "store" :true } } } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json index 564d4b5ac05..22b97dccf45 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json @@ -2,31 +2,28 @@ "person" : { "properties" :{ "name" : { - "type" : "string", - "index" : "analyzed", + "type" : "text", "store" : true, "fields": { "name" : { - "type" : "string", - "index" : "analyzed", + "type" : "text", "store" : true }, "indexed":{ - type:"string", - index:"analyzed" + "type": "text" }, "not_indexed":{ - type:"string", - index:"no", + "type": "text", + index:false, store:true }, "not_indexed2":{ - type:"string", - index:"no", + "type": "text", + index:false, store:true } } } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json index 7d2fea2d2f5..d7ba2508004 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json @@ -2,17 +2,16 @@ person:{ properties:{ "name":{ - type:"string", - index:"analyzed", + "type": "text", store:true, "fields":{ "not_indexed3":{ - type:"string", - index:"no", + "type": "text", + index:false, store:true } } } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade1.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade1.json index 8224cd69cf8..d000fca94b7 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade1.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade1.json @@ -2,17 +2,15 @@ person:{ properties:{ "name":{ - type:"string", - index:"analyzed", + "type": "text", store:true, "fields":{ "indexed":{ - type:"string", - index:"analyzed" + "type": "text" }, "not_indexed":{ - type:"string", - index:"no", + "type": "text", + index:false, store:true } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade2.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade2.json index 42315cc8e3e..478999ff6e1 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade2.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade2.json @@ -2,22 +2,20 @@ person:{ properties:{ "name":{ - type:"string", - index:"analyzed", + "type": "text", store:true, "fields":{ "indexed":{ - type:"string", - index:"analyzed" + "type": "text" }, "not_indexed":{ - type:"string", - index:"no", + "type": "text", + index:false, store:true }, "not_indexed2":{ - type:"string", - index:"no", + "type": "text", + index:false, store:true } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade3.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade3.json index 4d429475261..89f268efb33 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade3.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/merge/upgrade3.json @@ -2,12 +2,12 @@ person:{ properties:{ "name":{ - type:"string", - index:"no", + "type": "text", + index:false, "fields":{ "not_indexed3":{ - type:"string", - index:"no", + "type": "text", + index:false, store:true } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-completion.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-completion.json index d36e9d2d84e..bb04c1a509d 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-completion.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-completion.json @@ -5,8 +5,7 @@ "type":"multi_field", "fields":{ "a":{ - "type":"string", - "index":"not_analyzed" + "type":"keyword" }, "b":{ "type":"completion" @@ -17,8 +16,7 @@ "type":"multi_field", "fields":{ "a":{ - "type":"string", - "index":"not_analyzed" + "type":"keyword" }, "b":{ "type":"completion" @@ -27,4 +25,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-geo_point.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-geo_point.json index c7d11becc24..436879f6cf1 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-geo_point.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-geo_point.json @@ -5,8 +5,8 @@ "type":"multi_field", "fields":{ "a":{ - "type":"string", - "index":"not_analyzed" + "type":"text", + "index":false }, "b":{ "type":"geo_point" @@ -17,8 +17,7 @@ "type":"multi_field", "fields":{ "a":{ - "type":"string", - "index":"not_analyzed" + "type":"keyword" }, "b":{ "type":"geo_point" @@ -27,4 +26,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-no-default-field.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-no-default-field.json index 19d7e45ad48..1a9bd0e52a0 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-no-default-field.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-field-type-no-default-field.json @@ -5,11 +5,10 @@ "type": "multi_field", "fields": { "indexed": { - "type": "string", - "index": "analyzed" + "type": "text" }, "not_indexed": { - "type": "string", + "type": "text", "index": "no", "store": true } @@ -29,4 +28,4 @@ } } } -} \ No newline at end of file +} diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-fields.json b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-fields.json index 3be34a98398..528cd5bb9d2 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-fields.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/multifield/test-multi-fields.json @@ -2,23 +2,20 @@ "person": { "properties": { "name": { - "type": "string", - "index": "analyzed", + "type": "text", "store": true, "fields": { "indexed": { - "type": "string", - "index": "analyzed", + "type": "text", "store": false }, "not_indexed": { - "type": "string", - "index": "no", + "type": "text", + "index": false, "store": true }, "test1": { - "type": "string", - "index": "analyzed", + "type": "text", "store": true, "fielddata": { "loading": "eager" @@ -38,8 +35,7 @@ "type": "date", "fields": { "string": { - "type": "string", - "index": "not_analyzed" + "type": "keyword" } } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/path/test-mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/path/test-mapping.json index 8af451a0d1f..8d7505624b1 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/path/test-mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/path/test-mapping.json @@ -5,10 +5,10 @@ "type":"object", "properties":{ "first1":{ - "type":"string" + "type":"text" }, "last1":{ - "type":"string" + "type":"text" } } }, @@ -16,10 +16,10 @@ "type":"object", "properties":{ "first2":{ - "type":"string" + "type":"text" }, "last2":{ - "type":"string" + "type":"text" } } } diff --git a/core/src/test/resources/org/elasticsearch/index/mapper/simple/test-mapping.json b/core/src/test/resources/org/elasticsearch/index/mapper/simple/test-mapping.json index a37946bf2e6..b13cab0af61 100644 --- a/core/src/test/resources/org/elasticsearch/index/mapper/simple/test-mapping.json +++ b/core/src/test/resources/org/elasticsearch/index/mapper/simple/test-mapping.json @@ -14,12 +14,11 @@ dynamic:false, properties:{ first:{ - type:"string", + "type": "text", store:true }, last:{ - type:"string", - index:"not_analyzed" + "type": "keyword" } } }, @@ -29,7 +28,7 @@ first:{ properties:{ location:{ - type:"string", + "type": "text", store:true } } @@ -37,7 +36,7 @@ last:{ properties:{ location:{ - type:"string" + "type": "text" } } } @@ -55,16 +54,16 @@ type:"boolean" }, dogs:{ - type:"string" + "type": "text" }, complex:{ type:"object", properties:{ value1:{ - type:"string" + "type": "text" }, value2:{ - type:"string" + "type": "text" } } }, @@ -72,13 +71,13 @@ type:"object", properties:{ value1:{ - type:"string" + "type": "text" }, value2:{ - type:"string" + "type": "text" } } } } } -} \ No newline at end of file +} diff --git a/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/AttachmentMapper.java b/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/AttachmentMapper.java index 58e93c9dd64..fc389c2116e 100644 --- a/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/AttachmentMapper.java +++ b/plugins/mapper-attachments/src/main/java/org/elasticsearch/mapper/attachments/AttachmentMapper.java @@ -39,7 +39,7 @@ import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.elasticsearch.index.mapper.core.IntegerFieldMapper; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import java.io.IOException; import java.util.Arrays; @@ -130,26 +130,26 @@ public class AttachmentMapper extends FieldMapper { private Mapper.Builder contentBuilder; - private Mapper.Builder titleBuilder = new StringFieldMapper.Builder(FieldNames.TITLE); + private Mapper.Builder titleBuilder = new TextFieldMapper.Builder(FieldNames.TITLE); - private Mapper.Builder nameBuilder = new StringFieldMapper.Builder(FieldNames.NAME); + private Mapper.Builder nameBuilder = new TextFieldMapper.Builder(FieldNames.NAME); - private Mapper.Builder authorBuilder = new StringFieldMapper.Builder(FieldNames.AUTHOR); + private Mapper.Builder authorBuilder = new TextFieldMapper.Builder(FieldNames.AUTHOR); - private Mapper.Builder keywordsBuilder = new StringFieldMapper.Builder(FieldNames.KEYWORDS); + private Mapper.Builder keywordsBuilder = new TextFieldMapper.Builder(FieldNames.KEYWORDS); private Mapper.Builder dateBuilder = new DateFieldMapper.Builder(FieldNames.DATE); - private Mapper.Builder contentTypeBuilder = new StringFieldMapper.Builder(FieldNames.CONTENT_TYPE); + private Mapper.Builder contentTypeBuilder = new TextFieldMapper.Builder(FieldNames.CONTENT_TYPE); private Mapper.Builder contentLengthBuilder = new IntegerFieldMapper.Builder(FieldNames.CONTENT_LENGTH); - private Mapper.Builder languageBuilder = new StringFieldMapper.Builder(FieldNames.LANGUAGE); + private Mapper.Builder languageBuilder = new TextFieldMapper.Builder(FieldNames.LANGUAGE); public Builder(String name) { super(name, new AttachmentFieldType(), new AttachmentFieldType()); this.builder = this; - this.contentBuilder = new StringFieldMapper.Builder(FieldNames.CONTENT); + this.contentBuilder = new TextFieldMapper.Builder(FieldNames.CONTENT); } public Builder content(Mapper.Builder content) { diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/DateAttachmentMapperTests.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/DateAttachmentMapperTests.java index 7b93dbc3155..a384eb9f04e 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/DateAttachmentMapperTests.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/DateAttachmentMapperTests.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.MapperTestUtils; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; -import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.junit.Before; import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath; @@ -47,6 +47,6 @@ public class DateAttachmentMapperTests extends AttachmentUnitTestCase { DocumentMapper docMapper = mapperParser.parse("person", new CompressedXContent(mapping)); // Our mapping should be kept as a String - assertThat(docMapper.mappers().getMapper("file.date"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.date"), instanceOf(TextFieldMapper.class)); } } diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/LanguageDetectionAttachmentMapperTests.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/LanguageDetectionAttachmentMapperTests.java index 5d81df7a7fe..e8ed5bcdfe4 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/LanguageDetectionAttachmentMapperTests.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/LanguageDetectionAttachmentMapperTests.java @@ -27,6 +27,7 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.junit.Before; import java.io.IOException; @@ -56,7 +57,7 @@ public class LanguageDetectionAttachmentMapperTests extends AttachmentUnitTestCa String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/attachment/test/unit/language/language-mapping.json"); docMapper = mapperParser.parse("person", new CompressedXContent(mapping)); - assertThat(docMapper.mappers().getMapper("file.language"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.language"), instanceOf(TextFieldMapper.class)); } private void testLanguage(String filename, String expected, String... forcedLanguage) throws IOException { diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/MultifieldAttachmentMapperTests.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/MultifieldAttachmentMapperTests.java index 9e756796352..6b781a6f4a6 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/MultifieldAttachmentMapperTests.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/MultifieldAttachmentMapperTests.java @@ -30,6 +30,7 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.TextFieldMapper; import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; import org.junit.Before; @@ -66,26 +67,26 @@ public class MultifieldAttachmentMapperTests extends AttachmentUnitTestCase { DocumentMapper docMapper = mapperParser.parse("person", new CompressedXContent(mapping)); - assertThat(docMapper.mappers().getMapper("file.content"), instanceOf(StringFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.content.suggest"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.content"), instanceOf(TextFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.content.suggest"), instanceOf(TextFieldMapper.class)); assertThat(docMapper.mappers().getMapper("file.date"), instanceOf(DateFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.date.string"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.date.string"), instanceOf(TextFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.title"), instanceOf(StringFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.title.suggest"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.title"), instanceOf(TextFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.title.suggest"), instanceOf(TextFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.name"), instanceOf(StringFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.name.suggest"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.name"), instanceOf(TextFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.name.suggest"), instanceOf(TextFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.author"), instanceOf(StringFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.author.suggest"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.author"), instanceOf(TextFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.author.suggest"), instanceOf(TextFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.keywords"), instanceOf(StringFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.keywords.suggest"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.keywords"), instanceOf(TextFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.keywords.suggest"), instanceOf(TextFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.content_type"), instanceOf(StringFieldMapper.class)); - assertThat(docMapper.mappers().getMapper("file.content_type.suggest"), instanceOf(StringFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.content_type"), instanceOf(TextFieldMapper.class)); + assertThat(docMapper.mappers().getMapper("file.content_type.suggest"), instanceOf(TextFieldMapper.class)); } public void testExternalValues() throws Exception { diff --git a/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/date/date-mapping.json b/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/date/date-mapping.json index c4c90ce75e9..bf5824a6f4c 100644 --- a/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/date/date-mapping.json +++ b/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/date/date-mapping.json @@ -4,7 +4,7 @@ "file": { "type": "attachment", "fields": { - "date": { "type": "string" } + "date": { "type": "text" } } } } diff --git a/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/language/language-mapping.json b/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/language/language-mapping.json index 02176c7ca0d..5d629c4e1ac 100644 --- a/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/language/language-mapping.json +++ b/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/language/language-mapping.json @@ -4,7 +4,7 @@ "file": { "type": "attachment", "fields": { - "language": { "type": "string" } + "language": { "type": "text" } } } } diff --git a/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/multifield/multifield-mapping.json b/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/multifield/multifield-mapping.json index 314c70db2aa..b3bd077432e 100644 --- a/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/multifield/multifield-mapping.json +++ b/plugins/mapper-attachments/src/test/resources/org/elasticsearch/index/mapper/attachment/test/unit/multifield/multifield-mapping.json @@ -5,48 +5,48 @@ "type": "attachment", "fields": { "content": { - "type": "string", + "type": "text", "fields": { - "suggest": { "type": "string" } + "suggest": { "type": "text" } } }, "date": { "type": "date", "fields": { - "string": { "type": "string" } + "string": { "type": "text" } } }, "title": { - "type": "string", + "type": "text", "fields": { - "suggest": { "type": "string" } + "suggest": { "type": "text" } } }, "name": { - "type": "string", + "type": "text", "fields": { "suggest": { - "type": "string", + "type": "text", "store": true } } }, "author": { - "type": "string", + "type": "text", "fields": { - "suggest": { "type": "string" } + "suggest": { "type": "text" } } }, "keywords": { - "type": "string", + "type": "text", "fields": { - "suggest": { "type": "string" } + "suggest": { "type": "text" } } }, "content_type": { - "type": "string", + "type": "text", "fields": { - "suggest": { "type": "string" } + "suggest": { "type": "text" } } } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yaml index 4ce21978840..b4b5669a8a9 100755 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.aliases/10_basic.yaml @@ -110,7 +110,7 @@ type_1: properties: foo: - type: string + type: text - do: indices.put_alias: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.analyze/10_analyze.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.analyze/10_analyze.yaml index 0b1a090303e..88160ef4f1e 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.analyze/10_analyze.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.analyze/10_analyze.yaml @@ -33,7 +33,7 @@ setup: test: properties: text: - type: string + type: text analyzer: whitespace - do: cluster.health: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/10_basic.yaml index 3fc0e00d637..17b86d64764 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/10_basic.yaml @@ -41,7 +41,7 @@ type_1: properties: field: - type: string + type: text aliases: test_alias: {} test_blias: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yaml index 7df07343e2b..372b5695d32 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/10_basic.yaml @@ -8,7 +8,7 @@ setup: test_type: properties: text: - type: string + type: text - do: cluster.health: wait_for_status: yellow @@ -20,7 +20,7 @@ setup: indices.get_field_mapping: fields: text - - match: {test_index.mappings.test_type.text.mapping.text.type: string} + - match: {test_index.mappings.test_type.text.mapping.text.type: text} --- "Get field mapping by index only": @@ -29,7 +29,7 @@ setup: index: test_index fields: text - - match: {test_index.mappings.test_type.text.mapping.text.type: string} + - match: {test_index.mappings.test_type.text.mapping.text.type: text} --- "Get field mapping by type & field": @@ -40,7 +40,7 @@ setup: type: test_type fields: text - - match: {test_index.mappings.test_type.text.mapping.text.type: string} + - match: {test_index.mappings.test_type.text.mapping.text.type: text} --- "Get field mapping by type & field, with another field that doesn't exist": @@ -51,7 +51,7 @@ setup: type: test_type fields: [ text , text1 ] - - match: {test_index.mappings.test_type.text.mapping.text.type: string} + - match: {test_index.mappings.test_type.text.mapping.text.type: text} - is_false: test_index.mappings.test_type.text1 --- @@ -64,7 +64,7 @@ setup: fields: text include_defaults: true - - match: {test_index.mappings.test_type.text.mapping.text.type: string} + - match: {test_index.mappings.test_type.text.mapping.text.type: text} - match: {test_index.mappings.test_type.text.mapping.text.analyzer: default} --- @@ -75,5 +75,5 @@ setup: type: test_type fields: text - - match: {test_index.mappings.test_type.text.mapping.text.type: string} + - match: {test_index.mappings.test_type.text.mapping.text.type: text} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/20_missing_field.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/20_missing_field.yaml index d39fcc5b467..1a97f69ba89 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/20_missing_field.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/20_missing_field.yaml @@ -9,7 +9,7 @@ test_type: properties: text: - type: string + type: text analyzer: whitespace - do: cluster.health: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yaml index 6f8e9d29dfb..efee9cbc3a3 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yaml @@ -9,7 +9,7 @@ test_type: properties: text: - type: string + type: text analyzer: whitespace - do: cluster.health: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml index 78af1b3e349..15056d3377a 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml @@ -8,17 +8,17 @@ setup: test_type: properties: t1: - type: string + type: text t2: - type: string + type: text obj: properties: t1: - type: string + type: text i_t1: - type: string + type: text i_t3: - type: string + type: text - do: indices.create: @@ -28,17 +28,17 @@ setup: test_type_2: properties: t1: - type: string + type: text t2: - type: string + type: text obj: properties: t1: - type: string + type: text i_t1: - type: string + type: text i_t3: - type: string + type: text - do: cluster.health: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/20_missing_type.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/20_missing_type.yaml index 91b1883197b..8efe2a74c9b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/20_missing_type.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/20_missing_type.yaml @@ -8,7 +8,7 @@ test_type: properties: text: - type: string + type: text analyzer: whitespace - do: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/40_aliases.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/40_aliases.yaml index 9dff6edc9dc..a6085665441 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/40_aliases.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/40_aliases.yaml @@ -9,7 +9,7 @@ test_type: properties: text: - type: string + type: text analyzer: whitespace - do: @@ -21,6 +21,6 @@ indices.get_mapping: index: test_alias - - match: {test_index.mappings.test_type.properties.text.type: string} + - match: {test_index.mappings.test_type.properties.text.type: text} - match: {test_index.mappings.test_type.properties.text.analyzer: whitespace} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yaml index 2a63411937e..badb27c3708 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yaml @@ -12,19 +12,19 @@ test_type: properties: text1: - type: string + type: text analyzer: whitespace text2: - type: string + type: text analyzer: whitespace - do: indices.get_mapping: index: test_index - - match: {test_index.mappings.test_type.properties.text1.type: string} + - match: {test_index.mappings.test_type.properties.text1.type: text} - match: {test_index.mappings.test_type.properties.text1.analyzer: whitespace} - - match: {test_index.mappings.test_type.properties.text2.type: string} + - match: {test_index.mappings.test_type.properties.text2.type: text} - match: {test_index.mappings.test_type.properties.text2.analyzer: whitespace} - do: @@ -35,7 +35,7 @@ test_type: properties: text1: - type: string + type: text analyzer: whitespace fields: text_raw: @@ -46,5 +46,5 @@ indices.get_mapping: index: test_index - - match: {test_index.mappings.test_type.properties.text1.type: string} + - match: {test_index.mappings.test_type.properties.text1.type: text} - match: {test_index.mappings.test_type.properties.text1.fields.text_raw.type: keyword} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yaml index e53bbc3c1d3..e125ec2a70f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yaml @@ -20,7 +20,7 @@ setup: test_type: properties: text: - type: string + type: text analyzer: whitespace - do: indices.put_mapping: @@ -30,17 +30,17 @@ setup: test_type: properties: text: - type: string + type: text analyzer: whitespace - do: indices.get_mapping: {} - - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.test_type.properties.text.type: text} - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: string} + - match: {test_index2.mappings.test_type.properties.text.type: text} - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} - match: { foo.mappings: {} } @@ -56,19 +56,19 @@ setup: test_type: properties: text: - type: string + type: text analyzer: whitespace - do: indices.get_mapping: {} - - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.test_type.properties.text.type: text} - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: string} + - match: {test_index2.mappings.test_type.properties.text.type: text} - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} - - match: {foo.mappings.test_type.properties.text.type: string} + - match: {foo.mappings.test_type.properties.text.type: text} - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} --- @@ -81,19 +81,19 @@ setup: test_type: properties: text: - type: string + type: text analyzer: whitespace - do: indices.get_mapping: {} - - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.test_type.properties.text.type: text} - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: string} + - match: {test_index2.mappings.test_type.properties.text.type: text} - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} - - match: {foo.mappings.test_type.properties.text.type: string} + - match: {foo.mappings.test_type.properties.text.type: text} - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} --- @@ -106,16 +106,16 @@ setup: test_type: properties: text: - type: string + type: text analyzer: whitespace - do: indices.get_mapping: {} - - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.test_type.properties.text.type: text} - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: string} + - match: {test_index2.mappings.test_type.properties.text.type: text} - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} - match: { foo.mappings: {} } @@ -130,16 +130,16 @@ setup: test_type: properties: text: - type: string + type: text analyzer: whitespace - do: indices.get_mapping: {} - - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.test_type.properties.text.type: text} - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: string} + - match: {test_index2.mappings.test_type.properties.text.type: text} - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} - match: { foo.mappings: {} } @@ -153,19 +153,19 @@ setup: test_type: properties: text: - type: string + type: text analyzer: whitespace - do: indices.get_mapping: {} - - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.test_type.properties.text.type: text} - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: string} + - match: {test_index2.mappings.test_type.properties.text.type: text} - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} - - match: {foo.mappings.test_type.properties.text.type: string} + - match: {foo.mappings.test_type.properties.text.type: text} - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} --- @@ -188,9 +188,8 @@ setup: dynamic: false properties: text: - index: analyzed analyzer: default - type: string + type: text - do: indices.put_mapping: @@ -201,12 +200,11 @@ setup: dynamic: false properties: text: - index: analyzed analyzer: default - type: string + type: text - do: indices.get_mapping: {} - - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.test_type.properties.text.type: text} 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 b14e4cb4885..72fc228004e 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 @@ -9,12 +9,12 @@ setup: bar: properties: bar: - type: string + type: text fields: completion: type: completion baz: - type: string + type: text fields: completion: type: completion diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/20_query_string.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/20_query_string.yaml index 1207bc2a8ad..c6dd323aa6c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/20_query_string.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/20_query_string.yaml @@ -10,7 +10,7 @@ enabled: false properties: field: - type: string + type: text number: type: integer diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mlt/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/mlt/10_basic.yaml index e67a629046a..31049b07e21 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mlt/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mlt/10_basic.yaml @@ -11,9 +11,9 @@ test: properties: foo: - type : "string" + type : "text" title: - type : "string" + type : "text" - do: index: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/mtermvectors/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/mtermvectors/10_basic.yaml index 53005b0af8e..27fa94e85a4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/mtermvectors/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/mtermvectors/10_basic.yaml @@ -7,7 +7,7 @@ setup: testtype: properties: text: - type : "string" + type : "text" term_vector : "with_positions_offsets" - do: index: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/percolate/18_highligh_with_query.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/percolate/18_highligh_with_query.yaml index 97d652366da..83490c4d9a7 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/percolate/18_highligh_with_query.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/percolate/18_highligh_with_query.yaml @@ -9,7 +9,7 @@ type_1: properties: foo: - type: string + type: text - do: index: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/percolate/19_nested.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/percolate/19_nested.yaml index f310c08fc89..2713f5755c4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/percolate/19_nested.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/percolate/19_nested.yaml @@ -8,12 +8,12 @@ setup: company: properties: companyname: - type: string + type: text employee: type: nested properties: name: - type: string + type: text - do: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/10_basic.yaml index 013dbceba2d..2fbcb815d87 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/10_basic.yaml @@ -7,7 +7,7 @@ setup: testtype: "properties": "text": - "type" : "string" + "type" : "text" "term_vector" : "with_positions_offsets" - do: index: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/20_issue7121.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/20_issue7121.yaml index a1367f8c7d2..cc04ea32a6a 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/20_issue7121.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/20_issue7121.yaml @@ -13,7 +13,7 @@ doc: properties: text: - type : "string" + type : "text" term_vector : "with_positions_offsets" - do: