Class NumericTokenStream
Expert: this class provides a TokenStream for indexing numeric values that can be used by NumericRangeQuery or NumericRangeFilter.
Note that for simple usage, Int32Field, Int64Field, SingleField or DoubleField is recommended. These fields disable norms and term freqs, as they are not usually needed during searching. If you need to change these settings, you should use this class.
Here's an example usage, for an
IndexableFieldType fieldType = new IndexableFieldType(TextField.TYPE_NOT_STORED)
{
OmitNorms = true,
IndexOptions = IndexOptions.DOCS_ONLY
};
Field field = new Field(name, new NumericTokenStream(precisionStep).SetInt32Value(value), fieldType);
document.Add(field);
For optimal performance, re-use the TokenStream and Field instance for more than one document:
NumericTokenStream stream = new NumericTokenStream(precisionStep);
IndexableFieldType fieldType = new IndexableFieldType(TextField.TYPE_NOT_STORED)
{
OmitNorms = true,
IndexOptions = IndexOptions.DOCS_ONLY
};
Field field = new Field(name, stream, fieldType);
Document document = new Document();
document.Add(field);
for(all documents)
{
stream.SetInt32Value(value)
writer.AddDocument(document);
}
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.
@since 2.9
Inherited Members
Assembly: DistributedLucene.Net.dll
Syntax
public sealed class NumericTokenStream : TokenStream, IDisposable
Constructors
Name | Description |
---|---|
NumericTokenStream() | Creates a token stream for numeric values using the default Lucene.Net.Analysis.NumericTokenStream.precisionStep PRECISION_STEP_DEFAULT (4). The stream is not yet initialized, before using set a value using the various Set???Value() methods. |
NumericTokenStream(AttributeSource.AttributeFactory, Int32) | Expert: Creates a token stream for numeric values with the specified
|
NumericTokenStream(Int32) | Creates a token stream for numeric values with the specified
|
Fields
Name | Description |
---|---|
TOKEN_TYPE_FULL_PREC | The full precision token gets this token type assigned. |
TOKEN_TYPE_LOWER_PREC | The lower precision tokens gets this token type assigned. |
Properties
Name | Description |
---|---|
PrecisionStep | Returns the precision step. |
Methods
Name | Description |
---|---|
IncrementToken() | |
Reset() | |
SetDoubleValue(Double) | Initializes the token stream with the supplied |
SetInt32Value(Int32) | Initializes the token stream with the supplied NOTE: This was setIntValue() in Lucene |
SetInt64Value(Int64) | Initializes the token stream with the supplied NOTE: This was setLongValue() in Lucene |
SetSingleValue(Single) | Initializes the token stream with the supplied NOTE: This was setFloatValue() in Lucene |