Class DiversifyingChildrenFloatKnnVectorQuery


  • public class DiversifyingChildrenFloatKnnVectorQuery
    extends KnnFloatVectorQuery
    kNN float 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 DiversifyingChildrenFloatKnnVectorQuery(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 Detail

      • NO_RESULTS

        private static final TopDocs NO_RESULTS
      • childFilter

        private final Query childFilter
      • k

        private final int k
      • query

        private final float[] query
    • Constructor Detail

      • DiversifyingChildrenFloatKnnVectorQuery

        public DiversifyingChildrenFloatKnnVectorQuery​(java.lang.String field,
                                                       float[] query,
                                                       Query childFilter,
                                                       int k,
                                                       BitSetProducer parentsFilter)
        Create a ToParentBlockJoinFloatVectorQuery.
        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.