public abstract class DoubleValuesSource extends Object implements SegmentCacheable
DoubleValues
To obtain a DoubleValues
object for a leaf reader, clients should call
rewrite(IndexSearcher)
against the top-level searcher, and then
call getValues(LeafReaderContext, DoubleValues)
on the resulting
DoubleValuesSource.
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(Scorable)
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 |
constant(double value)
Creates a DoubleValuesSource that always returns a constant value
|
abstract boolean |
equals(Object obj) |
Explanation |
explain(LeafReaderContext ctx,
int docId,
Explanation scoreExplanation)
An explanation of the value for the named document.
|
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 DoubleValuesSource |
fromQuery(Query query)
Create a DoubleValuesSource that returns the score of a particular query
|
static DoubleValues |
fromScorer(Scorable 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 int |
hashCode() |
abstract boolean |
needsScores()
Return true if document scores are needed to calculate values
|
abstract DoubleValuesSource |
rewrite(IndexSearcher reader)
Return a DoubleValuesSource specialised for the given IndexSearcher
Implementations should assume that this will only be called once.
|
LongValuesSource |
toLongValuesSource()
Convert to a LongValuesSource by casting the double values to longs
|
abstract String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isCacheable
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 Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException
ctx
- the readers context to create the Explanation
for.docId
- the document's id relative to the given context's readerIOException
- if an IOException
occurspublic abstract DoubleValuesSource rewrite(IndexSearcher reader) throws IOException
this
Queries that use DoubleValuesSource objects should call rewrite() during
Query.createWeight(IndexSearcher, ScoreMode, float)
rather than during
Query.rewrite(IndexReader)
to avoid IndexReader reference leakage.
For the same reason, implementations that cache references to the IndexSearcher
should return a new object from this method.IOException
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 DoubleValuesSource constant(double value)
public static DoubleValues fromScorer(Scorable scorer)
public static DoubleValuesSource fromQuery(Query query)
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.