Save This Page
Home » lucene-3.0.1-src » org.apache » lucene » analysis » [javadoc | source]
public final class: NumericTokenStream [javadoc | source]

All Implemented Interfaces:

Expert: This class provides a TokenStream for indexing numeric values that can be used by NumericRangeQuery or NumericRangeFilter .

Note that for simple usage, NumericField is recommended. NumericField disables norms and term freqs, as they are not usually needed during searching. If you need to change these settings, you should use this class.

See NumericField for capabilities of fields indexed numerically.

Here's an example usage, for an int field:

 Field field = new Field(name, new NumericTokenStream(precisionStep).setIntValue(value));

For optimal performance, re-use the TokenStream and Field instance for more than one document:

 NumericTokenStream stream = new NumericTokenStream(precisionStep);
 Field field = new Field(name, stream);
 Document document = new Document();

 for(all documents) {

This stream is not intended to be used in analyzers; it's more for iterating the different precisions during indexing a specific numeric value.

NOTE: as token streams are only consumed once the document is added to the index, if you index more than one numeric field, use a separate NumericTokenStream instance for each.

See NumericRangeQuery for more details on the precisionStep parameter as well as how numeric fields work under the hood.

NOTE: This API is experimental and might change in incompatible ways in the next release.

Field Summary
public static final  String TOKEN_TYPE_FULL_PREC    The full precision token gets this token type assigned. 
public static final  String TOKEN_TYPE_LOWER_PREC    The lower precision tokens gets this token type assigned. 
 public NumericTokenStream() 
 public NumericTokenStream(int precisionStep) 
 public NumericTokenStream(AttributeSource source,
    int precisionStep) 
    Expert: Creates a token stream for numeric values with the specified precisionStep using the given AttributeSource . The stream is not yet initialized, before using set a value using the various set???Value() methods.
 public NumericTokenStream(AttributeFactory factory,
    int precisionStep) 
Method from org.apache.lucene.analysis.NumericTokenStream Summary:
incrementToken,   reset,   setDoubleValue,   setFloatValue,   setIntValue,   setLongValue,   toString
Methods from org.apache.lucene.analysis.TokenStream:
close,   end,   incrementToken,   reset
Methods from org.apache.lucene.util.AttributeSource:
addAttribute,   addAttributeImpl,   captureState,   clearAttributes,   cloneAttributes,   equals,   getAttribute,   getAttributeClassesIterator,   getAttributeFactory,   getAttributeImplsIterator,   hasAttribute,   hasAttributes,   hashCode,   restoreState,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.analysis.NumericTokenStream Detail:
 public boolean incrementToken() 
 public  void reset() 
 public NumericTokenStream setDoubleValue(double value) 
    Initializes the token stream with the supplied double value.
 public NumericTokenStream setFloatValue(float value) 
    Initializes the token stream with the supplied float value.
 public NumericTokenStream setIntValue(int value) 
    Initializes the token stream with the supplied int value.
 public NumericTokenStream setLongValue(long value) 
    Initializes the token stream with the supplied long value.
 public String toString()