Package org.apache.lucene.search.join
Class DiversifyingChildrenFloatKnnVectorQuery
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.lucene.search.KnnFloatVectorQuery
-
- org.apache.lucene.search.join.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 withToParentBlockJoinQuery
.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);
-
-
Constructor Summary
Constructors Constructor Description DiversifyingChildrenFloatKnnVectorQuery(String field, float[] query, Query childFilter, int k, BitSetProducer parentsFilter)
Create a ToParentBlockJoinFloatVectorQuery.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TopDocs
approximateSearch(LeafReaderContext context, Bits acceptDocs, int visitedLimit, KnnCollectorManager knnCollectorManager)
boolean
equals(Object o)
protected TopDocs
exactSearch(LeafReaderContext context, DocIdSetIterator acceptIterator)
String
getField()
Query
getFilter()
int
getK()
protected KnnCollectorManager
getKnnCollectorManager(int k, IndexSearcher searcher)
int
hashCode()
protected TopDocs
mergeLeafResults(TopDocs[] arg0)
Query
rewrite(IndexSearcher arg0)
String
toString(String field)
void
visit(QueryVisitor arg0)
-
Methods inherited from class org.apache.lucene.search.KnnFloatVectorQuery
getTargetCopy
-
Methods inherited from class org.apache.lucene.search.Query
classHash, createWeight, rewrite, sameClassAs, toString
-
-
-
-
Field Detail
-
field
protected final String field
-
-
Constructor Detail
-
DiversifyingChildrenFloatKnnVectorQuery
public DiversifyingChildrenFloatKnnVectorQuery(String field, float[] query, Query childFilter, int k, BitSetProducer parentsFilter)
Create a ToParentBlockJoinFloatVectorQuery.- 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 Detail
-
exactSearch
protected TopDocs exactSearch(LeafReaderContext context, DocIdSetIterator acceptIterator) throws IOException
- Throws:
IOException
-
getKnnCollectorManager
protected KnnCollectorManager getKnnCollectorManager(int k, IndexSearcher searcher)
-
approximateSearch
protected TopDocs approximateSearch(LeafReaderContext context, Bits acceptDocs, int visitedLimit, KnnCollectorManager knnCollectorManager) throws IOException
- Overrides:
approximateSearch
in classKnnFloatVectorQuery
- Throws:
IOException
-
toString
public String toString(String field)
- Overrides:
toString
in classKnnFloatVectorQuery
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classKnnFloatVectorQuery
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classKnnFloatVectorQuery
-
rewrite
public Query rewrite(IndexSearcher arg0) throws IOException
- Overrides:
rewrite
in classQuery
- Throws:
IOException
-
visit
public void visit(QueryVisitor arg0)
-
getField
public String getField()
-
getK
public int getK()
-
getFilter
public Query getFilter()
-
-