Package org.springframework.data.domain
Interface ScoringFunction
- All Known Implementing Classes:
VectorScoringFunctions
public interface ScoringFunction
Strategy interface for scoring functions.
Implementations define how score (distance or similarity) between two vectors is computed, allowing control over ranking behavior in search queries.
Provides commonly used scoring variants via static factory methods. See VectorScoringFunctions
for the
concrete implementations.
- Since:
- 4.0
- Author:
- Mark Paluch
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ScoringFunction
cosine()
Return the cosine similarity scoring function.static ScoringFunction
Return the dot product (also known as inner product) scoring function.static ScoringFunction
Return the Euclidean distance scoring function.getName()
Return the name of the scoring function.static ScoringFunction
Returns the defaultScoringFunction
to be used when none is explicitly specified.
-
Method Details
-
unspecified
Returns the defaultScoringFunction
to be used when none is explicitly specified.This is typically used to indicate the absence of a scoring definition.
- Returns:
- the default
ScoringFunction
instance.
-
euclidean
Return the Euclidean distance scoring function.Calculates the L2 norm (straight-line distance) between two vectors.
- Returns:
- the
ScoringFunction
based on Euclidean distance.
-
cosine
Return the cosine similarity scoring function.Measures the cosine of the angle between two vectors, independent of magnitude.
- Returns:
- the
ScoringFunction
based on cosine similarity.
-
dotProduct
Return the dot product (also known as inner product) scoring function.Computes the algebraic product of two vectors, considering both direction and magnitude.
- Returns:
- the
ScoringFunction
based on dot product.
-
getName
String getName()Return the name of the scoring function.Typically used for display or configuration purposes.
- Returns:
- the identifying name of this scoring function.
-