Merge null_value for boolean field and remove include_in_all for boolean field in doc

Close #5502
This commit is contained in:
Kevin 2014-03-24 20:32:05 +11:00 committed by Adrien Grand
parent 6f6dd90d1a
commit 1496b03458
2 changed files with 13 additions and 7 deletions

View File

@ -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` |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 `null_value` as the field value. Defaults to not adding the field at
all. 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] [float]

View File

@ -36,9 +36,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.codec.docvaluesformat.DocValuesFormatProvider; import org.elasticsearch.index.codec.docvaluesformat.DocValuesFormatProvider;
import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider; import org.elasticsearch.index.codec.postingsformat.PostingsFormatProvider;
import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.fielddata.FieldDataType;
import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.*;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.ParseContext;
import org.elasticsearch.index.similarity.SimilarityProvider; import org.elasticsearch.index.similarity.SimilarityProvider;
import java.io.IOException; import java.io.IOException;
@ -226,6 +224,18 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
fields.add(new Field(names.indexName(), value ? "T" : "F", fieldType)); 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 @Override
protected String contentType() { protected String contentType() {
return CONTENT_TYPE; return CONTENT_TYPE;