org.elasticsearch.index.mapper.xcontent
Class XContentNumberFieldMapper<T extends java.lang.Number>

java.lang.Object
  extended by org.elasticsearch.index.mapper.xcontent.XContentFieldMapper<T>
      extended by org.elasticsearch.index.mapper.xcontent.XContentNumberFieldMapper<T>
All Implemented Interfaces:
ToXContent, FieldMapper<T>, XContentIncludeInAllMapper, XContentMapper
Direct Known Subclasses:
XContentBoostFieldMapper, XContentDateFieldMapper, XContentDoubleFieldMapper, XContentFloatFieldMapper, XContentIntegerFieldMapper, XContentLongFieldMapper, XContentShortFieldMapper

public abstract class XContentNumberFieldMapper<T extends java.lang.Number>
extends XContentFieldMapper<T>
implements XContentIncludeInAllMapper


Nested Class Summary
static class XContentNumberFieldMapper.Builder<T extends XContentNumberFieldMapper.Builder,Y extends XContentNumberFieldMapper>
           
protected static class XContentNumberFieldMapper.CachedNumericTokenStream
          A wrapper around a numeric stream allowing to reuse it by implementing the end method which returns this stream back to the thread local cache.
static class XContentNumberFieldMapper.Defaults
           
 
Nested classes/interfaces inherited from class org.elasticsearch.index.mapper.xcontent.XContentFieldMapper
XContentFieldMapper.OpenBuilder<T extends XContentFieldMapper.Builder,Y extends XContentFieldMapper>
 
Nested classes/interfaces inherited from interface org.elasticsearch.index.mapper.xcontent.XContentMapper
XContentMapper.BuilderContext
 
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.MapParams, ToXContent.Params
 
Nested classes/interfaces inherited from interface org.elasticsearch.index.mapper.FieldMapper
FieldMapper.Names
 
Field Summary
protected  java.lang.Boolean includeInAll
           
protected  int precisionStep
           
 
Fields inherited from class org.elasticsearch.index.mapper.xcontent.XContentFieldMapper
boost, index, indexAnalyzer, names, omitNorms, omitTermFreqAndPositions, searchAnalyzer, store, termVector
 
Fields inherited from interface org.elasticsearch.index.mapper.xcontent.XContentMapper
EMPTY_ARRAY
 
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
 
Constructor Summary
protected XContentNumberFieldMapper(FieldMapper.Names names, int precisionStep, org.apache.lucene.document.Field.Index index, org.apache.lucene.document.Field.Store store, float boost, boolean omitNorms, boolean omitTermFreqAndPositions, NamedAnalyzer indexAnalyzer, NamedAnalyzer searchAnalyzer)
           
 
Method Summary
protected  void doXContentBody(XContentBuilder builder)
           
abstract  FieldData.Type fieldDataType()
           
 org.apache.lucene.search.Filter fieldFilter(java.lang.String value)
          Numeric field level filter are basically range queries with same value and included.
 org.apache.lucene.search.Query fieldQuery(java.lang.String value)
          Numeric field level query are basically range queries with same value and included.
 void includeInAll(java.lang.Boolean includeInAll)
           
protected abstract  int maxPrecisionStep()
           
 void merge(XContentMapper mergeWith, MergeContext mergeContext)
           
protected  XContentNumberFieldMapper.CachedNumericTokenStream popCachedStream(int precisionStep)
          Removes a cached numeric token stream.
 int precisionStep()
           
abstract  org.apache.lucene.search.Filter rangeFilter(java.lang.String lowerTerm, java.lang.String upperTerm, boolean includeLower, boolean includeUpper)
          Constructs a range query filter based on the mapper.
abstract  org.apache.lucene.search.Query rangeQuery(java.lang.String lowerTerm, java.lang.String upperTerm, boolean includeLower, boolean includeUpper)
          Constructs a range query based on the mapper.
 boolean useFieldQueryWithQueryString()
          Use the field query created here when matching on numbers.
 java.lang.String valueAsString(org.apache.lucene.document.Fieldable field)
          Returns the actual value of the field as string.
 java.lang.Object valueForSearch(org.apache.lucene.document.Fieldable field)
          Override the default behavior (to return the string, and return the actual Number instance).
abstract  java.lang.Object valueFromTerm(java.lang.String term)
          Simply returns the same string.
 
Methods inherited from class org.elasticsearch.index.mapper.xcontent.XContentFieldMapper
analyzed, boost, contentType, index, indexAnalyzer, indexed, indexedValue, name, names, omitNorms, omitTermFreqAndPositions, parse, parseCreateField, queryStringTermQuery, searchAnalyzer, store, stored, termVector, toXContent, traverse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.elasticsearch.index.mapper.xcontent.XContentMapper
name, parse, traverse
 
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
toXContent
 
Methods inherited from interface org.elasticsearch.index.mapper.FieldMapper
value
 

Field Detail

precisionStep

protected int precisionStep

includeInAll

protected java.lang.Boolean includeInAll
Constructor Detail

XContentNumberFieldMapper

protected XContentNumberFieldMapper(FieldMapper.Names names,
                                    int precisionStep,
                                    org.apache.lucene.document.Field.Index index,
                                    org.apache.lucene.document.Field.Store store,
                                    float boost,
                                    boolean omitNorms,
                                    boolean omitTermFreqAndPositions,
                                    NamedAnalyzer indexAnalyzer,
                                    NamedAnalyzer searchAnalyzer)
Method Detail

includeInAll

public void includeInAll(java.lang.Boolean includeInAll)
Specified by:
includeInAll in interface XContentIncludeInAllMapper

maxPrecisionStep

protected abstract int maxPrecisionStep()

precisionStep

public int precisionStep()

useFieldQueryWithQueryString

public boolean useFieldQueryWithQueryString()
Use the field query created here when matching on numbers.

Specified by:
useFieldQueryWithQueryString in interface FieldMapper<T extends java.lang.Number>
Overrides:
useFieldQueryWithQueryString in class XContentFieldMapper<T extends java.lang.Number>

fieldQuery

public org.apache.lucene.search.Query fieldQuery(java.lang.String value)
Numeric field level query are basically range queries with same value and included. That's the recommended way to execute it.

Specified by:
fieldQuery in interface FieldMapper<T extends java.lang.Number>
Overrides:
fieldQuery in class XContentFieldMapper<T extends java.lang.Number>

fieldFilter

public org.apache.lucene.search.Filter fieldFilter(java.lang.String value)
Numeric field level filter are basically range queries with same value and included. That's the recommended way to execute it.

Specified by:
fieldFilter in interface FieldMapper<T extends java.lang.Number>
Overrides:
fieldFilter in class XContentFieldMapper<T extends java.lang.Number>

rangeQuery

public abstract org.apache.lucene.search.Query rangeQuery(java.lang.String lowerTerm,
                                                          java.lang.String upperTerm,
                                                          boolean includeLower,
                                                          boolean includeUpper)
Description copied from interface: FieldMapper
Constructs a range query based on the mapper.

Specified by:
rangeQuery in interface FieldMapper<T extends java.lang.Number>
Overrides:
rangeQuery in class XContentFieldMapper<T extends java.lang.Number>

rangeFilter

public abstract org.apache.lucene.search.Filter rangeFilter(java.lang.String lowerTerm,
                                                            java.lang.String upperTerm,
                                                            boolean includeLower,
                                                            boolean includeUpper)
Description copied from interface: FieldMapper
Constructs a range query filter based on the mapper.

Specified by:
rangeFilter in interface FieldMapper<T extends java.lang.Number>
Overrides:
rangeFilter in class XContentFieldMapper<T extends java.lang.Number>

valueForSearch

public java.lang.Object valueForSearch(org.apache.lucene.document.Fieldable field)
Override the default behavior (to return the string, and return the actual Number instance).

Specified by:
valueForSearch in interface FieldMapper<T extends java.lang.Number>
Overrides:
valueForSearch in class XContentFieldMapper<T extends java.lang.Number>

valueAsString

public java.lang.String valueAsString(org.apache.lucene.document.Fieldable field)
Description copied from interface: FieldMapper
Returns the actual value of the field as string.

Specified by:
valueAsString in interface FieldMapper<T extends java.lang.Number>

valueFromTerm

public abstract java.lang.Object valueFromTerm(java.lang.String term)
Description copied from class: XContentFieldMapper
Simply returns the same string.

Specified by:
valueFromTerm in interface FieldMapper<T extends java.lang.Number>
Overrides:
valueFromTerm in class XContentFieldMapper<T extends java.lang.Number>

merge

public void merge(XContentMapper mergeWith,
                  MergeContext mergeContext)
           throws MergeMappingException
Specified by:
merge in interface XContentMapper
Overrides:
merge in class XContentFieldMapper<T extends java.lang.Number>
Throws:
MergeMappingException

doXContentBody

protected void doXContentBody(XContentBuilder builder)
                       throws java.io.IOException
Overrides:
doXContentBody in class XContentFieldMapper<T extends java.lang.Number>
Throws:
java.io.IOException

fieldDataType

public abstract FieldData.Type fieldDataType()
Specified by:
fieldDataType in interface FieldMapper<T extends java.lang.Number>
Overrides:
fieldDataType in class XContentFieldMapper<T extends java.lang.Number>

popCachedStream

protected XContentNumberFieldMapper.CachedNumericTokenStream popCachedStream(int precisionStep)
Removes a cached numeric token stream. The stream will be returned to the cahed once it is used sicne it implements the end method.