Class LegacyNumericTokenStream
- java.lang.Object
-
- org.apache.lucene.util.AttributeSource
-
- org.apache.lucene.analysis.TokenStream
-
- org.apache.solr.legacy.LegacyNumericTokenStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
@Deprecated public final class LegacyNumericTokenStream extends org.apache.lucene.analysis.TokenStream
Deprecated.Please switch toPointValuesinsteadExpert: This class provides aTokenStreamfor indexing numeric values that can be used byLegacyNumericRangeQuery.Note that for simple usage,
LegacyIntField,LegacyLongField,LegacyFloatFieldorLegacyDoubleFieldis 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
intfield:FieldType fieldType = new FieldType(TextField.TYPE_NOT_STORED); fieldType.setOmitNorms(true); fieldType.setIndexOptions(IndexOptions.DOCS_ONLY); Field field = new Field(name, new LegacyNumericTokenStream(precisionStep).setIntValue(value), fieldType); document.add(field);
For optimal performance, re-use the TokenStream and Field instance for more than one document:
LegacyNumericTokenStream stream = new LegacyNumericTokenStream(precisionStep); FieldType fieldType = new FieldType(TextField.TYPE_NOT_STORED); fieldType.setOmitNorms(true); fieldType.setIndexOptions(IndexOptions.DOCS_ONLY); Field field = new Field(name, stream, fieldType); 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
LegacyNumericTokenStreaminstance for each.See
LegacyNumericRangeQueryfor more details on theprecisionStepparameter as well as how numeric fields work under the hood.- Since:
- 2.9
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLegacyNumericTokenStream.LegacyNumericTermAttributeDeprecated.Expert: Use this attribute to get the details of the currently generated token.static classLegacyNumericTokenStream.LegacyNumericTermAttributeImplDeprecated.Implementation ofLegacyNumericTokenStream.LegacyNumericTermAttribute.
-
Field Summary
Fields Modifier and Type Field Description static StringTOKEN_TYPE_FULL_PRECDeprecated.The full precision token gets this token type assigned.static StringTOKEN_TYPE_LOWER_PRECDeprecated.The lower precision tokens gets this token type assigned.
-
Constructor Summary
Constructors Constructor Description LegacyNumericTokenStream()Deprecated.Creates a token stream for numeric values using the defaultprecisionStepLegacyNumericUtils.PRECISION_STEP_DEFAULT(16).LegacyNumericTokenStream(int precisionStep)Deprecated.Creates a token stream for numeric values with the specifiedprecisionStep.LegacyNumericTokenStream(org.apache.lucene.util.AttributeFactory factory, int precisionStep)Deprecated.Expert: Creates a token stream for numeric values with the specifiedprecisionStepusing the givenAttributeFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intgetPrecisionStep()Deprecated.Returns the precision step.booleanincrementToken()Deprecated.voidreset()Deprecated.LegacyNumericTokenStreamsetDoubleValue(double value)Deprecated.Initializes the token stream with the supplieddoublevalue.LegacyNumericTokenStreamsetFloatValue(float value)Deprecated.Initializes the token stream with the suppliedfloatvalue.LegacyNumericTokenStreamsetIntValue(int value)Deprecated.Initializes the token stream with the suppliedintvalue.LegacyNumericTokenStreamsetLongValue(long value)Deprecated.Initializes the token stream with the suppliedlongvalue.StringtoString()Deprecated.-
Methods inherited from class org.apache.lucene.util.AttributeSource
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState
-
-
-
-
Field Detail
-
TOKEN_TYPE_FULL_PREC
public static final String TOKEN_TYPE_FULL_PREC
Deprecated.The full precision token gets this token type assigned.- See Also:
- Constant Field Values
-
TOKEN_TYPE_LOWER_PREC
public static final String TOKEN_TYPE_LOWER_PREC
Deprecated.The lower precision tokens gets this token type assigned.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LegacyNumericTokenStream
public LegacyNumericTokenStream()
Deprecated.Creates a token stream for numeric values using the defaultprecisionStepLegacyNumericUtils.PRECISION_STEP_DEFAULT(16). The stream is not yet initialized, before using set a value using the various set???Value() methods.
-
LegacyNumericTokenStream
public LegacyNumericTokenStream(int precisionStep)
Deprecated.Creates a token stream for numeric values with the specifiedprecisionStep. The stream is not yet initialized, before using set a value using the various set???Value() methods.
-
LegacyNumericTokenStream
public LegacyNumericTokenStream(org.apache.lucene.util.AttributeFactory factory, int precisionStep)Deprecated.Expert: Creates a token stream for numeric values with the specifiedprecisionStepusing the givenAttributeFactory. The stream is not yet initialized, before using set a value using the various set???Value() methods.
-
-
Method Detail
-
setLongValue
public LegacyNumericTokenStream setLongValue(long value)
Deprecated.Initializes the token stream with the suppliedlongvalue.- Parameters:
value- the value, for which this TokenStream should enumerate tokens.- Returns:
- this instance, because of this you can use it the following way:
new Field(name, new LegacyNumericTokenStream(precisionStep).setLongValue(value))
-
setIntValue
public LegacyNumericTokenStream setIntValue(int value)
Deprecated.Initializes the token stream with the suppliedintvalue.- Parameters:
value- the value, for which this TokenStream should enumerate tokens.- Returns:
- this instance, because of this you can use it the following way:
new Field(name, new LegacyNumericTokenStream(precisionStep).setIntValue(value))
-
setDoubleValue
public LegacyNumericTokenStream setDoubleValue(double value)
Deprecated.Initializes the token stream with the supplieddoublevalue.- Parameters:
value- the value, for which this TokenStream should enumerate tokens.- Returns:
- this instance, because of this you can use it the following way:
new Field(name, new LegacyNumericTokenStream(precisionStep).setDoubleValue(value))
-
setFloatValue
public LegacyNumericTokenStream setFloatValue(float value)
Deprecated.Initializes the token stream with the suppliedfloatvalue.- Parameters:
value- the value, for which this TokenStream should enumerate tokens.- Returns:
- this instance, because of this you can use it the following way:
new Field(name, new LegacyNumericTokenStream(precisionStep).setFloatValue(value))
-
reset
public void reset()
Deprecated.- Overrides:
resetin classorg.apache.lucene.analysis.TokenStream
-
incrementToken
public boolean incrementToken()
Deprecated.- Specified by:
incrementTokenin classorg.apache.lucene.analysis.TokenStream
-
getPrecisionStep
public int getPrecisionStep()
Deprecated.Returns the precision step.
-
toString
public String toString()
Deprecated.- Overrides:
toStringin classorg.apache.lucene.util.AttributeSource
-
-