LateInteractionFloatValuesSource (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.search, class: LateInteractionFloatValuesSource

Package org.apache.lucene.search

# Class LateInteractionFloatValuesSource

java.lang.Object
org.apache.lucene.search.DoubleValuesSource
org.apache.lucene.search.LateInteractionFloatValuesSource

All Implemented Interfaces:
  `SegmentCacheable`

public class LateInteractionFloatValuesSource extends DoubleValuesSource
A `DoubleValuesSource` that scores documents using similarity between a multi-vector query, and indexed document multi-vectors.

This is useful re-ranking query results using late interaction models, where documents and queries are represented as multi-vectors of composing token vectors. Document vectors are indexed using `LateInteractionField`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `LateInteractionFloatValuesSource.ScoreFunction`
  Defines the function to compute similarity score between query and document multi-vectors

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.search.DoubleValuesSource

  `SCORES`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LateInteractionFloatValuesSource(String fieldName, float[][] queryVector)`
  `LateInteractionFloatValuesSource(String fieldName, float[][] queryVector, VectorSimilarityFunction vectorSimilarityFunction)`
  `LateInteractionFloatValuesSource(String fieldName, float[][] queryVector, VectorSimilarityFunction vectorSimilarityFunction, MultiVectorSimilarity scoreFunction)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `DoubleValues`
  `getValues(LeafReaderContext ctx, DoubleValues scores)`
  Returns a `DoubleValues` instance for the passed-in LeafReaderContext and scores
  `int`
  `hashCode()`
  `boolean`
  `isCacheable(LeafReaderContext ctx)`
  `boolean`
  `needsScores()`
  Return true if document scores are needed to calculate values
  `DoubleValuesSource`
  `rewrite(IndexSearcher reader)`
  Return a DoubleValuesSource specialised for the given IndexSearcher
  `String`
  `toString()`

  ### Methods inherited from class org.apache.lucene.search.DoubleValuesSource

  `constant, explain, fromDoubleField, fromField, fromFloatField, fromIntField, fromLongField, fromQuery, fromScorer, getSortField, getSortField, similarityToQueryVector, similarityToQueryVector, toLongValuesSource, toSortableLongDoubleValuesSource`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### LateInteractionFloatValuesSource

    public LateInteractionFloatValuesSource(String fieldName, float[][] queryVector)

  - ### LateInteractionFloatValuesSource

    public LateInteractionFloatValuesSource(String fieldName, float[][] queryVector, VectorSimilarityFunction vectorSimilarityFunction)

  - ### LateInteractionFloatValuesSource

    public LateInteractionFloatValuesSource(String fieldName, float[][] queryVector, VectorSimilarityFunction vectorSimilarityFunction, MultiVectorSimilarity scoreFunction)

- ## Method Details

  - ### getValues

    public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException
    Description copied from class: `DoubleValuesSource`
    Returns a `DoubleValues` instance for the passed-in LeafReaderContext and scores

    If scores are not needed to calculate the values (ie `returns false`, callers may safely pass `null` for the `scores` parameter.

    Specified by:
      `getValues` in class `DoubleValuesSource`
    Throws:
      `IOException`

  - ### needsScores

    public boolean needsScores()
    Description copied from class: `DoubleValuesSource`
    Return true if document scores are needed to calculate values
    Specified by:
      `needsScores` in class `DoubleValuesSource`

  - ### rewrite

    public DoubleValuesSource rewrite(IndexSearcher reader) throws IOException
    Description copied from class: `DoubleValuesSource`
    Return a DoubleValuesSource specialised for the given IndexSearcher

    Implementations 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 during `Query.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 class `DoubleValuesSource`
    Throws:
      `IOException`

  - ### hashCode

    public int hashCode()
    Specified by:
      `hashCode` in class `DoubleValuesSource`

  - ### equals

    public boolean equals(Object obj)
    Specified by:
      `equals` in class `DoubleValuesSource`

  - ### toString

    public String toString()
    Specified by:
      `toString` in class `DoubleValuesSource`

  - ### isCacheable

    public boolean isCacheable(LeafReaderContext ctx)
    Returns:
      `true` if the object can be cached against a given leaf