PointValues
instead@Deprecated public final class LegacyNumericTokenStream extends TokenStream
TokenStream
for indexing numeric values that can be used by LegacyNumericRangeQuery
.
Note that for simple usage, LegacyIntField
, LegacyLongField
, LegacyFloatField
or LegacyDoubleField
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 int
field:
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 LegacyNumericTokenStream
instance for each.
See LegacyNumericRangeQuery
for more details on the
precisionStep
parameter as well as how numeric fields work under the hood.
Modifier and Type | Class and Description |
---|---|
static interface |
LegacyNumericTokenStream.LegacyNumericTermAttribute
Deprecated.
Expert: Use this attribute to get the details of the currently generated token.
|
static class |
LegacyNumericTokenStream.LegacyNumericTermAttributeImpl
Deprecated.
Implementation of
LegacyNumericTokenStream.LegacyNumericTermAttribute . |
AttributeSource.State
Modifier and Type | Field and Description |
---|---|
static String |
TOKEN_TYPE_FULL_PREC
Deprecated.
The full precision token gets this token type assigned.
|
static String |
TOKEN_TYPE_LOWER_PREC
Deprecated.
The lower precision tokens gets this token type assigned.
|
DEFAULT_TOKEN_ATTRIBUTE_FACTORY
Constructor and Description |
---|
LegacyNumericTokenStream()
Deprecated.
Creates a token stream for numeric values using the default
precisionStep
LegacyNumericUtils.PRECISION_STEP_DEFAULT (16). |
LegacyNumericTokenStream(AttributeFactory factory,
int precisionStep)
Deprecated.
Expert: Creates a token stream for numeric values with the specified
precisionStep using the given
AttributeFactory . |
LegacyNumericTokenStream(int precisionStep)
Deprecated.
Creates a token stream for numeric values with the specified
precisionStep . |
Modifier and Type | Method and Description |
---|---|
int |
getPrecisionStep()
Deprecated.
Returns the precision step.
|
boolean |
incrementToken()
Deprecated.
|
void |
reset()
Deprecated.
|
LegacyNumericTokenStream |
setDoubleValue(double value)
Deprecated.
Initializes the token stream with the supplied
double value. |
LegacyNumericTokenStream |
setFloatValue(float value)
Deprecated.
Initializes the token stream with the supplied
float value. |
LegacyNumericTokenStream |
setIntValue(int value)
Deprecated.
Initializes the token stream with the supplied
int value. |
LegacyNumericTokenStream |
setLongValue(long value)
Deprecated.
Initializes the token stream with the supplied
long value. |
String |
toString()
Deprecated.
|
close, end
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState
public static final String TOKEN_TYPE_FULL_PREC
public static final String TOKEN_TYPE_LOWER_PREC
public LegacyNumericTokenStream()
precisionStep
LegacyNumericUtils.PRECISION_STEP_DEFAULT
(16). The stream is not yet initialized,
before using set a value using the various set???Value() methods.public LegacyNumericTokenStream(int precisionStep)
precisionStep
. The stream is not yet initialized,
before using set a value using the various set???Value() methods.public LegacyNumericTokenStream(AttributeFactory factory, int precisionStep)
precisionStep
using the given
AttributeFactory
.
The stream is not yet initialized,
before using set a value using the various set???Value() methods.public LegacyNumericTokenStream setLongValue(long value)
long
value.value
- the value, for which this TokenStream should enumerate tokens.new Field(name, new LegacyNumericTokenStream(precisionStep).setLongValue(value))
public LegacyNumericTokenStream setIntValue(int value)
int
value.value
- the value, for which this TokenStream should enumerate tokens.new Field(name, new LegacyNumericTokenStream(precisionStep).setIntValue(value))
public LegacyNumericTokenStream setDoubleValue(double value)
double
value.value
- the value, for which this TokenStream should enumerate tokens.new Field(name, new LegacyNumericTokenStream(precisionStep).setDoubleValue(value))
public LegacyNumericTokenStream setFloatValue(float value)
float
value.value
- the value, for which this TokenStream should enumerate tokens.new Field(name, new LegacyNumericTokenStream(precisionStep).setFloatValue(value))
public void reset()
reset
in class TokenStream
public boolean incrementToken()
incrementToken
in class TokenStream
public int getPrecisionStep()
public String toString()
toString
in class AttributeSource
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.