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:
parent
275fdcc08d
commit
e83ae64ea9
|
@ -81,7 +81,7 @@ public final class Settings implements ToXContent {
|
||||||
private transient ClassLoader classLoader;
|
private transient ClassLoader classLoader;
|
||||||
|
|
||||||
Settings(Map<String, String> settings, 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;
|
Map<String, String> forcedUnderscoreSettings = null;
|
||||||
for (Map.Entry<String, String> entry : settings.entrySet()) {
|
for (Map.Entry<String, String> entry : settings.entrySet()) {
|
||||||
String toUnderscoreCase = Strings.toUnderscoreCase(entry.getKey());
|
String toUnderscoreCase = Strings.toUnderscoreCase(entry.getKey());
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.lucene.util.BytesRef;
|
||||||
import org.elasticsearch.action.fieldstats.FieldStats;
|
import org.elasticsearch.action.fieldstats.FieldStats;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.lucene.BytesRefs;
|
import org.elasticsearch.common.lucene.BytesRefs;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.Fuzziness;
|
import org.elasticsearch.common.unit.Fuzziness;
|
||||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||||
import org.elasticsearch.index.fielddata.FieldDataType;
|
import org.elasticsearch.index.fielddata.FieldDataType;
|
||||||
|
@ -189,6 +190,7 @@ public abstract class MappedFieldType extends FieldType {
|
||||||
setOmitNorms(false);
|
setOmitNorms(false);
|
||||||
setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
|
setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
|
||||||
setBoost(1.0f);
|
setBoost(1.0f);
|
||||||
|
fieldDataType = new FieldDataType(typeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract MappedFieldType clone();
|
public abstract MappedFieldType clone();
|
||||||
|
|
|
@ -38,8 +38,8 @@ public abstract class MetadataFieldMapper extends AbstractFieldMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MetadataFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, @Nullable Settings fieldDataSettings, Settings indexSettings) {
|
protected MetadataFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings) {
|
||||||
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, MultiFields.empty(), null);
|
super(simpleName, fieldType, defaultFieldType, indexSettings, MultiFields.empty(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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> {
|
public abstract static class Builder<T extends Builder, Y extends AbstractFieldMapper> extends Mapper.Builder<T, Y> {
|
||||||
|
|
||||||
protected final MappedFieldType fieldType;
|
protected final MappedFieldType fieldType;
|
||||||
|
protected final MappedFieldType defaultFieldType;
|
||||||
private final IndexOptions defaultOptions;
|
private final IndexOptions defaultOptions;
|
||||||
protected Boolean docValues;
|
|
||||||
protected boolean omitNormsSet = false;
|
protected boolean omitNormsSet = false;
|
||||||
protected String indexName;
|
protected String indexName;
|
||||||
protected Boolean includeInAll;
|
protected Boolean includeInAll;
|
||||||
protected boolean indexOptionsSet = false;
|
protected boolean indexOptionsSet = false;
|
||||||
|
protected boolean docValuesSet = false;
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Settings fieldDataSettings;
|
protected Settings fieldDataSettings;
|
||||||
protected final MultiFields.Builder multiFieldsBuilder;
|
protected final MultiFields.Builder multiFieldsBuilder;
|
||||||
|
@ -84,6 +85,7 @@ public abstract class AbstractFieldMapper extends FieldMapper {
|
||||||
protected Builder(String name, MappedFieldType fieldType) {
|
protected Builder(String name, MappedFieldType fieldType) {
|
||||||
super(name);
|
super(name);
|
||||||
this.fieldType = fieldType.clone();
|
this.fieldType = fieldType.clone();
|
||||||
|
this.defaultFieldType = fieldType.clone();
|
||||||
this.defaultOptions = fieldType.indexOptions(); // we have to store it the fieldType is mutable
|
this.defaultOptions = fieldType.indexOptions(); // we have to store it the fieldType is mutable
|
||||||
multiFieldsBuilder = new MultiFields.Builder();
|
multiFieldsBuilder = new MultiFields.Builder();
|
||||||
}
|
}
|
||||||
|
@ -116,7 +118,8 @@ public abstract class AbstractFieldMapper extends FieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public T docValues(boolean docValues) {
|
public T docValues(boolean docValues) {
|
||||||
this.docValues = docValues;
|
this.fieldType.setHasDocValues(docValues);
|
||||||
|
this.docValuesSet = true;
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,76 +256,53 @@ public abstract class AbstractFieldMapper extends FieldMapper {
|
||||||
|
|
||||||
protected void setupFieldType(BuilderContext context) {
|
protected void setupFieldType(BuilderContext context) {
|
||||||
fieldType.setNames(buildNames(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) {
|
if (fieldType.indexAnalyzer() == null && fieldType.tokenized() == false && fieldType.indexOptions() != IndexOptions.NONE) {
|
||||||
fieldType.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
|
fieldType.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
|
||||||
fieldType.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
|
fieldType.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
|
||||||
}
|
}
|
||||||
fieldType.setHasDocValues(docValues == null ? defaultDocValues() : docValues);
|
if (fieldDataSettings != null) {
|
||||||
fieldType.setFieldDataType(fieldDataType);
|
Settings settings = Settings.builder().put(fieldType.fieldDataType().getSettings()).put(fieldDataSettings).build();
|
||||||
fieldType.freeze();
|
fieldType.setFieldDataType(new FieldDataType(fieldType.fieldDataType().getType(), settings));
|
||||||
this.fieldTypeRef.set(fieldType); // now reset ref once extra settings have been initialized
|
}
|
||||||
|
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.multiFields = multiFields;
|
||||||
this.copyTo = copyTo;
|
this.copyTo = copyTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean defaultDocValues() {
|
|
||||||
if (indexCreatedBefore2x) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return fieldType().tokenized() == false && fieldType().indexOptions() != IndexOptions.NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return fieldType().names().fullName();
|
return fieldType().names().fullName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract MappedFieldType defaultFieldType();
|
|
||||||
|
|
||||||
public abstract FieldDataType defaultFieldDataType();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MappedFieldType fieldType() {
|
public MappedFieldType fieldType() {
|
||||||
return fieldTypeRef.get();
|
return fieldTypeRef.get();
|
||||||
|
@ -417,7 +397,6 @@ public abstract class AbstractFieldMapper extends FieldMapper {
|
||||||
MappedFieldType fieldType = fieldMergeWith.fieldType().clone();
|
MappedFieldType fieldType = fieldMergeWith.fieldType().clone();
|
||||||
fieldType.freeze();
|
fieldType.freeze();
|
||||||
fieldTypeRef.set(fieldType);
|
fieldTypeRef.set(fieldType);
|
||||||
this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings;
|
|
||||||
this.copyTo = fieldMergeWith.copyTo;
|
this.copyTo = fieldMergeWith.copyTo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,7 +420,6 @@ public abstract class AbstractFieldMapper extends FieldMapper {
|
||||||
builder.field("boost", fieldType().boost());
|
builder.field("boost", fieldType().boost());
|
||||||
}
|
}
|
||||||
|
|
||||||
FieldType defaultFieldType = defaultFieldType();
|
|
||||||
boolean indexed = fieldType().indexOptions() != IndexOptions.NONE;
|
boolean indexed = fieldType().indexOptions() != IndexOptions.NONE;
|
||||||
boolean defaultIndexed = defaultFieldType.indexOptions() != IndexOptions.NONE;
|
boolean defaultIndexed = defaultFieldType.indexOptions() != IndexOptions.NONE;
|
||||||
if (includeDefaults || indexed != defaultIndexed ||
|
if (includeDefaults || indexed != defaultIndexed ||
|
||||||
|
@ -477,13 +455,8 @@ public abstract class AbstractFieldMapper extends FieldMapper {
|
||||||
builder.field("similarity", SimilarityLookupService.DEFAULT_SIMILARITY);
|
builder.field("similarity", SimilarityLookupService.DEFAULT_SIMILARITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeMap<String, Object> orderedFielddataSettings = new TreeMap<>();
|
if (includeDefaults || hasCustomFieldDataSettings()) {
|
||||||
if (hasCustomFieldDataSettings()) {
|
builder.field("fielddata", fieldType().fieldDataType().getSettings().getAsMap());
|
||||||
orderedFielddataSettings.putAll(customFieldDataSettings.getAsMap());
|
|
||||||
builder.field("fielddata", orderedFielddataSettings);
|
|
||||||
} else if (includeDefaults) {
|
|
||||||
orderedFielddataSettings.putAll(fieldType().fieldDataType().getSettings().getAsMap());
|
|
||||||
builder.field("fielddata", orderedFielddataSettings);
|
|
||||||
}
|
}
|
||||||
multiFields.toXContent(builder, params);
|
multiFields.toXContent(builder, params);
|
||||||
|
|
||||||
|
@ -506,7 +479,7 @@ public abstract class AbstractFieldMapper extends FieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doXContentDocValues(XContentBuilder builder, boolean includeDefaults) throws IOException {
|
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());
|
builder.field(DOC_VALUES, fieldType().hasDocValues());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,7 +532,7 @@ public abstract class AbstractFieldMapper extends FieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean hasCustomFieldDataSettings() {
|
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();
|
protected abstract String contentType();
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class BinaryFieldMapper extends AbstractFieldMapper {
|
||||||
public BinaryFieldMapper build(BuilderContext context) {
|
public BinaryFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
((BinaryFieldType)fieldType).setTryUncompressing(context.indexCreatedVersion().before(Version.V_2_0_0));
|
((BinaryFieldType)fieldType).setTryUncompressing(context.indexCreatedVersion().before(Version.V_2_0_0));
|
||||||
return new BinaryFieldMapper(name, fieldType, docValues,
|
return new BinaryFieldMapper(name, fieldType, defaultFieldType,
|
||||||
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,19 +181,9 @@ public class BinaryFieldMapper extends AbstractFieldMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BinaryFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
|
protected BinaryFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, multiFields, copyTo);
|
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("binary");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -90,8 +90,8 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public BooleanFieldMapper build(BuilderContext context) {
|
public BooleanFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
return new BooleanFieldMapper(name, fieldType, docValues,
|
return new BooleanFieldMapper(name, fieldType, defaultFieldType,
|
||||||
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,9 +194,9 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BooleanFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
|
protected BooleanFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, multiFields, copyTo);
|
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -204,17 +204,6 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
|
||||||
return (BooleanFieldType) super.fieldType();
|
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
|
@Override
|
||||||
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
||||||
if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored() && !fieldType().hasDocValues()) {
|
if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored() && !fieldType().hasDocValues()) {
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class ByteFieldMapper extends NumberFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public ByteFieldMapper build(BuilderContext context) {
|
public ByteFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
ByteFieldMapper fieldMapper = new ByteFieldMapper(name, fieldType, docValues, ignoreMalformed(context),
|
ByteFieldMapper fieldMapper = new ByteFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context),
|
||||||
coerce(context), fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
coerce(context), context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
fieldMapper.includeInAll(includeInAll);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
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,
|
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
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
|
@Override
|
||||||
|
@ -204,16 +204,6 @@ public class ByteFieldMapper extends NumberFieldMapper {
|
||||||
return (ByteFieldType) super.fieldType();
|
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) {
|
private static byte parseValue(Object value) {
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number) value).byteValue();
|
return ((Number) value).byteValue();
|
||||||
|
|
|
@ -226,7 +226,9 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
|
||||||
private AnalyzingCompletionLookupProvider analyzingSuggestLookupProvider;
|
private AnalyzingCompletionLookupProvider analyzingSuggestLookupProvider;
|
||||||
private SortedMap<String, ContextMapping> contextMapping = ContextMapping.EMPTY_MAPPING;
|
private SortedMap<String, ContextMapping> contextMapping = ContextMapping.EMPTY_MAPPING;
|
||||||
|
|
||||||
public CompletionFieldType() {}
|
public CompletionFieldType() {
|
||||||
|
setFieldDataType(null);
|
||||||
|
}
|
||||||
|
|
||||||
protected CompletionFieldType(CompletionFieldType ref) {
|
protected CompletionFieldType(CompletionFieldType ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
|
@ -312,7 +314,7 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
|
||||||
private int maxInputLength;
|
private int maxInputLength;
|
||||||
|
|
||||||
public CompletionFieldMapper(String simpleName, MappedFieldType fieldType, int maxInputLength, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
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;
|
this.maxInputLength = maxInputLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,16 +540,6 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
|
||||||
return CONTENT_TYPE;
|
return CONTENT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStoringPayloads() {
|
public boolean isStoringPayloads() {
|
||||||
return fieldType().analyzingSuggestLookupProvider.hasPayloads();
|
return fieldType().analyzingSuggestLookupProvider.hasPayloads();
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,9 +116,8 @@ public class DateFieldMapper extends NumberFieldMapper {
|
||||||
public DateFieldMapper build(BuilderContext context) {
|
public DateFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
fieldType.setNullValue(nullValue);
|
fieldType.setNullValue(nullValue);
|
||||||
DateFieldMapper fieldMapper = new DateFieldMapper(name, fieldType,
|
DateFieldMapper fieldMapper = new DateFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context),
|
||||||
docValues, ignoreMalformed(context), coerce(context),
|
coerce(context), context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
|
||||||
fieldMapper.includeInAll(includeInAll);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
return fieldMapper;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +258,7 @@ public class DateFieldMapper extends NumberFieldMapper {
|
||||||
|
|
||||||
public DateFieldType() {
|
public DateFieldType() {
|
||||||
super(NumericType.LONG);
|
super(NumericType.LONG);
|
||||||
|
setFieldDataType(new FieldDataType("long"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DateFieldType(DateFieldType ref) {
|
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,
|
protected DateFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Explicit<Boolean> ignoreMalformed,Explicit<Boolean> coerce,
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
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
|
@Override
|
||||||
|
@ -446,16 +446,6 @@ public class DateFieldMapper extends NumberFieldMapper {
|
||||||
return (DateFieldType) super.fieldType();
|
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() {
|
private static Callable<Long> now() {
|
||||||
return new Callable<Long>() {
|
return new Callable<Long>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -88,8 +88,8 @@ public class DoubleFieldMapper extends NumberFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public DoubleFieldMapper build(BuilderContext context) {
|
public DoubleFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
DoubleFieldMapper fieldMapper = new DoubleFieldMapper(name, fieldType, docValues, ignoreMalformed(context), coerce(context),
|
DoubleFieldMapper fieldMapper = new DoubleFieldMapper(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);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
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,
|
protected DoubleFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Explicit<Boolean> ignoreMalformed,
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
Explicit<Boolean> coerce, 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
|
@Override
|
||||||
|
@ -211,16 +211,6 @@ public class DoubleFieldMapper extends NumberFieldMapper {
|
||||||
return (DoubleFieldType) super.fieldType();
|
return (DoubleFieldType) super.fieldType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("double");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean customBoost() {
|
protected boolean customBoost() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -89,8 +89,8 @@ public class FloatFieldMapper extends NumberFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public FloatFieldMapper build(BuilderContext context) {
|
public FloatFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
FloatFieldMapper fieldMapper = new FloatFieldMapper(name, fieldType, docValues, ignoreMalformed(context), coerce(context),
|
FloatFieldMapper fieldMapper = new FloatFieldMapper(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);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
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,
|
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
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
|
@Override
|
||||||
|
@ -213,16 +213,6 @@ public class FloatFieldMapper extends NumberFieldMapper {
|
||||||
return (FloatFieldType) super.fieldType();
|
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) {
|
private static float parseValue(Object value) {
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number) value).floatValue();
|
return ((Number) value).floatValue();
|
||||||
|
|
|
@ -89,8 +89,8 @@ public class IntegerFieldMapper extends NumberFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IntegerFieldMapper build(BuilderContext context) {
|
public IntegerFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
IntegerFieldMapper fieldMapper = new IntegerFieldMapper(name, fieldType, docValues,
|
IntegerFieldMapper fieldMapper = new IntegerFieldMapper(name, fieldType, defaultFieldType,
|
||||||
ignoreMalformed(context), coerce(context), fieldDataSettings,
|
ignoreMalformed(context), coerce(context),
|
||||||
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
fieldMapper.includeInAll(includeInAll);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
return fieldMapper;
|
||||||
|
@ -145,7 +145,8 @@ public class IntegerFieldMapper extends NumberFieldMapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String typeName() {
|
public String typeName() {
|
||||||
return CONTENT_TYPE;
|
// TODO: this should be the same as the mapper type name, except fielddata expects int...
|
||||||
|
return "int";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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,
|
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
|
||||||
@Nullable Settings fieldDataSettings,
|
|
||||||
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
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
|
@Override
|
||||||
|
@ -214,16 +214,6 @@ public class IntegerFieldMapper extends NumberFieldMapper {
|
||||||
return (IntegerFieldType) super.fieldType();
|
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) {
|
private static int parseValue(Object value) {
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number) value).intValue();
|
return ((Number) value).intValue();
|
||||||
|
|
|
@ -89,8 +89,8 @@ public class LongFieldMapper extends NumberFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public LongFieldMapper build(BuilderContext context) {
|
public LongFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
LongFieldMapper fieldMapper = new LongFieldMapper(name, fieldType, docValues,
|
LongFieldMapper fieldMapper = new LongFieldMapper(name, fieldType, defaultFieldType,
|
||||||
ignoreMalformed(context), coerce(context), fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
ignoreMalformed(context), coerce(context), context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
fieldMapper.includeInAll(includeInAll);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
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,
|
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
|
||||||
@Nullable Settings fieldDataSettings,
|
|
||||||
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
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
|
@Override
|
||||||
|
@ -213,16 +212,6 @@ public class LongFieldMapper extends NumberFieldMapper {
|
||||||
return (LongFieldType) super.fieldType();
|
return (LongFieldType) super.fieldType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("long");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean customBoost() {
|
protected boolean customBoost() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -61,9 +61,9 @@ public class Murmur3FieldMapper extends LongFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public Murmur3FieldMapper build(BuilderContext context) {
|
public Murmur3FieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
Murmur3FieldMapper fieldMapper = new Murmur3FieldMapper(name, fieldType, docValues,
|
Murmur3FieldMapper fieldMapper = new Murmur3FieldMapper(name, fieldType, defaultFieldType,
|
||||||
ignoreMalformed(context), coerce(context),
|
ignoreMalformed(context), coerce(context),
|
||||||
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
fieldMapper.includeInAll(includeInAll);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
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,
|
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
|
||||||
@Nullable Settings fieldDataSettings,
|
|
||||||
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, docValues, ignoreMalformed, coerce,
|
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
|
||||||
fieldDataSettings, indexSettings, multiFields, copyTo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -185,11 +185,10 @@ public abstract class NumberFieldMapper extends AbstractFieldMapper implements A
|
||||||
*/
|
*/
|
||||||
protected final boolean useSortedNumericDocValues;
|
protected final boolean useSortedNumericDocValues;
|
||||||
|
|
||||||
protected NumberFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues,
|
protected NumberFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
|
||||||
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce, @Nullable Settings fieldDataSettings, Settings indexSettings,
|
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce, Settings indexSettings,
|
||||||
MultiFields multiFields, CopyTo copyTo) {
|
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, defaultFieldType, indexSettings, multiFields, copyTo);
|
||||||
super(simpleName, fieldType, docValues, fieldDataSettings, indexSettings, multiFields, copyTo);
|
|
||||||
this.ignoreMalformed = ignoreMalformed;
|
this.ignoreMalformed = ignoreMalformed;
|
||||||
this.coerce = coerce;
|
this.coerce = coerce;
|
||||||
this.useSortedNumericDocValues = Version.indexCreated(indexSettings).onOrAfter(Version.V_1_4_0_Beta1);
|
this.useSortedNumericDocValues = Version.indexCreated(indexSettings).onOrAfter(Version.V_1_4_0_Beta1);
|
||||||
|
|
|
@ -85,8 +85,8 @@ public class ShortFieldMapper extends NumberFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public ShortFieldMapper build(BuilderContext context) {
|
public ShortFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
ShortFieldMapper fieldMapper = new ShortFieldMapper(name, fieldType, docValues,
|
ShortFieldMapper fieldMapper = new ShortFieldMapper(name, fieldType, defaultFieldType,
|
||||||
ignoreMalformed(context), coerce(context), fieldDataSettings,
|
ignoreMalformed(context), coerce(context),
|
||||||
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
fieldMapper.includeInAll(includeInAll);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
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,
|
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
|
||||||
@Nullable Settings fieldDataSettings,
|
|
||||||
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, docValues, ignoreMalformed, coerce,
|
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
|
||||||
fieldDataSettings, indexSettings, multiFields, copyTo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -212,16 +210,6 @@ public class ShortFieldMapper extends NumberFieldMapper {
|
||||||
return (ShortFieldType) super.fieldType();
|
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) {
|
private static short parseValue(Object value) {
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number) value).shortValue();
|
return ((Number) value).shortValue();
|
||||||
|
|
|
@ -116,7 +116,6 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
|
||||||
// if they are set explicitly, we will use those values
|
// 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
|
// we also change the values on the default field type so that toXContent emits what
|
||||||
// differs from the defaults
|
// differs from the defaults
|
||||||
MappedFieldType defaultFieldType = Defaults.FIELD_TYPE.clone();
|
|
||||||
if (fieldType.indexOptions() != IndexOptions.NONE && !fieldType.tokenized()) {
|
if (fieldType.indexOptions() != IndexOptions.NONE && !fieldType.tokenized()) {
|
||||||
defaultFieldType.setOmitNorms(true);
|
defaultFieldType.setOmitNorms(true);
|
||||||
defaultFieldType.setIndexOptions(IndexOptions.DOCS);
|
defaultFieldType.setIndexOptions(IndexOptions.DOCS);
|
||||||
|
@ -127,11 +126,10 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
|
||||||
fieldType.setIndexOptions(IndexOptions.DOCS);
|
fieldType.setIndexOptions(IndexOptions.DOCS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defaultFieldType.freeze();
|
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
StringFieldMapper fieldMapper = new StringFieldMapper(
|
StringFieldMapper fieldMapper = new StringFieldMapper(
|
||||||
name, fieldType, defaultFieldType, docValues, positionOffsetGap, ignoreAbove,
|
name, fieldType, defaultFieldType, positionOffsetGap, ignoreAbove,
|
||||||
fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
|
||||||
fieldMapper.includeInAll(includeInAll);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
return fieldMapper;
|
||||||
}
|
}
|
||||||
|
@ -221,30 +219,18 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
|
||||||
private Boolean includeInAll;
|
private Boolean includeInAll;
|
||||||
private int positionOffsetGap;
|
private int positionOffsetGap;
|
||||||
private int ignoreAbove;
|
private int ignoreAbove;
|
||||||
private final MappedFieldType defaultFieldType;
|
|
||||||
|
|
||||||
protected StringFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Boolean docValues,
|
protected StringFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
|
||||||
int positionOffsetGap, int ignoreAbove, @Nullable Settings fieldDataSettings,
|
int positionOffsetGap, int ignoreAbove,
|
||||||
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
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()) {
|
if (fieldType.tokenized() && fieldType.indexOptions() != NONE && fieldType().hasDocValues()) {
|
||||||
throw new MapperParsingException("Field [" + fieldType.names().fullName() + "] cannot be analyzed and have doc values");
|
throw new MapperParsingException("Field [" + fieldType.names().fullName() + "] cannot be analyzed and have doc values");
|
||||||
}
|
}
|
||||||
this.defaultFieldType = defaultFieldType;
|
|
||||||
this.positionOffsetGap = positionOffsetGap;
|
this.positionOffsetGap = positionOffsetGap;
|
||||||
this.ignoreAbove = ignoreAbove;
|
this.ignoreAbove = ignoreAbove;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return defaultFieldType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("string");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void includeInAll(Boolean includeInAll) {
|
public void includeInAll(Boolean includeInAll) {
|
||||||
if (includeInAll != null) {
|
if (includeInAll != null) {
|
||||||
|
|
|
@ -78,8 +78,8 @@ public class TokenCountFieldMapper extends IntegerFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public TokenCountFieldMapper build(BuilderContext context) {
|
public TokenCountFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
TokenCountFieldMapper fieldMapper = new TokenCountFieldMapper(name, fieldType, docValues,
|
TokenCountFieldMapper fieldMapper = new TokenCountFieldMapper(name, fieldType, defaultFieldType,
|
||||||
ignoreMalformed(context), coerce(context), fieldDataSettings, context.indexSettings(),
|
ignoreMalformed(context), coerce(context), context.indexSettings(),
|
||||||
analyzer, multiFieldsBuilder.build(this, context), copyTo);
|
analyzer, multiFieldsBuilder.build(this, context), copyTo);
|
||||||
fieldMapper.includeInAll(includeInAll);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
return fieldMapper;
|
||||||
|
@ -127,10 +127,9 @@ public class TokenCountFieldMapper extends IntegerFieldMapper {
|
||||||
|
|
||||||
private NamedAnalyzer analyzer;
|
private NamedAnalyzer analyzer;
|
||||||
|
|
||||||
protected TokenCountFieldMapper(String simpleName, MappedFieldType fieldType, Boolean docValues, Explicit<Boolean> ignoreMalformed,
|
protected TokenCountFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Explicit<Boolean> ignoreMalformed,
|
||||||
Explicit<Boolean> coerce, Settings fieldDataSettings, Settings indexSettings,
|
Explicit<Boolean> coerce, Settings indexSettings, NamedAnalyzer analyzer, MultiFields multiFields, CopyTo copyTo) {
|
||||||
NamedAnalyzer analyzer, MultiFields multiFields, CopyTo copyTo) {
|
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
|
||||||
super(simpleName, fieldType, docValues, ignoreMalformed, coerce, fieldDataSettings, indexSettings, multiFields, copyTo);
|
|
||||||
this.analyzer = analyzer;
|
this.analyzer = analyzer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
// 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.
|
// store them as a single token.
|
||||||
fieldType.setTokenized(false);
|
fieldType.setTokenized(false);
|
||||||
fieldType.setHasDocValues(false);
|
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
|
fieldType.setHasDocValues(false);
|
||||||
return new GeoPointFieldMapper(name, fieldType, docValues, fieldDataSettings, context.indexSettings(), origPathType,
|
defaultFieldType.setHasDocValues(false);
|
||||||
|
return new GeoPointFieldMapper(name, fieldType, defaultFieldType, context.indexSettings(), origPathType,
|
||||||
latMapper, lonMapper, geohashMapper, multiFieldsBuilder.build(this, context));
|
latMapper, lonMapper, geohashMapper, multiFieldsBuilder.build(this, context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -586,9 +586,9 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
|
||||||
|
|
||||||
private final StringFieldMapper geohashMapper;
|
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) {
|
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.pathType = pathType;
|
||||||
this.latMapper = latMapper;
|
this.latMapper = latMapper;
|
||||||
this.lonMapper = lonMapper;
|
this.lonMapper = lonMapper;
|
||||||
|
@ -605,21 +605,6 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
|
||||||
return (GeoPointFieldType) super.fieldType();
|
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
|
@Override
|
||||||
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
||||||
throw new UnsupportedOperationException("Parsing is implemented in parse(), this method should NEVER be called");
|
throw new UnsupportedOperationException("Parsing is implemented in parse(), this method should NEVER be called");
|
||||||
|
|
|
@ -359,7 +359,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeoShapeFieldMapper(String simpleName, MappedFieldType fieldType, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
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
|
@Override
|
||||||
|
@ -367,16 +367,6 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper {
|
||||||
return (GeoShapeFieldType) super.fieldType();
|
return (GeoShapeFieldType) super.fieldType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mapper parse(ParseContext context) throws IOException {
|
public Mapper parse(ParseContext context) throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class AllFieldMapper extends MetadataFieldMapper {
|
||||||
}
|
}
|
||||||
fieldType.setTokenized(true);
|
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 {
|
static final class AllFieldType extends MappedFieldType {
|
||||||
|
|
||||||
public AllFieldType() {}
|
public AllFieldType() {
|
||||||
|
setFieldDataType(new FieldDataType("string"));
|
||||||
|
}
|
||||||
|
|
||||||
protected AllFieldType(AllFieldType ref) {
|
protected AllFieldType(AllFieldType ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
|
@ -194,15 +196,11 @@ public class AllFieldMapper extends MetadataFieldMapper {
|
||||||
private EnabledAttributeMapper enabledState;
|
private EnabledAttributeMapper enabledState;
|
||||||
|
|
||||||
public AllFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
public AllFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
||||||
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(),
|
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(), Defaults.ENABLED, indexSettings);
|
||||||
Defaults.ENABLED,
|
|
||||||
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
|
|
||||||
indexSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AllFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabled,
|
protected AllFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabled, Settings indexSettings) {
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings) {
|
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
|
||||||
super(NAME, fieldType, false, fieldDataSettings, indexSettings);
|
|
||||||
this.enabledState = enabled;
|
this.enabledState = enabled;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -211,16 +209,6 @@ public class AllFieldMapper extends MetadataFieldMapper {
|
||||||
return this.enabledState.enabled;
|
return this.enabledState.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("string");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preParse(ParseContext context) throws IOException {
|
public void preParse(ParseContext context) throws IOException {
|
||||||
}
|
}
|
||||||
|
@ -316,12 +304,6 @@ public class AllFieldMapper extends MetadataFieldMapper {
|
||||||
} else if (includeDefaults) {
|
} else if (includeDefaults) {
|
||||||
builder.field("similarity", SimilarityLookupService.DEFAULT_SIMILARITY);
|
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
|
@Override
|
||||||
|
|
|
@ -100,9 +100,10 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public FieldNamesFieldMapper build(BuilderContext context) {
|
public FieldNamesFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
|
fieldType.setHasDocValues(false);
|
||||||
FieldNamesFieldType fieldNamesFieldType = (FieldNamesFieldType)fieldType;
|
FieldNamesFieldType fieldNamesFieldType = (FieldNamesFieldType)fieldType;
|
||||||
fieldNamesFieldType.setEnabled(enabled);
|
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;
|
private boolean enabled = Defaults.ENABLED;
|
||||||
|
|
||||||
public FieldNamesFieldType() {}
|
public FieldNamesFieldType() {
|
||||||
|
setFieldDataType(new FieldDataType("string"));
|
||||||
|
}
|
||||||
|
|
||||||
protected FieldNamesFieldType(FieldNamesFieldType ref) {
|
protected FieldNamesFieldType(FieldNamesFieldType ref) {
|
||||||
super(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
|
private final boolean pre13Index; // if the index was created before 1.3, _field_names is always disabled
|
||||||
|
|
||||||
public FieldNamesFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
public FieldNamesFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
||||||
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(),
|
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(), indexSettings);
|
||||||
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
|
|
||||||
indexSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldNamesFieldMapper(MappedFieldType fieldType, @Nullable Settings fieldDataSettings, Settings indexSettings) {
|
public FieldNamesFieldMapper(MappedFieldType fieldType, Settings indexSettings) {
|
||||||
super(NAME, fieldType, false, fieldDataSettings, indexSettings);
|
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
|
||||||
this.defaultFieldType = Defaults.FIELD_TYPE;
|
|
||||||
this.pre13Index = Version.indexCreated(indexSettings).before(Version.V_1_3_0);
|
this.pre13Index = Version.indexCreated(indexSettings).before(Version.V_1_3_0);
|
||||||
if (this.pre13Index) {
|
if (this.pre13Index) {
|
||||||
FieldNamesFieldType newFieldType = fieldType().clone();
|
FieldNamesFieldType newFieldType = fieldType().clone();
|
||||||
|
@ -223,16 +222,6 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
|
||||||
return (FieldNamesFieldType) super.fieldType();
|
return (FieldNamesFieldType) super.fieldType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return defaultFieldType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("string");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preParse(ParseContext context) throws IOException {
|
public void preParse(ParseContext context) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,8 +108,8 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdFieldMapper build(BuilderContext context) {
|
public IdFieldMapper build(BuilderContext context) {
|
||||||
fieldType.setNames(new MappedFieldType.Names(indexName, indexName, name));
|
setupFieldType(context);
|
||||||
return new IdFieldMapper(fieldType, docValues, path, fieldDataSettings, context.indexSettings());
|
return new IdFieldMapper(fieldType, path, context.indexSettings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,9 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
static final class IdFieldType extends MappedFieldType {
|
static final class IdFieldType extends MappedFieldType {
|
||||||
|
|
||||||
public IdFieldType() {}
|
public IdFieldType() {
|
||||||
|
setFieldDataType(new FieldDataType("string"));
|
||||||
|
}
|
||||||
|
|
||||||
protected IdFieldType(IdFieldType ref) {
|
protected IdFieldType(IdFieldType ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
|
@ -228,14 +230,11 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
||||||
private final String path;
|
private final String path;
|
||||||
|
|
||||||
public IdFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
public IdFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
||||||
this(idFieldType(indexSettings, existing), null, Defaults.PATH,
|
this(idFieldType(indexSettings, existing), Defaults.PATH, indexSettings);
|
||||||
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
|
|
||||||
indexSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IdFieldMapper(MappedFieldType fieldType, Boolean docValues, String path,
|
protected IdFieldMapper(MappedFieldType fieldType, String path, Settings indexSettings) {
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings) {
|
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
|
||||||
super(NAME, fieldType, docValues, fieldDataSettings, indexSettings);
|
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,16 +254,6 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
||||||
return this.path;
|
return this.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("string");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preParse(ParseContext context) throws IOException {
|
public void preParse(ParseContext context) throws IOException {
|
||||||
if (context.sourceToParse().id() != null) {
|
if (context.sourceToParse().id() != null) {
|
||||||
|
@ -331,9 +320,7 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
||||||
builder.field("path", path);
|
builder.field("path", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasCustomFieldDataSettings()) {
|
if (includeDefaults || hasCustomFieldDataSettings()) {
|
||||||
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
|
|
||||||
} else if (includeDefaults) {
|
|
||||||
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -90,8 +90,9 @@ public class IndexFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldMapper build(BuilderContext context) {
|
public IndexFieldMapper build(BuilderContext context) {
|
||||||
fieldType.setNames(new MappedFieldType.Names(indexName, indexName, name));
|
setupFieldType(context);
|
||||||
return new IndexFieldMapper(fieldType, enabledState, fieldDataSettings, context.indexSettings());
|
fieldType.setHasDocValues(false);
|
||||||
|
return new IndexFieldMapper(fieldType, enabledState, context.indexSettings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,14 +148,11 @@ public class IndexFieldMapper extends MetadataFieldMapper {
|
||||||
private EnabledAttributeMapper enabledState;
|
private EnabledAttributeMapper enabledState;
|
||||||
|
|
||||||
public IndexFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
public IndexFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
||||||
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing,
|
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing, Defaults.ENABLED_STATE, indexSettings);
|
||||||
Defaults.ENABLED_STATE,
|
|
||||||
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()), indexSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabledState,
|
public IndexFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabledState, Settings indexSettings) {
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings) {
|
super(NAME, fieldType, Defaults.FIELD_TYPE, indexSettings);
|
||||||
super(NAME, fieldType, false, fieldDataSettings, indexSettings);
|
|
||||||
this.enabledState = enabledState;
|
this.enabledState = enabledState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,16 +160,6 @@ public class IndexFieldMapper extends MetadataFieldMapper {
|
||||||
return this.enabledState.enabled;
|
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) {
|
public String value(Document document) {
|
||||||
Field field = (Field) document.getField(fieldType().names().indexName());
|
Field field = (Field) document.getField(fieldType().names().indexName());
|
||||||
return field == null ? null : (String)fieldType().value(field);
|
return field == null ? null : (String)fieldType().value(field);
|
||||||
|
@ -220,14 +208,9 @@ public class IndexFieldMapper extends MetadataFieldMapper {
|
||||||
if (includeDefaults || enabledState != Defaults.ENABLED_STATE) {
|
if (includeDefaults || enabledState != Defaults.ENABLED_STATE) {
|
||||||
builder.field("enabled", enabledState.enabled);
|
builder.field("enabled", enabledState.enabled);
|
||||||
}
|
}
|
||||||
|
if (indexCreatedBefore2x && (includeDefaults || hasCustomFieldDataSettings())) {
|
||||||
if (indexCreatedBefore2x) {
|
|
||||||
if (hasCustomFieldDataSettings()) {
|
|
||||||
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
|
|
||||||
} else if (includeDefaults) {
|
|
||||||
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,6 @@ public class ParentFieldMapper extends MetadataFieldMapper {
|
||||||
FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
|
FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
|
||||||
FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
|
FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
|
||||||
FIELD_TYPE.setNames(new MappedFieldType.Names(NAME));
|
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();
|
FIELD_TYPE.freeze();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +86,6 @@ public class ParentFieldMapper extends MetadataFieldMapper {
|
||||||
protected String indexName;
|
protected String indexName;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
protected Settings fieldDataSettings;
|
|
||||||
|
|
||||||
public Builder() {
|
public Builder() {
|
||||||
super(Defaults.NAME, Defaults.FIELD_TYPE);
|
super(Defaults.NAME, Defaults.FIELD_TYPE);
|
||||||
|
@ -100,18 +98,14 @@ public class ParentFieldMapper extends MetadataFieldMapper {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fieldDataSettings(Settings settings) {
|
|
||||||
this.fieldDataSettings = settings;
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParentFieldMapper build(BuilderContext context) {
|
public ParentFieldMapper build(BuilderContext context) {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
throw new MapperParsingException("[_parent] field mapping must contain the [type] option");
|
throw new MapperParsingException("[_parent] field mapping must contain the [type] option");
|
||||||
}
|
}
|
||||||
setupFieldType(context);
|
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 {
|
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) {
|
protected ParentFieldType(ParentFieldType ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
|
@ -229,32 +225,25 @@ public class ParentFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
protected ParentFieldMapper(MappedFieldType fieldType, String type, @Nullable Settings fieldDataSettings, Settings indexSettings) {
|
protected ParentFieldMapper(MappedFieldType fieldType, String type, Settings indexSettings) {
|
||||||
super(NAME, fieldType, Version.indexCreated(indexSettings).onOrAfter(Version.V_2_0_0), fieldDataSettings, indexSettings);
|
super(NAME, setupDocValues(indexSettings, fieldType), setupDocValues(indexSettings, Defaults.FIELD_TYPE), indexSettings);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParentFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
public ParentFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
||||||
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(),
|
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing.clone(), null, indexSettings);
|
||||||
null,
|
}
|
||||||
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
|
|
||||||
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() {
|
public String type() {
|
||||||
return 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
|
@Override
|
||||||
public void preParse(ParseContext context) throws IOException {
|
public void preParse(ParseContext context) throws IOException {
|
||||||
}
|
}
|
||||||
|
@ -328,9 +317,7 @@ public class ParentFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
builder.startObject(CONTENT_TYPE);
|
builder.startObject(CONTENT_TYPE);
|
||||||
builder.field("type", type);
|
builder.field("type", type);
|
||||||
if (hasCustomFieldDataSettings()) {
|
if (includeDefaults || hasCustomFieldDataSettings()) {
|
||||||
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
|
|
||||||
} else if (includeDefaults) {
|
|
||||||
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -124,7 +124,9 @@ public class RoutingFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
static final class RoutingFieldType extends MappedFieldType {
|
static final class RoutingFieldType extends MappedFieldType {
|
||||||
|
|
||||||
public RoutingFieldType() {}
|
public RoutingFieldType() {
|
||||||
|
setFieldDataType(new FieldDataType("string"));
|
||||||
|
}
|
||||||
|
|
||||||
protected RoutingFieldType(RoutingFieldType ref) {
|
protected RoutingFieldType(RoutingFieldType ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
|
@ -157,21 +159,11 @@ public class RoutingFieldMapper extends MetadataFieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RoutingFieldMapper(MappedFieldType fieldType, boolean required, String path, Settings indexSettings) {
|
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.required = required;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("string");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markAsRequired() {
|
public void markAsRequired() {
|
||||||
this.required = true;
|
this.required = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class SizeFieldMapper extends MetadataFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public SizeFieldMapper build(BuilderContext context) {
|
public SizeFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
|
fieldType.setHasDocValues(false);
|
||||||
return new SizeFieldMapper(enabledState, fieldType, context.indexSettings());
|
return new SizeFieldMapper(enabledState, fieldType, context.indexSettings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +115,7 @@ public class SizeFieldMapper extends MetadataFieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SizeFieldMapper(EnabledAttributeMapper enabled, MappedFieldType fieldType, Settings indexSettings) {
|
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;
|
this.enabledState = enabled;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -138,16 +139,6 @@ public class SizeFieldMapper extends MetadataFieldMapper {
|
||||||
super.parse(context);
|
super.parse(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.SIZE_FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("int");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mapper parse(ParseContext context) throws IOException {
|
public Mapper parse(ParseContext context) throws IOException {
|
||||||
// nothing to do here, we call the parent in postParse
|
// nothing to do here, we call the parent in postParse
|
||||||
|
|
|
@ -256,7 +256,7 @@ public class SourceFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
protected SourceFieldMapper(boolean enabled, String format, Boolean compress, long compressThreshold,
|
protected SourceFieldMapper(boolean enabled, String format, Boolean compress, long compressThreshold,
|
||||||
String[] includes, String[] excludes, Settings indexSettings) {
|
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.enabled = enabled;
|
||||||
this.compress = compress;
|
this.compress = compress;
|
||||||
this.compressThreshold = compressThreshold;
|
this.compressThreshold = compressThreshold;
|
||||||
|
@ -284,16 +284,6 @@ public class SourceFieldMapper extends MetadataFieldMapper {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preParse(ParseContext context) throws IOException {
|
public void preParse(ParseContext context) throws IOException {
|
||||||
super.parse(context);
|
super.parse(context);
|
||||||
|
|
|
@ -101,6 +101,7 @@ public class TTLFieldMapper extends MetadataFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public TTLFieldMapper build(BuilderContext context) {
|
public TTLFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
|
fieldType.setHasDocValues(false);
|
||||||
return new TTLFieldMapper(fieldType, enabledState, defaultTTL, fieldDataSettings, context.indexSettings());
|
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,
|
protected TTLFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabled, long defaultTTL,
|
||||||
@Nullable Settings fieldDataSettings, Settings indexSettings) {
|
@Nullable Settings fieldDataSettings, Settings indexSettings) {
|
||||||
super(NAME, fieldType, false, fieldDataSettings, indexSettings);
|
super(NAME, fieldType, Defaults.TTL_FIELD_TYPE, indexSettings);
|
||||||
this.enabledState = enabled;
|
this.enabledState = enabled;
|
||||||
this.defaultTTL = defaultTTL;
|
this.defaultTTL = defaultTTL;
|
||||||
}
|
}
|
||||||
|
@ -194,16 +195,6 @@ public class TTLFieldMapper extends MetadataFieldMapper {
|
||||||
super.parse(context);
|
super.parse(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.TTL_FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("long");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mapper parse(ParseContext context) throws IOException, MapperParsingException {
|
public Mapper parse(ParseContext context) throws IOException, MapperParsingException {
|
||||||
if (context.sourceToParse().ttl() < 0) { // no ttl has been provided externally
|
if (context.sourceToParse().ttl() < 0) { // no ttl has been provided externally
|
||||||
|
|
|
@ -77,9 +77,11 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
|
||||||
FIELD_TYPE.setDateTimeFormatter(DATE_TIME_FORMATTER);
|
FIELD_TYPE.setDateTimeFormatter(DATE_TIME_FORMATTER);
|
||||||
FIELD_TYPE.setIndexAnalyzer(NumericDateAnalyzer.buildNamedAnalyzer(DATE_TIME_FORMATTER, Defaults.PRECISION_STEP_64_BIT));
|
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.setSearchAnalyzer(NumericDateAnalyzer.buildNamedAnalyzer(DATE_TIME_FORMATTER, Integer.MAX_VALUE));
|
||||||
|
FIELD_TYPE.setHasDocValues(true);
|
||||||
FIELD_TYPE.freeze();
|
FIELD_TYPE.freeze();
|
||||||
PRE_20_FIELD_TYPE = FIELD_TYPE.clone();
|
PRE_20_FIELD_TYPE = FIELD_TYPE.clone();
|
||||||
PRE_20_FIELD_TYPE.setStored(false);
|
PRE_20_FIELD_TYPE.setStored(false);
|
||||||
|
PRE_20_FIELD_TYPE.setHasDocValues(false);
|
||||||
PRE_20_FIELD_TYPE.freeze();
|
PRE_20_FIELD_TYPE.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,8 +147,7 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
|
||||||
fieldType.setStored(false);
|
fieldType.setStored(false);
|
||||||
}
|
}
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
return new TimestampFieldMapper(fieldType, docValues, enabledState, path, defaultTimestamp,
|
return new TimestampFieldMapper(fieldType, defaultFieldType, enabledState, path, defaultTimestamp, ignoreMissing, context.indexSettings());
|
||||||
ignoreMissing, fieldDataSettings, 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) {
|
if (existing != null) {
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
@ -238,22 +239,18 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
private final String defaultTimestamp;
|
private final String defaultTimestamp;
|
||||||
private final MappedFieldType defaultFieldType;
|
|
||||||
private final Boolean ignoreMissing;
|
private final Boolean ignoreMissing;
|
||||||
|
|
||||||
public TimestampFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
public TimestampFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
||||||
this(defaultFieldType(indexSettings, existing).clone(), null, Defaults.ENABLED, Defaults.PATH, Defaults.DEFAULT_TIMESTAMP, null,
|
this(chooseFieldType(indexSettings, existing).clone(), chooseFieldType(indexSettings, null), Defaults.ENABLED, Defaults.PATH, Defaults.DEFAULT_TIMESTAMP, null, indexSettings);
|
||||||
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
|
|
||||||
indexSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TimestampFieldMapper(MappedFieldType fieldType, Boolean docValues, EnabledAttributeMapper enabledState, String path,
|
protected TimestampFieldMapper(MappedFieldType fieldType, MappedFieldType defaultFieldType, EnabledAttributeMapper enabledState, String path,
|
||||||
String defaultTimestamp, Boolean ignoreMissing, @Nullable Settings fieldDataSettings, Settings indexSettings) {
|
String defaultTimestamp, Boolean ignoreMissing, Settings indexSettings) {
|
||||||
super(NAME, fieldType, docValues, fieldDataSettings, indexSettings);
|
super(NAME, fieldType, defaultFieldType, indexSettings);
|
||||||
this.enabledState = enabledState;
|
this.enabledState = enabledState;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.defaultTimestamp = defaultTimestamp;
|
this.defaultTimestamp = defaultTimestamp;
|
||||||
this.defaultFieldType = defaultFieldType(indexSettings, null);
|
|
||||||
this.ignoreMissing = ignoreMissing;
|
this.ignoreMissing = ignoreMissing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,16 +259,6 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
|
||||||
return (TimestampFieldType)super.fieldType();
|
return (TimestampFieldType)super.fieldType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return defaultFieldType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("long");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean enabled() {
|
public boolean enabled() {
|
||||||
return this.enabledState.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().stored() == Defaults.FIELD_TYPE.stored() && enabledState == Defaults.ENABLED && path == Defaults.PATH
|
||||||
&& fieldType().dateTimeFormatter().format().equals(Defaults.DATE_TIME_FORMATTER.format())
|
&& fieldType().dateTimeFormatter().format().equals(Defaults.DATE_TIME_FORMATTER.format())
|
||||||
&& Defaults.DEFAULT_TIMESTAMP.equals(defaultTimestamp)
|
&& Defaults.DEFAULT_TIMESTAMP.equals(defaultTimestamp)
|
||||||
&& defaultDocValues() == fieldType().hasDocValues()) {
|
&& defaultFieldType.hasDocValues() == fieldType().hasDocValues()) {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
builder.startObject(CONTENT_TYPE);
|
builder.startObject(CONTENT_TYPE);
|
||||||
|
@ -363,12 +350,8 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
|
||||||
if (includeDefaults || ignoreMissing != null) {
|
if (includeDefaults || ignoreMissing != null) {
|
||||||
builder.field("ignore_missing", ignoreMissing);
|
builder.field("ignore_missing", ignoreMissing);
|
||||||
}
|
}
|
||||||
if (indexCreatedBefore2x) {
|
if (indexCreatedBefore2x && (includeDefaults || hasCustomFieldDataSettings())) {
|
||||||
if (hasCustomFieldDataSettings()) {
|
builder.field("fielddata", fieldType().fieldDataType().getSettings().getAsMap());
|
||||||
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
|
|
||||||
} else if (includeDefaults) {
|
|
||||||
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -106,7 +106,9 @@ public class TypeFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
static final class TypeFieldType extends MappedFieldType {
|
static final class TypeFieldType extends MappedFieldType {
|
||||||
|
|
||||||
public TypeFieldType() {}
|
public TypeFieldType() {
|
||||||
|
setFieldDataType(new FieldDataType("string"));
|
||||||
|
}
|
||||||
|
|
||||||
protected TypeFieldType(TypeFieldType ref) {
|
protected TypeFieldType(TypeFieldType ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
|
@ -150,20 +152,9 @@ public class TypeFieldMapper extends MetadataFieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeFieldMapper(MappedFieldType fieldType, Settings indexSettings) {
|
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
|
@Override
|
||||||
public void preParse(ParseContext context) throws IOException {
|
public void preParse(ParseContext context) throws IOException {
|
||||||
super.parse(context);
|
super.parse(context);
|
||||||
|
|
|
@ -88,8 +88,9 @@ public class UidFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UidFieldMapper build(BuilderContext context) {
|
public UidFieldMapper build(BuilderContext context) {
|
||||||
fieldType.setNames(new MappedFieldType.Names(indexName, indexName, name));
|
setupFieldType(context);
|
||||||
return new UidFieldMapper(fieldType, docValues, fieldDataSettings, context.indexSettings());
|
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 {
|
static final class UidFieldType extends MappedFieldType {
|
||||||
|
|
||||||
public UidFieldType() {}
|
public UidFieldType() {
|
||||||
|
setFieldDataType(new FieldDataType("string"));
|
||||||
|
}
|
||||||
|
|
||||||
protected UidFieldType(UidFieldType ref) {
|
protected UidFieldType(UidFieldType ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
|
@ -133,30 +136,11 @@ public class UidFieldMapper extends MetadataFieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public UidFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
public UidFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
||||||
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing, null,
|
this(existing == null ? Defaults.FIELD_TYPE.clone() : existing, Defaults.FIELD_TYPE, indexSettings);
|
||||||
existing == null ? null : (existing.fieldDataType() == null ? null : existing.fieldDataType().getSettings()),
|
|
||||||
indexSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UidFieldMapper(MappedFieldType fieldType, Boolean docValues, @Nullable Settings fieldDataSettings, Settings indexSettings) {
|
protected UidFieldMapper(MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings) {
|
||||||
super(NAME, fieldType, docValuesEnabled(docValues, indexSettings), fieldDataSettings, indexSettings);
|
super(NAME, fieldType, defaultFieldType, 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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -230,9 +214,7 @@ public class UidFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
builder.startObject(CONTENT_TYPE);
|
builder.startObject(CONTENT_TYPE);
|
||||||
|
|
||||||
if (hasCustomFieldDataSettings()) {
|
if (includeDefaults || hasCustomFieldDataSettings()) {
|
||||||
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
|
|
||||||
} else if (includeDefaults) {
|
|
||||||
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.index.mapper.MergeResult;
|
||||||
import org.elasticsearch.index.mapper.MetadataFieldMapper;
|
import org.elasticsearch.index.mapper.MetadataFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.ParseContext.Document;
|
import org.elasticsearch.index.mapper.ParseContext.Document;
|
||||||
|
import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -55,6 +56,7 @@ public class VersionFieldMapper extends MetadataFieldMapper {
|
||||||
static {
|
static {
|
||||||
FIELD_TYPE.setNames(new MappedFieldType.Names(NAME));
|
FIELD_TYPE.setNames(new MappedFieldType.Names(NAME));
|
||||||
FIELD_TYPE.setDocValuesType(DocValuesType.NUMERIC);
|
FIELD_TYPE.setDocValuesType(DocValuesType.NUMERIC);
|
||||||
|
FIELD_TYPE.setHasDocValues(true);
|
||||||
FIELD_TYPE.freeze();
|
FIELD_TYPE.freeze();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +91,9 @@ public class VersionFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
static final class VersionFieldType extends MappedFieldType {
|
static final class VersionFieldType extends MappedFieldType {
|
||||||
|
|
||||||
public VersionFieldType() {}
|
public VersionFieldType() {
|
||||||
|
setFieldDataType(new FieldDataType("long"));
|
||||||
|
}
|
||||||
|
|
||||||
protected VersionFieldType(VersionFieldType ref) {
|
protected VersionFieldType(VersionFieldType ref) {
|
||||||
super(ref);
|
super(ref);
|
||||||
|
@ -116,7 +120,7 @@ public class VersionFieldMapper extends MetadataFieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public VersionFieldMapper(Settings indexSettings) {
|
public VersionFieldMapper(Settings indexSettings) {
|
||||||
super(NAME, Defaults.FIELD_TYPE, true, null, indexSettings);
|
super(NAME, Defaults.FIELD_TYPE, Defaults.FIELD_TYPE, indexSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
@Override
|
||||||
protected String contentType() {
|
protected String contentType() {
|
||||||
return CONTENT_TYPE;
|
return CONTENT_TYPE;
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||||
import org.elasticsearch.index.mapper.MergeResult;
|
import org.elasticsearch.index.mapper.MergeResult;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
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.LongFieldMapper.CustomLongNumericField;
|
||||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
|
@ -119,8 +120,8 @@ public class IpFieldMapper extends NumberFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IpFieldMapper build(BuilderContext context) {
|
public IpFieldMapper build(BuilderContext context) {
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
IpFieldMapper fieldMapper = new IpFieldMapper(name, fieldType, docValues, ignoreMalformed(context), coerce(context),
|
IpFieldMapper fieldMapper = new IpFieldMapper(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);
|
fieldMapper.includeInAll(includeInAll);
|
||||||
return fieldMapper;
|
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() {
|
public IpFieldType() {
|
||||||
super(NumericType.LONG);
|
setFieldDataType(new FieldDataType("long"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IpFieldType(IpFieldType ref) {
|
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,
|
Explicit<Boolean> ignoreMalformed, Explicit<Boolean> coerce,
|
||||||
@Nullable Settings fieldDataSettings,
|
|
||||||
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, docValues, ignoreMalformed, coerce,
|
super(simpleName, fieldType, defaultFieldType, ignoreMalformed, coerce, indexSettings, multiFields, copyTo);
|
||||||
fieldDataSettings, indexSettings, multiFields, copyTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return Defaults.FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("long");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long parseValue(Object value) {
|
private static long parseValue(Object value) {
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class FieldTypeLookupTests extends ElasticsearchTestCase {
|
||||||
static class FakeFieldMapper extends AbstractFieldMapper {
|
static class FakeFieldMapper extends AbstractFieldMapper {
|
||||||
static Settings dummySettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
|
static Settings dummySettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
|
||||||
public FakeFieldMapper(String fullName, String indexName) {
|
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) {
|
static MappedFieldType makeFieldType(String fullName, String indexName) {
|
||||||
FakeFieldType fieldType = new FakeFieldType();
|
FakeFieldType fieldType = new FakeFieldType();
|
||||||
|
@ -201,10 +201,6 @@ public class FieldTypeLookupTests extends ElasticsearchTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public MappedFieldType defaultFieldType() { return null; }
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() { return null; }
|
|
||||||
@Override
|
|
||||||
protected String contentType() { return null; }
|
protected String contentType() { return null; }
|
||||||
@Override
|
@Override
|
||||||
protected void parseCreateField(ParseContext context, List list) throws IOException {}
|
protected void parseCreateField(ParseContext context, List list) throws IOException {}
|
||||||
|
|
|
@ -226,7 +226,6 @@ public class SimpleAllMapperTests extends ElasticsearchSingleNodeTest {
|
||||||
boolean tv_offsets = false;
|
boolean tv_offsets = false;
|
||||||
boolean tv_positions = false;
|
boolean tv_positions = false;
|
||||||
String similarity = null;
|
String similarity = null;
|
||||||
boolean fieldData = false;
|
|
||||||
XContentBuilder mappingBuilder = jsonBuilder();
|
XContentBuilder mappingBuilder = jsonBuilder();
|
||||||
mappingBuilder.startObject().startObject("test");
|
mappingBuilder.startObject().startObject("test");
|
||||||
List<Tuple<String, Boolean>> booleanOptionList = new ArrayList<>();
|
List<Tuple<String, Boolean>> booleanOptionList = new ArrayList<>();
|
||||||
|
@ -263,12 +262,6 @@ public class SimpleAllMapperTests extends ElasticsearchSingleNodeTest {
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
mappingBuilder.field("similarity", similarity = randomBoolean() ? "BM25" : "TF/IDF");
|
mappingBuilder.field("similarity", similarity = randomBoolean() ? "BM25" : "TF/IDF");
|
||||||
}
|
}
|
||||||
if (randomBoolean()) {
|
|
||||||
fieldData = true;
|
|
||||||
mappingBuilder.startObject("fielddata");
|
|
||||||
mappingBuilder.field("foo", "bar");
|
|
||||||
mappingBuilder.endObject();
|
|
||||||
}
|
|
||||||
mappingBuilder.endObject();
|
mappingBuilder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +303,6 @@ public class SimpleAllMapperTests extends ElasticsearchSingleNodeTest {
|
||||||
} else {
|
} else {
|
||||||
assertThat(similarity, equalTo(builtDocMapper.allFieldMapper().fieldType().similarity().name()));
|
assertThat(similarity, equalTo(builtDocMapper.allFieldMapper().fieldType().similarity().name()));
|
||||||
}
|
}
|
||||||
assertThat(builtMapping.contains("fielddata"), is(fieldData));
|
|
||||||
if (allDefault) {
|
if (allDefault) {
|
||||||
BytesStreamOutput bytesStreamOutput = new BytesStreamOutput(0);
|
BytesStreamOutput bytesStreamOutput = new BytesStreamOutput(0);
|
||||||
XContentBuilder b = new XContentBuilder(XContentType.JSON.xContent(), bytesStreamOutput);
|
XContentBuilder b = new XContentBuilder(XContentType.JSON.xContent(), bytesStreamOutput);
|
||||||
|
|
|
@ -174,8 +174,7 @@ public class ExternalMapper extends AbstractFieldMapper {
|
||||||
String generatedValue, String mapperName,
|
String generatedValue, String mapperName,
|
||||||
BinaryFieldMapper binMapper, BooleanFieldMapper boolMapper, GeoPointFieldMapper pointMapper,
|
BinaryFieldMapper binMapper, BooleanFieldMapper boolMapper, GeoPointFieldMapper pointMapper,
|
||||||
GeoShapeFieldMapper shapeMapper, FieldMapper stringMapper, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
GeoShapeFieldMapper shapeMapper, FieldMapper stringMapper, Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, false, null, indexSettings,
|
super(simpleName, fieldType, new ExternalFieldType(), indexSettings, multiFields, copyTo);
|
||||||
multiFields, copyTo);
|
|
||||||
this.generatedValue = generatedValue;
|
this.generatedValue = generatedValue;
|
||||||
this.mapperName = mapperName;
|
this.mapperName = mapperName;
|
||||||
this.binMapper = binMapper;
|
this.binMapper = binMapper;
|
||||||
|
@ -185,16 +184,6 @@ public class ExternalMapper extends AbstractFieldMapper {
|
||||||
this.stringMapper = stringMapper;
|
this.stringMapper = stringMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return new ExternalFieldType();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mapper parse(ParseContext context) throws IOException {
|
public Mapper parse(ParseContext context) throws IOException {
|
||||||
byte[] bytes = "Hello world".getBytes(Charset.defaultCharset());
|
byte[] bytes = "Hello world".getBytes(Charset.defaultCharset());
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ExternalMetadataMapper extends MetadataFieldMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ExternalMetadataMapper(Settings indexSettings) {
|
protected ExternalMetadataMapper(Settings indexSettings) {
|
||||||
super(FIELD_NAME, FIELD_TYPE, true, null, indexSettings);
|
super(FIELD_NAME, FIELD_TYPE, FIELD_TYPE, indexSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,16 +61,6 @@ public class ExternalMetadataMapper extends MetadataFieldMapper {
|
||||||
return CONTENT_TYPE;
|
return CONTENT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MappedFieldType defaultFieldType() {
|
|
||||||
return FIELD_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FieldDataType defaultFieldDataType() {
|
|
||||||
return new FieldDataType("string");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
||||||
// handled in post parse
|
// handled in post parse
|
||||||
|
|
Loading…
Reference in New Issue