Package org.apache.lucene.util.hnsw
Interface RandomVectorScorer
-
- All Known Implementing Classes:
RandomVectorScorer.AbstractRandomVectorScorer,ScalarQuantizedRandomVectorScorer
public interface RandomVectorScorerARandomVectorScorerfor scoring random nodes in batches against an abstract query.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classRandomVectorScorer.AbstractRandomVectorScorer<T>Creates a default scorer for random access vectors.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static RandomVectorScorercreateBytes(RandomAccessVectorValues<byte[]> vectors, VectorSimilarityFunction similarityFunction, byte[] query)Creates a default scorer for byte vectors.static RandomVectorScorercreateFloats(RandomAccessVectorValues<float[]> vectors, VectorSimilarityFunction similarityFunction, float[] query)Creates a default scorer for float vectors.default BitsgetAcceptOrds(Bits acceptDocs)Returns theBitsrepresenting live documents.intmaxOrd()default intordToDoc(int ord)Translates vector ordinal to the correct document ID.floatscore(int node)Returns the score between the query and the provided node.
-
-
-
Method Detail
-
score
float score(int node) throws IOExceptionReturns the score between the query and the provided node.- Parameters:
node- a random node in the graph- Returns:
- the computed score
- Throws:
IOException
-
maxOrd
int maxOrd()
- Returns:
- the maximum possible ordinal for this scorer
-
ordToDoc
default int ordToDoc(int ord)
Translates vector ordinal to the correct document ID. By default, this is an identity function.- Parameters:
ord- the vector ordinal- Returns:
- the document Id for that vector ordinal
-
getAcceptOrds
default Bits getAcceptOrds(Bits acceptDocs)
Returns theBitsrepresenting live documents. By default, this is an identity function.- Parameters:
acceptDocs- the accept docs- Returns:
- the accept docs
-
createFloats
static RandomVectorScorer createFloats(RandomAccessVectorValues<float[]> vectors, VectorSimilarityFunction similarityFunction, float[] query)
Creates a default scorer for float vectors.WARNING: The
RandomAccessVectorValuesgiven can contain stateful buffers. Avoid using it after calling this function. If you plan to use it again outside the returnedRandomVectorScorer, think about passing a copied version (RandomAccessVectorValues.copy()).- Parameters:
vectors- the underlying storage for vectorssimilarityFunction- the similarity function to score vectorsquery- the actual query
-
createBytes
static RandomVectorScorer createBytes(RandomAccessVectorValues<byte[]> vectors, VectorSimilarityFunction similarityFunction, byte[] query)
Creates a default scorer for byte vectors.WARNING: The
RandomAccessVectorValuesgiven can contain stateful buffers. Avoid using it after calling this function. If you plan to use it again outside the returnedRandomVectorScorer, think about passing a copied version (RandomAccessVectorValues.copy()).- Parameters:
vectors- the underlying storage for vectorssimilarityFunction- the similarity function to use to score vectorsquery- the actual query
-
-