public abstract class DoubleValuesSource extends Object
DoubleValues
To obtain a DoubleValues
object for a leaf reader, clients should
call getValues(LeafReaderContext, DoubleValues)
.
DoubleValuesSource objects for NumericDocValues fields can be obtained by calling
fromDoubleField(String)
, fromFloatField(String)
, fromIntField(String)
or fromLongField(String)
, or from fromField(String, LongToDoubleFunction)
if
special long-to-double encoding is required.
Scores may be used as a source for value calculations by wrapping a Scorer
using
fromScorer(Scorer)
and passing the resulting DoubleValues to getValues(LeafReaderContext, DoubleValues)
.
The scores can then be accessed using the SCORES
DoubleValuesSource.Modifier and Type | Field and Description |
---|---|
static DoubleValuesSource |
SCORES
A DoubleValuesSource that exposes a document's score
If this source is used as part of a values calculation, then callers must not
pass
null as the DoubleValues parameter on getValues(LeafReaderContext, DoubleValues) |
Constructor and Description |
---|
DoubleValuesSource() |
Modifier and Type | Method and Description |
---|---|
static DoubleValuesSource |
fromDoubleField(String field)
Creates a DoubleValuesSource that wraps a double-valued field
|
static DoubleValuesSource |
fromField(String field,
LongToDoubleFunction decoder)
Creates a DoubleValuesSource that wraps a generic NumericDocValues field
|
static DoubleValuesSource |
fromFloatField(String field)
Creates a DoubleValuesSource that wraps a float-valued field
|
static DoubleValuesSource |
fromIntField(String field)
Creates a DoubleValuesSource that wraps an int-valued field
|
static DoubleValuesSource |
fromLongField(String field)
Creates a DoubleValuesSource that wraps a long-valued field
|
static DoubleValues |
fromScorer(Scorer scorer)
Returns a DoubleValues instance that wraps scores returned by a Scorer
|
SortField |
getSortField(boolean reverse)
Create a sort field based on the value of this producer
|
abstract DoubleValues |
getValues(LeafReaderContext ctx,
DoubleValues scores)
Returns a
DoubleValues instance for the passed-in LeafReaderContext and scores
If scores are not needed to calculate the values (ie returns false , callers
may safely pass null for the scores parameter. |
abstract boolean |
needsScores()
Return true if document scores are needed to calculate values
|
LongValuesSource |
toLongValuesSource()
Convert to a LongValuesSource by casting the double values to longs
|
public static final DoubleValuesSource SCORES
null
as the DoubleValues
parameter on getValues(LeafReaderContext, DoubleValues)
public abstract DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException
DoubleValues
instance for the passed-in LeafReaderContext and scores
If scores are not needed to calculate the values (ie returns false
, callers
may safely pass null
for the scores
parameter.IOException
public abstract boolean needsScores()
public SortField getSortField(boolean reverse)
reverse
- true if the sort should be decreasingpublic final LongValuesSource toLongValuesSource()
public static DoubleValuesSource fromField(String field, LongToDoubleFunction decoder)
field
- the field to wrap, must have NumericDocValuesdecoder
- a function to convert the long-valued doc values to doublespublic static DoubleValuesSource fromDoubleField(String field)
public static DoubleValuesSource fromFloatField(String field)
public static DoubleValuesSource fromLongField(String field)
public static DoubleValuesSource fromIntField(String field)
public static DoubleValues fromScorer(Scorer scorer)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.