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

Package org.apache.lucene.document

# Class LateInteractionField

java.lang.Object
org.apache.lucene.document.Field
org.apache.lucene.document.BinaryDocValuesField
org.apache.lucene.document.LateInteractionField

All Implemented Interfaces:
  `IndexableField`

public class LateInteractionField extends BinaryDocValuesField
A field for storing multi-vector values for late interaction models.

The value is stored as a binary payload, and can be retrieved using `decode(BytesRef)`. Multi-vectors are expected to have the same dimension for each composing token vector. This is stored along with the token vectors in the first 4 bytes of the payload.

Note: This field does not ensure consistency in token vector dimensions for values across documents.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.apache.lucene.document.Field

  `Field.Store`

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.document.BinaryDocValuesField

  `TYPE`

  ### Fields inherited from class org.apache.lucene.document.Field

  `fieldsData, name, type`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LateInteractionField(String name, float[][] value)`
  Creates a new `LateInteractionField` from the provided multi-vector matrix.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static float[][]`
  `decode(BytesRef payload)`
  Decodes provided `BytesRef` into a multi-vector matrix.
  `static BytesRef`
  `encode(float[][] value)`
  Encodes provided multi-vector matrix into a `BytesRef` that can be stored in the `LateInteractionField`.
  `float[][]`
  `getValue()`
  Returns the multi-vector value stored in this field
  `void`
  `setValue(float[][] value)`
  Set multi-vector value for the field.

  ### Methods inherited from class org.apache.lucene.document.Field

  `binaryValue, fieldType, getCharSequenceValue, invertableType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, storedValue, stringValue, tokenStream, tokenStreamValue, toString`

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

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

- ## Constructor Details

  - ### LateInteractionField

    public LateInteractionField(String name, float[][] value)
    Creates a new `LateInteractionField` from the provided multi-vector matrix.
    Parameters:
      `name` - field name
      `value` - multi-vector value

- ## Method Details

  - ### setValue

    public void setValue(float[][] value)
    Set multi-vector value for the field.

    Value should not be null or empty. Composing token vectors for provided multi-vector value should have the same dimension.

  - ### getValue

    public float[][] getValue()
    Returns the multi-vector value stored in this field

  - ### encode

    public static BytesRef encode(float[][] value)
    Encodes provided multi-vector matrix into a `BytesRef` that can be stored in the `LateInteractionField`.

    Composing token vectors for the multi-vector are expected to have the same dimension, which is stored along with the token vectors in the first 4 bytes of the payload. Use `decode(BytesRef)` to retrieve the multi-vector.

    Parameters:
      `value` - Multi-Vector to encode
    Returns:
      BytesRef representation for provided multi-vector

  - ### decode

    public static float[][] decode(BytesRef payload)
    Decodes provided `BytesRef` into a multi-vector matrix.

    The token vectors are expected to have the same dimension, which is stored along with the token vectors in the first 4 bytes of the payload. Meant to be used as a counterpart to `encode(float[][])`

    Parameters:
      `payload` - to decode into multi-vector value
    Returns:
      decoded multi-vector value