Class VectorValues

java.lang.Object
org.apache.lucene.search.DocIdSetIterator
org.apache.lucene.index.VectorValues

public abstract class VectorValues extends DocIdSetIterator
This class provides access to per-document floating point vector values indexed as KnnVectorField.
WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Field Details

    • MAX_DIMENSIONS

      public static final int MAX_DIMENSIONS
      The maximum length of a vector
      See Also:
    • EMPTY

      public static final VectorValues EMPTY
      Represents the lack of vector values. It is returned by providers that do not support VectorValues.
  • Constructor Details

    • VectorValues

      protected VectorValues()
      Sole constructor
  • Method Details

    • dimension

      public abstract int dimension()
      Return the dimension of the vectors
    • size

      public abstract int size()
      TODO: should we use cost() for this? We rely on its always being exactly the number of documents having a value for this field, which is not guaranteed by the cost() contract, but in all the implementations so far they are the same.
      Returns:
      the number of vectors returned by this iterator
    • vectorValue

      public abstract float[] vectorValue() throws IOException
      Return the vector value for the current document ID. It is illegal to call this method when the iterator is not positioned: before advancing, or after failing to advance. The returned array may be shared across calls, re-used, and modified as the iterator advances.
      Returns:
      the vector value
      Throws:
      IOException
    • binaryValue

      public BytesRef binaryValue() throws IOException
      Return the binary encoded vector value for the current document ID. These are the bytes corresponding to the float array return by vectorValue(). It is illegal to call this method when the iterator is not positioned: before advancing, or after failing to advance. The returned storage may be shared across calls, re-used and modified as the iterator advances.
      Returns:
      the binary value
      Throws:
      IOException