Mappings: Completely move doc values and fielddata settings to field types

While MappedFieldType contains settings for doc values and fielddata,
AbstractFieldMapper had special logic in its constructor that
required setting these on the field type from there. This change
removes those settings from the AbstractFieldMapper constructor.
As a result, defaultDocValues(), defaultFieldType() and
defaultFieldDataType() are no longer needed.
This commit is contained in:
Ryan Ernst 2015-07-02 18:30:09 -07:00
parent 275fdcc08d
commit e83ae64ea9
38 changed files with 210 additions and 582 deletions

View File

@ -81,7 +81,7 @@ public final class Settings implements ToXContent {
private transient ClassLoader classLoader;
Settings(Map<String, String> settings, ClassLoader classLoader) {
this.settings = ImmutableMap.copyOf(settings);
this.settings = ImmutableMap.copyOf(new TreeMap<>(settings));
Map<String, String> forcedUnderscoreSettings = null;
for (Map.Entry<String, String> entry : settings.entrySet()) {
String toUnderscoreCase = Strings.toUnderscoreCase(entry.getKey());

View File

@ -37,6 +37,7 @@ import org.apache.lucene.util.BytesRef;
import org.elasticsearch.action.fieldstats.FieldStats;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.index.fielddata.FieldDataType;
@ -189,6 +190,7 @@ public abstract class MappedFieldType extends FieldType {
setOmitNorms(false);
setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
setBoost(1.0f);
fieldDataType = new FieldDataType(typeName());
}
public abstract MappedFieldType clone();

View File

@ -38,8 +38,8 @@ public abstract class MetadataFieldMapper extends AbstractFieldMapper {
}
}
protected MetadataFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, @Nullable Settings fieldDataSettings, Settings indexSettings) {
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, MultiFields.empty(), null);
protected MetadataFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings) {
super(simpleName, fieldType, defaultFieldType, indexSettings, MultiFields.empty(), null);
}
/**

View File

@ -70,12 +70,13 @@ public abstract class AbstractFieldMapper extends FieldMapper {
public abstract static class Builder<T extends Builder, Y extends AbstractFieldMapper> extends Mapper.Builder<T, Y> {
protected final MappedFieldType fieldType;
protected final MappedFieldType defaultFieldType;
private final IndexOptions defaultOptions;
protected Boolean docValues;
protected boolean omitNormsSet = false;
protected String indexName;
protected Boolean includeInAll;
protected boolean indexOptionsSet = false;
protected boolean docValuesSet = false;
@Nullable
protected Settings fieldDataSettings;
protected final MultiFields.Builder multiFieldsBuilder;
@ -84,6 +85,7 @@ public abstract class AbstractFieldMapper extends FieldMapper {
protected Builder(String name, MappedFieldType fieldType) {
super(name);
this.fieldType = fieldType.clone();
this.defaultFieldType = fieldType.clone();
this.defaultOptions = fieldType.indexOptions(); // we have to store it the fieldType is mutable
multiFieldsBuilder = new MultiFields.Builder();
}
@ -116,7 +118,8 @@ public abstract class AbstractFieldMapper extends FieldMapper {
}
public T docValues(boolean docValues) {
this.docValues = docValues;
this.fieldType.setHasDocValues(docValues);
this.docValuesSet = true;
return builder;
}
@ -253,76 +256,53 @@ public abstract class AbstractFieldMapper extends FieldMapper {
protected void setupFieldType(BuilderContext context) {
fieldType.setNames(buildNames(context));
}
}
protected MappedFieldTypeReference fieldTypeRef;
protected final boolean hasDefaultDocValues;
protected Settings customFieldDataSettings;
protected final MultiFields multiFields;
protected CopyTo copyTo;
protected final boolean indexCreatedBefore2x;
protected AbstractFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, @Nullable Settings fieldDataSettings, Settings indexSettings) {
this(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, MultiFields.empty(), null);
}
protected AbstractFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, @Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName);
assert indexSettings != null;
this.indexCreatedBefore2x = Version.indexCreated(indexSettings).before(Version.V_2_0_0);
this.customFieldDataSettings = fieldDataSettings;
FieldDataType fieldDataType;
if (fieldDataSettings == null) {
fieldDataType = defaultFieldDataType();
} else {
// create a new field data type, with the default settings as well as the "new ones"
fieldDataType = new FieldDataType(defaultFieldDataType().getType(),
Settings.builder().put(defaultFieldDataType().getSettings()).put(fieldDataSettings)
);
}
// TODO: hasDocValues should just be set directly on the field type by callers of this ctor, but
// then we need to eliminate defaultDocValues() (only needed by geo, which needs to be fixed with passing
// doc values setting down to lat/lon) and get rid of specifying doc values in fielddata (which
// complicates whether we can just compare to the default value to know whether to write the setting)
if (docValues == null && fieldDataType != null && FieldDataType.DOC_VALUES_FORMAT_VALUE.equals(fieldDataType.getFormat(indexSettings))) {
docValues = true;
}
hasDefaultDocValues = docValues == null;
this.fieldTypeRef = new MappedFieldTypeReference(fieldType); // must init first so defaultDocValues() can be called
fieldType = fieldType.clone();
if (fieldType.indexAnalyzer() == null && fieldType.tokenized() == false && fieldType.indexOptions() != IndexOptions.NONE) {
fieldType.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
fieldType.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
}
fieldType.setHasDocValues(docValues == null ? defaultDocValues() : docValues);
fieldType.setFieldDataType(fieldDataType);
fieldType.freeze();
this.fieldTypeRef.set(fieldType); // now reset ref once extra settings have been initialized
if (fieldDataSettings != null) {
Settings settings = Settings.builder().put(fieldType.fieldDataType().getSettings()).put(fieldDataSettings).build();
fieldType.setFieldDataType(new FieldDataType(fieldType.fieldDataType().getType(), settings));
}
boolean defaultDocValues = false; // pre 2.0
if (context.indexCreatedVersion().onOrAfter(Version.V_2_0_0)) {
defaultDocValues = fieldType.tokenized() == false && fieldType.indexOptions() != IndexOptions.NONE;
}
// backcompat for "fielddata: format: docvalues" for now...
boolean fieldDataDocValues = fieldType.fieldDataType() != null
&& FieldDataType.DOC_VALUES_FORMAT_VALUE.equals(fieldType.fieldDataType().getFormat(context.indexSettings()));
if (fieldDataDocValues && docValuesSet && fieldType.hasDocValues() == false) {
// this forces the doc_values setting to be written, so fielddata does not mask the original setting
defaultDocValues = true;
}
defaultFieldType.setHasDocValues(defaultDocValues);
if (docValuesSet == false) {
fieldType.setHasDocValues(defaultDocValues || fieldDataDocValues);
}
}
}
protected MappedFieldTypeReference fieldTypeRef;
protected final MappedFieldType defaultFieldType;
protected final MultiFields multiFields;
protected CopyTo copyTo;
protected final boolean indexCreatedBefore2x;
protected AbstractFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName);
assert indexSettings != null;
this.indexCreatedBefore2x = Version.indexCreated(indexSettings).before(Version.V_2_0_0);
this.fieldTypeRef = new MappedFieldTypeReference(fieldType);
this.defaultFieldType = defaultFieldType;
this.multiFields = multiFields;
this.copyTo = copyTo;
}
protected boolean defaultDocValues() {
if (indexCreatedBefore2x) {
return false;
} else {
return fieldType().tokenized() == false && fieldType().indexOptions() != IndexOptions.NONE;
}
}
@Override
public String name() {
return fieldType().names().fullName();
}
public abstract MappedFieldType defaultFieldType();
public abstract FieldDataType defaultFieldDataType();
@Override
public MappedFieldType fieldType() {
return fieldTypeRef.get();
@ -417,7 +397,6 @@ public abstract class AbstractFieldMapper extends FieldMapper {
MappedFieldType fieldType = fieldMergeWith.fieldType().clone();
fieldType.freeze();
fieldTypeRef.set(fieldType);
this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings;
this.copyTo = fieldMergeWith.copyTo;
}
}
@ -441,7 +420,6 @@ public abstract class AbstractFieldMapper extends FieldMapper {
builder.field("boost", fieldType().boost());
}
FieldType defaultFieldType = defaultFieldType();
boolean indexed = fieldType().indexOptions() != IndexOptions.NONE;
boolean defaultIndexed = defaultFieldType.indexOptions() != IndexOptions.NONE;
if (includeDefaults || indexed != defaultIndexed ||
@ -477,13 +455,8 @@ public abstract class AbstractFieldMapper extends FieldMapper {
builder.field("similarity", SimilarityLookupService.DEFAULT_SIMILARITY);
}
TreeMap<String, Object> orderedFielddataSettings = new TreeMap<>();
if (hasCustomFieldDataSettings()) {
orderedFielddataSettings.putAll(customFieldDataSettings.getAsMap());
builder.field("fielddata", orderedFielddataSettings);
} else if (includeDefaults) {
orderedFielddataSettings.putAll(fieldType().fieldDataType().getSettings().getAsMap());
builder.field("fielddata", orderedFielddataSettings);
if (includeDefaults || hasCustomFieldDataSettings()) {
builder.field("fielddata", fieldType().fieldDataType().getSettings().getAsMap());
}
multiFields.toXContent(builder, params);
@ -506,7 +479,7 @@ public abstract class AbstractFieldMapper extends FieldMapper {
}
protected void doXContentDocValues(XContentBuilder builder, boolean includeDefaults) throws IOException {
if (includeDefaults || hasDefaultDocValues == false) {
if (includeDefaults || defaultFieldType.hasDocValues() != fieldType().hasDocValues()) {
builder.field(DOC_VALUES, fieldType().hasDocValues());
}
}
@ -559,7 +532,7 @@ public abstract class AbstractFieldMapper extends FieldMapper {
}
protected boolean hasCustomFieldDataSettings() {
return customFieldDataSettings != null && customFieldDataSettings.equals(Settings.EMPTY) == false;
return fieldType().fieldDataType() != null && fieldType().fieldDataType().equals(defaultFieldType.fieldDataType()) == false;
}
protected abstract String contentType();

View File

@ -81,8 +81,8 @@ public class BinaryFieldMapper extends AbstractFieldMapper {
public BinaryFieldMapper build(BuilderContext context) {
setupFieldType(context);
((BinaryFieldType)fieldType).setTryUncompressing(context.indexCreatedVersion().before(Version.V_2_0_0));
return new BinaryFieldMapper(name, fieldType, docValues,
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
return new BinaryFieldMapper(name, fieldType, defaultFieldType,
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
}
}
@ -181,19 +181,9 @@ public class BinaryFieldMapper extends AbstractFieldMapper {
}
}
protected BinaryFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, multiFields, copyTo);
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("binary");
protected BinaryFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
}
@Override

View File

@ -90,8 +90,8 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
@Override
public BooleanFieldMapper build(BuilderContext context) {
setupFieldType(context);
return new BooleanFieldMapper(name, fieldType, docValues,
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
return new BooleanFieldMapper(name, fieldType, defaultFieldType,
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
}
}
@ -194,9 +194,9 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
}
}
protected BooleanFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, multiFields, copyTo);
protected BooleanFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
}
@Override
@ -204,17 +204,6 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
return (BooleanFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
// TODO have a special boolean type?
return new FieldDataType(CONTENT_TYPE);
}
@Override
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored() && !fieldType().hasDocValues()) {

View File

@ -81,8 +81,8 @@ public class ByteFieldMapper extends NumberFieldMapper {
@Override
public ByteFieldMapper build(BuilderContext context) {
setupFieldType(context);
ByteFieldMapper fieldMapper = new ByteFieldMapper(name, fieldType, docValues, ignoreMalformed(context),
coerce(context), fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
ByteFieldMapper fieldMapper = new ByteFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context),
coerce(context), context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
}
@ -193,10 +193,10 @@ public class ByteFieldMapper extends NumberFieldMapper {
}
}
protected ByteFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
protected ByteFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce, fieldDataSettings, indexSettings, multiFields, copyTo);
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
@Override
@ -204,16 +204,6 @@ public class ByteFieldMapper extends NumberFieldMapper {
return (ByteFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("byte");
}
private static byte parseValue(Object value) {
if (value instanceof Number) {
return ((Number) value).byteValue();

View File

@ -226,7 +226,9 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
private AnalyzingCompletionLookupProvider analyzingSuggestLookupProvider;
private SortedMap<String, ContextMapping> contextMapping = ContextMapping.EMPTY_MAPPING;
public CompletionFieldType() {}
public CompletionFieldType() {
setFieldDataType(null);
}
protected CompletionFieldType(CompletionFieldType ref) {
super(ref);
@ -312,7 +314,7 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
private int maxInputLength;
public CompletionFieldMapper(String simpleName, MappedFieldType fieldType, int maxInputLength, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, false, null, indexSettings, multiFields, copyTo);
super(simpleName, fieldType, Defaults.FIELD_TYPE, indexSettings, multiFields, copyTo);
this.maxInputLength = maxInputLength;
}
@ -538,16 +540,6 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
return CONTENT_TYPE;
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return null;
}
public boolean isStoringPayloads() {
return fieldType().analyzingSuggestLookupProvider.hasPayloads();
}

View File

@ -116,9 +116,8 @@ public class DateFieldMapper extends NumberFieldMapper {
public DateFieldMapper build(BuilderContext context) {
setupFieldType(context);
fieldType.setNullValue(nullValue);
DateFieldMapper fieldMapper = new DateFieldMapper(name, fieldType,
docValues, ignoreMalformed(context), coerce(context),
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
DateFieldMapper fieldMapper = new DateFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context),
coerce(context), context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
}
@ -259,6 +258,7 @@ public class DateFieldMapper extends NumberFieldMapper {
public DateFieldType() {
super(NumericType.LONG);
setFieldDataType(new FieldDataType("long"));
}
protected DateFieldType(DateFieldType ref) {
@ -436,9 +436,9 @@ public class DateFieldMapper extends NumberFieldMapper {
}
}
protected DateFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, Explicit<Boolean> ignoreMalformed,Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce, fieldDataSettings, indexSettings, multiFields, copyTo);
protected DateFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Explicit<Boolean> ignoreMalformed,Explicit<Boolean> coerce,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
@Override
@ -446,16 +446,6 @@ public class DateFieldMapper extends NumberFieldMapper {
return (DateFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("long");
}
private static Callable<Long> now() {
return new Callable<Long>() {
@Override

View File

@ -88,8 +88,8 @@ public class DoubleFieldMapper extends NumberFieldMapper {
@Override
public DoubleFieldMapper build(BuilderContext context) {
setupFieldType(context);
DoubleFieldMapper fieldMapper = new DoubleFieldMapper(name, fieldType, docValues, ignoreMalformed(context), coerce(context),
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
DoubleFieldMapper fieldMapper = new DoubleFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context), coerce(context),
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
}
@ -201,9 +201,9 @@ public class DoubleFieldMapper extends NumberFieldMapper {
}
}
protected DoubleFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce, fieldDataSettings, indexSettings, multiFields, copyTo);
protected DoubleFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Explicit<Boolean> ignoreMalformed,
Explicit<Boolean> coerce, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
@Override
@ -211,16 +211,6 @@ public class DoubleFieldMapper extends NumberFieldMapper {
return (DoubleFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("double");
}
@Override
protected boolean customBoost() {
return true;

View File

@ -89,8 +89,8 @@ public class FloatFieldMapper extends NumberFieldMapper {
@Override
public FloatFieldMapper build(BuilderContext context) {
setupFieldType(context);
FloatFieldMapper fieldMapper = new FloatFieldMapper(name, fieldType, docValues, ignoreMalformed(context), coerce(context),
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
FloatFieldMapper fieldMapper = new FloatFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context), coerce(context),
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
}
@ -202,10 +202,10 @@ public class FloatFieldMapper extends NumberFieldMapper {
}
}
protected FloatFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
protected FloatFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce, fieldDataSettings, indexSettings, multiFields, copyTo);
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
@Override
@ -213,16 +213,6 @@ public class FloatFieldMapper extends NumberFieldMapper {
return (FloatFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("float");
}
private static float parseValue(Object value) {
if (value instanceof Number) {
return ((Number) value).floatValue();

View File

@ -89,8 +89,8 @@ public class IntegerFieldMapper extends NumberFieldMapper {
@Override
public IntegerFieldMapper build(BuilderContext context) {
setupFieldType(context);
IntegerFieldMapper fieldMapper = new IntegerFieldMapper(name, fieldType, docValues,
ignoreMalformed(context), coerce(context), fieldDataSettings,
IntegerFieldMapper fieldMapper = new IntegerFieldMapper(name, fieldType, defaultFieldType,
ignoreMalformed(context), coerce(context),
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
@ -145,7 +145,8 @@ public class IntegerFieldMapper extends NumberFieldMapper {
@Override
public String typeName() {
return CONTENT_TYPE;
// TODO: this should be the same as the mapper type name, except fielddata expects int...
return "int";
}
@Override
@ -202,11 +203,10 @@ public class IntegerFieldMapper extends NumberFieldMapper {
}
}
protected IntegerFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
protected IntegerFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce, fieldDataSettings, indexSettings, multiFields, copyTo);
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
@Override
@ -214,16 +214,6 @@ public class IntegerFieldMapper extends NumberFieldMapper {
return (IntegerFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("int");
}
private static int parseValue(Object value) {
if (value instanceof Number) {
return ((Number) value).intValue();

View File

@ -89,8 +89,8 @@ public class LongFieldMapper extends NumberFieldMapper {
@Override
public LongFieldMapper build(BuilderContext context) {
setupFieldType(context);
LongFieldMapper fieldMapper = new LongFieldMapper(name, fieldType, docValues,
ignoreMalformed(context), coerce(context), fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
LongFieldMapper fieldMapper = new LongFieldMapper(name, fieldType, defaultFieldType,
ignoreMalformed(context), coerce(context), context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
}
@ -201,11 +201,10 @@ public class LongFieldMapper extends NumberFieldMapper {
}
}
protected LongFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
protected LongFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce, fieldDataSettings, indexSettings, multiFields, copyTo);
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
@Override
@ -213,16 +212,6 @@ public class LongFieldMapper extends NumberFieldMapper {
return (LongFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("long");
}
@Override
protected boolean customBoost() {
return true;

View File

@ -61,9 +61,9 @@ public class Murmur3FieldMapper extends LongFieldMapper {
@Override
public Murmur3FieldMapper build(BuilderContext context) {
setupFieldType(context);
Murmur3FieldMapper fieldMapper = new Murmur3FieldMapper(name, fieldType, docValues,
Murmur3FieldMapper fieldMapper = new Murmur3FieldMapper(name, fieldType, defaultFieldType,
ignoreMalformed(context), coerce(context),
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
}
@ -119,12 +119,10 @@ public class Murmur3FieldMapper extends LongFieldMapper {
}
}
protected Murmur3FieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
protected Murmur3FieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce,
fieldDataSettings, indexSettings, multiFields, copyTo);
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
@Override

View File

@ -185,11 +185,10 @@ public abstract class NumberFieldMapper extends AbstractFieldMapper implements A
*/
protected final boolean useSortedNumericDocValues;
protected NumberFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce, @Nullable Settings fieldDataSettings, Settings indexSettings,
protected NumberFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce, Settings indexSettings,
MultiFields multiFields, CopyTo copyTo) {
// LUCENE 4 UPGRADE: Since we can't do anything before the super call, we have to push the boost check down to subclasses
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, multiFields, copyTo);
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
this.ignoreMalformed = ignoreMalformed;
this.coerce = coerce;
this.useSortedNumericDocValues = Version.indexCreated(indexSettings).onOrAfter(Version.V_1_4_0_Beta1);

View File

@ -85,8 +85,8 @@ public class ShortFieldMapper extends NumberFieldMapper {
@Override
public ShortFieldMapper build(BuilderContext context) {
setupFieldType(context);
ShortFieldMapper fieldMapper = new ShortFieldMapper(name, fieldType, docValues,
ignoreMalformed(context), coerce(context), fieldDataSettings,
ShortFieldMapper fieldMapper = new ShortFieldMapper(name, fieldType, defaultFieldType,
ignoreMalformed(context), coerce(context),
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
@ -199,12 +199,10 @@ public class ShortFieldMapper extends NumberFieldMapper {
}
}
protected ShortFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
protected ShortFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce,
fieldDataSettings, indexSettings, multiFields, copyTo);
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
@Override
@ -212,16 +210,6 @@ public class ShortFieldMapper extends NumberFieldMapper {
return (ShortFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("short");
}
private static short parseValue(Object value) {
if (value instanceof Number) {
return ((Number) value).shortValue();

View File

@ -116,7 +116,6 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
// if they are set explicitly, we will use those values
// we also change the values on the default field type so that toXContent emits what
// differs from the defaults
MappedFieldType defaultFieldType = Defaults.FIELD_TYPE.clone();
if (fieldType.indexOptions() != IndexOptions.NONE && !fieldType.tokenized()) {
defaultFieldType.setOmitNorms(true);
defaultFieldType.setIndexOptions(IndexOptions.DOCS);
@ -127,11 +126,10 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
fieldType.setIndexOptions(IndexOptions.DOCS);
}
}
defaultFieldType.freeze();
setupFieldType(context);
StringFieldMapper fieldMapper = new StringFieldMapper(
name, fieldType, defaultFieldType, docValues, positionOffsetGap, ignoreAbove,
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
name, fieldType, defaultFieldType, positionOffsetGap, ignoreAbove,
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
}
@ -221,30 +219,18 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
private Boolean includeInAll;
private int positionOffsetGap;
private int ignoreAbove;
private final MappedFieldType defaultFieldType;
protected StringFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Boolean docValues,
int positionOffsetGap, int ignoreAbove, @Nullable Settings fieldDataSettings,
protected StringFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
int positionOffsetGap, int ignoreAbove,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, multiFields, copyTo);
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
if (fieldType.tokenized() && fieldType.indexOptions() != NONE && fieldType().hasDocValues()) {
throw new MapperParsingException("Field [" + fieldType.names().fullName() + "] cannot be analyzed and have doc values");
}
this.defaultFieldType = defaultFieldType;
this.positionOffsetGap = positionOffsetGap;
this.ignoreAbove = ignoreAbove;
}
@Override
public MappedFieldType defaultFieldType() {
return defaultFieldType;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("string");
}
@Override
public void includeInAll(Boolean includeInAll) {
if (includeInAll != null) {

View File

@ -78,8 +78,8 @@ public class TokenCountFieldMapper extends IntegerFieldMapper {
@Override
public TokenCountFieldMapper build(BuilderContext context) {
setupFieldType(context);
TokenCountFieldMapper fieldMapper = new TokenCountFieldMapper(name, fieldType, docValues,
ignoreMalformed(context), coerce(context), fieldDataSettings, context.indexSettings(),
TokenCountFieldMapper fieldMapper = new TokenCountFieldMapper(name, fieldType, defaultFieldType,
ignoreMalformed(context), coerce(context), context.indexSettings(),
analyzer, multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
@ -127,10 +127,9 @@ public class TokenCountFieldMapper extends IntegerFieldMapper {
private NamedAnalyzer analyzer;
protected TokenCountFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, Explicit<Boolean> ignoreMalformed,
Explicit<Boolean> coerce, Settings fieldDataSettings, Settings indexSettings,
NamedAnalyzer analyzer, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce, fieldDataSettings, indexSettings, multiFields, copyTo);
protected TokenCountFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Explicit<Boolean> ignoreMalformed,
Explicit<Boolean> coerce, Settings indexSettings, NamedAnalyzer analyzer, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
this.analyzer = analyzer;
}

View File

@ -204,10 +204,10 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
// this is important: even if geo points feel like they need to be tokenized to distinguish lat from lon, we actually want to
// store them as a single token.
fieldType.setTokenized(false);
fieldType.setHasDocValues(false);
setupFieldType(context);
return new GeoPointFieldMapper(name, fieldType, docValues, fieldDataSettings, context.indexSettings(), origPathType,
fieldType.setHasDocValues(false);
defaultFieldType.setHasDocValues(false);
return new GeoPointFieldMapper(name, fieldType, defaultFieldType, context.indexSettings(), origPathType,
latMapper, lonMapper, geohashMapper, multiFieldsBuilder.build(this, context));
}
}
@ -586,9 +586,9 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
private final StringFieldMapper geohashMapper;
public GeoPointFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, @Nullable Settings fieldDataSettings, Settings indexSettings,
public GeoPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
ContentPath.Type pathType, DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper, StringFieldMapper geohashMapper,MultiFields multiFields) {
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, multiFields, null);
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, null);
this.pathType = pathType;
this.latMapper = latMapper;
this.lonMapper = lonMapper;
@ -605,21 +605,6 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
return (GeoPointFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("geo_point");
}
@Override
protected boolean defaultDocValues() {
return false;
}
@Override
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
throw new UnsupportedOperationException("Parsing is implemented in parse(), this method should NEVER be called");

View File

@ -359,7 +359,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper {
}
public GeoShapeFieldMapper(String simpleName, MappedFieldType fieldType, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, false, null, indexSettings, multiFields, copyTo);
super(simpleName, fieldType, Defaults.FIELD_TYPE, indexSettings, multiFields, copyTo);
}
@Override
@ -367,16 +367,6 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper {
return (GeoShapeFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return null;
}
@Override
public Mapper parse(ParseContext context) throws IOException {
try {

View File

@ -111,7 +111,7 @@ public class AllFieldMapper extends MetadataFieldMapper {
}
fieldType.setTokenized(true);
return new AllFieldMapper(fieldType, enabled, fieldDataSettings, context.indexSettings());
return new AllFieldMapper(fieldType, enabled, context.indexSettings());
}
}
@ -156,7 +156,9 @@ public class AllFieldMapper extends MetadataFieldMapper {
static final class AllFieldType extends MappedFieldType {
public AllFieldType() {}
public AllFieldType() {
setFieldDataType(new FieldDataType("string"));
}
protected AllFieldType(AllFieldType ref) {
super(ref);
@ -194,15 +196,11 @@ public class AllFieldMapper extends MetadataFieldMapper {
private EnabledAttributeMapper enabledState;
public AllFieldMapper(Settings indexSettings, MappedFieldType existing) {
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(),
Defaults.ENABLED,
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
indexSettings);
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(), Defaults.ENABLED, indexSettings);
}
protected AllFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabled,
@Nullable Settings fieldDataSettings, Settings indexSettings) {
super(NAME, fieldType, false, fieldDataSettings, indexSettings);
protected AllFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabled, Settings indexSettings) {
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
this.enabledState = enabled;
}
@ -211,16 +209,6 @@ public class AllFieldMapper extends MetadataFieldMapper {
return this.enabledState.enabled;
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("string");
}
@Override
public void preParse(ParseContext context) throws IOException {
}
@ -316,12 +304,6 @@ public class AllFieldMapper extends MetadataFieldMapper {
} else if (includeDefaults) {
builder.field("similarity", SimilarityLookupService.DEFAULT_SIMILARITY);
}
if (hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) {
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
}
}
@Override

View File

@ -100,9 +100,10 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
@Override
public FieldNamesFieldMapper build(BuilderContext context) {
setupFieldType(context);
fieldType.setHasDocValues(false);
FieldNamesFieldType fieldNamesFieldType = (FieldNamesFieldType)fieldType;
fieldNamesFieldType.setEnabled(enabled);
return new FieldNamesFieldMapper(fieldType, fieldDataSettings, context.indexSettings());
return new FieldNamesFieldMapper(fieldType, context.indexSettings());
}
}
@ -135,7 +136,9 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
private boolean enabled = Defaults.ENABLED;
public FieldNamesFieldType() {}
public FieldNamesFieldType() {
setFieldDataType(new FieldDataType("string"));
}
protected FieldNamesFieldType(FieldNamesFieldType ref) {
super(ref);
@ -197,18 +200,14 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
}
}
private final MappedFieldType defaultFieldType;
private final boolean pre13Index; // if the index was created before 1.3, _field_names is always disabled
public FieldNamesFieldMapper(Settings indexSettings, MappedFieldType existing) {
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(),
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
indexSettings);
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(), indexSettings);
}
public FieldNamesFieldMapper(MappedFieldType fieldType, @Nullable Settings fieldDataSettings, Settings indexSettings) {
super(NAME, fieldType, false, fieldDataSettings, indexSettings);
this.defaultFieldType = Defaults.FIELD_TYPE;
public FieldNamesFieldMapper(MappedFieldType fieldType, Settings indexSettings) {
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
this.pre13Index = Version.indexCreated(indexSettings).before(Version.V_1_3_0);
if (this.pre13Index) {
FieldNamesFieldType newFieldType = fieldType().clone();
@ -223,16 +222,6 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
return (FieldNamesFieldType) super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return defaultFieldType;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("string");
}
@Override
public void preParse(ParseContext context) throws IOException {
}

View File

@ -108,8 +108,8 @@ public class IdFieldMapper extends MetadataFieldMapper {
@Override
public IdFieldMapper build(BuilderContext context) {
fieldType.setNames(new MappedFieldType.Names(indexName, indexName, name));
return new IdFieldMapper(fieldType, docValues, path, fieldDataSettings, context.indexSettings());
setupFieldType(context);
return new IdFieldMapper(fieldType, path, context.indexSettings());
}
}
@ -136,7 +136,9 @@ public class IdFieldMapper extends MetadataFieldMapper {
static final class IdFieldType extends MappedFieldType {
public IdFieldType() {}
public IdFieldType() {
setFieldDataType(new FieldDataType("string"));
}
protected IdFieldType(IdFieldType ref) {
super(ref);
@ -228,14 +230,11 @@ public class IdFieldMapper extends MetadataFieldMapper {
private final String path;
public IdFieldMapper(Settings indexSettings, MappedFieldType existing) {
this(idFieldType(indexSettings, existing), null, Defaults.PATH,
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
indexSettings);
this(idFieldType(indexSettings, existing), Defaults.PATH, indexSettings);
}
protected IdFieldMapper(MappedFieldType fieldType, Boolean docValues, String path,
@Nullable Settings fieldDataSettings, Settings indexSettings) {
super(NAME, fieldType, docValues, fieldDataSettings, indexSettings);
protected IdFieldMapper(MappedFieldType fieldType, String path, Settings indexSettings) {
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
this.path = path;
}
@ -255,16 +254,6 @@ public class IdFieldMapper extends MetadataFieldMapper {
return this.path;
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("string");
}
@Override
public void preParse(ParseContext context) throws IOException {
if (context.sourceToParse().id() != null) {
@ -331,9 +320,7 @@ public class IdFieldMapper extends MetadataFieldMapper {
builder.field("path", path);
}
if (hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) {
if (includeDefaults || hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
}
builder.endObject();

View File

@ -90,8 +90,9 @@ public class IndexFieldMapper extends MetadataFieldMapper {
@Override
public IndexFieldMapper build(BuilderContext context) {
fieldType.setNames(new MappedFieldType.Names(indexName, indexName, name));
return new IndexFieldMapper(fieldType, enabledState, fieldDataSettings, context.indexSettings());
setupFieldType(context);
fieldType.setHasDocValues(false);
return new IndexFieldMapper(fieldType, enabledState, context.indexSettings());
}
}
@ -147,14 +148,11 @@ public class IndexFieldMapper extends MetadataFieldMapper {
private EnabledAttributeMapper enabledState;
public IndexFieldMapper(Settings indexSettings, MappedFieldType existing) {
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing,
Defaults.ENABLED_STATE,
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()), indexSettings);
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing, Defaults.ENABLED_STATE, indexSettings);
}
public IndexFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabledState,
@Nullable Settings fieldDataSettings, Settings indexSettings) {
super(NAME, fieldType, false, fieldDataSettings, indexSettings);
public IndexFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabledState, Settings indexSettings) {
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
this.enabledState = enabledState;
}
@ -162,16 +160,6 @@ public class IndexFieldMapper extends MetadataFieldMapper {
return this.enabledState.enabled;
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType(IndexFieldMapper.NAME);
}
public String value(Document document) {
Field field = (Field) document.getField(fieldType().names().indexName());
return field == null ? null : (String)fieldType().value(field);
@ -220,14 +208,9 @@ public class IndexFieldMapper extends MetadataFieldMapper {
if (includeDefaults || enabledState != Defaults.ENABLED_STATE) {
builder.field("enabled", enabledState.enabled);
}
if (indexCreatedBefore2x) {
if (hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) {
if (indexCreatedBefore2x && (includeDefaults || hasCustomFieldDataSettings())) {
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
}
}
builder.endObject();
return builder;
}

View File

@ -77,7 +77,6 @@ public class ParentFieldMapper extends MetadataFieldMapper {
FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
FIELD_TYPE.setNames(new MappedFieldType.Names(NAME));
FIELD_TYPE.setFieldDataType(new FieldDataType("_parent", settingsBuilder().put(MappedFieldType.Loading.KEY, MappedFieldType.Loading.LAZY_VALUE)));
FIELD_TYPE.freeze();
}
}
@ -87,7 +86,6 @@ public class ParentFieldMapper extends MetadataFieldMapper {
protected String indexName;
private String type;
protected Settings fieldDataSettings;
public Builder() {
super(Defaults.NAME, Defaults.FIELD_TYPE);
@ -100,18 +98,14 @@ public class ParentFieldMapper extends MetadataFieldMapper {
return builder;
}
public Builder fieldDataSettings(Settings settings) {
this.fieldDataSettings = settings;
return builder;
}
@Override
public ParentFieldMapper build(BuilderContext context) {
if (type == null) {
throw new MapperParsingException("[_parent] field mapping must contain the [type] option");
}
setupFieldType(context);
return new ParentFieldMapper(fieldType, type, fieldDataSettings, context.indexSettings());
fieldType.setHasDocValues(context.indexCreatedVersion().onOrAfter(Version.V_2_0_0));
return new ParentFieldMapper(fieldType, type, context.indexSettings());
}
}
@ -145,7 +139,9 @@ public class ParentFieldMapper extends MetadataFieldMapper {
static final class ParentFieldType extends MappedFieldType {
public ParentFieldType() {}
public ParentFieldType() {
setFieldDataType(new FieldDataType("_parent", settingsBuilder().put(MappedFieldType.Loading.KEY, Loading.EAGER_VALUE)));
}
protected ParentFieldType(ParentFieldType ref) {
super(ref);
@ -229,32 +225,25 @@ public class ParentFieldMapper extends MetadataFieldMapper {
private final String type;
protected ParentFieldMapper(MappedFieldType fieldType, String type, @Nullable Settings fieldDataSettings, Settings indexSettings) {
super(NAME, fieldType, Version.indexCreated(indexSettings).onOrAfter(Version.V_2_0_0), fieldDataSettings, indexSettings);
protected ParentFieldMapper(MappedFieldType fieldType, String type, Settings indexSettings) {
super(NAME, setupDocValues(indexSettings, fieldType), setupDocValues(indexSettings, Defaults.FIELD_TYPE), indexSettings);
this.type = type;
}
public ParentFieldMapper(Settings indexSettings, MappedFieldType existing) {
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(),
null,
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
indexSettings);
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(), null, indexSettings);
}
static MappedFieldType setupDocValues(Settings indexSettings, MappedFieldType fieldType) {
fieldType = fieldType.clone();
fieldType.setHasDocValues(Version.indexCreated(indexSettings).onOrAfter(Version.V_2_0_0));
return fieldType;
}
public String type() {
return type;
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("_parent", settingsBuilder().put(MappedFieldType.Loading.KEY, MappedFieldType.Loading.EAGER_VALUE));
}
@Override
public void preParse(ParseContext context) throws IOException {
}
@ -328,9 +317,7 @@ public class ParentFieldMapper extends MetadataFieldMapper {
builder.startObject(CONTENT_TYPE);
builder.field("type", type);
if (hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) {
if (includeDefaults || hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
}
builder.endObject();

View File

@ -124,7 +124,9 @@ public class RoutingFieldMapper extends MetadataFieldMapper {
static final class RoutingFieldType extends MappedFieldType {
public RoutingFieldType() {}
public RoutingFieldType() {
setFieldDataType(new FieldDataType("string"));
}
protected RoutingFieldType(RoutingFieldType ref) {
super(ref);
@ -157,21 +159,11 @@ public class RoutingFieldMapper extends MetadataFieldMapper {
}
protected RoutingFieldMapper(MappedFieldType fieldType, boolean required, String path, Settings indexSettings) {
super(NAME, fieldType, false, null, indexSettings);
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
this.required = required;
this.path = path;
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("string");
}
public void markAsRequired() {
this.required = true;
}

View File

@ -83,6 +83,7 @@ public class SizeFieldMapper extends MetadataFieldMapper {
@Override
public SizeFieldMapper build(BuilderContext context) {
setupFieldType(context);
fieldType.setHasDocValues(false);
return new SizeFieldMapper(enabledState, fieldType, context.indexSettings());
}
}
@ -114,7 +115,7 @@ public class SizeFieldMapper extends MetadataFieldMapper {
}
public SizeFieldMapper(EnabledAttributeMapper enabled, MappedFieldType fieldType, Settings indexSettings) {
super(NAME, fieldType, false, null, indexSettings);
super(NAME, fieldType, Defaults.SIZE_FIELD_TYPE, indexSettings);
this.enabledState = enabled;
}
@ -138,16 +139,6 @@ public class SizeFieldMapper extends MetadataFieldMapper {
super.parse(context);
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.SIZE_FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("int");
}
@Override
public Mapper parse(ParseContext context) throws IOException {
// nothing to do here, we call the parent in postParse

View File

@ -256,7 +256,7 @@ public class SourceFieldMapper extends MetadataFieldMapper {
protected SourceFieldMapper(boolean enabled, String format, Boolean compress, long compressThreshold,
String[] includes, String[] excludes, Settings indexSettings) {
super(NAME, Defaults.FIELD_TYPE.clone(), false, null, indexSettings); // Only stored.
super(NAME, Defaults.FIELD_TYPE.clone(), Defaults.FIELD_TYPE, indexSettings); // Only stored.
this.enabled = enabled;
this.compress = compress;
this.compressThreshold = compressThreshold;
@ -284,16 +284,6 @@ public class SourceFieldMapper extends MetadataFieldMapper {
return complete;
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return null;
}
@Override
public void preParse(ParseContext context) throws IOException {
super.parse(context);

View File

@ -101,6 +101,7 @@ public class TTLFieldMapper extends MetadataFieldMapper {
@Override
public TTLFieldMapper build(BuilderContext context) {
setupFieldType(context);
fieldType.setHasDocValues(false);
return new TTLFieldMapper(fieldType, enabledState, defaultTTL, fieldDataSettings, context.indexSettings());
}
}
@ -167,7 +168,7 @@ public class TTLFieldMapper extends MetadataFieldMapper {
protected TTLFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabled, long defaultTTL,
@Nullable Settings fieldDataSettings, Settings indexSettings) {
super(NAME, fieldType, false, fieldDataSettings, indexSettings);
super(NAME, fieldType, Defaults.TTL_FIELD_TYPE, indexSettings);
this.enabledState = enabled;
this.defaultTTL = defaultTTL;
}
@ -194,16 +195,6 @@ public class TTLFieldMapper extends MetadataFieldMapper {
super.parse(context);
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.TTL_FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("long");
}
@Override
public Mapper parse(ParseContext context) throws IOException, MapperParsingException {
if (context.sourceToParse().ttl() < 0) { // no ttl has been provided externally

View File

@ -77,9 +77,11 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
FIELD_TYPE.setDateTimeFormatter(DATE_TIME_FORMATTER);
FIELD_TYPE.setIndexAnalyzer(NumericDateAnalyzer.buildNamedAnalyzer(DATE_TIME_FORMATTER, Defaults.PRECISION_STEP_64_BIT));
FIELD_TYPE.setSearchAnalyzer(NumericDateAnalyzer.buildNamedAnalyzer(DATE_TIME_FORMATTER, Integer.MAX_VALUE));
FIELD_TYPE.setHasDocValues(true);
FIELD_TYPE.freeze();
PRE_20_FIELD_TYPE = FIELD_TYPE.clone();
PRE_20_FIELD_TYPE.setStored(false);
PRE_20_FIELD_TYPE.setHasDocValues(false);
PRE_20_FIELD_TYPE.freeze();
}
@ -145,8 +147,7 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
fieldType.setStored(false);
}
setupFieldType(context);
return new TimestampFieldMapper(fieldType, docValues, enabledState, path, defaultTimestamp,
ignoreMissing, fieldDataSettings, context.indexSettings());
return new TimestampFieldMapper(fieldType, defaultFieldType, enabledState, path, defaultTimestamp, ignoreMissing, context.indexSettings());
}
}
@ -227,7 +228,7 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
}
}
private static MappedFieldType defaultFieldType(Settings settings, MappedFieldType existing) {
private static MappedFieldType chooseFieldType(Settings settings, MappedFieldType existing) {
if (existing != null) {
return existing;
}
@ -238,22 +239,18 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
private final String path;
private final String defaultTimestamp;
private final MappedFieldType defaultFieldType;
private final Boolean ignoreMissing;
public TimestampFieldMapper(Settings indexSettings, MappedFieldType existing) {
this(defaultFieldType(indexSettings, existing).clone(), null, Defaults.ENABLED, Defaults.PATH, Defaults.DEFAULT_TIMESTAMP, null,
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
indexSettings);
this(chooseFieldType(indexSettings, existing).clone(), chooseFieldType(indexSettings, null), Defaults.ENABLED, Defaults.PATH, Defaults.DEFAULT_TIMESTAMP, null, indexSettings);
}
protected TimestampFieldMapper(MappedFieldType fieldType, Boolean docValues, EnabledAttributeMapper enabledState, String path,
String defaultTimestamp, Boolean ignoreMissing, @Nullable Settings fieldDataSettings, Settings indexSettings) {
super(NAME, fieldType, docValues, fieldDataSettings, indexSettings);
protected TimestampFieldMapper(MappedFieldType fieldType, MappedFieldType defaultFieldType, EnabledAttributeMapper enabledState, String path,
String defaultTimestamp, Boolean ignoreMissing, Settings indexSettings) {
super(NAME, fieldType, defaultFieldType, indexSettings);
this.enabledState = enabledState;
this.path = path;
this.defaultTimestamp = defaultTimestamp;
this.defaultFieldType = defaultFieldType(indexSettings, null);
this.ignoreMissing = ignoreMissing;
}
@ -262,16 +259,6 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
return (TimestampFieldType)super.fieldType();
}
@Override
public MappedFieldType defaultFieldType() {
return defaultFieldType;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("long");
}
public boolean enabled() {
return this.enabledState.enabled;
}
@ -335,7 +322,7 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
fieldType().stored() == Defaults.FIELD_TYPE.stored() && enabledState == Defaults.ENABLED && path == Defaults.PATH
&& fieldType().dateTimeFormatter().format().equals(Defaults.DATE_TIME_FORMATTER.format())
&& Defaults.DEFAULT_TIMESTAMP.equals(defaultTimestamp)
&& defaultDocValues() == fieldType().hasDocValues()) {
&& defaultFieldType.hasDocValues() == fieldType().hasDocValues()) {
return builder;
}
builder.startObject(CONTENT_TYPE);
@ -363,12 +350,8 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
if (includeDefaults || ignoreMissing != null) {
builder.field("ignore_missing", ignoreMissing);
}
if (indexCreatedBefore2x) {
if (hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) {
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
}
if (indexCreatedBefore2x && (includeDefaults || hasCustomFieldDataSettings())) {
builder.field("fielddata", fieldType().fieldDataType().getSettings().getAsMap());
}
builder.endObject();

View File

@ -106,7 +106,9 @@ public class TypeFieldMapper extends MetadataFieldMapper {
static final class TypeFieldType extends MappedFieldType {
public TypeFieldType() {}
public TypeFieldType() {
setFieldDataType(new FieldDataType("string"));
}
protected TypeFieldType(TypeFieldType ref) {
super(ref);
@ -150,20 +152,9 @@ public class TypeFieldMapper extends MetadataFieldMapper {
}
public TypeFieldMapper(MappedFieldType fieldType, Settings indexSettings) {
super(NAME, fieldType, false, null, indexSettings);
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("string");
}
@Override
public void preParse(ParseContext context) throws IOException {
super.parse(context);

View File

@ -88,8 +88,9 @@ public class UidFieldMapper extends MetadataFieldMapper {
@Override
public UidFieldMapper build(BuilderContext context) {
fieldType.setNames(new MappedFieldType.Names(indexName, indexName, name));
return new UidFieldMapper(fieldType, docValues, fieldDataSettings, context.indexSettings());
setupFieldType(context);
fieldType.setHasDocValues(context.indexCreatedVersion().before(Version.V_2_0_0));
return new UidFieldMapper(fieldType, defaultFieldType, context.indexSettings());
}
}
@ -107,7 +108,9 @@ public class UidFieldMapper extends MetadataFieldMapper {
static final class UidFieldType extends MappedFieldType {
public UidFieldType() {}
public UidFieldType() {
setFieldDataType(new FieldDataType("string"));
}
protected UidFieldType(UidFieldType ref) {
super(ref);
@ -133,30 +136,11 @@ public class UidFieldMapper extends MetadataFieldMapper {
}
public UidFieldMapper(Settings indexSettings, MappedFieldType existing) {
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing, null,
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
indexSettings);
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing, Defaults.FIELD_TYPE, indexSettings);
}
protected UidFieldMapper(MappedFieldType fieldType, Boolean docValues, @Nullable Settings fieldDataSettings, Settings indexSettings) {
super(NAME, fieldType, docValuesEnabled(docValues, indexSettings), fieldDataSettings, indexSettings);
}
static Boolean docValuesEnabled(Boolean docValues, Settings indexSettings) {
if (Version.indexCreated(indexSettings).onOrAfter(Version.V_2_0_0)) {
return false; // explicitly disable doc values for 2.0+, for now
}
return docValues;
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("string");
protected UidFieldMapper(MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings) {
super(NAME, fieldType, defaultFieldType, indexSettings);
}
@Override
@ -230,9 +214,7 @@ public class UidFieldMapper extends MetadataFieldMapper {
builder.startObject(CONTENT_TYPE);
if (hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) {
if (includeDefaults || hasCustomFieldDataSettings()) {
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
}

View File

@ -35,6 +35,7 @@ import org.elasticsearch.index.mapper.MergeResult;
import org.elasticsearch.index.mapper.MetadataFieldMapper;
import org.elasticsearch.index.mapper.ParseContext;
import org.elasticsearch.index.mapper.ParseContext.Document;
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
import java.io.IOException;
import java.util.Iterator;
@ -55,6 +56,7 @@ public class VersionFieldMapper extends MetadataFieldMapper {
static {
FIELD_TYPE.setNames(new MappedFieldType.Names(NAME));
FIELD_TYPE.setDocValuesType(DocValuesType.NUMERIC);
FIELD_TYPE.setHasDocValues(true);
FIELD_TYPE.freeze();
}
}
@ -89,7 +91,9 @@ public class VersionFieldMapper extends MetadataFieldMapper {
static final class VersionFieldType extends MappedFieldType {
public VersionFieldType() {}
public VersionFieldType() {
setFieldDataType(new FieldDataType("long"));
}
protected VersionFieldType(VersionFieldType ref) {
super(ref);
@ -116,7 +120,7 @@ public class VersionFieldMapper extends MetadataFieldMapper {
}
public VersionFieldMapper(Settings indexSettings) {
super(NAME, Defaults.FIELD_TYPE, true, null, indexSettings);
super(NAME, Defaults.FIELD_TYPE, Defaults.FIELD_TYPE, indexSettings);
}
@Override
@ -148,16 +152,6 @@ public class VersionFieldMapper extends MetadataFieldMapper {
}
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("long");
}
@Override
protected String contentType() {
return CONTENT_TYPE;

View File

@ -48,6 +48,7 @@ import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.MergeMappingException;
import org.elasticsearch.index.mapper.MergeResult;
import org.elasticsearch.index.mapper.ParseContext;
import org.elasticsearch.index.mapper.core.LongFieldMapper;
import org.elasticsearch.index.mapper.core.LongFieldMapper.CustomLongNumericField;
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
import org.elasticsearch.index.query.QueryParseContext;
@ -119,8 +120,8 @@ public class IpFieldMapper extends NumberFieldMapper {
@Override
public IpFieldMapper build(BuilderContext context) {
setupFieldType(context);
IpFieldMapper fieldMapper = new IpFieldMapper(name, fieldType, docValues, ignoreMalformed(context), coerce(context),
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
IpFieldMapper fieldMapper = new IpFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context), coerce(context),
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
fieldMapper.includeInAll(includeInAll);
return fieldMapper;
}
@ -158,10 +159,10 @@ public class IpFieldMapper extends NumberFieldMapper {
}
}
public static final class IpFieldType extends NumberFieldType {
public static final class IpFieldType extends LongFieldMapper.LongFieldType {
public IpFieldType() {
super(NumericType.LONG);
setFieldDataType(new FieldDataType("long"));
}
protected IpFieldType(IpFieldType ref) {
@ -235,22 +236,10 @@ public class IpFieldMapper extends NumberFieldMapper {
}
}
protected IpFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
protected IpFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
@Nullable Settings fieldDataSettings,
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, docValues, ignoreMalformed, coerce,
fieldDataSettings, indexSettings, multiFields, copyTo);
}
@Override
public MappedFieldType defaultFieldType() {
return Defaults.FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("long");
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
}
private static long parseValue(Object value) {

View File

@ -179,7 +179,7 @@ public class FieldTypeLookupTests extends ElasticsearchTestCase {
static class FakeFieldMapper extends AbstractFieldMapper {
static Settings dummySettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
public FakeFieldMapper(String fullName, String indexName) {
super(fullName, makeFieldType(fullName, indexName), null, null, dummySettings, null, null);
super(fullName, makeFieldType(fullName, indexName), null, dummySettings, null, null);
}
static MappedFieldType makeFieldType(String fullName, String indexName) {
FakeFieldType fieldType = new FakeFieldType();
@ -201,10 +201,6 @@ public class FieldTypeLookupTests extends ElasticsearchTestCase {
}
}
@Override
public MappedFieldType defaultFieldType() { return null; }
@Override
public FieldDataType defaultFieldDataType() { return null; }
@Override
protected String contentType() { return null; }
@Override
protected void parseCreateField(ParseContext context, List list) throws IOException {}

View File

@ -226,7 +226,6 @@ public class SimpleAllMapperTests extends ElasticsearchSingleNodeTest {
boolean tv_offsets = false;
boolean tv_positions = false;
String similarity = null;
boolean fieldData = false;
XContentBuilder mappingBuilder = jsonBuilder();
mappingBuilder.startObject().startObject("test");
List<Tuple<String, Boolean>> booleanOptionList = new ArrayList<>();
@ -263,12 +262,6 @@ public class SimpleAllMapperTests extends ElasticsearchSingleNodeTest {
if (randomBoolean()) {
mappingBuilder.field("similarity", similarity = randomBoolean() ? "BM25" : "TF/IDF");
}
if (randomBoolean()) {
fieldData = true;
mappingBuilder.startObject("fielddata");
mappingBuilder.field("foo", "bar");
mappingBuilder.endObject();
}
mappingBuilder.endObject();
}
@ -310,7 +303,6 @@ public class SimpleAllMapperTests extends ElasticsearchSingleNodeTest {
} else {
assertThat(similarity, equalTo(builtDocMapper.allFieldMapper().fieldType().similarity().name()));
}
assertThat(builtMapping.contains("fielddata"), is(fieldData));
if (allDefault) {
BytesStreamOutput bytesStreamOutput = new BytesStreamOutput(0);
XContentBuilder b = new XContentBuilder(XContentType.JSON.xContent(), bytesStreamOutput);

View File

@ -174,8 +174,7 @@ public class ExternalMapper extends AbstractFieldMapper {
String generatedValue, String mapperName,
BinaryFieldMapper binMapper, BooleanFieldMapper boolMapper, GeoPointFieldMapper pointMapper,
GeoShapeFieldMapper shapeMapper, FieldMapper stringMapper, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
super(simpleName, fieldType, false, null, indexSettings,
multiFields, copyTo);
super(simpleName, fieldType, new ExternalFieldType(), indexSettings, multiFields, copyTo);
this.generatedValue = generatedValue;
this.mapperName = mapperName;
this.binMapper = binMapper;
@ -185,16 +184,6 @@ public class ExternalMapper extends AbstractFieldMapper {
this.stringMapper = stringMapper;
}
@Override
public MappedFieldType defaultFieldType() {
return new ExternalFieldType();
}
@Override
public FieldDataType defaultFieldDataType() {
return null;
}
@Override
public Mapper parse(ParseContext context) throws IOException {
byte[] bytes = "Hello world".getBytes(Charset.defaultCharset());

View File

@ -53,7 +53,7 @@ public class ExternalMetadataMapper extends MetadataFieldMapper {
}
protected ExternalMetadataMapper(Settings indexSettings) {
super(FIELD_NAME, FIELD_TYPE, true, null, indexSettings);
super(FIELD_NAME, FIELD_TYPE, FIELD_TYPE, indexSettings);
}
@Override
@ -61,16 +61,6 @@ public class ExternalMetadataMapper extends MetadataFieldMapper {
return CONTENT_TYPE;
}
@Override
public MappedFieldType defaultFieldType() {
return FIELD_TYPE;
}
@Override
public FieldDataType defaultFieldDataType() {
return new FieldDataType("string");
}
@Override
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
// handled in post parse