Class DiversifyingChildrenByteKnnVectorQuery

java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.KnnByteVectorQuery
org.apache.lucene.search.join.DiversifyingChildrenByteKnnVectorQuery

public class DiversifyingChildrenByteKnnVectorQuery extends KnnByteVectorQuery
kNN byte vector query that joins matching children vector documents with their parent doc id. The top documents returned are the child document ids and the calculated scores. Here is how to use this in conjunction with ToParentBlockJoinQuery.
   Query knnQuery = new DiversifyingChildrenByteKnnVectorQuery(fieldName, queryVector, ...);
   // Rewrite executes kNN search and collects nearest children docIds and their scores
   Query rewrittenKnnQuery = searcher.rewrite(knnQuery);
   // Join the scored children docs with their parents and score the parents
   Query childrenToParents = new ToParentBlockJoinQuery(rewrittenKnnQuery, parentsFilter, ScoreMode.MAX);
 
  • Field Details

    • field

      protected final String field
    • filter

      protected final Query filter
    • searchStrategy

      protected final KnnSearchStrategy searchStrategy
  • Constructor Details

    • DiversifyingChildrenByteKnnVectorQuery

      public DiversifyingChildrenByteKnnVectorQuery(String field, byte[] query, Query childFilter, int k, BitSetProducer parentsFilter)
      Create a ToParentBlockJoinByteVectorQuery.
      Parameters:
      field - the query field
      query - the vector query
      childFilter - the child filter
      k - how many parent documents to return given the matching children
      parentsFilter - Filter identifying the parent documents.
    • DiversifyingChildrenByteKnnVectorQuery

      public DiversifyingChildrenByteKnnVectorQuery(String field, byte[] query, Query childFilter, int k, BitSetProducer parentsFilter, KnnSearchStrategy searchStrategy)
      Create a DiversifyingChildrenByteKnnVectorQuery.
      Parameters:
      field - the query field
      query - the vector query
      childFilter - the child filter
      k - how many parent documents to return given the matching children
      parentsFilter - Filter identifying the parent documents.
      searchStrategy - the search strategy to use. If null, the default strategy will be used. The underlying format may not support all strategies and is free to ignore the requested strategy.
      WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Method Details