Expert: This class provides a {@link TokenStream}
for indexing numeric values that can be used by {@link
NumericRangeQuery} or {@link NumericRangeFilter}.
Note that for simple usage, {@link NumericField} is
recommended. {@link 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 {@link NumericField} for capabilities of fields
indexed numerically.Here's an example usage, for an
CopyC# field:
CopyC#
instance for each.See {@link NumericRangeQuery} for more details on the
CopyC#
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.
Namespace: Lucene.Net.Analysisint
Field field = new Field(name, new NumericTokenStream(precisionStep).setIntValue(value));
field.setOmitNorms(true);
field.setOmitTermFreqAndPositions(true);
document.add(field);
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);
field.setOmitNorms(true);
field.setOmitTermFreqAndPositions(true);
Document document = new Document();
document.add(field);
for(all documents) {
stream.setIntValue(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
precisionStep
Assembly: Lucene.Net (in Lucene.Net.dll) Version: 2.9.4.1
Syntax
| C# |
|---|
public sealed class NumericTokenStream : TokenStream |
| Visual Basic |
|---|
Public NotInheritable Class NumericTokenStream _ Inherits TokenStream |
| Visual C++ |
|---|
public ref class NumericTokenStream sealed : public TokenStream |
Inheritance Hierarchy
System..::..Object
Lucene.Net.Util..::..AttributeSource
Lucene.Net.Analysis..::..TokenStream
Lucene.Net.Analysis..::..NumericTokenStream
Lucene.Net.Util..::..AttributeSource
Lucene.Net.Analysis..::..TokenStream
Lucene.Net.Analysis..::..NumericTokenStream