Lucene.Net
3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
|
Expert: This class provides a TokenStream for indexing numeric values that can be used by NumericRangeQuery{T} or NumericRangeFilter{T}. More...
Inherits Lucene.Net.Analysis.TokenStream.
Public Member Functions | |
NumericTokenStream () | |
Creates a token stream for numeric values using the default precisionStep NumericUtils.PRECISION_STEP_DEFAULT (4). The stream is not yet initialized, before using set a value using the various set???Value() methods. | |
NumericTokenStream (int precisionStep) | |
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. | |
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. | |
NumericTokenStream (AttributeFactory factory, int precisionStep) | |
Expert: Creates a token stream for numeric values with the specified precisionStep using the given Lucene.Net.Util.AttributeSource.AttributeFactory. The stream is not yet initialized, before using set a value using the various set???Value() methods. | |
NumericTokenStream | SetLongValue (long value_Renamed) |
Initializes the token stream with the supplied long value. | |
NumericTokenStream | SetIntValue (int value_Renamed) |
Initializes the token stream with the supplied int value. | |
NumericTokenStream | SetDoubleValue (double value_Renamed) |
Initializes the token stream with the supplied double value. | |
NumericTokenStream | SetFloatValue (float value_Renamed) |
Initializes the token stream with the supplied float value. | |
override void | Reset () |
Resets this stream to the beginning. This is an optional operation, so subclasses may or may not implement this method. Reset() is not needed for the standard indexing process. However, if the tokens of a TokenStream are intended to be consumed more than once, it is necessary to implement Reset(). Note that if your TokenStream caches tokens and feeds them back again after a reset, it is imperative that you clone the tokens when you store them away (on the first pass) as well as when you return them (on future passes after Reset()). | |
override bool | IncrementToken () |
Consumers (i.e., IndexWriter) use this method to advance the stream to the next token. Implementing classes must implement this method and update the appropriate Util.Attributes with the attributes of the next token. | |
override System.String | ToString () |
Public Member Functions inherited from Lucene.Net.Analysis.TokenStream | |
virtual void | End () |
This method is called by the consumer after the last token has been consumed, after IncrementToken returned false (using the new TokenStream API). Streams implementing the old API should upgrade to use this feature. This method can be used to perform any end-of-stream operations, such as setting the final offset of a stream. The final offset of a stream might differ from the offset of the last token eg in case one or more whitespaces followed after the last token, but a WhitespaceTokenizer was used. | |
void | Close () |
Releases resources associated with this stream. | |
void | Dispose () |
Public Member Functions inherited from Lucene.Net.Util.AttributeSource | |
AttributeSource () | |
An AttributeSource using the default attribute factory AttributeSource.AttributeFactory.DEFAULT_ATTRIBUTE_FACTORY. | |
AttributeSource (AttributeSource input) | |
An AttributeSource that uses the same attributes as the supplied one. | |
AttributeSource (AttributeFactory factory) | |
An AttributeSource using the supplied AttributeFactory for creating new IAttribute instances. | |
virtual IEnumerable< Type > | GetAttributeTypesIterator () |
Returns a new iterator that iterates the attribute classes in the same order they were added in. Signature for Java 1.5: public Iterator<Class<? extends Attribute>> getAttributeClassesIterator() | |
virtual IEnumerable< Attribute > | GetAttributeImplsIterator () |
Returns a new iterator that iterates all unique Attribute implementations. This iterator may contain less entries that GetAttributeTypesIterator, if one instance implements more than one Attribute interface. Signature for Java 1.5: public Iterator<AttributeImpl> getAttributeImplsIterator() | |
virtual void | AddAttributeImpl (Attribute att) |
Expert: Adds a custom AttributeImpl instance with one or more Attribute interfaces. | |
virtual T | AddAttribute< T > () |
The caller must pass in a Class<? extends Attribute> value. This method first checks if an instance of that class is already in this AttributeSource and returns it. Otherwise a new instance is created, added to this AttributeSource and returned. | |
virtual bool | HasAttribute< T > () |
The caller must pass in a Class<? extends Attribute> value. Returns true, iff this AttributeSource contains the passed-in Attribute. | |
virtual T | GetAttribute< T > () |
The caller must pass in a Class<? extends Attribute> value. Returns the instance of the passed in Attribute contained in this AttributeSource | |
virtual void | ClearAttributes () |
Resets all Attributes in this AttributeSource by calling Attribute.Clear() on each Attribute implementation. | |
virtual State | CaptureState () |
Captures the state of all Attributes. The return value can be passed to RestoreState to restore the state of this or another AttributeSource. | |
virtual void | RestoreState (State state) |
Restores this state by copying the values of all attribute implementations that this state contains into the attributes implementations of the targetStream. The targetStream must contain a corresponding instance for each argument contained in this state (e.g. it is not possible to restore the state of an AttributeSource containing a TermAttribute into a AttributeSource using a Token instance as implementation). | |
override int | GetHashCode () |
override bool | Equals (System.Object obj) |
override System.String | ToString () |
virtual AttributeSource | CloneAttributes () |
Performs a clone of all Attribute instances returned in a new AttributeSource instance. This method can be used to e.g. create another TokenStream with exactly the same attributes (using AttributeSource(AttributeSource)) | |
Public Attributes | |
const System.String | TOKEN_TYPE_FULL_PREC = "fullPrecNumeric" |
The full precision token gets this token type assigned. | |
const System.String | TOKEN_TYPE_LOWER_PREC = "lowerPrecNumeric" |
The lower precision tokens gets this token type assigned. | |
Protected Member Functions | |
override void | Dispose (bool disposing) |
Additional Inherited Members | |
Properties inherited from Lucene.Net.Util.AttributeSource | |
virtual AttributeFactory | Factory [get] |
Returns the used AttributeFactory. | |
virtual bool | HasAttributes [get] |
Returns true, iff this AttributeSource has any attributes | |
Expert: This class provides a TokenStream for indexing numeric values that can be used by NumericRangeQuery{T} or NumericRangeFilter{T}.
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)); 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
instance for each.
See NumericRangeQuery{T} for more details on the precisionStep
parameter as well as how numeric fields work under the hood.
<font color="red">NOTE: This API is experimental and might change in incompatible ways in the next release.</font> Since 2.9
Definition at line 84 of file NumericTokenStream.cs.
Lucene.Net.Analysis.NumericTokenStream.NumericTokenStream | ( | ) |
Creates a token stream for numeric values using the default precisionStep
NumericUtils.PRECISION_STEP_DEFAULT (4). The stream is not yet initialized, before using set a value using the various set???Value() methods.
Definition at line 103 of file NumericTokenStream.cs.
Lucene.Net.Analysis.NumericTokenStream.NumericTokenStream | ( | int | precisionStep | ) |
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.
Definition at line 111 of file NumericTokenStream.cs.
Lucene.Net.Analysis.NumericTokenStream.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.
Definition at line 124 of file NumericTokenStream.cs.
Lucene.Net.Analysis.NumericTokenStream.NumericTokenStream | ( | AttributeFactory | factory, |
int | precisionStep | ||
) |
Expert: Creates a token stream for numeric values with the specified precisionStep
using the given Lucene.Net.Util.AttributeSource.AttributeFactory. The stream is not yet initialized, before using set a value using the various set???Value() methods.
Definition at line 138 of file NumericTokenStream.cs.
|
protectedvirtual |
Implements Lucene.Net.Analysis.TokenStream.
Definition at line 210 of file NumericTokenStream.cs.
|
virtual |
Consumers (i.e., IndexWriter) use this method to advance the stream to the next token. Implementing classes must implement this method and update the appropriate Util.Attributes with the attributes of the next token.
The producer must make no assumptions about the attributes after the method has been returned: the caller may arbitrarily change it. If the producer needs to preserve the state for subsequent calls, it can use AttributeSource.CaptureState to create a copy of the current attribute state.
This method is called for every token of a document, so an efficient implementation is crucial for good performance. To avoid calls to AttributeSource.AddAttribute{T}() and AttributeSource.GetAttribute{T}(), references to all Util.Attributes that this stream uses should be retrieved during instantiation.
To ensure that filters and consumers know which attributes are available, the attributes must be added during instantiation. Filters and consumers are not required to check for availability of attributes in IncrementToken().
Implements Lucene.Net.Analysis.TokenStream.
Definition at line 216 of file NumericTokenStream.cs.
|
virtual |
Resets this stream to the beginning. This is an optional operation, so subclasses may or may not implement this method. Reset() is not needed for the standard indexing process. However, if the tokens of a TokenStream
are intended to be consumed more than once, it is necessary to implement Reset(). Note that if your TokenStream caches tokens and feeds them back again after a reset, it is imperative that you clone the tokens when you store them away (on the first pass) as well as when you return them (on future passes after Reset()).
Reimplemented from Lucene.Net.Analysis.TokenStream.
Definition at line 203 of file NumericTokenStream.cs.
NumericTokenStream Lucene.Net.Analysis.NumericTokenStream.SetDoubleValue | ( | double | value_Renamed | ) |
Initializes the token stream with the supplied double
value.
value_Renamed | the value, for which this TokenStream should enumerate tokens. |
new Field(name, new NumericTokenStream(precisionStep).SetDoubleValue(value))
Definition at line 180 of file NumericTokenStream.cs.
NumericTokenStream Lucene.Net.Analysis.NumericTokenStream.SetFloatValue | ( | float | value_Renamed | ) |
Initializes the token stream with the supplied float
value.
value_Renamed | the value, for which this TokenStream should enumerate tokens. |
new Field(name, new NumericTokenStream(precisionStep).SetFloatValue(value))
Definition at line 194 of file NumericTokenStream.cs.
NumericTokenStream Lucene.Net.Analysis.NumericTokenStream.SetIntValue | ( | int | value_Renamed | ) |
Initializes the token stream with the supplied int
value.
value_Renamed | the value, for which this TokenStream should enumerate tokens. |
new Field(name, new NumericTokenStream(precisionStep).SetIntValue(value))
Definition at line 166 of file NumericTokenStream.cs.
NumericTokenStream Lucene.Net.Analysis.NumericTokenStream.SetLongValue | ( | long | value_Renamed | ) |
Initializes the token stream with the supplied long
value.
value_Renamed | the value, for which this TokenStream should enumerate tokens. |
new Field(name, new NumericTokenStream(precisionStep).SetLongValue(value))
Definition at line 152 of file NumericTokenStream.cs.
override System.String Lucene.Net.Analysis.NumericTokenStream.ToString | ( | ) |
Definition at line 253 of file NumericTokenStream.cs.
const System.String Lucene.Net.Analysis.NumericTokenStream.TOKEN_TYPE_FULL_PREC = "fullPrecNumeric" |
The full precision token gets this token type assigned.
Definition at line 94 of file NumericTokenStream.cs.
const System.String Lucene.Net.Analysis.NumericTokenStream.TOKEN_TYPE_LOWER_PREC = "lowerPrecNumeric" |
The lower precision tokens gets this token type assigned.
Definition at line 97 of file NumericTokenStream.cs.