Mappings: Replace fieldType access in mappers with getter

A small refactoring to allow changing how the field type is stored later.
This commit is contained in:
Ryan Ernst 2015-06-18 11:47:38 -07:00
parent 8c21a84b09
commit f09e0d7fb4
24 changed files with 197 additions and 213 deletions

View File

@ -304,12 +304,12 @@ public abstract class AbstractFieldMapper implements FieldMapper {
this.fieldType = fieldType.clone(); this.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) {
this.fieldType.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); this.fieldType().setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
this.fieldType.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); this.fieldType().setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
} }
this.fieldType.setHasDocValues(docValues == null ? defaultDocValues() : docValues); this.fieldType().setHasDocValues(docValues == null ? defaultDocValues() : docValues);
this.fieldType.setFieldDataType(fieldDataType); this.fieldType().setFieldDataType(fieldDataType);
this.fieldType.freeze(); this.fieldType().freeze();
this.multiFields = multiFields; this.multiFields = multiFields;
this.copyTo = copyTo; this.copyTo = copyTo;
@ -319,14 +319,14 @@ public abstract class AbstractFieldMapper implements FieldMapper {
if (indexCreatedBefore2x) { if (indexCreatedBefore2x) {
return false; return false;
} else { } else {
return fieldType.tokenized() == false && fieldType.indexOptions() != IndexOptions.NONE; return fieldType().tokenized() == false && fieldType().indexOptions() != IndexOptions.NONE;
} }
} }
@Override @Override
public String name() { public String name() {
// TODO: cleanup names so Mapper knows about paths, so that it is always clear whether we are using short or full name // TODO: cleanup names so Mapper knows about paths, so that it is always clear whether we are using short or full name
return fieldType.names().shortName(); return fieldType().names().shortName();
} }
public abstract MappedFieldType defaultFieldType(); public abstract MappedFieldType defaultFieldType();
@ -350,12 +350,12 @@ public abstract class AbstractFieldMapper implements FieldMapper {
parseCreateField(context, fields); parseCreateField(context, fields);
for (Field field : fields) { for (Field field : fields) {
if (!customBoost()) { if (!customBoost()) {
field.setBoost(fieldType.boost()); field.setBoost(fieldType().boost());
} }
context.doc().add(field); context.doc().add(field);
} }
} catch (Exception e) { } catch (Exception e) {
throw new MapperParsingException("failed to parse [" + fieldType.names().fullName() + "]", e); throw new MapperParsingException("failed to parse [" + fieldType().names().fullName() + "]", e);
} }
multiFields.parse(this, context); multiFields.parse(this, context);
return null; return null;
@ -387,94 +387,94 @@ public abstract class AbstractFieldMapper implements FieldMapper {
if (mergeWith instanceof AbstractFieldMapper) { if (mergeWith instanceof AbstractFieldMapper) {
mergedType = ((AbstractFieldMapper) mergeWith).contentType(); mergedType = ((AbstractFieldMapper) mergeWith).contentType();
} }
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] of different type, current_type [" + contentType() + "], merged_type [" + mergedType + "]"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] of different type, current_type [" + contentType() + "], merged_type [" + mergedType + "]");
// different types, return // different types, return
return; return;
} }
AbstractFieldMapper fieldMergeWith = (AbstractFieldMapper) mergeWith; AbstractFieldMapper fieldMergeWith = (AbstractFieldMapper) mergeWith;
boolean indexed = fieldType.indexOptions() != IndexOptions.NONE; boolean indexed = fieldType().indexOptions() != IndexOptions.NONE;
boolean mergeWithIndexed = fieldMergeWith.fieldType().indexOptions() != IndexOptions.NONE; boolean mergeWithIndexed = fieldMergeWith.fieldType().indexOptions() != IndexOptions.NONE;
if (indexed != mergeWithIndexed || this.fieldType().tokenized() != fieldMergeWith.fieldType().tokenized()) { if (indexed != mergeWithIndexed || this.fieldType().tokenized() != fieldMergeWith.fieldType().tokenized()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different index values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different index values");
} }
if (this.fieldType().stored() != fieldMergeWith.fieldType().stored()) { if (this.fieldType().stored() != fieldMergeWith.fieldType().stored()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different store values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different store values");
} }
if (!this.fieldType().hasDocValues() && fieldMergeWith.fieldType().hasDocValues()) { if (!this.fieldType().hasDocValues() && fieldMergeWith.fieldType().hasDocValues()) {
// don't add conflict if this mapper has doc values while the mapper to merge doesn't since doc values are implicitely set // don't add conflict if this mapper has doc values while the mapper to merge doesn't since doc values are implicitely set
// when the doc_values field data format is configured // when the doc_values field data format is configured
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different " + TypeParsers.DOC_VALUES + " values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different " + TypeParsers.DOC_VALUES + " values");
} }
if (this.fieldType().omitNorms() && !fieldMergeWith.fieldType.omitNorms()) { if (this.fieldType().omitNorms() && !fieldMergeWith.fieldType().omitNorms()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] cannot enable norms (`norms.enabled`)"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] cannot enable norms (`norms.enabled`)");
} }
if (this.fieldType().tokenized() != fieldMergeWith.fieldType().tokenized()) { if (this.fieldType().tokenized() != fieldMergeWith.fieldType().tokenized()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different tokenize values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different tokenize values");
} }
if (this.fieldType().storeTermVectors() != fieldMergeWith.fieldType().storeTermVectors()) { if (this.fieldType().storeTermVectors() != fieldMergeWith.fieldType().storeTermVectors()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different store_term_vector values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different store_term_vector values");
} }
if (this.fieldType().storeTermVectorOffsets() != fieldMergeWith.fieldType().storeTermVectorOffsets()) { if (this.fieldType().storeTermVectorOffsets() != fieldMergeWith.fieldType().storeTermVectorOffsets()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different store_term_vector_offsets values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different store_term_vector_offsets values");
} }
if (this.fieldType().storeTermVectorPositions() != fieldMergeWith.fieldType().storeTermVectorPositions()) { if (this.fieldType().storeTermVectorPositions() != fieldMergeWith.fieldType().storeTermVectorPositions()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different store_term_vector_positions values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different store_term_vector_positions values");
} }
if (this.fieldType().storeTermVectorPayloads() != fieldMergeWith.fieldType().storeTermVectorPayloads()) { if (this.fieldType().storeTermVectorPayloads() != fieldMergeWith.fieldType().storeTermVectorPayloads()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different store_term_vector_payloads values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different store_term_vector_payloads values");
} }
// null and "default"-named index analyzers both mean the default is used // null and "default"-named index analyzers both mean the default is used
if (this.fieldType.indexAnalyzer() == null || "default".equals(this.fieldType.indexAnalyzer().name())) { if (this.fieldType().indexAnalyzer() == null || "default".equals(this.fieldType().indexAnalyzer().name())) {
if (fieldMergeWith.fieldType.indexAnalyzer() != null && "default".equals(fieldMergeWith.fieldType.indexAnalyzer().name()) == false) { if (fieldMergeWith.fieldType().indexAnalyzer() != null && "default".equals(fieldMergeWith.fieldType().indexAnalyzer().name()) == false) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different analyzer"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different analyzer");
} }
} else if (fieldMergeWith.fieldType.indexAnalyzer() == null || "default".equals(fieldMergeWith.fieldType.indexAnalyzer().name())) { } else if (fieldMergeWith.fieldType().indexAnalyzer() == null || "default".equals(fieldMergeWith.fieldType().indexAnalyzer().name())) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different analyzer"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different analyzer");
} else if (this.fieldType.indexAnalyzer().name().equals(fieldMergeWith.fieldType.indexAnalyzer().name()) == false) { } else if (this.fieldType().indexAnalyzer().name().equals(fieldMergeWith.fieldType().indexAnalyzer().name()) == false) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different analyzer"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different analyzer");
} }
if (!this.fieldType().names().equals(fieldMergeWith.fieldType().names())) { if (!this.fieldType().names().equals(fieldMergeWith.fieldType().names())) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different index_name"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different index_name");
} }
if (this.fieldType.similarity() == null) { if (this.fieldType().similarity() == null) {
if (fieldMergeWith.fieldType.similarity() != null) { if (fieldMergeWith.fieldType().similarity() != null) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different similarity"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different similarity");
} }
} else if (fieldMergeWith.fieldType().similarity() == null) { } else if (fieldMergeWith.fieldType().similarity() == null) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different similarity"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different similarity");
} else if (!this.fieldType().similarity().equals(fieldMergeWith.fieldType().similarity())) { } else if (!this.fieldType().similarity().equals(fieldMergeWith.fieldType().similarity())) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different similarity"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different similarity");
} }
multiFields.merge(mergeWith, mergeResult); multiFields.merge(mergeWith, mergeResult);
if (!mergeResult.simulate()) { if (!mergeResult.simulate()) {
// apply changeable values // apply changeable values
this.fieldType = this.fieldType.clone(); this.fieldType = this.fieldType().clone();
this.fieldType.setOmitNorms(fieldMergeWith.fieldType.omitNorms()); this.fieldType().setOmitNorms(fieldMergeWith.fieldType().omitNorms());
this.fieldType.setBoost(fieldMergeWith.fieldType.boost()); this.fieldType().setBoost(fieldMergeWith.fieldType().boost());
this.fieldType.setNormsLoading(fieldMergeWith.fieldType.normsLoading()); this.fieldType().setNormsLoading(fieldMergeWith.fieldType().normsLoading());
if (fieldMergeWith.fieldType.searchAnalyzer() != null) { if (fieldMergeWith.fieldType().searchAnalyzer() != null) {
this.fieldType.setSearchAnalyzer(fieldMergeWith.fieldType.searchAnalyzer()); this.fieldType().setSearchAnalyzer(fieldMergeWith.fieldType().searchAnalyzer());
} }
if (fieldMergeWith.customFieldDataSettings != null) { if (fieldMergeWith.customFieldDataSettings != null) {
if (!Objects.equal(fieldMergeWith.customFieldDataSettings, this.customFieldDataSettings)) { if (!Objects.equal(fieldMergeWith.customFieldDataSettings, this.customFieldDataSettings)) {
this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings; this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings;
this.fieldType.setFieldDataType(new FieldDataType(defaultFieldDataType().getType(), this.fieldType().setFieldDataType(new FieldDataType(defaultFieldDataType().getType(),
Settings.builder().put(defaultFieldDataType().getSettings()).put(this.customFieldDataSettings) Settings.builder().put(defaultFieldDataType().getSettings()).put(this.customFieldDataSettings)
)); ));
} }
} }
this.fieldType.freeze(); this.fieldType().freeze();
this.copyTo = fieldMergeWith.copyTo; this.copyTo = fieldMergeWith.copyTo;
} }
} }
@Override @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(fieldType.names().shortName()); builder.startObject(fieldType().names().shortName());
boolean includeDefaults = params.paramAsBoolean("include_defaults", false); boolean includeDefaults = params.paramAsBoolean("include_defaults", false);
doXContentBody(builder, includeDefaults, params); doXContentBody(builder, includeDefaults, params);
return builder.endObject(); return builder.endObject();
@ -483,40 +483,40 @@ public abstract class AbstractFieldMapper implements FieldMapper {
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
builder.field("type", contentType()); builder.field("type", contentType());
if (indexCreatedBefore2x && (includeDefaults || !fieldType.names().shortName().equals(fieldType.names().originalIndexName()))) { if (indexCreatedBefore2x && (includeDefaults || !fieldType().names().shortName().equals(fieldType().names().originalIndexName()))) {
builder.field("index_name", fieldType.names().originalIndexName()); builder.field("index_name", fieldType().names().originalIndexName());
} }
if (includeDefaults || fieldType.boost() != 1.0f) { if (includeDefaults || fieldType().boost() != 1.0f) {
builder.field("boost", fieldType.boost()); builder.field("boost", fieldType().boost());
} }
FieldType defaultFieldType = defaultFieldType(); 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 ||
fieldType.tokenized() != defaultFieldType.tokenized()) { fieldType().tokenized() != defaultFieldType.tokenized()) {
builder.field("index", indexTokenizeOptionToString(indexed, fieldType.tokenized())); builder.field("index", indexTokenizeOptionToString(indexed, fieldType().tokenized()));
} }
if (includeDefaults || fieldType.stored() != defaultFieldType.stored()) { if (includeDefaults || fieldType().stored() != defaultFieldType.stored()) {
builder.field("store", fieldType.stored()); builder.field("store", fieldType().stored());
} }
doXContentDocValues(builder, includeDefaults); doXContentDocValues(builder, includeDefaults);
if (includeDefaults || fieldType.storeTermVectors() != defaultFieldType.storeTermVectors()) { if (includeDefaults || fieldType().storeTermVectors() != defaultFieldType.storeTermVectors()) {
builder.field("term_vector", termVectorOptionsToString(fieldType)); builder.field("term_vector", termVectorOptionsToString(fieldType()));
} }
if (includeDefaults || fieldType.omitNorms() != defaultFieldType.omitNorms() || fieldType.normsLoading() != null) { if (includeDefaults || fieldType().omitNorms() != defaultFieldType.omitNorms() || fieldType().normsLoading() != null) {
builder.startObject("norms"); builder.startObject("norms");
if (includeDefaults || fieldType.omitNorms() != defaultFieldType.omitNorms()) { if (includeDefaults || fieldType().omitNorms() != defaultFieldType.omitNorms()) {
builder.field("enabled", !fieldType.omitNorms()); builder.field("enabled", !fieldType().omitNorms());
} }
if (fieldType.normsLoading() != null) { if (fieldType().normsLoading() != null) {
builder.field(MappedFieldType.Loading.KEY, fieldType.normsLoading()); builder.field(MappedFieldType.Loading.KEY, fieldType().normsLoading());
} }
builder.endObject(); builder.endObject();
} }
if (indexed && (includeDefaults || fieldType.indexOptions() != defaultFieldType.indexOptions())) { if (indexed && (includeDefaults || fieldType().indexOptions() != defaultFieldType.indexOptions())) {
builder.field("index_options", indexOptionToString(fieldType.indexOptions())); builder.field("index_options", indexOptionToString(fieldType().indexOptions()));
} }
doXContentAnalyzers(builder, includeDefaults); doXContentAnalyzers(builder, includeDefaults);
@ -532,7 +532,7 @@ public abstract class AbstractFieldMapper implements FieldMapper {
orderedFielddataSettings.putAll(customFieldDataSettings.getAsMap()); orderedFielddataSettings.putAll(customFieldDataSettings.getAsMap());
builder.field("fielddata", orderedFielddataSettings); builder.field("fielddata", orderedFielddataSettings);
} else if (includeDefaults) { } else if (includeDefaults) {
orderedFielddataSettings.putAll(fieldType.fieldDataType().getSettings().getAsMap()); orderedFielddataSettings.putAll(fieldType().fieldDataType().getSettings().getAsMap());
builder.field("fielddata", orderedFielddataSettings); builder.field("fielddata", orderedFielddataSettings);
} }
multiFields.toXContent(builder, params); multiFields.toXContent(builder, params);
@ -543,14 +543,14 @@ public abstract class AbstractFieldMapper implements FieldMapper {
} }
protected void doXContentAnalyzers(XContentBuilder builder, boolean includeDefaults) throws IOException { protected void doXContentAnalyzers(XContentBuilder builder, boolean includeDefaults) throws IOException {
if (fieldType.indexAnalyzer() == null) { if (fieldType().indexAnalyzer() == null) {
if (includeDefaults) { if (includeDefaults) {
builder.field("analyzer", "default"); builder.field("analyzer", "default");
} }
} else if (includeDefaults || fieldType.indexAnalyzer().name().startsWith("_") == false && fieldType.indexAnalyzer().name().equals("default") == false) { } else if (includeDefaults || fieldType().indexAnalyzer().name().startsWith("_") == false && fieldType().indexAnalyzer().name().equals("default") == false) {
builder.field("analyzer", fieldType.indexAnalyzer().name()); builder.field("analyzer", fieldType().indexAnalyzer().name());
if (fieldType.searchAnalyzer().name().equals(fieldType.indexAnalyzer().name()) == false) { if (fieldType().searchAnalyzer().name().equals(fieldType().indexAnalyzer().name()) == false) {
builder.field("search_analyzer", fieldType.searchAnalyzer().name()); builder.field("search_analyzer", fieldType().searchAnalyzer().name());
} }
} }
} }

View File

@ -198,7 +198,7 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
@Override @Override
public BooleanFieldType fieldType() { public BooleanFieldType fieldType() {
return (BooleanFieldType)fieldType; return (BooleanFieldType) super.fieldType();
} }
@Override @Override
@ -233,9 +233,9 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
if (value == null) { if (value == null) {
return; return;
} }
fields.add(new Field(fieldType.names().indexName(), value ? "T" : "F", fieldType)); fields.add(new Field(fieldType().names().indexName(), value ? "T" : "F", fieldType()));
if (fieldType().hasDocValues()) { if (fieldType().hasDocValues()) {
fields.add(new SortedNumericDocValuesField(fieldType.names().indexName(), value ? 1 : 0)); fields.add(new SortedNumericDocValuesField(fieldType().names().indexName(), value ? 1 : 0));
} }
} }
@ -247,9 +247,9 @@ public class BooleanFieldMapper extends AbstractFieldMapper {
} }
if (!mergeResult.simulate()) { if (!mergeResult.simulate()) {
this.fieldType = this.fieldType.clone(); this.fieldType = fieldType().clone();
this.fieldType.setNullValue(((BooleanFieldMapper) mergeWith).fieldType().nullValue()); fieldType().setNullValue(((BooleanFieldMapper) mergeWith).fieldType().nullValue());
this.fieldType.freeze(); fieldType().freeze();
} }
} }

View File

@ -23,7 +23,6 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.Terms; import org.apache.lucene.index.Terms;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;

View File

@ -297,7 +297,7 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
@Override @Override
public CompletionFieldType fieldType() { public CompletionFieldType fieldType() {
return (CompletionFieldType)fieldType; return (CompletionFieldType) super.fieldType();
} }
@Override @Override
@ -448,7 +448,7 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
+ "] at position " + i + " is a reserved character"); + "] at position " + i + " is a reserved character");
} }
} }
return new SuggestField(fieldType.names().indexName(), ctx, input, this.fieldType, payload, fieldType().analyzingSuggestLookupProvider); return new SuggestField(fieldType().names().indexName(), ctx, input, fieldType(), payload, fieldType().analyzingSuggestLookupProvider);
} }
public static int correctSubStringLen(String input, int len) { public static int correctSubStringLen(String input, int len) {
@ -487,9 +487,9 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
builder.startObject(fieldType().names().shortName()) builder.startObject(fieldType().names().shortName())
.field(Fields.TYPE, CONTENT_TYPE); .field(Fields.TYPE, CONTENT_TYPE);
builder.field(Fields.ANALYZER, fieldType.indexAnalyzer().name()); builder.field(Fields.ANALYZER, fieldType().indexAnalyzer().name());
if (fieldType.indexAnalyzer().name().equals(fieldType.searchAnalyzer().name()) == false) { if (fieldType().indexAnalyzer().name().equals(fieldType().searchAnalyzer().name()) == false) {
builder.field(Fields.SEARCH_ANALYZER.getPreferredName(), fieldType.searchAnalyzer().name()); builder.field(Fields.SEARCH_ANALYZER.getPreferredName(), fieldType().searchAnalyzer().name());
} }
builder.field(Fields.PAYLOADS, fieldType().analyzingSuggestLookupProvider.hasPayloads()); builder.field(Fields.PAYLOADS, fieldType().analyzingSuggestLookupProvider.hasPayloads());
builder.field(Fields.PRESERVE_SEPARATORS.getPreferredName(), fieldType().analyzingSuggestLookupProvider.getPreserveSep()); builder.field(Fields.PRESERVE_SEPARATORS.getPreferredName(), fieldType().analyzingSuggestLookupProvider.getPreserveSep());
@ -536,16 +536,16 @@ public class CompletionFieldMapper extends AbstractFieldMapper {
super.merge(mergeWith, mergeResult); super.merge(mergeWith, mergeResult);
CompletionFieldMapper fieldMergeWith = (CompletionFieldMapper) mergeWith; CompletionFieldMapper fieldMergeWith = (CompletionFieldMapper) mergeWith;
if (fieldType().analyzingSuggestLookupProvider.hasPayloads() != fieldMergeWith.fieldType().analyzingSuggestLookupProvider.hasPayloads()) { if (fieldType().analyzingSuggestLookupProvider.hasPayloads() != fieldMergeWith.fieldType().analyzingSuggestLookupProvider.hasPayloads()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different payload values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different payload values");
} }
if (fieldType().analyzingSuggestLookupProvider.getPreservePositionsIncrements() != fieldMergeWith.fieldType().analyzingSuggestLookupProvider.getPreservePositionsIncrements()) { if (fieldType().analyzingSuggestLookupProvider.getPreservePositionsIncrements() != fieldMergeWith.fieldType().analyzingSuggestLookupProvider.getPreservePositionsIncrements()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different 'preserve_position_increments' values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different 'preserve_position_increments' values");
} }
if (fieldType().analyzingSuggestLookupProvider.getPreserveSep() != fieldMergeWith.fieldType().analyzingSuggestLookupProvider.getPreserveSep()) { if (fieldType().analyzingSuggestLookupProvider.getPreserveSep() != fieldMergeWith.fieldType().analyzingSuggestLookupProvider.getPreserveSep()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different 'preserve_separators' values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different 'preserve_separators' values");
} }
if(!ContextMapping.mappingsAreEqual(fieldType().getContextMapping(), fieldMergeWith.fieldType().getContextMapping())) { if(!ContextMapping.mappingsAreEqual(fieldType().getContextMapping(), fieldMergeWith.fieldType().getContextMapping())) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different 'context_mapping' values"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different 'context_mapping' values");
} }
if (!mergeResult.simulate()) { if (!mergeResult.simulate()) {
this.maxInputLength = fieldMergeWith.maxInputLength; this.maxInputLength = fieldMergeWith.maxInputLength;

View File

@ -23,7 +23,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Terms; import org.apache.lucene.index.Terms;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;

View File

@ -23,10 +23,8 @@ import com.carrotsearch.hppc.FloatArrayList;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.Terms; import org.apache.lucene.index.Terms;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;

View File

@ -24,7 +24,6 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.Terms; import org.apache.lucene.index.Terms;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;

View File

@ -24,7 +24,6 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.Terms; import org.apache.lucene.index.Terms;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;

View File

@ -188,7 +188,7 @@ public abstract class NumberFieldMapper extends AbstractFieldMapper implements A
private ThreadLocal<NumericTokenStream> tokenStream = new ThreadLocal<NumericTokenStream>() { private ThreadLocal<NumericTokenStream> tokenStream = new ThreadLocal<NumericTokenStream>() {
@Override @Override
protected NumericTokenStream initialValue() { protected NumericTokenStream initialValue() {
return new NumericTokenStream(fieldType.numericPrecisionStep()); return new NumericTokenStream(fieldType().numericPrecisionStep());
} }
}; };
@ -319,9 +319,9 @@ public abstract class NumberFieldMapper extends AbstractFieldMapper implements A
} }
if (!mergeResult.simulate()) { if (!mergeResult.simulate()) {
NumberFieldMapper nfmMergeWith = (NumberFieldMapper) mergeWith; NumberFieldMapper nfmMergeWith = (NumberFieldMapper) mergeWith;
this.fieldType = this.fieldType.clone(); this.fieldType = this.fieldType().clone();
this.fieldType.setNumericPrecisionStep(nfmMergeWith.fieldType.numericPrecisionStep()); this.fieldType().setNumericPrecisionStep(nfmMergeWith.fieldType().numericPrecisionStep());
this.fieldType.freeze(); this.fieldType().freeze();
this.includeInAll = nfmMergeWith.includeInAll; this.includeInAll = nfmMergeWith.includeInAll;
if (nfmMergeWith.ignoreMalformed.explicit()) { if (nfmMergeWith.ignoreMalformed.explicit()) {
this.ignoreMalformed = nfmMergeWith.ignoreMalformed; this.ignoreMalformed = nfmMergeWith.ignoreMalformed;
@ -337,13 +337,13 @@ public abstract class NumberFieldMapper extends AbstractFieldMapper implements A
} }
protected NumericTokenStream popCachedStream() { protected NumericTokenStream popCachedStream() {
if (fieldType.numericPrecisionStep() == 4) { if (fieldType().numericPrecisionStep() == 4) {
return tokenStream4.get(); return tokenStream4.get();
} else if (fieldType.numericPrecisionStep() == 8) { } else if (fieldType().numericPrecisionStep() == 8) {
return tokenStream8.get(); return tokenStream8.get();
} else if (fieldType.numericPrecisionStep() == 16) { } else if (fieldType().numericPrecisionStep() == 16) {
return tokenStream16.get(); return tokenStream16.get();
} else if (fieldType.numericPrecisionStep() == Integer.MAX_VALUE) { } else if (fieldType().numericPrecisionStep() == Integer.MAX_VALUE) {
return tokenStreamMax.get(); return tokenStreamMax.get();
} }
return tokenStream.get(); return tokenStream.get();

View File

@ -24,7 +24,6 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.Terms; import org.apache.lucene.index.Terms;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;

View File

@ -276,7 +276,7 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
@Override @Override
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException { protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
ValueAndBoost valueAndBoost = parseCreateFieldForString(context, fieldType().nullValueAsString(), fieldType.boost()); ValueAndBoost valueAndBoost = parseCreateFieldForString(context, fieldType().nullValueAsString(), fieldType().boost());
if (valueAndBoost.value() == null) { if (valueAndBoost.value() == null) {
return; return;
} }
@ -284,19 +284,19 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
return; return;
} }
if (context.includeInAll(includeInAll, this)) { if (context.includeInAll(includeInAll, this)) {
context.allEntries().addText(fieldType.names().fullName(), valueAndBoost.value(), valueAndBoost.boost()); context.allEntries().addText(fieldType().names().fullName(), valueAndBoost.value(), valueAndBoost.boost());
} }
if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) { if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
Field field = new Field(fieldType.names().indexName(), valueAndBoost.value(), fieldType); Field field = new Field(fieldType().names().indexName(), valueAndBoost.value(), fieldType());
field.setBoost(valueAndBoost.boost()); field.setBoost(valueAndBoost.boost());
fields.add(field); fields.add(field);
} }
if (fieldType().hasDocValues()) { if (fieldType().hasDocValues()) {
fields.add(new SortedSetDocValuesField(fieldType.names().indexName(), new BytesRef(valueAndBoost.value()))); fields.add(new SortedSetDocValuesField(fieldType().names().indexName(), new BytesRef(valueAndBoost.value())));
} }
if (fields.isEmpty()) { if (fields.isEmpty()) {
context.ignoredValue(fieldType.names().indexName(), valueAndBoost.value()); context.ignoredValue(fieldType().names().indexName(), valueAndBoost.value());
} }
} }
@ -353,9 +353,9 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
if (!mergeResult.simulate()) { if (!mergeResult.simulate()) {
this.includeInAll = ((StringFieldMapper) mergeWith).includeInAll; this.includeInAll = ((StringFieldMapper) mergeWith).includeInAll;
this.ignoreAbove = ((StringFieldMapper) mergeWith).ignoreAbove; this.ignoreAbove = ((StringFieldMapper) mergeWith).ignoreAbove;
this.fieldType = this.fieldType.clone(); this.fieldType = this.fieldType().clone();
this.fieldType.setNullValue(((StringFieldMapper) mergeWith).fieldType().nullValue()); this.fieldType().setNullValue(((StringFieldMapper) mergeWith).fieldType().nullValue());
this.fieldType.freeze(); this.fieldType().freeze();
} }
} }
@ -375,8 +375,8 @@ public class StringFieldMapper extends AbstractFieldMapper implements AllFieldMa
if (includeDefaults || positionOffsetGap != Defaults.POSITION_OFFSET_GAP) { if (includeDefaults || positionOffsetGap != Defaults.POSITION_OFFSET_GAP) {
builder.field("position_offset_gap", positionOffsetGap); builder.field("position_offset_gap", positionOffsetGap);
} }
NamedAnalyzer searchQuoteAnalyzer = fieldType.searchQuoteAnalyzer(); NamedAnalyzer searchQuoteAnalyzer = fieldType().searchQuoteAnalyzer();
if (searchQuoteAnalyzer != null && !searchQuoteAnalyzer.name().equals(fieldType.searchAnalyzer().name())) { if (searchQuoteAnalyzer != null && !searchQuoteAnalyzer.name().equals(fieldType().searchAnalyzer().name())) {
builder.field("search_quote_analyzer", searchQuoteAnalyzer.name()); builder.field("search_quote_analyzer", searchQuoteAnalyzer.name());
} else if (includeDefaults) { } else if (includeDefaults) {
if (searchQuoteAnalyzer == null) { if (searchQuoteAnalyzer == null) {

View File

@ -36,7 +36,6 @@ 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.StringFieldMapper.ValueAndBoost; import org.elasticsearch.index.mapper.core.StringFieldMapper.ValueAndBoost;
import org.elasticsearch.index.similarity.SimilarityProvider;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;

View File

@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper.geo;
import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.google.common.base.Objects;
import com.google.common.collect.Iterators; import com.google.common.collect.Iterators;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
@ -568,7 +567,7 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
@Override @Override
public GeoPointFieldType fieldType() { public GeoPointFieldType fieldType() {
return (GeoPointFieldType)fieldType; return (GeoPointFieldType) super.fieldType();
} }
@Override @Override
@ -679,8 +678,8 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
} }
} }
if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) { if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
Field field = new Field(fieldType.names().indexName(), Double.toString(point.lat()) + ',' + Double.toString(point.lon()), fieldType); Field field = new Field(fieldType().names().indexName(), Double.toString(point.lat()) + ',' + Double.toString(point.lon()), fieldType());
context.doc().add(field); context.doc().add(field);
} }
if (fieldType().isGeohashEnabled()) { if (fieldType().isGeohashEnabled()) {
@ -728,32 +727,32 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
GeoPointFieldMapper fieldMergeWith = (GeoPointFieldMapper) mergeWith; GeoPointFieldMapper fieldMergeWith = (GeoPointFieldMapper) mergeWith;
if (this.fieldType().isLatLonEnabled() != fieldMergeWith.fieldType().isLatLonEnabled()) { if (this.fieldType().isLatLonEnabled() != fieldMergeWith.fieldType().isLatLonEnabled()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different lat_lon"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different lat_lon");
} }
if (this.fieldType().isGeohashEnabled() != fieldMergeWith.fieldType().isGeohashEnabled()) { if (this.fieldType().isGeohashEnabled() != fieldMergeWith.fieldType().isGeohashEnabled()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different geohash"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different geohash");
} }
if (this.fieldType().geohashPrecision() != fieldMergeWith.fieldType().geohashPrecision()) { if (this.fieldType().geohashPrecision() != fieldMergeWith.fieldType().geohashPrecision()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different geohash_precision"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different geohash_precision");
} }
if (this.fieldType().isGeohashPrefixEnabled() != fieldMergeWith.fieldType().isGeohashPrefixEnabled()) { if (this.fieldType().isGeohashPrefixEnabled() != fieldMergeWith.fieldType().isGeohashPrefixEnabled()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different geohash_prefix"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different geohash_prefix");
} }
if (this.fieldType().normalizeLat() != fieldMergeWith.fieldType().normalizeLat()) { if (this.fieldType().normalizeLat() != fieldMergeWith.fieldType().normalizeLat()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different normalize_lat"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different normalize_lat");
} }
if (this.fieldType().normalizeLon() != fieldMergeWith.fieldType().normalizeLon()) { if (this.fieldType().normalizeLon() != fieldMergeWith.fieldType().normalizeLon()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different normalize_lon"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different normalize_lon");
} }
if (fieldType().isLatLonEnabled() && if (fieldType().isLatLonEnabled() &&
this.fieldType().latFieldType().numericPrecisionStep() != fieldMergeWith.fieldType().latFieldType().numericPrecisionStep()) { this.fieldType().latFieldType().numericPrecisionStep() != fieldMergeWith.fieldType().latFieldType().numericPrecisionStep()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different precision_step"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different precision_step");
} }
if (this.fieldType().validateLat() != fieldMergeWith.fieldType().validateLat()) { if (this.fieldType().validateLat() != fieldMergeWith.fieldType().validateLat()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different validate_lat"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different validate_lat");
} }
if (this.fieldType().validateLon() != fieldMergeWith.fieldType().validateLon()) { if (this.fieldType().validateLon() != fieldMergeWith.fieldType().validateLon()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different validate_lon"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different validate_lon");
} }
} }

View File

@ -38,7 +38,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.fielddata.FieldDataType;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.Mapper; import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MapperParsingException;
@ -340,7 +339,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper {
@Override @Override
public GeoShapeFieldType fieldType() { public GeoShapeFieldType fieldType() {
return (GeoShapeFieldType)fieldType; return (GeoShapeFieldType) super.fieldType();
} }
@Override @Override
@ -370,12 +369,12 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper {
} }
for (Field field : fields) { for (Field field : fields) {
if (!customBoost()) { if (!customBoost()) {
field.setBoost(fieldType.boost()); field.setBoost(fieldType().boost());
} }
context.doc().add(field); context.doc().add(field);
} }
} catch (Exception e) { } catch (Exception e) {
throw new MapperParsingException("failed to parse [" + fieldType.names().fullName() + "]", e); throw new MapperParsingException("failed to parse [" + fieldType().names().fullName() + "]", e);
} }
return null; return null;
} }
@ -384,28 +383,28 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper {
public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException { public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException {
super.merge(mergeWith, mergeResult); super.merge(mergeWith, mergeResult);
if (!this.getClass().equals(mergeWith.getClass())) { if (!this.getClass().equals(mergeWith.getClass())) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different field type"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different field type");
return; return;
} }
final GeoShapeFieldMapper fieldMergeWith = (GeoShapeFieldMapper) mergeWith; final GeoShapeFieldMapper fieldMergeWith = (GeoShapeFieldMapper) mergeWith;
// prevent user from changing strategies // prevent user from changing strategies
if (fieldType().strategyName().equals(fieldMergeWith.fieldType().strategyName()) == false) { if (fieldType().strategyName().equals(fieldMergeWith.fieldType().strategyName()) == false) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different strategy"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different strategy");
} }
// prevent user from changing trees (changes encoding) // prevent user from changing trees (changes encoding)
if (fieldType().tree().equals(fieldMergeWith.fieldType().tree()) == false) { if (fieldType().tree().equals(fieldMergeWith.fieldType().tree()) == false) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different tree"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different tree");
} }
// TODO we should allow this, but at the moment levels is used to build bookkeeping variables // TODO we should allow this, but at the moment levels is used to build bookkeeping variables
// in lucene's SpatialPrefixTree implementations, need a patch to correct that first // in lucene's SpatialPrefixTree implementations, need a patch to correct that first
if (fieldType().treeLevels() != fieldMergeWith.fieldType().treeLevels()) { if (fieldType().treeLevels() != fieldMergeWith.fieldType().treeLevels()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different tree_levels"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different tree_levels");
} }
if (fieldType().precisionInMeters() != fieldMergeWith.fieldType().precisionInMeters()) { if (fieldType().precisionInMeters() != fieldMergeWith.fieldType().precisionInMeters()) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] has different precision"); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] has different precision");
} }
// bail if there were merge conflicts // bail if there were merge conflicts
@ -414,12 +413,12 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper {
} }
// change distance error percent // change distance error percent
this.fieldType = this.fieldType.clone(); this.fieldType = fieldType().clone();
this.fieldType().setDistanceErrorPct(fieldMergeWith.fieldType().distanceErrorPct()); this.fieldType().setDistanceErrorPct(fieldMergeWith.fieldType().distanceErrorPct());
// change orientation - this is allowed because existing dateline spanning shapes // change orientation - this is allowed because existing dateline spanning shapes
// have already been unwound and segmented // have already been unwound and segmented
this.fieldType().setOrientation(fieldMergeWith.fieldType().orientation()); this.fieldType().setOrientation(fieldMergeWith.fieldType().orientation());
this.fieldType.freeze(); fieldType().freeze();
} }
@Override @Override

View File

@ -239,11 +239,11 @@ public class AllFieldMapper extends AbstractFieldMapper implements RootMapper {
// reset the entries // reset the entries
context.allEntries().reset(); context.allEntries().reset();
Analyzer analyzer = findAnalyzer(context); Analyzer analyzer = findAnalyzer(context);
fields.add(new AllField(fieldType.names().indexName(), context.allEntries(), analyzer, fieldType)); fields.add(new AllField(fieldType().names().indexName(), context.allEntries(), analyzer, fieldType()));
} }
private Analyzer findAnalyzer(ParseContext context) { private Analyzer findAnalyzer(ParseContext context) {
Analyzer analyzer = fieldType.indexAnalyzer(); Analyzer analyzer = fieldType().indexAnalyzer();
if (analyzer == null) { if (analyzer == null) {
analyzer = context.docMapper().mappers().indexAnalyzer(); analyzer = context.docMapper().mappers().indexAnalyzer();
if (analyzer == null) { if (analyzer == null) {
@ -285,23 +285,23 @@ public class AllFieldMapper extends AbstractFieldMapper implements RootMapper {
if (includeDefaults || enabledState != Defaults.ENABLED) { if (includeDefaults || enabledState != Defaults.ENABLED) {
builder.field("enabled", enabledState.enabled); builder.field("enabled", enabledState.enabled);
} }
if (includeDefaults || fieldType.stored() != Defaults.FIELD_TYPE.stored()) { if (includeDefaults || fieldType().stored() != Defaults.FIELD_TYPE.stored()) {
builder.field("store", fieldType.stored()); builder.field("store", fieldType().stored());
} }
if (includeDefaults || fieldType.storeTermVectors() != Defaults.FIELD_TYPE.storeTermVectors()) { if (includeDefaults || fieldType().storeTermVectors() != Defaults.FIELD_TYPE.storeTermVectors()) {
builder.field("store_term_vectors", fieldType.storeTermVectors()); builder.field("store_term_vectors", fieldType().storeTermVectors());
} }
if (includeDefaults || fieldType.storeTermVectorOffsets() != Defaults.FIELD_TYPE.storeTermVectorOffsets()) { if (includeDefaults || fieldType().storeTermVectorOffsets() != Defaults.FIELD_TYPE.storeTermVectorOffsets()) {
builder.field("store_term_vector_offsets", fieldType.storeTermVectorOffsets()); builder.field("store_term_vector_offsets", fieldType().storeTermVectorOffsets());
} }
if (includeDefaults || fieldType.storeTermVectorPositions() != Defaults.FIELD_TYPE.storeTermVectorPositions()) { if (includeDefaults || fieldType().storeTermVectorPositions() != Defaults.FIELD_TYPE.storeTermVectorPositions()) {
builder.field("store_term_vector_positions", fieldType.storeTermVectorPositions()); builder.field("store_term_vector_positions", fieldType().storeTermVectorPositions());
} }
if (includeDefaults || fieldType.storeTermVectorPayloads() != Defaults.FIELD_TYPE.storeTermVectorPayloads()) { if (includeDefaults || fieldType().storeTermVectorPayloads() != Defaults.FIELD_TYPE.storeTermVectorPayloads()) {
builder.field("store_term_vector_payloads", fieldType.storeTermVectorPayloads()); builder.field("store_term_vector_payloads", fieldType().storeTermVectorPayloads());
} }
if (includeDefaults || fieldType.omitNorms() != Defaults.FIELD_TYPE.omitNorms()) { if (includeDefaults || fieldType().omitNorms() != Defaults.FIELD_TYPE.omitNorms()) {
builder.field("omit_norms", fieldType.omitNorms()); builder.field("omit_norms", fieldType().omitNorms());
} }
doXContentAnalyzers(builder, includeDefaults); doXContentAnalyzers(builder, includeDefaults);
@ -315,14 +315,14 @@ public class AllFieldMapper extends AbstractFieldMapper implements RootMapper {
if (customFieldDataSettings != null) { if (customFieldDataSettings != null) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap()); builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) { } else if (includeDefaults) {
builder.field("fielddata", (Map) fieldType.fieldDataType().getSettings().getAsMap()); builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
} }
} }
@Override @Override
public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException { public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException {
if (((AllFieldMapper)mergeWith).enabled() != this.enabled() && ((AllFieldMapper)mergeWith).enabledState != Defaults.ENABLED) { if (((AllFieldMapper)mergeWith).enabled() != this.enabled() && ((AllFieldMapper)mergeWith).enabledState != Defaults.ENABLED) {
mergeResult.addConflict("mapper [" + fieldType.names().fullName() + "] enabled is " + this.enabled() + " now encountering "+ ((AllFieldMapper)mergeWith).enabled()); mergeResult.addConflict("mapper [" + fieldType().names().fullName() + "] enabled is " + this.enabled() + " now encountering "+ ((AllFieldMapper)mergeWith).enabled());
} }
super.merge(mergeWith, mergeResult); super.merge(mergeWith, mergeResult);
} }

View File

@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper.internal;
import com.google.common.collect.UnmodifiableIterator; import com.google.common.collect.UnmodifiableIterator;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.elasticsearch.Version; import org.elasticsearch.Version;
@ -39,7 +38,6 @@ import org.elasticsearch.index.mapper.MergeResult;
import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.ParseContext;
import org.elasticsearch.index.mapper.RootMapper; import org.elasticsearch.index.mapper.RootMapper;
import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
import org.elasticsearch.search.highlight.HighlightBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -201,15 +199,15 @@ public class FieldNamesFieldMapper extends AbstractFieldMapper implements RootMa
this.defaultFieldType = Defaults.FIELD_TYPE; 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) {
this.fieldType = this.fieldType.clone(); this.fieldType = fieldType().clone();
fieldType().setEnabled(false); fieldType().setEnabled(false);
this.fieldType.freeze(); fieldType().freeze();
} }
} }
@Override @Override
public FieldNamesFieldType fieldType() { public FieldNamesFieldType fieldType() {
return (FieldNamesFieldType)fieldType; return (FieldNamesFieldType) super.fieldType();
} }
@Override @Override
@ -281,8 +279,8 @@ public class FieldNamesFieldMapper extends AbstractFieldMapper implements RootMa
} }
for (String path : paths) { for (String path : paths) {
for (String fieldName : extractFieldNames(path)) { for (String fieldName : extractFieldNames(path)) {
if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) { if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
document.add(new Field(fieldType().names().indexName(), fieldName, fieldType)); document.add(new Field(fieldType().names().indexName(), fieldName, fieldType()));
} }
} }
} }

View File

@ -31,7 +31,6 @@ import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.search.RegexpQuery; import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Nullable;
@ -288,11 +287,11 @@ public class IdFieldMapper extends AbstractFieldMapper implements RootMapper {
context.id(id); context.id(id);
} // else we are in the pre/post parse phase } // else we are in the pre/post parse phase
if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) { if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
fields.add(new Field(fieldType.names().indexName(), context.id(), fieldType)); fields.add(new Field(fieldType().names().indexName(), context.id(), fieldType()));
} }
if (fieldType().hasDocValues()) { if (fieldType().hasDocValues()) {
fields.add(new BinaryDocValuesField(fieldType.names().indexName(), new BytesRef(context.id()))); fields.add(new BinaryDocValuesField(fieldType().names().indexName(), new BytesRef(context.id())));
} }
} }
@ -309,18 +308,18 @@ public class IdFieldMapper extends AbstractFieldMapper implements RootMapper {
boolean includeDefaults = params.paramAsBoolean("include_defaults", false); boolean includeDefaults = params.paramAsBoolean("include_defaults", false);
// if all are defaults, no sense to write it at all // if all are defaults, no sense to write it at all
if (!includeDefaults && fieldType.stored() == Defaults.FIELD_TYPE.stored() if (!includeDefaults && fieldType().stored() == Defaults.FIELD_TYPE.stored()
&& fieldType.indexOptions() == Defaults.FIELD_TYPE.indexOptions() && fieldType().indexOptions() == Defaults.FIELD_TYPE.indexOptions()
&& path == Defaults.PATH && path == Defaults.PATH
&& customFieldDataSettings == null) { && customFieldDataSettings == null) {
return builder; return builder;
} }
builder.startObject(CONTENT_TYPE); builder.startObject(CONTENT_TYPE);
if (includeDefaults || fieldType.stored() != Defaults.FIELD_TYPE.stored()) { if (includeDefaults || fieldType().stored() != Defaults.FIELD_TYPE.stored()) {
builder.field("store", fieldType.stored()); builder.field("store", fieldType().stored());
} }
if (includeDefaults || fieldType.indexOptions() != Defaults.FIELD_TYPE.indexOptions()) { if (includeDefaults || fieldType().indexOptions() != Defaults.FIELD_TYPE.indexOptions()) {
builder.field("index", indexTokenizeOptionToString(fieldType.indexOptions() != IndexOptions.NONE, fieldType.tokenized())); builder.field("index", indexTokenizeOptionToString(fieldType().indexOptions() != IndexOptions.NONE, fieldType().tokenized()));
} }
if (includeDefaults || path != Defaults.PATH) { if (includeDefaults || path != Defaults.PATH) {
builder.field("path", path); builder.field("path", path);
@ -329,7 +328,7 @@ public class IdFieldMapper extends AbstractFieldMapper implements RootMapper {
if (customFieldDataSettings != null) { if (customFieldDataSettings != null) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap()); builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) { } 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;

View File

@ -38,7 +38,6 @@ import org.elasticsearch.index.mapper.MergeResult;
import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.ParseContext;
import org.elasticsearch.index.mapper.RootMapper; import org.elasticsearch.index.mapper.RootMapper;
import org.elasticsearch.index.mapper.core.AbstractFieldMapper; import org.elasticsearch.index.mapper.core.AbstractFieldMapper;
import org.elasticsearch.search.highlight.HighlightBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
@ -170,7 +169,7 @@ public class IndexFieldMapper extends AbstractFieldMapper implements RootMapper
} }
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);
} }
@ -194,7 +193,7 @@ public class IndexFieldMapper extends AbstractFieldMapper implements RootMapper
if (!enabledState.enabled) { if (!enabledState.enabled) {
return; return;
} }
fields.add(new Field(fieldType.names().indexName(), context.index(), fieldType)); fields.add(new Field(fieldType().names().indexName(), context.index(), fieldType()));
} }
@Override @Override
@ -222,7 +221,7 @@ public class IndexFieldMapper extends AbstractFieldMapper implements RootMapper
if (customFieldDataSettings != null) { if (customFieldDataSettings != null) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap()); builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) { } else if (includeDefaults) {
builder.field("fielddata", (Map) fieldType.fieldDataType().getSettings().getAsMap()); builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
} }
} }
builder.endObject(); builder.endObject();

View File

@ -20,7 +20,6 @@ package org.elasticsearch.index.mapper.internal;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.SortedDocValuesField; import org.apache.lucene.document.SortedDocValuesField;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.queries.TermsQuery; import org.apache.lucene.queries.TermsQuery;
@ -237,9 +236,9 @@ public class ParentFieldMapper extends AbstractFieldMapper implements RootMapper
public ParentFieldMapper(Settings indexSettings) { public ParentFieldMapper(Settings indexSettings) {
this(Defaults.FIELD_TYPE.clone(), null, null, indexSettings); this(Defaults.FIELD_TYPE.clone(), null, null, indexSettings);
this.fieldType = this.fieldType.clone(); this.fieldType = this.fieldType().clone();
this.fieldType.setFieldDataType(new FieldDataType("_parent", settingsBuilder().put(MappedFieldType.Loading.KEY, MappedFieldType.Loading.LAZY_VALUE))); this.fieldType().setFieldDataType(new FieldDataType("_parent", settingsBuilder().put(MappedFieldType.Loading.KEY, MappedFieldType.Loading.LAZY_VALUE)));
this.fieldType.freeze(); this.fieldType().freeze();
} }
public String type() { public String type() {
@ -268,7 +267,7 @@ public class ParentFieldMapper extends AbstractFieldMapper implements RootMapper
@Override @Override
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException { protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
boolean parent = context.docMapper().isParent(context.type()); boolean parent = context.docMapper().isParent(context.type());
if (parent && fieldType.hasDocValues()) { if (parent && fieldType().hasDocValues()) {
fields.add(createJoinField(context.type(), context.id())); fields.add(createJoinField(context.type(), context.id()));
} }
@ -280,8 +279,8 @@ public class ParentFieldMapper extends AbstractFieldMapper implements RootMapper
// we are in the parsing of _parent phase // we are in the parsing of _parent phase
String parentId = context.parser().text(); String parentId = context.parser().text();
context.sourceToParse().parent(parentId); context.sourceToParse().parent(parentId);
fields.add(new Field(fieldType.names().indexName(), Uid.createUid(context.stringBuilder(), type, parentId), fieldType)); fields.add(new Field(fieldType().names().indexName(), Uid.createUid(context.stringBuilder(), type, parentId), fieldType()));
if (fieldType.hasDocValues()) { if (fieldType().hasDocValues()) {
fields.add(createJoinField(type, parentId)); fields.add(createJoinField(type, parentId));
} }
} else { } else {
@ -294,8 +293,8 @@ public class ParentFieldMapper extends AbstractFieldMapper implements RootMapper
throw new MapperParsingException("No parent id provided, not within the document, and not externally"); throw new MapperParsingException("No parent id provided, not within the document, and not externally");
} }
// we did not add it in the parsing phase, add it now // we did not add it in the parsing phase, add it now
fields.add(new Field(fieldType.names().indexName(), Uid.createUid(context.stringBuilder(), type, parentId), fieldType)); fields.add(new Field(fieldType().names().indexName(), Uid.createUid(context.stringBuilder(), type, parentId), fieldType()));
if (fieldType.hasDocValues()) { if (fieldType().hasDocValues()) {
fields.add(createJoinField(type, parentId)); fields.add(createJoinField(type, parentId));
} }
} else if (parentId != null && !parsedParentId.equals(Uid.createUid(context.stringBuilder(), type, parentId))) { } else if (parentId != null && !parsedParentId.equals(Uid.createUid(context.stringBuilder(), type, parentId))) {
@ -332,7 +331,7 @@ public class ParentFieldMapper extends AbstractFieldMapper implements RootMapper
if (customFieldDataSettings != null) { if (customFieldDataSettings != null) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap()); builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) { } 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;
@ -347,16 +346,16 @@ public class ParentFieldMapper extends AbstractFieldMapper implements RootMapper
if (!mergeResult.simulate()) { if (!mergeResult.simulate()) {
ParentFieldMapper fieldMergeWith = (ParentFieldMapper) mergeWith; ParentFieldMapper fieldMergeWith = (ParentFieldMapper) mergeWith;
this.fieldType = this.fieldType.clone(); this.fieldType = this.fieldType().clone();
if (fieldMergeWith.customFieldDataSettings != null) { if (fieldMergeWith.customFieldDataSettings != null) {
if (!Objects.equal(fieldMergeWith.customFieldDataSettings, this.customFieldDataSettings)) { if (!Objects.equal(fieldMergeWith.customFieldDataSettings, this.customFieldDataSettings)) {
this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings; this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings;
this.fieldType.setFieldDataType(new FieldDataType(defaultFieldDataType().getType(), this.fieldType().setFieldDataType(new FieldDataType(defaultFieldDataType().getType(),
builder().put(defaultFieldDataType().getSettings()).put(this.customFieldDataSettings) builder().put(defaultFieldDataType().getSettings()).put(this.customFieldDataSettings)
)); ));
} }
} }
this.fieldType.freeze(); this.fieldType().freeze();
} }
} }

View File

@ -184,7 +184,7 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements RootMappe
} }
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);
} }
@ -210,11 +210,11 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements RootMappe
if (context.sourceToParse().routing() != null) { if (context.sourceToParse().routing() != null) {
String routing = context.sourceToParse().routing(); String routing = context.sourceToParse().routing();
if (routing != null) { if (routing != null) {
if (fieldType.indexOptions() == IndexOptions.NONE && !fieldType.stored()) { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) {
context.ignoredValue(fieldType.names().indexName(), routing); context.ignoredValue(fieldType().names().indexName(), routing);
return; return;
} }
fields.add(new Field(fieldType.names().indexName(), routing, fieldType)); fields.add(new Field(fieldType().names().indexName(), routing, fieldType()));
} }
} }
} }
@ -229,18 +229,18 @@ public class RoutingFieldMapper extends AbstractFieldMapper implements RootMappe
boolean includeDefaults = params.paramAsBoolean("include_defaults", false); boolean includeDefaults = params.paramAsBoolean("include_defaults", false);
// if all are defaults, no sense to write it at all // if all are defaults, no sense to write it at all
boolean indexed = fieldType.indexOptions() != IndexOptions.NONE; boolean indexed = fieldType().indexOptions() != IndexOptions.NONE;
boolean indexedDefault = Defaults.FIELD_TYPE.indexOptions() != IndexOptions.NONE; boolean indexedDefault = Defaults.FIELD_TYPE.indexOptions() != IndexOptions.NONE;
if (!includeDefaults && indexed == indexedDefault && if (!includeDefaults && indexed == indexedDefault &&
fieldType.stored() == Defaults.FIELD_TYPE.stored() && required == Defaults.REQUIRED && path == Defaults.PATH) { fieldType().stored() == Defaults.FIELD_TYPE.stored() && required == Defaults.REQUIRED && path == Defaults.PATH) {
return builder; return builder;
} }
builder.startObject(CONTENT_TYPE); builder.startObject(CONTENT_TYPE);
if (indexCreatedBefore2x && (includeDefaults || indexed != indexedDefault)) { if (indexCreatedBefore2x && (includeDefaults || indexed != indexedDefault)) {
builder.field("index", indexTokenizeOptionToString(indexed, fieldType.tokenized())); builder.field("index", indexTokenizeOptionToString(indexed, fieldType().tokenized()));
} }
if (indexCreatedBefore2x && (includeDefaults || fieldType.stored() != Defaults.FIELD_TYPE.stored())) { if (indexCreatedBefore2x && (includeDefaults || fieldType().stored() != Defaults.FIELD_TYPE.stored())) {
builder.field("store", fieldType.stored()); builder.field("store", fieldType().stored());
} }
if (includeDefaults || required != Defaults.REQUIRED) { if (includeDefaults || required != Defaults.REQUIRED) {
builder.field("required", required); builder.field("required", required);

View File

@ -313,7 +313,7 @@ public class SourceFieldMapper extends AbstractFieldMapper implements RootMapper
if (!enabled) { if (!enabled) {
return; return;
} }
if (!fieldType.stored()) { if (!fieldType().stored()) {
return; return;
} }
if (context.flyweight()) { if (context.flyweight()) {

View File

@ -178,12 +178,12 @@ public class TypeFieldMapper extends AbstractFieldMapper implements RootMapper {
@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()) { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) {
return; return;
} }
fields.add(new Field(fieldType.names().indexName(), context.type(), fieldType)); fields.add(new Field(fieldType().names().indexName(), context.type(), fieldType()));
if (fieldType().hasDocValues()) { if (fieldType().hasDocValues()) {
fields.add(new SortedSetDocValuesField(fieldType.names().indexName(), new BytesRef(context.type()))); fields.add(new SortedSetDocValuesField(fieldType().names().indexName(), new BytesRef(context.type())));
} }
} }
@ -200,17 +200,17 @@ public class TypeFieldMapper extends AbstractFieldMapper implements RootMapper {
boolean includeDefaults = params.paramAsBoolean("include_defaults", false); boolean includeDefaults = params.paramAsBoolean("include_defaults", false);
// if all are defaults, no sense to write it at all // if all are defaults, no sense to write it at all
boolean indexed = fieldType.indexOptions() != IndexOptions.NONE; boolean indexed = fieldType().indexOptions() != IndexOptions.NONE;
boolean defaultIndexed = Defaults.FIELD_TYPE.indexOptions() != IndexOptions.NONE; boolean defaultIndexed = Defaults.FIELD_TYPE.indexOptions() != IndexOptions.NONE;
if (!includeDefaults && fieldType.stored() == Defaults.FIELD_TYPE.stored() && indexed == defaultIndexed) { if (!includeDefaults && fieldType().stored() == Defaults.FIELD_TYPE.stored() && indexed == defaultIndexed) {
return builder; return builder;
} }
builder.startObject(CONTENT_TYPE); builder.startObject(CONTENT_TYPE);
if (includeDefaults || fieldType.stored() != Defaults.FIELD_TYPE.stored()) { if (includeDefaults || fieldType().stored() != Defaults.FIELD_TYPE.stored()) {
builder.field("store", fieldType.stored()); builder.field("store", fieldType().stored());
} }
if (includeDefaults || indexed != defaultIndexed) { if (includeDefaults || indexed != defaultIndexed) {
builder.field("index", indexTokenizeOptionToString(indexed, fieldType.tokenized())); builder.field("index", indexTokenizeOptionToString(indexed, fieldType().tokenized()));
} }
builder.endObject(); builder.endObject();
return builder; return builder;

View File

@ -229,7 +229,7 @@ public class UidFieldMapper extends AbstractFieldMapper implements RootMapper {
if (customFieldDataSettings != null) { if (customFieldDataSettings != null) {
builder.field("fielddata", (Map) customFieldDataSettings.getAsMap()); builder.field("fielddata", (Map) customFieldDataSettings.getAsMap());
} else if (includeDefaults) { } else if (includeDefaults) {
builder.field("fielddata", (Map) fieldType.fieldDataType().getSettings().getAsMap()); builder.field("fielddata", (Map) fieldType().fieldDataType().getSettings().getAsMap());
} }
builder.endObject(); builder.endObject();

View File

@ -23,7 +23,6 @@ import com.google.common.net.InetAddresses;
import org.apache.lucene.analysis.NumericTokenStream; import org.apache.lucene.analysis.NumericTokenStream;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.NumericRangeQuery; import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
@ -275,13 +274,13 @@ public class IpFieldMapper extends NumberFieldMapper {
return; return;
} }
if (context.includeInAll(includeInAll, this)) { if (context.includeInAll(includeInAll, this)) {
context.allEntries().addText(fieldType.names().fullName(), ipAsString, fieldType.boost()); context.allEntries().addText(fieldType().names().fullName(), ipAsString, fieldType().boost());
} }
final long value = ipToLong(ipAsString); final long value = ipToLong(ipAsString);
if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) { if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
CustomLongNumericField field = new CustomLongNumericField(this, value, fieldType); CustomLongNumericField field = new CustomLongNumericField(this, value, fieldType());
field.setBoost(fieldType.boost()); field.setBoost(fieldType().boost());
fields.add(field); fields.add(field);
} }
if (fieldType().hasDocValues()) { if (fieldType().hasDocValues()) {
@ -301,8 +300,8 @@ public class IpFieldMapper extends NumberFieldMapper {
return; return;
} }
if (!mergeResult.simulate()) { if (!mergeResult.simulate()) {
this.fieldType = this.fieldType.clone(); this.fieldType = this.fieldType().clone();
this.fieldType.setNullValue(((IpFieldMapper) mergeWith).fieldType().nullValue()); this.fieldType().setNullValue(((IpFieldMapper) mergeWith).fieldType().nullValue());
} }
} }
@ -310,8 +309,8 @@ public class IpFieldMapper extends NumberFieldMapper {
protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
super.doXContentBody(builder, includeDefaults, params); super.doXContentBody(builder, includeDefaults, params);
if (includeDefaults || fieldType.numericPrecisionStep() != Defaults.PRECISION_STEP_64_BIT) { if (includeDefaults || fieldType().numericPrecisionStep() != Defaults.PRECISION_STEP_64_BIT) {
builder.field("precision_step", fieldType.numericPrecisionStep()); builder.field("precision_step", fieldType().numericPrecisionStep());
} }
if (includeDefaults || fieldType().nullValueAsString() != null) { if (includeDefaults || fieldType().nullValueAsString() != null) {
builder.field("null_value", fieldType().nullValueAsString()); builder.field("null_value", fieldType().nullValueAsString());