Package org.apache.lucene.search
Class FullPrecisionFloatVectorSimilarityValuesSource
java.lang.Object
org.apache.lucene.search.DoubleValuesSource
org.apache.lucene.search.FullPrecisionFloatVectorSimilarityValuesSource
- All Implemented Interfaces:
SegmentCacheable
A
DoubleValuesSource that computes vector similarity between a query vector and raw full
precision vectors indexed in provided KnnFloatVectorField in
documents.-
Field Summary
Fields inherited from class org.apache.lucene.search.DoubleValuesSource
SCORES -
Constructor Summary
ConstructorsConstructorDescriptionFullPrecisionFloatVectorSimilarityValuesSource(float[] vector, String fieldName) Creates aDoubleValuesSourcethat returns vector similarity score between provided query vector and field for documents.FullPrecisionFloatVectorSimilarityValuesSource(float[] vector, String fieldName, VectorSimilarityFunction vectorSimilarityFunction) Creates aDoubleValuesSourcethat returns vector similarity score between provided query vector and field for documents. -
Method Summary
Modifier and TypeMethodDescriptionbooleanSugar to fetch full precision similarity score valuesgetValues(LeafReaderContext ctx, DoubleValues scores) Returns aDoubleValuesinstance for the passed-in LeafReaderContext and scoresinthashCode()booleanbooleanReturn true if document scores are needed to calculate valuesrewrite(IndexSearcher reader) Return a DoubleValuesSource specialised for the given IndexSearchertoString()Methods inherited from class org.apache.lucene.search.DoubleValuesSource
constant, explain, fromDoubleField, fromField, fromFloatField, fromIntField, fromLongField, fromQuery, fromScorer, getSortField, similarityToQueryVector, similarityToQueryVector, toLongValuesSource, toSortableLongDoubleValuesSource
-
Constructor Details
-
FullPrecisionFloatVectorSimilarityValuesSource
public FullPrecisionFloatVectorSimilarityValuesSource(float[] vector, String fieldName, VectorSimilarityFunction vectorSimilarityFunction) Creates aDoubleValuesSourcethat returns vector similarity score between provided query vector and field for documents.- Parameters:
vector- the query vectorfieldName- the field name of theKnnFloatVectorFieldvectorSimilarityFunction- the vector similarity function to use
-
FullPrecisionFloatVectorSimilarityValuesSource
Creates aDoubleValuesSourcethat returns vector similarity score between provided query vector and field for documents. Uses the configured vector similarity function for the field.- Parameters:
vector- the query vectorfieldName- the field name of theKnnFloatVectorField
-
-
Method Details
-
getSimilarityScores
Sugar to fetch full precision similarity score values- Throws:
IOException
-
getValues
Description copied from class:DoubleValuesSourceReturns aDoubleValuesinstance for the passed-in LeafReaderContext and scoresIf scores are not needed to calculate the values (ie
returns false, callers may safely passnullfor thescoresparameter.- Specified by:
getValuesin classDoubleValuesSource- Throws:
IOException
-
needsScores
public boolean needsScores()Description copied from class:DoubleValuesSourceReturn true if document scores are needed to calculate values- Specified by:
needsScoresin classDoubleValuesSource
-
rewrite
Description copied from class:DoubleValuesSourceReturn a DoubleValuesSource specialised for the given IndexSearcherImplementations should assume that this will only be called once. IndexReader-independent implementations can just return
thisQueries 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:
rewritein classDoubleValuesSource- Throws:
IOException
-
hashCode
public int hashCode()- Specified by:
hashCodein classDoubleValuesSource
-
equals
- Specified by:
equalsin classDoubleValuesSource
-
toString
- Specified by:
toStringin classDoubleValuesSource
-
isCacheable
- Returns:
trueif the object can be cached against a given leaf
-