DiversifyingChildrenByteKnnVectorQuery (Lucene 10.5.0 join API)
Description: declaration: package: org.apache.lucene.search.join, class: DiversifyingChildrenByteKnnVectorQuery

Package org.apache.lucene.search.join

# 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 Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final String`
  `field`
  `protected final Query`
  `filter`
  `protected final KnnSearchStrategy`
  `searchStrategy`

  ### Fields inherited from class org.apache.lucene.search.KnnByteVectorQuery

  `target`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DiversifyingChildrenByteKnnVectorQuery(String field, byte[] query, Query childFilter, int k, BitSetProducer parentsFilter)`
  Create a ToParentBlockJoinByteVectorQuery.
  `DiversifyingChildrenByteKnnVectorQuery(String field, byte[] query, Query childFilter, int k, BitSetProducer parentsFilter, KnnSearchStrategy searchStrategy)`
  Create a DiversifyingChildrenByteKnnVectorQuery.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected TopDocs`
  `approximateSearch(LeafReaderContext context, AcceptDocs acceptDocs, int visitedLimit, KnnCollectorManager knnCollectorManager)`
  `boolean`
  `equals(Object o)`
  `protected TopDocs`
  `exactSearch(LeafReaderContext context, DocIdSetIterator acceptIterator, QueryTimeout queryTimeout)`
  `String`
  `getField()`
  `Query`
  `getFilter()`
  `int`
  `getK()`
  `protected KnnCollectorManager`
  `getKnnCollectorManager(int k, IndexSearcher searcher)`
  `KnnSearchStrategy`
  `getSearchStrategy()`
  `int`
  `hashCode()`
  `protected TopDocs`
  `mergeLeafResults(TopDocs[] arg0)`
  `Query`
  `rewrite(IndexSearcher arg0)`
  `protected TopDocs`
  `searchLeaf(LeafReaderContext arg0, Weight arg1, TimeLimitingKnnCollectorManager arg2)`
  `String`
  `toString(String field)`
  `void`
  `visit(QueryVisitor arg0)`

  ### Methods inherited from class org.apache.lucene.search.KnnByteVectorQuery

  `getTargetCopy`

  ### Methods inherited from class org.apache.lucene.search.Query

  `classHash, createWeight, sameClassAs, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## 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

  - ### exactSearch

    protected TopDocs exactSearch(LeafReaderContext context, DocIdSetIterator acceptIterator, QueryTimeout queryTimeout) throws IOException
    Throws:
      `IOException`

  - ### getKnnCollectorManager

    protected KnnCollectorManager getKnnCollectorManager(int k, IndexSearcher searcher)

  - ### approximateSearch

    protected TopDocs approximateSearch(LeafReaderContext context, AcceptDocs acceptDocs, int visitedLimit, KnnCollectorManager knnCollectorManager) throws IOException
    Overrides:
      `approximateSearch` in class `KnnByteVectorQuery`
    Throws:
      `IOException`

  - ### toString

    public String toString(String field)
    Overrides:
      `toString` in class `KnnByteVectorQuery`

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `KnnByteVectorQuery`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `KnnByteVectorQuery`

  - ### rewrite

    public Query rewrite(IndexSearcher arg0) throws IOException
    Overrides:
      `rewrite` in class `Query`
    Throws:
      `IOException`

  - ### searchLeaf

    protected TopDocs searchLeaf(LeafReaderContext arg0, Weight arg1, TimeLimitingKnnCollectorManager arg2) throws IOException
    Throws:
      `IOException`

  - ### mergeLeafResults

    protected TopDocs mergeLeafResults(TopDocs[] arg0)

  - ### visit

    public void visit(QueryVisitor arg0)
    Specified by:
      `visit` in class `Query`

  - ### getField

    public String getField()

  - ### getK

    public int getK()

  - ### getFilter

    public Query getFilter()

  - ### getSearchStrategy

    public KnnSearchStrategy getSearchStrategy()