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
FieldsModifier and TypeFieldDescriptionprotected final String
protected final Query
protected final KnnSearchStrategy
Fields inherited from class org.apache.lucene.search.KnnByteVectorQuery
target
-
Constructor Summary
ConstructorsConstructorDescriptionDiversifyingChildrenByteKnnVectorQuery
(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 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, sameClassAs, toString
-
Field Details
-
field
-
filter
-
searchStrategy
-
-
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.
-
DiversifyingChildrenByteKnnVectorQuery
public DiversifyingChildrenByteKnnVectorQuery(String field, byte[] query, Query childFilter, int k, BitSetProducer parentsFilter, KnnSearchStrategy searchStrategy) Create a DiversifyingChildrenByteKnnVectorQuery.- 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.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
-
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
-