Class NumericTokenStream
Expert: this class provides a Token
Note that for simple usage, Int32Field, Int64Field,
Single
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 Token
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 Numeric
See NumericprecisionStep
parameter as well as how numeric fields work under the hood.
@since 2.9
Implements
Inherited Members
Namespace: Lucene.Net.Analysis
Assembly: Lucene.Net.dll
Syntax
public sealed class NumericTokenStream : TokenStream, IDisposable
Constructors
| Improve this Doc View SourceNumericTokenStream()
Creates a token stream for numeric values using the default Lucene.
Declaration
public NumericTokenStream()
NumericTokenStream(AttributeSource.AttributeFactory, Int32)
Expert: Creates a token stream for numeric values with the specified
precisionStep
using the given
Attribute
Declaration
public NumericTokenStream(AttributeSource.AttributeFactory factory, int precisionStep)
Parameters
Type | Name | Description |
---|---|---|
Attribute |
factory | |
System. |
precisionStep |
NumericTokenStream(Int32)
Creates a token stream for numeric values with the specified
precisionStep
. The stream is not yet initialized,
before using set a value using the various Set???Value() methods.
Declaration
public NumericTokenStream(int precisionStep)
Parameters
Type | Name | Description |
---|---|---|
System. |
precisionStep |
Fields
| Improve this Doc View SourceTOKEN_TYPE_FULL_PREC
The full precision token gets this token type assigned.
Declaration
public const string TOKEN_TYPE_FULL_PREC = null
Field Value
Type | Description |
---|---|
System. |
TOKEN_TYPE_LOWER_PREC
The lower precision tokens gets this token type assigned.
Declaration
public const string TOKEN_TYPE_LOWER_PREC = null
Field Value
Type | Description |
---|---|
System. |
Properties
| Improve this Doc View SourcePrecisionStep
Returns the precision step.
Declaration
public int PrecisionStep { get; }
Property Value
Type | Description |
---|---|
System. |
Methods
| Improve this Doc View SourceIncrementToken()
Declaration
public override bool IncrementToken()
Returns
Type | Description |
---|---|
System. |
Overrides
| Improve this Doc View SourceReset()
Declaration
public override void Reset()
Overrides
| Improve this Doc View SourceSetDoubleValue(Double)
Initializes the token stream with the supplied
Declaration
public NumericTokenStream SetDoubleValue(double value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | the value, for which this Token |
Returns
Type | Description |
---|---|
Numeric |
this instance, because of this you can use it the following way: |
SetInt32Value(Int32)
Initializes the token stream with the supplied
NOTE: This was setIntValue() in Lucene
Declaration
public NumericTokenStream SetInt32Value(int value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | the value, for which this Token |
Returns
Type | Description |
---|---|
Numeric |
this instance, because of this you can use it the following way: |
SetInt64Value(Int64)
Initializes the token stream with the supplied
NOTE: This was setLongValue() in Lucene
Declaration
public NumericTokenStream SetInt64Value(long value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | the value, for which this Token |
Returns
Type | Description |
---|---|
Numeric |
this instance, because of this you can use it the following way: |
SetSingleValue(Single)
Initializes the token stream with the supplied
NOTE: This was setFloatValue() in Lucene
Declaration
public NumericTokenStream SetSingleValue(float value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | the value, for which this Token |
Returns
Type | Description |
---|---|
Numeric |
this instance, because of this you can use it the following way: |