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 Type
    Method
    Description
    Return the cosine similarity scoring function.
    Return the dot product (also known as inner product) scoring function.
    Return the Euclidean distance scoring function.
    Return the name of the scoring function.
    Returns the default ScoringFunction to be used when none is explicitly specified.
  • Method Details

    • unspecified

      static ScoringFunction unspecified()
      Returns the default ScoringFunction 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

      static ScoringFunction 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

      static ScoringFunction 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

      static ScoringFunction 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.