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
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
-
Constructor Summary
ConstructorDescriptionDiversifyingChildrenByteKnnVectorQuery
(String field, byte[] query, Query childFilter, int k, BitSetProducer parentsFilter) Create a ToParentBlockJoinByteVectorQuery. -
Method Summary
Modifier and TypeMethodDescriptionprotected TopDocs
approximateSearch
(LeafReaderContext context, Bits acceptDocs, int visitedLimit, KnnCollectorManager knnCollectorManager) boolean
protected TopDocs
exactSearch
(LeafReaderContext context, DocIdSetIterator acceptIterator, QueryTimeout queryTimeout) getField()
int
getK()
protected KnnCollectorManager
getKnnCollectorManager
(int k, IndexSearcher searcher) int
hashCode()
protected TopDocs
mergeLeafResults
(TopDocs[] arg0) rewrite
(IndexSearcher arg0) 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, rewrite, sameClassAs, toString
-
Field Details
-
field
-
-
Constructor Details
-
DiversifyingChildrenByteKnnVectorQuery
public DiversifyingChildrenByteKnnVectorQuery(String field, byte[] query, Query childFilter, int k, BitSetProducer parentsFilter) Create a ToParentBlockJoinByteVectorQuery.- Parameters:
field
- the query fieldquery
- the vector querychildFilter
- the child filterk
- how many parent documents to return given the matching childrenparentsFilter
- Filter identifying the parent documents.
-
-
Method Details
-
exactSearch
protected TopDocs exactSearch(LeafReaderContext context, DocIdSetIterator acceptIterator, QueryTimeout queryTimeout) throws IOException - Throws:
IOException
-
getKnnCollectorManager
-
approximateSearch
protected TopDocs approximateSearch(LeafReaderContext context, Bits acceptDocs, int visitedLimit, KnnCollectorManager knnCollectorManager) throws IOException - Overrides:
approximateSearch
in classKnnByteVectorQuery
- Throws:
IOException
-
toString
- Overrides:
toString
in classKnnByteVectorQuery
-
equals
- Overrides:
equals
in classKnnByteVectorQuery
-
hashCode
public int hashCode()- Overrides:
hashCode
in classKnnByteVectorQuery
-
rewrite
- Overrides:
rewrite
in classQuery
- Throws:
IOException
-
mergeLeafResults
-
visit
-
getField
-
getK
public int getK() -
getFilter
-