Remove / deprecated omit_term_freq_and_positions in favor of IndexOptions exposed via mapping API
This commit is contained in:
parent
980fc6ca34
commit
53f65d8ff2
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.MultiTermQuery;
|
||||
|
@ -135,7 +136,7 @@ public interface FieldMapper<T> {
|
|||
|
||||
boolean omitNorms();
|
||||
|
||||
boolean omitTermFreqAndPositions();
|
||||
IndexOptions indexOptions();
|
||||
|
||||
/**
|
||||
* The analyzer that will be used to index the field.
|
||||
|
|
|
@ -23,8 +23,10 @@ import org.apache.lucene.analysis.Analyzer;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
|
@ -47,7 +49,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
public static final Field.TermVector TERM_VECTOR = Field.TermVector.NO;
|
||||
public static final float BOOST = 1.0f;
|
||||
public static final boolean OMIT_NORMS = false;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = false;
|
||||
public static final IndexOptions INDEX_OPTIONS = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
|
||||
}
|
||||
|
||||
public abstract static class OpenBuilder<T extends Builder, Y extends AbstractFieldMapper> extends AbstractFieldMapper.Builder<T, Y> {
|
||||
|
@ -82,8 +84,8 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public T omitTermFreqAndPositions(boolean omitTermFreqAndPositions) {
|
||||
return super.omitTermFreqAndPositions(omitTermFreqAndPositions);
|
||||
public T indexOptions(IndexOptions indexOptions) {
|
||||
return super.indexOptions(indexOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -113,9 +115,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
protected float boost = Defaults.BOOST;
|
||||
|
||||
protected boolean omitNorms = Defaults.OMIT_NORMS;
|
||||
|
||||
protected boolean omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS;
|
||||
|
||||
|
||||
protected String indexName;
|
||||
|
||||
protected NamedAnalyzer indexAnalyzer;
|
||||
|
@ -124,6 +124,8 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
|
||||
protected Boolean includeInAll;
|
||||
|
||||
protected IndexOptions indexOptions = Defaults.INDEX_OPTIONS;
|
||||
|
||||
protected Builder(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
@ -152,12 +154,12 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
this.omitNorms = omitNorms;
|
||||
return builder;
|
||||
}
|
||||
|
||||
protected T omitTermFreqAndPositions(boolean omitTermFreqAndPositions) {
|
||||
this.omitTermFreqAndPositions = omitTermFreqAndPositions;
|
||||
|
||||
protected T indexOptions(IndexOptions indexOptions) {
|
||||
this.indexOptions = indexOptions;
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
protected T indexName(String indexName) {
|
||||
this.indexName = indexName;
|
||||
return builder;
|
||||
|
@ -206,8 +208,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
protected float boost;
|
||||
|
||||
protected final boolean omitNorms;
|
||||
|
||||
protected final boolean omitTermFreqAndPositions;
|
||||
|
||||
protected final FieldInfo.IndexOptions indexOptions;
|
||||
|
||||
protected final NamedAnalyzer indexAnalyzer;
|
||||
|
@ -215,15 +216,15 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
protected final NamedAnalyzer searchAnalyzer;
|
||||
|
||||
protected AbstractFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
this.names = names;
|
||||
this.index = index;
|
||||
this.store = store;
|
||||
this.termVector = termVector;
|
||||
this.boost = boost;
|
||||
this.omitNorms = omitNorms;
|
||||
this.omitTermFreqAndPositions = omitTermFreqAndPositions;
|
||||
this.indexOptions = omitTermFreqAndPositions ? FieldInfo.IndexOptions.DOCS_ONLY : FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
|
||||
this.indexOptions = indexOptions;
|
||||
|
||||
// automatically set to keyword analyzer if its indexed and not analyzed
|
||||
if (indexAnalyzer == null && !index.isAnalyzed() && index.isIndexed()) {
|
||||
this.indexAnalyzer = Lucene.KEYWORD_ANALYZER;
|
||||
|
@ -287,10 +288,10 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
public boolean omitNorms() {
|
||||
return this.omitNorms;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean omitTermFreqAndPositions() {
|
||||
return this.omitTermFreqAndPositions;
|
||||
public IndexOptions indexOptions() {
|
||||
return this.indexOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -479,6 +480,19 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
|
|||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
||||
protected static String indexOptionToString(IndexOptions indexOption) {
|
||||
switch (indexOption) {
|
||||
case DOCS_AND_FREQS:
|
||||
return TypeParsers.INDEX_OPTIONS_FREQS;
|
||||
case DOCS_AND_FREQS_AND_POSITIONS:
|
||||
return TypeParsers.INDEX_OPTIONS_POSITIONS;
|
||||
case DOCS_ONLY:
|
||||
return TypeParsers.INDEX_OPTIONS_DOCS;
|
||||
default:
|
||||
throw new ElasticSearchIllegalArgumentException("Unknown IndexOptions [" + indexOption + "]");
|
||||
}
|
||||
}
|
||||
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
builder.field("type", contentType());
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.elasticsearch.ElasticSearchParseException;
|
||||
import org.elasticsearch.common.Base64;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -114,7 +115,7 @@ public class BinaryFieldMapper extends AbstractFieldMapper<byte[]> {
|
|||
private long compressThreshold;
|
||||
|
||||
protected BinaryFieldMapper(Names names, Field.Store store, Boolean compress, long compressThreshold) {
|
||||
super(names, Field.Index.NO, store, Field.TermVector.NO, 1.0f, true, true, null, null);
|
||||
super(names, Field.Index.NO, store, Field.TermVector.NO, 1.0f, true, IndexOptions.DOCS_ONLY, null, null);
|
||||
this.compress = compress;
|
||||
this.compressThreshold = compressThreshold;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -92,15 +93,11 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
return super.indexName(indexName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder omitTermFreqAndPositions(boolean omitTermFreqAndPositions) {
|
||||
return super.omitTermFreqAndPositions(omitTermFreqAndPositions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BooleanFieldMapper build(BuilderContext context) {
|
||||
return new BooleanFieldMapper(buildNames(context), index, store,
|
||||
termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
termVector, boost, omitNorms, indexOptions, nullValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,8 +120,8 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
private Boolean nullValue;
|
||||
|
||||
protected BooleanFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, Boolean nullValue) {
|
||||
super(names, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions, Boolean nullValue) {
|
||||
super(names, index, store, termVector, boost, omitNorms, indexOptions, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
|
@ -210,8 +207,8 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.NumericRangeFilter;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
@ -36,6 +37,7 @@ import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
|
|||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.search.NumericRangeFieldDataFilter;
|
||||
|
||||
|
@ -74,8 +76,7 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
@Override
|
||||
public ByteFieldMapper build(BuilderContext context) {
|
||||
ByteFieldMapper fieldMapper = new ByteFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms,
|
||||
omitTermFreqAndPositions, nullValue, ignoreMalformed);
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions, nullValue, ignoreMalformed);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -102,9 +103,9 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
private String nullValueAsString;
|
||||
|
||||
protected ByteFieldMapper(Names names, int precisionStep, String fuzzyFactor, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
Byte nullValue, boolean ignoreMalformed) {
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions,
|
||||
ignoreMalformed, new NamedAnalyzer("_byte/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_byte/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
|
||||
this.nullValue = nullValue;
|
||||
|
@ -323,8 +324,8 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.NumericRangeFilter;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
@ -40,6 +41,7 @@ import org.elasticsearch.index.analysis.NumericDateAnalyzer;
|
|||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.search.NumericRangeFieldDataFilter;
|
||||
|
||||
|
@ -102,7 +104,7 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
parseUpperInclusive = context.indexSettings().getAsBoolean("index.mapping.date.parse_upper_inclusive", Defaults.PARSE_UPPER_INCLUSIVE);
|
||||
}
|
||||
DateFieldMapper fieldMapper = new DateFieldMapper(buildNames(context), dateTimeFormatter,
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue,
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions, nullValue,
|
||||
timeUnit, parseUpperInclusive, ignoreMalformed);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
|
@ -141,9 +143,9 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
protected DateFieldMapper(Names names, FormatDateTimeFormatter dateTimeFormatter, int precisionStep, String fuzzyFactor,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
String nullValue, TimeUnit timeUnit, boolean parseUpperInclusive, boolean ignoreMalformed) {
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions,
|
||||
ignoreMalformed, new NamedAnalyzer("_date/" + precisionStep,
|
||||
new NumericDateAnalyzer(precisionStep, dateTimeFormatter.parser())),
|
||||
new NamedAnalyzer("_date/max", new NumericDateAnalyzer(Integer.MAX_VALUE, dateTimeFormatter.parser())));
|
||||
|
@ -395,8 +397,8 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.NumericRangeFilter;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
@ -36,6 +37,7 @@ import org.elasticsearch.index.analysis.NumericDoubleAnalyzer;
|
|||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.search.NumericRangeFieldDataFilter;
|
||||
|
||||
|
@ -74,7 +76,7 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
@Override
|
||||
public DoubleFieldMapper build(BuilderContext context) {
|
||||
DoubleFieldMapper fieldMapper = new DoubleFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue,
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions, nullValue,
|
||||
ignoreMalformed);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
|
@ -104,9 +106,9 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
|
||||
protected DoubleFieldMapper(Names names, int precisionStep, String fuzzyFactor,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
Double nullValue, boolean ignoreMalformed) {
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions,
|
||||
ignoreMalformed, new NamedAnalyzer("_double/" + precisionStep, new NumericDoubleAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_double/max", new NumericDoubleAnalyzer(Integer.MAX_VALUE)));
|
||||
this.nullValue = nullValue;
|
||||
|
@ -325,8 +327,8 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.NumericRangeFilter;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
@ -37,6 +38,7 @@ import org.elasticsearch.index.analysis.NumericFloatAnalyzer;
|
|||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.search.NumericRangeFieldDataFilter;
|
||||
|
||||
|
@ -75,7 +77,7 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
@Override
|
||||
public FloatFieldMapper build(BuilderContext context) {
|
||||
FloatFieldMapper fieldMapper = new FloatFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue,
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions, nullValue,
|
||||
ignoreMalformed);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
|
@ -103,9 +105,9 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
private String nullValueAsString;
|
||||
|
||||
protected FloatFieldMapper(Names names, int precisionStep, String fuzzyFactor, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
Float nullValue, boolean ignoreMalformed) {
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions,
|
||||
ignoreMalformed, new NamedAnalyzer("_float/" + precisionStep, new NumericFloatAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_float/max", new NumericFloatAnalyzer(Integer.MAX_VALUE)));
|
||||
this.nullValue = nullValue;
|
||||
|
@ -321,8 +323,8 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.NumericRangeFilter;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
@ -37,6 +38,7 @@ import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
|
|||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.search.NumericRangeFieldDataFilter;
|
||||
|
||||
|
@ -75,7 +77,7 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
@Override
|
||||
public IntegerFieldMapper build(BuilderContext context) {
|
||||
IntegerFieldMapper fieldMapper = new IntegerFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions,
|
||||
nullValue, ignoreMalformed);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
|
@ -103,9 +105,9 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
private String nullValueAsString;
|
||||
|
||||
protected IntegerFieldMapper(Names names, int precisionStep, String fuzzyFactor, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
Integer nullValue, boolean ignoreMalformed) {
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions,
|
||||
ignoreMalformed, new NamedAnalyzer("_int/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_int/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
|
||||
this.nullValue = nullValue;
|
||||
|
@ -325,8 +327,8 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.NumericRangeFilter;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
@ -37,6 +38,7 @@ import org.elasticsearch.index.analysis.NumericLongAnalyzer;
|
|||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.search.NumericRangeFieldDataFilter;
|
||||
|
||||
|
@ -75,7 +77,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
@Override
|
||||
public LongFieldMapper build(BuilderContext context) {
|
||||
LongFieldMapper fieldMapper = new LongFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue,
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions, nullValue,
|
||||
ignoreMalformed);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
|
@ -103,9 +105,9 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
private String nullValueAsString;
|
||||
|
||||
protected LongFieldMapper(Names names, int precisionStep, String fuzzyFactor, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
Long nullValue, boolean ignoreMalformed) {
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions,
|
||||
ignoreMalformed, new NamedAnalyzer("_long/" + precisionStep, new NumericLongAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_long/max", new NumericLongAnalyzer(Integer.MAX_VALUE)));
|
||||
this.nullValue = nullValue;
|
||||
|
@ -324,8 +326,8 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.lucene.document.AbstractField;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
|
@ -48,7 +49,7 @@ public abstract class NumberFieldMapper<T extends Number> extends AbstractFieldM
|
|||
public static final int PRECISION_STEP = NumericUtils.PRECISION_STEP_DEFAULT;
|
||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
public static final IndexOptions INDEX_OPTIONS = IndexOptions.DOCS_ONLY;
|
||||
public static final String FUZZY_FACTOR = null;
|
||||
public static final boolean IGNORE_MALFORMED = false;
|
||||
}
|
||||
|
@ -65,7 +66,7 @@ public abstract class NumberFieldMapper<T extends Number> extends AbstractFieldM
|
|||
super(name);
|
||||
this.index = Defaults.INDEX;
|
||||
this.omitNorms = Defaults.OMIT_NORMS;
|
||||
this.omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS;
|
||||
this.indexOptions = Defaults.INDEX_OPTIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,9 +125,9 @@ public abstract class NumberFieldMapper<T extends Number> extends AbstractFieldM
|
|||
|
||||
protected NumberFieldMapper(Names names, int precisionStep, @Nullable String fuzzyFactor,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
boolean ignoreMalformed, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
super(names, index, store, Field.TermVector.NO, boost, boost != 1.0f || omitNorms, omitTermFreqAndPositions, indexAnalyzer, searchAnalyzer);
|
||||
super(names, index, store, Field.TermVector.NO, boost, boost != 1.0f || omitNorms, indexOptions, indexAnalyzer, searchAnalyzer);
|
||||
if (precisionStep <= 0 || precisionStep >= maxPrecisionStep()) {
|
||||
this.precisionStep = Integer.MAX_VALUE;
|
||||
} else {
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.NumericRangeFilter;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
@ -37,6 +38,7 @@ import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
|
|||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.search.NumericRangeFieldDataFilter;
|
||||
|
||||
|
@ -75,7 +77,7 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
@Override
|
||||
public ShortFieldMapper build(BuilderContext context) {
|
||||
ShortFieldMapper fieldMapper = new ShortFieldMapper(buildNames(context),
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue,
|
||||
precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions, nullValue,
|
||||
ignoreMalformed);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
|
@ -103,9 +105,9 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
private String nullValueAsString;
|
||||
|
||||
protected ShortFieldMapper(Names names, int precisionStep, String fuzzyFactor, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
Short nullValue, boolean ignoreMalformed) {
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(names, precisionStep, fuzzyFactor, index, store, boost, omitNorms, indexOptions,
|
||||
ignoreMalformed, new NamedAnalyzer("_short/" + precisionStep, new NumericIntegerAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_short/max", new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
|
||||
this.nullValue = nullValue;
|
||||
|
@ -324,8 +326,8 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.core;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -30,6 +31,7 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
|||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NamedCustomAnalyzer;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -110,7 +112,7 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
searchQuotedAnalyzer = new NamedCustomAnalyzer(searchQuotedAnalyzer, positionOffsetGap);
|
||||
}
|
||||
StringFieldMapper fieldMapper = new StringFieldMapper(buildNames(context),
|
||||
index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue,
|
||||
index, store, termVector, boost, omitNorms, indexOptions, nullValue,
|
||||
indexAnalyzer, searchAnalyzer, searchQuotedAnalyzer, positionOffsetGap, ignoreAbove);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
|
@ -165,17 +167,17 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
private int ignoreAbove;
|
||||
|
||||
protected StringFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
this(names, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue, indexAnalyzer,
|
||||
this(names, index, store, termVector, boost, omitNorms, indexOptions, nullValue, indexAnalyzer,
|
||||
searchAnalyzer, searchAnalyzer, Defaults.POSITION_OFFSET_GAP, Defaults.IGNORE_ABOVE);
|
||||
}
|
||||
|
||||
protected StringFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer,
|
||||
NamedAnalyzer searchQuotedAnalyzer, int positionOffsetGap, int ignoreAbove) {
|
||||
super(names, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, indexAnalyzer, searchAnalyzer);
|
||||
super(names, index, store, termVector, boost, omitNorms, indexOptions, indexAnalyzer, searchAnalyzer);
|
||||
this.nullValue = nullValue;
|
||||
this.positionOffsetGap = positionOffsetGap;
|
||||
this.searchQuotedAnalyzer = searchQuotedAnalyzer != null ? searchQuotedAnalyzer : this.searchAnalyzer;
|
||||
|
@ -317,8 +319,8 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
package org.elasticsearch.index.mapper.core;
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Field.Index;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.elasticsearch.ElasticSearchParseException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
||||
import org.elasticsearch.common.joda.Joda;
|
||||
|
@ -36,6 +39,10 @@ import static org.elasticsearch.common.xcontent.support.XContentMapValues.*;
|
|||
*
|
||||
*/
|
||||
public class TypeParsers {
|
||||
|
||||
public static final String INDEX_OPTIONS_DOCS = "docs";
|
||||
public static final String INDEX_OPTIONS_FREQS = "freqs";
|
||||
public static final String INDEX_OPTIONS_POSITIONS = "positions";
|
||||
|
||||
public static void parseNumberField(NumberFieldMapper.Builder builder, String name, Map<String, Object> numberNode, Mapper.TypeParser.ParserContext parserContext) {
|
||||
parseField(builder, name, numberNode, parserContext);
|
||||
|
@ -69,7 +76,10 @@ public class TypeParsers {
|
|||
} else if (propName.equals("omit_norms")) {
|
||||
builder.omitNorms(nodeBooleanValue(propNode));
|
||||
} else if (propName.equals("omit_term_freq_and_positions")) {
|
||||
builder.omitTermFreqAndPositions(nodeBooleanValue(propNode));
|
||||
// deprecated option for BW compat
|
||||
builder.indexOptions(nodeBooleanValue(propNode) ? IndexOptions.DOCS_ONLY : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
|
||||
} else if (propName.equals("index_options")) {
|
||||
builder.indexOptions(nodeIndexOptionValue(propNode));
|
||||
} else if (propName.equals("analyzer")) {
|
||||
NamedAnalyzer analyzer = parserContext.analysisService().analyzer(propNode.toString());
|
||||
if (analyzer == null) {
|
||||
|
@ -95,6 +105,19 @@ public class TypeParsers {
|
|||
}
|
||||
}
|
||||
|
||||
private static IndexOptions nodeIndexOptionValue(final Object propNode) {
|
||||
final String value = propNode.toString();
|
||||
if (INDEX_OPTIONS_POSITIONS.equalsIgnoreCase(value)) {
|
||||
return IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
|
||||
} else if (INDEX_OPTIONS_FREQS.equalsIgnoreCase(value)) {
|
||||
return IndexOptions.DOCS_AND_FREQS;
|
||||
} else if (INDEX_OPTIONS_DOCS.equalsIgnoreCase(value)) {
|
||||
return IndexOptions.DOCS_ONLY;
|
||||
} else {
|
||||
throw new ElasticSearchParseException("Failed to parse index option [" + value + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public static FormatDateTimeFormatter parseDateTimeFormatter(String fieldName, Object node) {
|
||||
return Joda.forPattern(node.toString());
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.index.mapper.geo;
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -142,7 +143,7 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
context.path().pathType(pathType);
|
||||
|
||||
GeoStringFieldMapper geoStringMapper = new GeoStringFieldMapper.Builder(name)
|
||||
.index(Field.Index.NOT_ANALYZED).omitNorms(true).omitTermFreqAndPositions(true).includeInAll(false).store(store).build(context);
|
||||
.index(Field.Index.NOT_ANALYZED).omitNorms(true).indexOptions(IndexOptions.DOCS_ONLY).includeInAll(false).store(store).build(context);
|
||||
|
||||
|
||||
DoubleFieldMapper latMapper = null;
|
||||
|
@ -161,7 +162,7 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
}
|
||||
StringFieldMapper geohashMapper = null;
|
||||
if (enableGeoHash) {
|
||||
geohashMapper = stringField(Names.GEOHASH).index(Field.Index.NOT_ANALYZED).includeInAll(false).omitNorms(true).omitTermFreqAndPositions(true).build(context);
|
||||
geohashMapper = stringField(Names.GEOHASH).index(Field.Index.NOT_ANALYZED).includeInAll(false).omitNorms(true).indexOptions(IndexOptions.DOCS_ONLY).build(context);
|
||||
}
|
||||
context.path().remove();
|
||||
|
||||
|
@ -551,7 +552,7 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
@Override
|
||||
public GeoStringFieldMapper build(BuilderContext context) {
|
||||
GeoStringFieldMapper fieldMapper = new GeoStringFieldMapper(buildNames(context),
|
||||
index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue,
|
||||
index, store, termVector, boost, omitNorms, indexOptions, nullValue,
|
||||
indexAnalyzer, searchAnalyzer);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
|
@ -560,8 +561,8 @@ public class GeoPointFieldMapper implements Mapper, ArrayValueMapperParser {
|
|||
|
||||
GeoPointFieldMapper geoMapper;
|
||||
|
||||
public GeoStringFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector, float boost, boolean omitNorms, boolean omitTermFreqAndPositions, String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
super(names, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, nullValue, indexAnalyzer, searchAnalyzer);
|
||||
public GeoStringFieldMapper(Names names, Field.Index index, Field.Store store, Field.TermVector termVector, float boost, boolean omitNorms, IndexOptions indexOptions, String nullValue, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer) {
|
||||
super(names, index, store, termVector, boost, omitNorms, indexOptions, nullValue, indexAnalyzer, searchAnalyzer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.internal;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -100,7 +101,7 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
|
||||
@Override
|
||||
public AllFieldMapper build(BuilderContext context) {
|
||||
return new AllFieldMapper(name, store, termVector, omitNorms, omitTermFreqAndPositions,
|
||||
return new AllFieldMapper(name, store, termVector, omitNorms, indexOptions,
|
||||
indexAnalyzer, searchAnalyzer, enabled);
|
||||
}
|
||||
}
|
||||
|
@ -125,13 +126,13 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements Interna
|
|||
private boolean enabled;
|
||||
|
||||
public AllFieldMapper() {
|
||||
this(Defaults.NAME, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, null, null, Defaults.ENABLED);
|
||||
this(Defaults.NAME, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, null, null, Defaults.ENABLED);
|
||||
}
|
||||
|
||||
protected AllFieldMapper(String name, Field.Store store, Field.TermVector termVector, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
protected AllFieldMapper(String name, Field.Store store, Field.TermVector termVector, boolean omitNorms, IndexOptions indexOptions,
|
||||
NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer, boolean enabled) {
|
||||
super(new Names(name, name, name, name), Field.Index.ANALYZED, store, termVector, 1.0f, omitNorms, omitTermFreqAndPositions,
|
||||
indexAnalyzer, searchAnalyzer);
|
||||
super(new Names(name, name, name, name), Field.Index.ANALYZED, store, termVector, 1.0f, omitNorms, indexOptions, indexAnalyzer,
|
||||
searchAnalyzer);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper.internal;
|
|||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.NumericRangeFilter;
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
|
@ -81,7 +82,7 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements Intern
|
|||
@Override
|
||||
public BoostFieldMapper build(BuilderContext context) {
|
||||
return new BoostFieldMapper(name, buildIndexName(context),
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
precisionStep, index, store, boost, omitNorms, indexOptions, nullValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,13 +111,13 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements Intern
|
|||
|
||||
protected BoostFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.PRECISION_STEP, Defaults.INDEX, Defaults.STORE,
|
||||
Defaults.BOOST, Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Defaults.NULL_VALUE);
|
||||
Defaults.BOOST, Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, Defaults.NULL_VALUE);
|
||||
}
|
||||
|
||||
protected BoostFieldMapper(String name, String indexName, int precisionStep, Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
Float nullValue) {
|
||||
super(new Names(name, indexName, indexName, name), precisionStep, null, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(new Names(name, indexName, indexName, name), precisionStep, null, index, store, boost, omitNorms, indexOptions,
|
||||
false, new NamedAnalyzer("_float/" + precisionStep, new NumericFloatAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_float/max", new NumericFloatAnalyzer(Integer.MAX_VALUE)));
|
||||
this.nullValue = nullValue;
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.google.common.collect.Iterables;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -58,7 +59,7 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
public static final Field.Index INDEX = Field.Index.NO;
|
||||
public static final Field.Store STORE = Field.Store.NO;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
public static final IndexOptions INDEX_OPTIONS = IndexOptions.DOCS_ONLY;
|
||||
public static final String PATH = null;
|
||||
}
|
||||
|
||||
|
@ -72,7 +73,7 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
store = Defaults.STORE;
|
||||
index = Defaults.INDEX;
|
||||
omitNorms = Defaults.OMIT_NORMS;
|
||||
omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS;
|
||||
indexOptions = Defaults.INDEX_OPTIONS;
|
||||
}
|
||||
|
||||
public Builder path(String path) {
|
||||
|
@ -82,7 +83,7 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
|
||||
@Override
|
||||
public IdFieldMapper build(BuilderContext context) {
|
||||
return new IdFieldMapper(name, indexName, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions, path);
|
||||
return new IdFieldMapper(name, indexName, index, store, termVector, boost, omitNorms, indexOptions, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,13 +115,13 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements Intern
|
|||
|
||||
protected IdFieldMapper(String name, String indexName, Field.Index index) {
|
||||
this(name, indexName, index, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Defaults.PATH);
|
||||
Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, Defaults.PATH);
|
||||
}
|
||||
|
||||
protected IdFieldMapper(String name, String indexName, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, String path) {
|
||||
super(new Names(name, indexName, indexName, name), index, store, termVector, boost, omitNorms, omitTermFreqAndPositions,
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions, String path) {
|
||||
super(new Names(name, indexName, indexName, name), index, store, termVector, boost, omitNorms, indexOptions, Lucene.KEYWORD_ANALYZER,
|
||||
Lucene.KEYWORD_ANALYZER);
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.lucene.document.Document;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -50,7 +51,7 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final Field.Store STORE = Field.Store.NO;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
public static final IndexOptions INDEX_OPTIONS = IndexOptions.DOCS_ONLY;
|
||||
public static final boolean ENABLED = false;
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,7 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
index = Defaults.INDEX;
|
||||
store = Defaults.STORE;
|
||||
omitNorms = Defaults.OMIT_NORMS;
|
||||
omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS;
|
||||
indexOptions = Defaults.INDEX_OPTIONS;
|
||||
}
|
||||
|
||||
public Builder enabled(boolean enabled) {
|
||||
|
@ -74,7 +75,7 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
|
||||
@Override
|
||||
public IndexFieldMapper build(BuilderContext context) {
|
||||
return new IndexFieldMapper(name, indexName, store, termVector, boost, omitNorms, omitTermFreqAndPositions, enabled);
|
||||
return new IndexFieldMapper(name, indexName, store, termVector, boost, omitNorms, indexOptions, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,13 +104,13 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements Int
|
|||
|
||||
protected IndexFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Defaults.ENABLED);
|
||||
Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, Defaults.ENABLED);
|
||||
}
|
||||
|
||||
public IndexFieldMapper(String name, String indexName, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions, boolean enabled) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.INDEX, store, termVector, boost, omitNorms, omitTermFreqAndPositions,
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions, boolean enabled) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.INDEX, store, termVector, boost, omitNorms, indexOptions, Lucene.KEYWORD_ANALYZER,
|
||||
Lucene.KEYWORD_ANALYZER);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper.internal;
|
|||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.ConstantScoreQuery;
|
||||
import org.apache.lucene.search.Filter;
|
||||
|
@ -50,7 +51,7 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
public static final String NAME = ParentFieldMapper.NAME;
|
||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
public static final IndexOptions INDEX_OPTIONS = IndexOptions.DOCS_ONLY;
|
||||
}
|
||||
|
||||
public static class Builder extends Mapper.Builder<Builder, ParentFieldMapper> {
|
||||
|
@ -97,7 +98,7 @@ public class ParentFieldMapper extends AbstractFieldMapper<Uid> implements Inter
|
|||
|
||||
protected ParentFieldMapper(String name, String indexName, String type) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.INDEX, Field.Store.YES, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.internal;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -49,7 +50,7 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final Field.Store STORE = Field.Store.YES;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
public static final IndexOptions INDEX_OPTIONS = IndexOptions.DOCS_ONLY;
|
||||
public static final boolean REQUIRED = false;
|
||||
public static final String PATH = null;
|
||||
}
|
||||
|
@ -110,8 +111,8 @@ public class RoutingFieldMapper extends AbstractFieldMapper<String> implements I
|
|||
}
|
||||
|
||||
protected RoutingFieldMapper(Field.Store store, Field.Index index, boolean required, String path) {
|
||||
super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), index, store, Defaults.TERM_VECTOR, 1.0f, Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS,
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), index, store, Defaults.TERM_VECTOR, 1.0f, Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, Lucene.KEYWORD_ANALYZER,
|
||||
Lucene.KEYWORD_ANALYZER);
|
||||
this.required = required;
|
||||
this.path = path;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class SizeFieldMapper extends IntegerFieldMapper implements RootMapper {
|
|||
|
||||
public SizeFieldMapper(boolean enabled, Field.Store store) {
|
||||
super(new Names(Defaults.NAME), Defaults.PRECISION_STEP, Defaults.FUZZY_FACTOR, Defaults.INDEX, store,
|
||||
Defaults.BOOST, Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Defaults.NULL_VALUE,
|
||||
Defaults.BOOST, Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, Defaults.NULL_VALUE,
|
||||
Defaults.IGNORE_MALFORMED);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.google.common.base.Objects;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.elasticsearch.ElasticSearchParseException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
|
@ -69,7 +70,7 @@ public class SourceFieldMapper extends AbstractFieldMapper<byte[]> implements In
|
|||
public static final Field.Index INDEX = Field.Index.NO;
|
||||
public static final Field.Store STORE = Field.Store.YES;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
public static final IndexOptions INDEX_OPTIONS = IndexOptions.DOCS_ONLY;
|
||||
public static final String[] INCLUDES = Strings.EMPTY_ARRAY;
|
||||
public static final String[] EXCLUDES = Strings.EMPTY_ARRAY;
|
||||
}
|
||||
|
@ -190,7 +191,7 @@ public class SourceFieldMapper extends AbstractFieldMapper<byte[]> implements In
|
|||
|
||||
protected SourceFieldMapper(String name, boolean enabled, String format, Boolean compress, long compressThreshold, String[] includes, String[] excludes) {
|
||||
super(new Names(name, name, name, name), Defaults.INDEX, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
this.enabled = enabled;
|
||||
this.compress = compress;
|
||||
this.compressThreshold = compressThreshold;
|
||||
|
|
|
@ -109,8 +109,8 @@ public class TTLFieldMapper extends LongFieldMapper implements InternalMapper, R
|
|||
|
||||
protected TTLFieldMapper(Field.Store store, Field.Index index, boolean enabled, long defaultTTL) {
|
||||
super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), Defaults.PRECISION_STEP,
|
||||
Defaults.FUZZY_FACTOR, index, store, Defaults.BOOST, Defaults.OMIT_NORMS,
|
||||
Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Defaults.NULL_VALUE, Defaults.IGNORE_MALFORMED);
|
||||
Defaults.FUZZY_FACTOR, index, store, Defaults.BOOST, Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS,
|
||||
Defaults.NULL_VALUE, Defaults.IGNORE_MALFORMED);
|
||||
this.enabled = enabled;
|
||||
this.defaultTTL = defaultTTL;
|
||||
}
|
||||
|
|
|
@ -124,8 +124,8 @@ public class TimestampFieldMapper extends DateFieldMapper implements InternalMap
|
|||
|
||||
protected TimestampFieldMapper(Field.Store store, Field.Index index, boolean enabled, String path, FormatDateTimeFormatter dateTimeFormatter, boolean parseUpperInclusive) {
|
||||
super(new Names(Defaults.NAME, Defaults.NAME, Defaults.NAME, Defaults.NAME), dateTimeFormatter,
|
||||
Defaults.PRECISION_STEP, Defaults.FUZZY_FACTOR, index, store, Defaults.BOOST, Defaults.OMIT_NORMS,
|
||||
Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Defaults.NULL_VALUE, TimeUnit.MILLISECONDS /*always milliseconds*/,
|
||||
Defaults.PRECISION_STEP, Defaults.FUZZY_FACTOR, index, store, Defaults.BOOST, Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS,
|
||||
Defaults.NULL_VALUE, TimeUnit.MILLISECONDS /*always milliseconds*/,
|
||||
parseUpperInclusive, Defaults.IGNORE_MALFORMED);
|
||||
this.enabled = enabled;
|
||||
this.path = path;
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.internal;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.DeletionAwareConstantScoreQuery;
|
||||
import org.apache.lucene.search.Filter;
|
||||
|
@ -58,7 +59,7 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final Field.Store STORE = Field.Store.NO;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = true;
|
||||
public static final IndexOptions INDEX_OPTIONS = IndexOptions.DOCS_ONLY;
|
||||
}
|
||||
|
||||
public static class Builder extends AbstractFieldMapper.Builder<Builder, TypeFieldMapper> {
|
||||
|
@ -69,12 +70,12 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
index = Defaults.INDEX;
|
||||
store = Defaults.STORE;
|
||||
omitNorms = Defaults.OMIT_NORMS;
|
||||
omitTermFreqAndPositions = Defaults.OMIT_TERM_FREQ_AND_POSITIONS;
|
||||
indexOptions = Defaults.INDEX_OPTIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeFieldMapper build(BuilderContext context) {
|
||||
return new TypeFieldMapper(name, indexName, index, store, termVector, boost, omitNorms, omitTermFreqAndPositions);
|
||||
return new TypeFieldMapper(name, indexName, index, store, termVector, boost, omitNorms, indexOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,13 +95,13 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements Inte
|
|||
|
||||
protected TypeFieldMapper(String name, String indexName) {
|
||||
this(name, indexName, Defaults.INDEX, Defaults.STORE, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS);
|
||||
Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS);
|
||||
}
|
||||
|
||||
public TypeFieldMapper(String name, String indexName, Field.Index index, Field.Store store, Field.TermVector termVector,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
|
||||
super(new Names(name, indexName, indexName, name), index, store, termVector, boost, omitNorms, omitTermFreqAndPositions,
|
||||
Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions) {
|
||||
super(new Names(name, indexName, indexName, name), index, store, termVector, boost, omitNorms, indexOptions, Lucene.KEYWORD_ANALYZER,
|
||||
Lucene.KEYWORD_ANALYZER);
|
||||
}
|
||||
|
||||
public String value(Document document) {
|
||||
|
|
|
@ -48,7 +48,6 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
|||
public static final String NAME = UidFieldMapper.NAME;
|
||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||
public static final boolean OMIT_NORMS = true;
|
||||
public static final boolean OMIT_TERM_FREQ_AND_POSITIONS = false; // we store payload
|
||||
}
|
||||
|
||||
public static class Builder extends Mapper.Builder<Builder, UidFieldMapper> {
|
||||
|
@ -90,7 +89,7 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
|||
|
||||
protected UidFieldMapper(String name, String indexName) {
|
||||
super(new Names(name, indexName, indexName, name), Defaults.INDEX, Field.Store.YES, Defaults.TERM_VECTOR, Defaults.BOOST,
|
||||
Defaults.OMIT_NORMS, Defaults.OMIT_TERM_FREQ_AND_POSITIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
Defaults.OMIT_NORMS, Defaults.INDEX_OPTIONS, Lucene.KEYWORD_ANALYZER, Lucene.KEYWORD_ANALYZER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.ip;
|
|||
import org.apache.lucene.analysis.NumericTokenStream;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
|
@ -38,6 +39,7 @@ import org.elasticsearch.index.field.data.FieldDataType;
|
|||
import org.elasticsearch.index.mapper.*;
|
||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.BooleanFieldMapper.Defaults;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.search.NumericRangeFieldDataFilter;
|
||||
|
||||
|
@ -103,7 +105,7 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
@Override
|
||||
public IpFieldMapper build(BuilderContext context) {
|
||||
IpFieldMapper fieldMapper = new IpFieldMapper(buildNames(context),
|
||||
precisionStep, index, store, boost, omitNorms, omitTermFreqAndPositions, nullValue);
|
||||
precisionStep, index, store, boost, omitNorms, indexOptions, nullValue);
|
||||
fieldMapper.includeInAll(includeInAll);
|
||||
return fieldMapper;
|
||||
}
|
||||
|
@ -129,9 +131,9 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
protected IpFieldMapper(Names names, int precisionStep,
|
||||
Field.Index index, Field.Store store,
|
||||
float boost, boolean omitNorms, boolean omitTermFreqAndPositions,
|
||||
float boost, boolean omitNorms, IndexOptions indexOptions,
|
||||
String nullValue) {
|
||||
super(names, precisionStep, null, index, store, boost, omitNorms, omitTermFreqAndPositions,
|
||||
super(names, precisionStep, null, index, store, boost, omitNorms, indexOptions,
|
||||
false, new NamedAnalyzer("_ip/" + precisionStep, new NumericIpAnalyzer(precisionStep)),
|
||||
new NamedAnalyzer("_ip/max", new NumericIpAnalyzer(Integer.MAX_VALUE)));
|
||||
this.nullValue = nullValue;
|
||||
|
@ -301,8 +303,8 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
if (indexOptions != Defaults.INDEX_OPTIONS) {
|
||||
builder.field("index_options", indexOptionToString(indexOptions));
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.test.integration.search.query;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
@ -33,6 +34,8 @@ import org.testng.annotations.BeforeClass;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.FilterBuilders.*;
|
||||
|
@ -81,6 +84,49 @@ public class SimpleQueryTests extends AbstractNodesTests {
|
|||
SearchResponse searchResponse = client.prepareSearch().setQuery("{ \"term\" : { \"field1\" : \"value1_1\" }}").execute().actionGet();
|
||||
assertThat(searchResponse.hits().totalHits(), equalTo(1l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexOptions() throws Exception {
|
||||
try {
|
||||
client.admin().indices().prepareDelete("test").execute().actionGet();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
client.admin().indices().prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1").field("index_options", "docs").field("type", "string").endObject().endObject().endObject().endObject())
|
||||
.setSettings(ImmutableSettings.settingsBuilder().put("number_of_shards", 1)).execute().actionGet();
|
||||
|
||||
client.prepareIndex("test", "type1", "1").setSource("field1", "quick brown fox", "field2", "quick brown fox").execute().actionGet();
|
||||
client.prepareIndex("test", "type1", "2").setSource("field1", "quick lazy huge brown fox", "field2", "quick lazy huge brown fox").setRefresh(true).execute().actionGet();
|
||||
|
||||
SearchResponse searchResponse = client.prepareSearch().setQuery("{ \"text_phrase\" : { \"field2\" : \"quick brown\", \"slop\" : \"2\" }}").execute().actionGet();
|
||||
assertThat(searchResponse.hits().totalHits(), equalTo(1l));
|
||||
SearchResponse actionGet = client.prepareSearch().setQuery("{ \"text_phrase\" : { \"field1\" : \"quick brown\", \"slop\" : \"2\" }}").execute().actionGet();
|
||||
assertThat(actionGet.hits().totalHits(), equalTo(0l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOmitTermFreqsAndPositions() throws Exception {
|
||||
// backwards compat test!
|
||||
try {
|
||||
client.admin().indices().prepareDelete("test").execute().actionGet();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
client.admin().indices().prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1").field("omit_term_freq_and_positions", true).field("type", "string").endObject().endObject().endObject().endObject())
|
||||
.setSettings(ImmutableSettings.settingsBuilder().put("number_of_shards", 1)).execute().actionGet();
|
||||
|
||||
client.prepareIndex("test", "type1", "1").setSource("field1", "quick brown fox", "field2", "quick brown fox").execute().actionGet();
|
||||
client.prepareIndex("test", "type1", "2").setSource("field1", "quick lazy huge brown fox", "field2", "quick lazy huge brown fox").setRefresh(true).execute().actionGet();
|
||||
|
||||
SearchResponse searchResponse = client.prepareSearch().setQuery("{ \"text_phrase\" : { \"field2\" : \"quick brown\", \"slop\" : \"2\" }}").execute().actionGet();
|
||||
assertThat(searchResponse.hits().totalHits(), equalTo(1l));
|
||||
SearchResponse actionGet = client.prepareSearch().setQuery("{ \"text_phrase\" : { \"field1\" : \"quick brown\", \"slop\" : \"2\" }}").execute().actionGet();
|
||||
assertThat(actionGet.hits().totalHits(), equalTo(0l));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryStringAnalyzedWildcard() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue