- java.lang.Object
-
- org.apache.lucene.search.DoubleValuesSource
-
- org.apache.lucene.search.VectorSimilarityValuesSource
-
- All Implemented Interfaces:
SegmentCacheable
- Direct Known Subclasses:
ByteVectorSimilarityValuesSource
,FloatVectorSimilarityValuesSource
abstract class VectorSimilarityValuesSource extends DoubleValuesSource
An abstract class that provides the vector similarity scores between the query vector and theKnnFloatVectorField
orKnnByteVectorField
for documents.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
fieldName
-
Fields inherited from class org.apache.lucene.search.DoubleValuesSource
SCORES
-
-
Constructor Summary
Constructors Constructor Description VectorSimilarityValuesSource(java.lang.String fieldName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract VectorScorer
getScorer(LeafReaderContext ctx)
DoubleValues
getValues(LeafReaderContext ctx, DoubleValues scores)
Returns aDoubleValues
instance for the passed-in LeafReaderContext and scoresboolean
isCacheable(LeafReaderContext ctx)
boolean
needsScores()
Return true if document scores are needed to calculate valuesDoubleValuesSource
rewrite(IndexSearcher reader)
Return a DoubleValuesSource specialised for the given IndexSearcher-
Methods inherited from class org.apache.lucene.search.DoubleValuesSource
constant, equals, explain, fromDoubleField, fromField, fromFloatField, fromIntField, fromLongField, fromQuery, fromScorer, getSortField, hashCode, similarityToQueryVector, similarityToQueryVector, toLongValuesSource, toString
-
-
-
-
Method Detail
-
getValues
public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws java.io.IOException
Description copied from class:DoubleValuesSource
Returns aDoubleValues
instance for the passed-in LeafReaderContext and scoresIf scores are not needed to calculate the values (ie
returns false
, callers may safely passnull
for thescores
parameter.- Specified by:
getValues
in classDoubleValuesSource
- Throws:
java.io.IOException
-
getScorer
protected abstract VectorScorer getScorer(LeafReaderContext ctx) throws java.io.IOException
- Throws:
java.io.IOException
-
needsScores
public boolean needsScores()
Description copied from class:DoubleValuesSource
Return true if document scores are needed to calculate values- Specified by:
needsScores
in classDoubleValuesSource
-
rewrite
public DoubleValuesSource rewrite(IndexSearcher reader) throws java.io.IOException
Description copied from class:DoubleValuesSource
Return a DoubleValuesSource specialised for the given IndexSearcherImplementations should assume that this will only be called once. IndexReader-independent implementations can just return
this
Queries that use DoubleValuesSource objects should call rewrite() during
Query.createWeight(IndexSearcher, ScoreMode, float)
rather than duringQuery.rewrite(IndexSearcher)
to avoid IndexReader reference leakage.For the same reason, implementations that cache references to the IndexSearcher should return a new object from this method.
- Specified by:
rewrite
in classDoubleValuesSource
- Throws:
java.io.IOException
-
isCacheable
public boolean isCacheable(LeafReaderContext ctx)
- Returns:
true
if the object can be cached against a given leaf
-
-