From 1496b0345832e4a57ae569f72de8df524e11f408 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 24 Mar 2014 20:32:05 +1100 Subject: [PATCH] Merge null_value for boolean field and remove include_in_all for boolean field in doc Close #5502 --- docs/reference/mapping/types/core-types.asciidoc | 4 ---- .../index/mapper/core/BooleanFieldMapper.java | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/reference/mapping/types/core-types.asciidoc b/docs/reference/mapping/types/core-types.asciidoc index 7781d6cbac0..f271a17a614 100644 --- a/docs/reference/mapping/types/core-types.asciidoc +++ b/docs/reference/mapping/types/core-types.asciidoc @@ -389,10 +389,6 @@ in `_source`, have `include_in_all` enabled, or `store` be set to |`null_value` |When there is a (JSON) null value for the field, use the `null_value` as the field value. Defaults to not adding the field at all. - -|`include_in_all` |Should the field be included in the `_all` field (if -enabled). If `index` is set to `no` this defaults to `false`, otherwise, -defaults to `true` or to the parent `object` type setting. |======================================================================= [float] 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 89c42105a96..fa7a28a4858 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java @@ -36,9 +36,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.codec.docvaluesformat.DocValuesFormatProvider; import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider; import org.elasticsearch.index.fielddata.FieldDataType; -import org.elasticsearch.index.mapper.Mapper; -import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.mapper.ParseContext; +import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.similarity.SimilarityProvider; import java.io.IOException; @@ -226,6 +224,18 @@ public class BooleanFieldMapper extends AbstractFieldMapper { fields.add(new Field(names.indexName(), value ? "T" : "F", fieldType)); } + @Override + public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { + super.merge(mergeWith, mergeContext); + if (!this.getClass().equals(mergeWith.getClass())) { + return; + } + + if (!mergeContext.mergeFlags().simulate()) { + this.nullValue = ((BooleanFieldMapper) mergeWith).nullValue; + } + } + @Override protected String contentType() { return CONTENT_TYPE;