public abstract class DoubleValuesSource extends 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 |
obj) |
Explanation |
explain(LeafReaderContext ctx,
int docId,
Explanation scoreExplanation)
An explanation of the value for the named document.
|
static DoubleValuesSource |
field)
Creates a DoubleValuesSource that wraps a double-valued field
|
static DoubleValuesSource |
field,
decoder)
Creates a DoubleValuesSource that wraps a generic NumericDocValues field
|
static DoubleValuesSource |
field)
Creates a DoubleValuesSource that wraps a float-valued field
|
static DoubleValuesSource |
field)
Creates a DoubleValuesSource that wraps an int-valued field
|
static DoubleValuesSource |
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 |
toString() |
isCacheable
public static final DoubleValuesSource SCORES
null
as the DoubleValues
parameter on getValues(LeafReaderContext, DoubleValues)
public abstract DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws
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.
public abstract boolean needsScores()
public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws
ctx
- the readers context to create the Explanation
for.docId
- the document's id relative to the given context's reader
- if an occurspublic abstract DoubleValuesSource rewrite(IndexSearcher reader) throws
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.
public SortField getSortField(boolean reverse)
reverse
- true if the sort should be decreasingpublic abstract int hashCode()
in class
public abstract boolean equals( obj)
in class
public abstract toString()
in class
public final LongValuesSource toLongValuesSource()
public static field, decoder)
field
- the field to wrap, must have NumericDocValuesdecoder
- a function to convert the long-valued doc values to doublespublic static field)
public static field)
public static field)
public static field)
public static DoubleValuesSource constant(double value)
public static DoubleValues fromScorer(Scorable scorer)
public static DoubleValuesSource fromQuery(Query query)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.