From 1654ae89379aeea586cbdff45a0b1d0cf4d00ebd Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Fri, 27 Dec 2013 14:40:24 +0100 Subject: [PATCH] Explicit doc_values setting. Once doc values are enabled on a field, they can't be disabled. Close #4560 --- .../mapping/types/core-types.asciidoc | 9 ++++++++ .../mapper/core/AbstractFieldMapper.java | 23 ++++++++++++++++--- .../index/mapper/core/BinaryFieldMapper.java | 2 +- .../index/mapper/core/BooleanFieldMapper.java | 2 +- .../index/mapper/core/ByteFieldMapper.java | 6 ++--- .../mapper/core/CompletionFieldMapper.java | 2 +- .../index/mapper/core/DateFieldMapper.java | 6 ++--- .../index/mapper/core/DoubleFieldMapper.java | 6 ++--- .../index/mapper/core/FloatFieldMapper.java | 6 ++--- .../index/mapper/core/IntegerFieldMapper.java | 6 ++--- .../index/mapper/core/LongFieldMapper.java | 6 ++--- .../index/mapper/core/NumberFieldMapper.java | 4 ++-- .../index/mapper/core/ShortFieldMapper.java | 6 ++--- .../index/mapper/core/StringFieldMapper.java | 6 ++--- .../mapper/core/TokenCountFieldMapper.java | 6 ++--- .../index/mapper/core/TypeParsers.java | 3 +++ .../index/mapper/geo/GeoPointFieldMapper.java | 6 ++--- .../index/mapper/geo/GeoShapeFieldMapper.java | 2 +- .../index/mapper/internal/AllFieldMapper.java | 2 +- .../mapper/internal/BoostFieldMapper.java | 8 +++---- .../index/mapper/internal/IdFieldMapper.java | 14 +++++------ .../mapper/internal/IndexFieldMapper.java | 8 +++---- .../mapper/internal/ParentFieldMapper.java | 9 +++----- .../mapper/internal/RoutingFieldMapper.java | 2 +- .../mapper/internal/SizeFieldMapper.java | 2 +- .../mapper/internal/SourceFieldMapper.java | 2 +- .../index/mapper/internal/TTLFieldMapper.java | 2 +- .../mapper/internal/TimestampFieldMapper.java | 8 +++---- .../mapper/internal/TypeFieldMapper.java | 2 +- .../index/mapper/internal/UidFieldMapper.java | 8 +++---- .../mapper/internal/VersionFieldMapper.java | 2 +- .../index/mapper/ip/IpFieldMapper.java | 6 ++--- .../string/SimpleStringMappingTests.java | 4 ++++ 33 files changed, 108 insertions(+), 78 deletions(-) diff --git a/docs/reference/mapping/types/core-types.asciidoc b/docs/reference/mapping/types/core-types.asciidoc index 0f3209cb244..0f665724b4f 100644 --- a/docs/reference/mapping/types/core-types.asciidoc +++ b/docs/reference/mapping/types/core-types.asciidoc @@ -88,6 +88,9 @@ searchable at all (as an individual field; it may still be included in `_all`). Setting to `no` disables `include_in_all`. Defaults to `analyzed`. +|`doc_values` |Set to `true` to store field values in a column-stride fashion. +Automatically set to `true` when the fielddata format is `doc_values`. + |`term_vector` |Possible values are `no`, `yes`, `with_offsets`, `with_positions`, `with_positions_offsets`. Defaults to `no`. @@ -195,6 +198,9 @@ and it can be retrieved from it). in `_source`, have `include_in_all` enabled, or `store` should be set to `true` for this to be useful. +|`doc_values` |Set to `true` to store field values in a column-stride fashion. +Automatically set to `true` when the fielddata format is `doc_values`. + |`precision_step` |The precision step (number of terms generated for each number value). Defaults to `4`. @@ -303,6 +309,9 @@ and it can be retrieved from it). in `_source`, have `include_in_all` enabled, or `store` should be set to `true` for this to be useful. +|`doc_values` |Set to `true` to store field values in a column-stride fashion. +Automatically set to `true` when the fielddata format is `doc_values`. + |`precision_step` |The precision step (number of terms generated for each number value). Defaults to `4`. diff --git a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java index b6f90f1c64a..760f9ef4488 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java @@ -64,6 +64,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { public static class Defaults { public static final FieldType FIELD_TYPE = new FieldType(); + public static final boolean DOC_VALUES = false; static { FIELD_TYPE.setIndexed(true); @@ -81,6 +82,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { public abstract static class Builder extends Mapper.Builder { protected final FieldType fieldType; + protected Boolean docValues; protected float boost = Defaults.BOOST; protected boolean omitNormsSet = false; protected String indexName; @@ -109,6 +111,11 @@ public abstract class AbstractFieldMapper implements FieldMapper { return builder; } + public T docValues(boolean docValues) { + this.docValues = docValues; + return builder; + } + public T storeTermVectors(boolean termVectors) { this.fieldType.setStoreTermVectors(termVectors); return builder; @@ -227,7 +234,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { protected Settings customFieldDataSettings; protected FieldDataType fieldDataType; - protected AbstractFieldMapper(Names names, float boost, FieldType fieldType, NamedAnalyzer indexAnalyzer, + protected AbstractFieldMapper(Names names, float boost, FieldType fieldType, Boolean docValues, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, PostingsFormatProvider postingsFormat, DocValuesFormatProvider docValuesFormat, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { @@ -266,8 +273,10 @@ public abstract class AbstractFieldMapper implements FieldMapper { ImmutableSettings.builder().put(defaultFieldDataType().getSettings()).put(fieldDataSettings) ); } - if (fieldDataType == null) { - docValues = false; + if (docValues != null) { + this.docValues = docValues; + } else if (fieldDataType == null) { + this.docValues = false; } else { this.docValues = FieldDataType.DOC_VALUES_FORMAT_VALUE.equals(fieldDataType.getFormat(indexSettings)); } @@ -498,6 +507,11 @@ public abstract class AbstractFieldMapper implements FieldMapper { if (this.fieldType().stored() != fieldMergeWith.fieldType().stored()) { mergeContext.addConflict("mapper [" + names.fullName() + "] has different store values"); } + if (!this.hasDocValues() && fieldMergeWith.hasDocValues()) { + // don't add conflict if this mapper has doc values while the mapper to merge doesn't since doc values are implicitely set + // when the doc_values field data format is configured + mergeContext.addConflict("mapper [" + names.fullName() + "] has different " + TypeParsers.DOC_VALUES + " values"); + } if (this.fieldType().tokenized() != fieldMergeWith.fieldType().tokenized()) { mergeContext.addConflict("mapper [" + names.fullName() + "] has different tokenize values"); } @@ -593,6 +607,9 @@ public abstract class AbstractFieldMapper implements FieldMapper { if (includeDefaults || fieldType.stored() != defaultFieldType.stored()) { builder.field("store", fieldType.stored()); } + if (includeDefaults || hasDocValues() != Defaults.DOC_VALUES) { + builder.field(TypeParsers.DOC_VALUES, docValues); + } if (includeDefaults || fieldType.storeTermVectors() != defaultFieldType.storeTermVectors()) { builder.field("term_vector", termVectorOptionsToString(fieldType)); } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java index 577f431801e..884b3131738 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java @@ -121,7 +121,7 @@ public class BinaryFieldMapper extends AbstractFieldMapper { protected BinaryFieldMapper(Names names, FieldType fieldType, Boolean compress, long compressThreshold, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider) { - super(names, 1.0f, fieldType, null, null, postingsProvider, docValuesProvider, null, null, null); + super(names, 1.0f, fieldType, null, null, null, postingsProvider, docValuesProvider, null, null, null); this.compress = compress; this.compressThreshold = compressThreshold; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java index 2a0c4aefb32..7fa26d56ad8 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java @@ -124,7 +124,7 @@ public class BooleanFieldMapper extends AbstractFieldMapper { protected BooleanFieldMapper(Names names, float boost, FieldType fieldType, Boolean nullValue, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, boost, fieldType, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); + super(names, boost, fieldType, null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); this.nullValue = nullValue; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java index 1a28fca67f7..4253efc7da5 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java @@ -91,7 +91,7 @@ public class ByteFieldMapper extends NumberFieldMapper { public ByteFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); ByteFieldMapper fieldMapper = new ByteFieldMapper(buildNames(context), - precisionStep, boost, fieldType, nullValue, ignoreMalformed(context), + precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -118,11 +118,11 @@ public class ByteFieldMapper extends NumberFieldMapper { private String nullValueAsString; - protected ByteFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, + protected ByteFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Byte nullValue, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, precisionStep, boost, fieldType, + super(names, precisionStep, boost, fieldType, docValues, ignoreMalformed, new NamedAnalyzer("_byte/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)), new NamedAnalyzer("_byte/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)), postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); diff --git a/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java index eed3c156036..0b66060e1d4 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java @@ -195,7 +195,7 @@ public class CompletionFieldMapper extends AbstractFieldMapper { public CompletionFieldMapper(Names names, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, PostingsFormatProvider postingsProvider, SimilarityProvider similarity, boolean payloads, boolean preserveSeparators, boolean preservePositionIncrements, int maxInputLength) { - super(names, 1.0f, Defaults.FIELD_TYPE, indexAnalyzer, searchAnalyzer, postingsProvider, null, similarity, null, null); + super(names, 1.0f, Defaults.FIELD_TYPE, null, indexAnalyzer, searchAnalyzer, postingsProvider, null, similarity, null, null); analyzingSuggestLookupProvider = new AnalyzingCompletionLookupProvider(preserveSeparators, false, preservePositionIncrements, payloads); this.completionPostingsFormatProvider = new CompletionPostingsFormatProvider("completion", postingsProvider, analyzingSuggestLookupProvider); this.preserveSeparators = preserveSeparators; diff --git a/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java index 68ef81c4f1b..79301f2d38c 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java @@ -128,7 +128,7 @@ public class DateFieldMapper extends NumberFieldMapper { dateTimeFormatter = new FormatDateTimeFormatter(dateTimeFormatter.format(), dateTimeFormatter.parser(), dateTimeFormatter.printer(), locale); } DateFieldMapper fieldMapper = new DateFieldMapper(buildNames(context), dateTimeFormatter, - precisionStep, boost, fieldType, nullValue, timeUnit, roundCeil, ignoreMalformed(context), + precisionStep, boost, fieldType, docValues, nullValue, timeUnit, roundCeil, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -200,11 +200,11 @@ public class DateFieldMapper extends NumberFieldMapper { protected final TimeUnit timeUnit; - protected DateFieldMapper(Names names, FormatDateTimeFormatter dateTimeFormatter, int precisionStep, float boost, FieldType fieldType, + protected DateFieldMapper(Names names, FormatDateTimeFormatter dateTimeFormatter, int precisionStep, float boost, FieldType fieldType, Boolean docValues, String nullValue, TimeUnit timeUnit, boolean roundCeil, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, precisionStep, boost, fieldType, ignoreMalformed, new NamedAnalyzer("_date/" + precisionStep, + super(names, precisionStep, boost, fieldType, docValues, ignoreMalformed, new NamedAnalyzer("_date/" + precisionStep, new NumericDateAnalyzer(precisionStep, dateTimeFormatter.parser())), new NamedAnalyzer("_date/max", new NumericDateAnalyzer(Integer.MAX_VALUE, dateTimeFormatter.parser())), postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); diff --git a/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java index ce13775446c..3b3e9849bc8 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java @@ -94,7 +94,7 @@ public class DoubleFieldMapper extends NumberFieldMapper { public DoubleFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); DoubleFieldMapper fieldMapper = new DoubleFieldMapper(buildNames(context), - precisionStep, boost, fieldType, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, + precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -122,11 +122,11 @@ public class DoubleFieldMapper extends NumberFieldMapper { private String nullValueAsString; - protected DoubleFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, + protected DoubleFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Double nullValue, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, precisionStep, boost, fieldType, ignoreMalformed, + super(names, precisionStep, boost, fieldType, docValues, ignoreMalformed, NumericDoubleAnalyzer.buildNamedAnalyzer(precisionStep), NumericDoubleAnalyzer.buildNamedAnalyzer(Integer.MAX_VALUE), postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); this.nullValue = nullValue; diff --git a/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java index d5e2618710d..aa35585840d 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java @@ -95,7 +95,7 @@ public class FloatFieldMapper extends NumberFieldMapper { public FloatFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); FloatFieldMapper fieldMapper = new FloatFieldMapper(buildNames(context), - precisionStep, boost, fieldType, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, + precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -122,11 +122,11 @@ public class FloatFieldMapper extends NumberFieldMapper { private String nullValueAsString; - protected FloatFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, + protected FloatFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Float nullValue, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, precisionStep, boost, fieldType, ignoreMalformed, + super(names, precisionStep, boost, fieldType, docValues, ignoreMalformed, NumericFloatAnalyzer.buildNamedAnalyzer(precisionStep), NumericFloatAnalyzer.buildNamedAnalyzer(Integer.MAX_VALUE), postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); this.nullValue = nullValue; diff --git a/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java index b7ec56b5a62..06d8539eab9 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java @@ -90,7 +90,7 @@ public class IntegerFieldMapper extends NumberFieldMapper { @Override public IntegerFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); - IntegerFieldMapper fieldMapper = new IntegerFieldMapper(buildNames(context), precisionStep, boost, fieldType, + IntegerFieldMapper fieldMapper = new IntegerFieldMapper(buildNames(context), precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -117,11 +117,11 @@ public class IntegerFieldMapper extends NumberFieldMapper { private String nullValueAsString; - protected IntegerFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, + protected IntegerFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Integer nullValue, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, precisionStep, boost, fieldType, ignoreMalformed, + super(names, precisionStep, boost, fieldType, docValues, ignoreMalformed, NumericIntegerAnalyzer.buildNamedAnalyzer(precisionStep), NumericIntegerAnalyzer.buildNamedAnalyzer(Integer.MAX_VALUE), postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); this.nullValue = nullValue; diff --git a/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java index 178168c8a49..32d43ce4f9d 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java @@ -90,7 +90,7 @@ public class LongFieldMapper extends NumberFieldMapper { @Override public LongFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); - LongFieldMapper fieldMapper = new LongFieldMapper(buildNames(context), precisionStep, boost, fieldType, nullValue, + LongFieldMapper fieldMapper = new LongFieldMapper(buildNames(context), precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -117,11 +117,11 @@ public class LongFieldMapper extends NumberFieldMapper { private String nullValueAsString; - protected LongFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, + protected LongFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Long nullValue, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, precisionStep, boost, fieldType, ignoreMalformed, + super(names, precisionStep, boost, fieldType, docValues, ignoreMalformed, NumericLongAnalyzer.buildNamedAnalyzer(precisionStep), NumericLongAnalyzer.buildNamedAnalyzer(Integer.MAX_VALUE), postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); this.nullValue = nullValue; diff --git a/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java index 847ff445e8f..1e9e852ddef 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java @@ -143,13 +143,13 @@ public abstract class NumberFieldMapper extends AbstractFieldM } }; - protected NumberFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, + protected NumberFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Explicit ignoreMalformed, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { // LUCENE 4 UPGRADE: Since we can't do anything before the super call, we have to push the boost check down to subclasses - super(names, boost, fieldType, indexAnalyzer, searchAnalyzer, postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); + super(names, boost, fieldType, docValues, indexAnalyzer, searchAnalyzer, postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); if (precisionStep <= 0 || precisionStep >= maxPrecisionStep()) { this.precisionStep = Integer.MAX_VALUE; } else { diff --git a/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java index 332e14bca7f..aee381eda4b 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java @@ -91,7 +91,7 @@ public class ShortFieldMapper extends NumberFieldMapper { @Override public ShortFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); - ShortFieldMapper fieldMapper = new ShortFieldMapper(buildNames(context), precisionStep, boost, fieldType, nullValue, + ShortFieldMapper fieldMapper = new ShortFieldMapper(buildNames(context), precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -118,11 +118,11 @@ public class ShortFieldMapper extends NumberFieldMapper { private String nullValueAsString; - protected ShortFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, + protected ShortFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Short nullValue, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, precisionStep, boost, fieldType, ignoreMalformed, new NamedAnalyzer("_short/" + precisionStep, + super(names, precisionStep, boost, fieldType, docValues, ignoreMalformed, new NamedAnalyzer("_short/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)), new NamedAnalyzer("_short/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)), postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); this.nullValue = nullValue; diff --git a/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java index 515dad5e89f..93efa2bfe85 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java @@ -134,7 +134,7 @@ public class StringFieldMapper extends AbstractFieldMapper implements Al } } StringFieldMapper fieldMapper = new StringFieldMapper(buildNames(context), - boost, fieldType, nullValue, indexAnalyzer, searchAnalyzer, searchQuotedAnalyzer, + boost, fieldType, docValues, nullValue, indexAnalyzer, searchAnalyzer, searchQuotedAnalyzer, positionOffsetGap, ignoreAbove, postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -188,12 +188,12 @@ public class StringFieldMapper extends AbstractFieldMapper implements Al private int ignoreAbove; - protected StringFieldMapper(Names names, float boost, FieldType fieldType, + protected StringFieldMapper(Names names, float boost, FieldType fieldType, Boolean docValues, String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, NamedAnalyzer searchQuotedAnalyzer, int positionOffsetGap, int ignoreAbove, PostingsFormatProvider postingsFormat, DocValuesFormatProvider docValuesFormat, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, boost, fieldType, indexAnalyzer, searchAnalyzer, postingsFormat, docValuesFormat, similarity, fieldDataSettings, indexSettings); + super(names, boost, fieldType, docValues, indexAnalyzer, searchAnalyzer, postingsFormat, docValuesFormat, similarity, fieldDataSettings, indexSettings); if (fieldType.tokenized() && fieldType.indexed() && hasDocValues()) { throw new MapperParsingException("Field [" + names.fullName() + "] cannot be analyzed and have doc values"); } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java index 1839e952e1a..11f1c1d17d1 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java @@ -78,7 +78,7 @@ public class TokenCountFieldMapper extends IntegerFieldMapper { @Override public TokenCountFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); - TokenCountFieldMapper fieldMapper = new TokenCountFieldMapper(buildNames(context), precisionStep, boost, fieldType, nullValue, + TokenCountFieldMapper fieldMapper = new TokenCountFieldMapper(buildNames(context), precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings(), analyzer); fieldMapper.includeInAll(includeInAll); @@ -114,10 +114,10 @@ public class TokenCountFieldMapper extends IntegerFieldMapper { private NamedAnalyzer analyzer; - protected TokenCountFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Integer nullValue, + protected TokenCountFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Integer nullValue, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, Settings fieldDataSettings, Settings indexSettings, NamedAnalyzer analyzer) { - super(names, precisionStep, boost, fieldType, nullValue, ignoreMalformed, postingsProvider, docValuesProvider, similarity, + super(names, precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed, postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); this.analyzer = analyzer; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java b/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java index fb18ca06eff..81081f78b25 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java @@ -42,6 +42,7 @@ import static org.elasticsearch.index.mapper.FieldMapper.DOC_VALUES_FORMAT; */ public class TypeParsers { + public static final String DOC_VALUES = "doc_values"; public static final String INDEX_OPTIONS_DOCS = "docs"; public static final String INDEX_OPTIONS_FREQS = "freqs"; public static final String INDEX_OPTIONS_POSITIONS = "positions"; @@ -76,6 +77,8 @@ public class TypeParsers { parseIndex(name, propNode.toString(), builder); } else if (propName.equals("tokenized")) { builder.tokenized(nodeBooleanValue(propNode)); + } else if (propName.equals(DOC_VALUES)) { + builder.docValues(nodeBooleanValue(propNode)); } else if (propName.equals("term_vector")) { parseTermVector(name, propNode.toString(), builder); } else if (propName.equals("boost")) { diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java index 67d9c7e034d..df4d525d1ea 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java @@ -196,7 +196,7 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implement // store them as a single token. fieldType.setTokenized(false); - return new GeoPointFieldMapper(buildNames(context), fieldType, indexAnalyzer, searchAnalyzer, postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings(), origPathType, enableLatLon, enableGeoHash, enableGeohashPrefix, precisionStep, geoHashPrecision, latMapper, lonMapper, geohashMapper, validateLon, validateLat, normalizeLon, normalizeLat); + return new GeoPointFieldMapper(buildNames(context), fieldType, docValues, indexAnalyzer, searchAnalyzer, postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings(), origPathType, enableLatLon, enableGeoHash, enableGeohashPrefix, precisionStep, geoHashPrecision, latMapper, lonMapper, geohashMapper, validateLon, validateLat, normalizeLon, normalizeLat); } } @@ -392,7 +392,7 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implement private final boolean normalizeLon; private final boolean normalizeLat; - public GeoPointFieldMapper(FieldMapper.Names names, FieldType fieldType, + public GeoPointFieldMapper(FieldMapper.Names names, FieldType fieldType, Boolean docValues, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, PostingsFormatProvider postingsFormat, DocValuesFormatProvider docValuesFormat, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings, @@ -400,7 +400,7 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implement DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper, StringFieldMapper geohashMapper, boolean validateLon, boolean validateLat, boolean normalizeLon, boolean normalizeLat) { - super(names, 1f, fieldType, null, indexAnalyzer, postingsFormat, docValuesFormat, similarity, fieldDataSettings, indexSettings); + super(names, 1f, fieldType, docValues, null, indexAnalyzer, postingsFormat, docValuesFormat, similarity, fieldDataSettings, indexSettings); this.pathType = pathType; this.enableLatLon = enableLatLon; this.enableGeoHash = enableGeoHash || enableGeohashPrefix; // implicitly enable geohashes if geohash_prefix is set diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java index 0133cb8f7a6..451d879bcc9 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java @@ -196,7 +196,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper { public GeoShapeFieldMapper(FieldMapper.Names names, SpatialPrefixTree tree, String defaultStrategyName, double distanceErrorPct, FieldType fieldType, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider) { - super(names, 1, fieldType, null, null, postingsProvider, docValuesProvider, null, null, null); + super(names, 1, fieldType, null, null, null, postingsProvider, docValuesProvider, null, null, null); this.recursiveStrategy = new RecursivePrefixTreeStrategy(tree, names.indexName()); this.recursiveStrategy.setDistErrPct(distanceErrorPct); this.termStrategy = new TermQueryPrefixTreeStrategy(tree, names.indexName()); diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java index 620591cad66..21c842a7ec4 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java @@ -145,7 +145,7 @@ public class AllFieldMapper extends AbstractFieldMapper implements Interna boolean enabled, boolean autoBoost, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(name, name, name, name), 1.0f, fieldType, indexAnalyzer, searchAnalyzer, postingsProvider, docValuesProvider, + super(new Names(name, name, name, name), 1.0f, fieldType, null, indexAnalyzer, searchAnalyzer, postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); this.enabled = enabled; this.autoBoost = autoBoost; diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/BoostFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/BoostFieldMapper.java index 2fb388451af..073ffb5bc2b 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/BoostFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/BoostFieldMapper.java @@ -90,7 +90,7 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern @Override public BoostFieldMapper build(BuilderContext context) { return new BoostFieldMapper(name, buildIndexName(context), - precisionStep, boost, fieldType, nullValue, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); + precisionStep, boost, fieldType, docValues, nullValue, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); } } @@ -118,13 +118,13 @@ public class BoostFieldMapper extends NumberFieldMapper implements Intern } protected BoostFieldMapper(String name, String indexName) { - this(name, indexName, Defaults.PRECISION_STEP, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), + this(name, indexName, Defaults.PRECISION_STEP, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null, Defaults.NULL_VALUE, null, null, null, ImmutableSettings.EMPTY); } - protected BoostFieldMapper(String name, String indexName, int precisionStep, float boost, FieldType fieldType, Float nullValue, + protected BoostFieldMapper(String name, String indexName, int precisionStep, float boost, FieldType fieldType, Boolean docValues, Float nullValue, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(name, indexName, indexName, name), precisionStep, boost, fieldType, Defaults.IGNORE_MALFORMED, + super(new Names(name, indexName, indexName, name), precisionStep, boost, fieldType, docValues, Defaults.IGNORE_MALFORMED, NumericFloatAnalyzer.buildNamedAnalyzer(precisionStep), NumericFloatAnalyzer.buildNamedAnalyzer(Integer.MAX_VALUE), postingsProvider, docValuesProvider, null, fieldDataSettings, indexSettings); this.nullValue = nullValue; diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java index 2739a62e1d4..39d53bea1c3 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java @@ -97,7 +97,7 @@ public class IdFieldMapper extends AbstractFieldMapper implements Intern @Override public IdFieldMapper build(BuilderContext context) { - return new IdFieldMapper(name, indexName, boost, fieldType, path, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); + return new IdFieldMapper(name, indexName, boost, fieldType, docValues, path, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); } } @@ -120,21 +120,21 @@ public class IdFieldMapper extends AbstractFieldMapper implements Intern private final String path; public IdFieldMapper() { - this(Defaults.NAME, Defaults.INDEX_NAME, new FieldType(Defaults.FIELD_TYPE)); + this(new FieldType(Defaults.FIELD_TYPE)); } public IdFieldMapper(FieldType fieldType) { - this(Defaults.NAME, Defaults.INDEX_NAME, fieldType); + this(Defaults.NAME, Defaults.INDEX_NAME, fieldType, null); } - protected IdFieldMapper(String name, String indexName, FieldType fieldType) { - this(name, indexName, Defaults.BOOST, fieldType, Defaults.PATH, null, null, null, ImmutableSettings.EMPTY); + protected IdFieldMapper(String name, String indexName, FieldType fieldType, Boolean docValues) { + this(name, indexName, Defaults.BOOST, fieldType, docValues, Defaults.PATH, null, null, null, ImmutableSettings.EMPTY); } - protected IdFieldMapper(String name, String indexName, float boost, FieldType fieldType, String path, + protected IdFieldMapper(String name, String indexName, float boost, FieldType fieldType, Boolean docValues, String path, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(name, indexName, indexName, name), boost, fieldType, Lucene.KEYWORD_ANALYZER, + super(new Names(name, indexName, indexName, name), boost, fieldType, docValues, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsProvider, docValuesProvider, null, fieldDataSettings, indexSettings); this.path = path; } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java index 1fb8fe3b424..0869002015d 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java @@ -85,7 +85,7 @@ public class IndexFieldMapper extends AbstractFieldMapper implements Int @Override public IndexFieldMapper build(BuilderContext context) { - return new IndexFieldMapper(name, indexName, boost, fieldType, enabledState, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); + return new IndexFieldMapper(name, indexName, boost, fieldType, docValues, enabledState, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); } } @@ -114,12 +114,12 @@ public class IndexFieldMapper extends AbstractFieldMapper implements Int } protected IndexFieldMapper(String name, String indexName) { - this(name, indexName, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), Defaults.ENABLED_STATE, null, null, null, ImmutableSettings.EMPTY); + this(name, indexName, Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null, Defaults.ENABLED_STATE, null, null, null, ImmutableSettings.EMPTY); } - public IndexFieldMapper(String name, String indexName, float boost, FieldType fieldType, EnabledAttributeMapper enabledState, + public IndexFieldMapper(String name, String indexName, float boost, FieldType fieldType, Boolean docValues, EnabledAttributeMapper enabledState, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(name, indexName, indexName, name), boost, fieldType, Lucene.KEYWORD_ANALYZER, + super(new Names(name, indexName, indexName, name), boost, fieldType, docValues, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsProvider, docValuesProvider, null, fieldDataSettings, indexSettings); this.enabledState = enabledState; } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java index 40202c8ac55..d775f5abe20 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java @@ -126,17 +126,14 @@ public class ParentFieldMapper extends AbstractFieldMapper implements Inter private final BytesRef typeAsBytes; protected ParentFieldMapper(String name, String indexName, String type, PostingsFormatProvider postingsFormat, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), + super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsFormat, null, null, fieldDataSettings, indexSettings); this.type = type; - this.typeAsBytes = new BytesRef(type); + this.typeAsBytes = type == null ? null : new BytesRef(type); } public ParentFieldMapper() { - super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), - Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, null, null, null, null, null); - type = null; - typeAsBytes = null; + this(Defaults.NAME, Defaults.NAME, null, null, null, null); } public String type() { diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java index 394da26d421..70dcef04c77 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java @@ -125,7 +125,7 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements I protected RoutingFieldMapper(FieldType fieldType, boolean required, String path, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), 1.0f, fieldType, Lucene.KEYWORD_ANALYZER, + super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), 1.0f, fieldType, null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsProvider, docValuesProvider, null, fieldDataSettings, indexSettings); this.required = required; this.path = path; diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java index 4b2e15e761c..4d66b1ffb16 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/SizeFieldMapper.java @@ -101,7 +101,7 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper { public SizeFieldMapper(EnabledAttributeMapper enabled, FieldType fieldType, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(Defaults.NAME), Defaults.PRECISION_STEP, Defaults.BOOST, fieldType, Defaults.NULL_VALUE, + super(new Names(Defaults.NAME), Defaults.PRECISION_STEP, Defaults.BOOST, fieldType, null, Defaults.NULL_VALUE, Defaults.IGNORE_MALFORMED, postingsProvider, docValuesProvider, null, fieldDataSettings, indexSettings); this.enabledState = enabled; } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java index 07978fe84b1..c994f4d8904 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java @@ -195,7 +195,7 @@ public class SourceFieldMapper extends AbstractFieldMapper implements In protected SourceFieldMapper(String name, boolean enabled, String format, Boolean compress, long compressThreshold, String[] includes, String[] excludes) { - super(new Names(name, name, name, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), + super(new Names(name, name, name, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, null, null, null, null, null); // Only stored. this.enabled = enabled; this.compress = compress; diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java index 3b6d25ca1fd..1038e60fd2f 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java @@ -126,7 +126,7 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, @Nullable Settings fieldDataSettings, Settings indexSettings) { super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), Defaults.PRECISION_STEP, - Defaults.BOOST, fieldType, Defaults.NULL_VALUE, ignoreMalformed, + Defaults.BOOST, fieldType, null, Defaults.NULL_VALUE, ignoreMalformed, postingsProvider, docValuesProvider, null, fieldDataSettings, indexSettings); this.enabledState = enabled; this.defaultTTL = defaultTTL; diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java index f9bcbe3572b..fbadf6f0fbf 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java @@ -104,7 +104,7 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap Settings settings = context.indexSettings(); roundCeil = settings.getAsBoolean("index.mapping.date.round_ceil", settings.getAsBoolean("index.mapping.date.parse_upper_inclusive", Defaults.ROUND_CEIL)); } - return new TimestampFieldMapper(fieldType, enabledState, path, dateTimeFormatter, roundCeil, + return new TimestampFieldMapper(fieldType, docValues, enabledState, path, dateTimeFormatter, roundCeil, ignoreMalformed(context), postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); } } @@ -136,17 +136,17 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap private final String path; public TimestampFieldMapper() { - this(new FieldType(Defaults.FIELD_TYPE), Defaults.ENABLED, Defaults.PATH, Defaults.DATE_TIME_FORMATTER, + this(new FieldType(Defaults.FIELD_TYPE), null, Defaults.ENABLED, Defaults.PATH, Defaults.DATE_TIME_FORMATTER, Defaults.ROUND_CEIL, Defaults.IGNORE_MALFORMED, null, null, null, ImmutableSettings.EMPTY); } - protected TimestampFieldMapper(FieldType fieldType, EnabledAttributeMapper enabledState, String path, + protected TimestampFieldMapper(FieldType fieldType, Boolean docValues, EnabledAttributeMapper enabledState, String path, FormatDateTimeFormatter dateTimeFormatter, boolean roundCeil, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, @Nullable Settings fieldDataSettings, Settings indexSettings) { super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), dateTimeFormatter, - Defaults.PRECISION_STEP, Defaults.BOOST, fieldType, + Defaults.PRECISION_STEP, Defaults.BOOST, fieldType, docValues, Defaults.NULL_VALUE, TimeUnit.MILLISECONDS /*always milliseconds*/, roundCeil, ignoreMalformed, postingsProvider, docValuesProvider, null, fieldDataSettings, indexSettings); this.enabledState = enabledState; diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java index 055b399bb9f..01bb11fe980 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java @@ -108,7 +108,7 @@ public class TypeFieldMapper extends AbstractFieldMapper implements Inte public TypeFieldMapper(String name, String indexName, float boost, FieldType fieldType, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(name, indexName, indexName, name), boost, fieldType, Lucene.KEYWORD_ANALYZER, + super(new Names(name, indexName, indexName, name), boost, fieldType, null, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsProvider, docValuesProvider, null, fieldDataSettings, indexSettings); } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java index 63d49b9c7bf..a6eefaf6c35 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java @@ -86,7 +86,7 @@ public class UidFieldMapper extends AbstractFieldMapper implements Internal @Override public UidFieldMapper build(BuilderContext context) { - return new UidFieldMapper(name, indexName, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); + return new UidFieldMapper(name, indexName, docValues, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); } } @@ -104,11 +104,11 @@ public class UidFieldMapper extends AbstractFieldMapper implements Internal } protected UidFieldMapper(String name) { - this(name, name, null, null, null, ImmutableSettings.EMPTY); + this(name, name, null, null, null, null, ImmutableSettings.EMPTY); } - protected UidFieldMapper(String name, String indexName, PostingsFormatProvider postingsFormat, DocValuesFormatProvider docValuesFormat, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), + protected UidFieldMapper(String name, String indexName, Boolean docValues, PostingsFormatProvider postingsFormat, DocValuesFormatProvider docValuesFormat, @Nullable Settings fieldDataSettings, Settings indexSettings) { + super(new Names(name, indexName, indexName, name), Defaults.BOOST, new FieldType(Defaults.FIELD_TYPE), docValues, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER, postingsFormat, docValuesFormat, null, fieldDataSettings, indexSettings); } diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/VersionFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/VersionFieldMapper.java index ea4bba0f206..d867959028e 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/VersionFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/VersionFieldMapper.java @@ -99,7 +99,7 @@ public class VersionFieldMapper extends AbstractFieldMapper implements Int } VersionFieldMapper(DocValuesFormatProvider docValuesFormat) { - super(new Names(NAME, NAME, NAME, NAME), Defaults.BOOST, Defaults.FIELD_TYPE, null, null, null, docValuesFormat, null, null, ImmutableSettings.EMPTY); + super(new Names(NAME, NAME, NAME, NAME), Defaults.BOOST, Defaults.FIELD_TYPE, null, null, null, null, docValuesFormat, null, null, ImmutableSettings.EMPTY); } @Override diff --git a/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java index 0684797f2a1..4fe05a6f2e3 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java @@ -121,7 +121,7 @@ public class IpFieldMapper extends NumberFieldMapper { public IpFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); IpFieldMapper fieldMapper = new IpFieldMapper(buildNames(context), - precisionStep, boost, fieldType, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, + precisionStep, boost, fieldType, docValues, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; @@ -146,11 +146,11 @@ public class IpFieldMapper extends NumberFieldMapper { private String nullValue; - protected IpFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, + protected IpFieldMapper(Names names, int precisionStep, float boost, FieldType fieldType, Boolean docValues, String nullValue, Explicit ignoreMalformed, PostingsFormatProvider postingsProvider, DocValuesFormatProvider docValuesProvider, SimilarityProvider similarity, @Nullable Settings fieldDataSettings, Settings indexSettings) { - super(names, precisionStep, boost, fieldType, + super(names, precisionStep, boost, fieldType, docValues, ignoreMalformed, new NamedAnalyzer("_ip/" + precisionStep, new NumericIpAnalyzer(precisionStep)), new NamedAnalyzer("_ip/max", new NumericIpAnalyzer(Integer.MAX_VALUE)), postingsProvider, docValuesProvider, similarity, fieldDataSettings, indexSettings); diff --git a/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java index 45bd6bccbc1..b2c939072c5 100644 --- a/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java @@ -224,6 +224,10 @@ public class SimpleStringMappingTests extends ElasticsearchTestCase { new StringFieldMapper.Builder("anything").tokenized(false).fieldDataSettings(DOC_VALUES_SETTINGS).build(ctx); new StringFieldMapper.Builder("anything").index(false).fieldDataSettings(DOC_VALUES_SETTINGS).build(ctx); + assertFalse(new StringFieldMapper.Builder("anything").index(false).build(ctx).hasDocValues()); + assertTrue(new StringFieldMapper.Builder("anything").index(false).fieldDataSettings(DOC_VALUES_SETTINGS).build(ctx).hasDocValues()); + assertTrue(new StringFieldMapper.Builder("anything").index(false).docValues(true).build(ctx).hasDocValues()); + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") .startObject("properties") .startObject("str1")