Class KnnByteVectorQuery

Direct Known Subclasses:
DiversifyingChildrenByteKnnVectorQuery

public class KnnByteVectorQuery extends AbstractKnnVectorQuery
Uses KnnVectorsReader.search(String, byte[], KnnCollector, Bits) to perform nearest neighbour search.

This query also allows for performing a kNN search subject to a filter. In this case, it first executes the filter for each leaf, then chooses a strategy dynamically:

  • If the filter cost is less than k, just execute an exact search
  • Otherwise run a kNN search subject to the filter
  • If the kNN search visits too many vectors without completing, stop and run an exact search
  • Field Details

    • NO_RESULTS

      private static final TopDocs NO_RESULTS
    • target

      private final byte[] target
  • Constructor Details

    • KnnByteVectorQuery

      public KnnByteVectorQuery(String field, byte[] target, int k)
      Find the k nearest documents to the target vector according to the vectors in the given field. target vector.
      Parameters:
      field - a field that has been indexed as a KnnFloatVectorField.
      target - the target of the search
      k - the number of documents to find
      Throws:
      IllegalArgumentException - if k is less than 1
    • KnnByteVectorQuery

      public KnnByteVectorQuery(String field, byte[] target, int k, Query filter)
      Find the k nearest documents to the target vector according to the vectors in the given field. target vector.
      Parameters:
      field - a field that has been indexed as a KnnFloatVectorField.
      target - the target of the search
      k - the number of documents to find
      filter - a filter applied before the vector search
      Throws:
      IllegalArgumentException - if k is less than 1
  • Method Details