Module org.apache.lucene.join
Package org.apache.lucene.search.join
Class DiversifyingChildrenByteKnnVectorQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.AbstractKnnVectorQuery
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 TypeFieldDescriptionprivate final Queryprivate final intprivate static final TopDocsprivate final BitSetProducerprivate final byte[]Fields inherited from class org.apache.lucene.search.AbstractKnnVectorQuery
field -
Constructor Summary
ConstructorsConstructorDescriptionDiversifyingChildrenByteKnnVectorQuery(String field, byte[] query, Query childFilter, int k, BitSetProducer parentsFilter) Create a ToParentBlockJoinByteVectorQuery. -
Method Summary
Modifier and TypeMethodDescriptionprotected TopDocsapproximateSearch(LeafReaderContext context, Bits acceptDocs, int visitedLimit, KnnCollectorManager knnCollectorManager) booleanOverride and implement query instance equivalence properly in a subclass.protected TopDocsexactSearch(LeafReaderContext context, DocIdSetIterator acceptIterator, QueryTimeout queryTimeout) protected KnnCollectorManagergetKnnCollectorManager(int k, IndexSearcher searcher) inthashCode()Override and implement query hash code properly in a subclass.Prints a query to a string, withfieldassumed to be the default field and omitted.Methods inherited from class org.apache.lucene.search.KnnByteVectorQuery
getTargetCopyMethods inherited from class org.apache.lucene.search.AbstractKnnVectorQuery
getField, getFilter, getK, mergeLeafResults, rewrite, visitMethods inherited from class org.apache.lucene.search.Query
classHash, createWeight, rewrite, sameClassAs, toString
-
Field Details
-
NO_RESULTS
-
parentsFilter
-
childFilter
-
k
private final int k -
query
private final byte[] query
-
-
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 - Overrides:
exactSearchin classAbstractKnnVectorQuery- Throws:
IOException
-
getKnnCollectorManager
- Overrides:
getKnnCollectorManagerin classAbstractKnnVectorQuery
-
approximateSearch
protected TopDocs approximateSearch(LeafReaderContext context, Bits acceptDocs, int visitedLimit, KnnCollectorManager knnCollectorManager) throws IOException - Overrides:
approximateSearchin classKnnByteVectorQuery- Throws:
IOException
-
toString
Description copied from class:QueryPrints a query to a string, withfieldassumed to be the default field and omitted.- Overrides:
toStringin classKnnByteVectorQuery
-
equals
Description copied from class:QueryOverride and implement query instance equivalence properly in a subclass. This is required so thatQueryCacheworks properly.Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical to those of the other instance. Utility methods are provided for certain repetitive code.
- Overrides:
equalsin classKnnByteVectorQuery- See Also:
-
hashCode
public int hashCode()Description copied from class:QueryOverride and implement query hash code properly in a subclass. This is required so thatQueryCacheworks properly.- Overrides:
hashCodein classKnnByteVectorQuery- See Also:
-