Class FlatVectorsReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Accountable
    Direct Known Subclasses:
    Lucene99FlatVectorsReader, Lucene99ScalarQuantizedVectorsReader

    public abstract class FlatVectorsReader
    extends java.lang.Object
    implements java.io.Closeable, Accountable
    Reads vectors from an index. When searching this reader, it iterates every vector in the index and scores them

    This class is useful when:

    • the number of vectors is small
    • when used along side some additional indexing structure that can be used to better search the vectors (like HNSW).
    • Field Detail

      • vectorScorer

        protected final FlatVectorsScorer vectorScorer
        Scorer for flat vectors
    • Constructor Detail

      • FlatVectorsReader

        protected FlatVectorsReader​(FlatVectorsScorer vectorsScorer)
        Sole constructor
    • Method Detail

      • getRandomVectorScorer

        public abstract RandomVectorScorer getRandomVectorScorer​(java.lang.String field,
                                                                 float[] target)
                                                          throws java.io.IOException
        Returns a RandomVectorScorer for the given field and target vector.
        Parameters:
        field - the field to search
        target - the target vector
        Returns:
        a RandomVectorScorer for the given field and target vector.
        Throws:
        java.io.IOException - if an I/O error occurs when reading from the index.
      • getRandomVectorScorer

        public abstract RandomVectorScorer getRandomVectorScorer​(java.lang.String field,
                                                                 byte[] target)
                                                          throws java.io.IOException
        Returns a RandomVectorScorer for the given field and target vector.
        Parameters:
        field - the field to search
        target - the target vector
        Returns:
        a RandomVectorScorer for the given field and target vector.
        Throws:
        java.io.IOException - if an I/O error occurs when reading from the index.
      • checkIntegrity

        public abstract void checkIntegrity()
                                     throws java.io.IOException
        Checks consistency of this reader.

        Note that this may be costly in terms of I/O, e.g. may involve computing a checksum value against large data files.

        Throws:
        java.io.IOException
      • getFloatVectorValues

        public abstract FloatVectorValues getFloatVectorValues​(java.lang.String field)
                                                        throws java.io.IOException
        Returns the FloatVectorValues for the given field. The behavior is undefined if the given field doesn't have KNN vectors enabled on its FieldInfo. The return value is never null.
        Throws:
        java.io.IOException
      • getByteVectorValues

        public abstract ByteVectorValues getByteVectorValues​(java.lang.String field)
                                                      throws java.io.IOException
        Returns the ByteVectorValues for the given field. The behavior is undefined if the given field doesn't have KNN vectors enabled on its FieldInfo. The return value is never null.
        Throws:
        java.io.IOException