Parent / child queries should work with non-default similarities
This commit is contained in:
parent
244723d401
commit
74dd33689e
|
@ -95,6 +95,7 @@ public class ChildrenConstantScoreQuery extends Query {
|
|||
childQuery = rewrittenChildQuery;
|
||||
}
|
||||
IndexSearcher indexSearcher = new IndexSearcher(searcher.getIndexReader());
|
||||
indexSearcher.setSimilarity(searcher.getSimilarity());
|
||||
indexSearcher.search(childQuery, collector);
|
||||
|
||||
int remaining = collectedUids.v().size();
|
||||
|
|
|
@ -157,6 +157,7 @@ public class ChildrenQuery extends Query {
|
|||
childQuery = rewrittenChildQuery;
|
||||
}
|
||||
IndexSearcher indexSearcher = new IndexSearcher(searcher.getIndexReader());
|
||||
indexSearcher.setSimilarity(searcher.getSimilarity());
|
||||
indexSearcher.search(childQuery, collector);
|
||||
|
||||
int size = uidToScore.v().size();
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.lucene.index.AtomicReaderContext;
|
|||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.MultiReader;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.apache.lucene.search.similarities.Similarity;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
||||
|
@ -65,7 +66,9 @@ public class DeleteByQueryWrappingFilter extends Filter {
|
|||
try {
|
||||
if (!contains(indexReader, context)) {
|
||||
multiReader = new MultiReader(new IndexReader[]{indexReader, context.reader()}, false);
|
||||
Similarity similarity = searcher.getSimilarity();
|
||||
searcher = new IndexSearcher(new MultiReader(indexReader, context.reader()));
|
||||
searcher.setSimilarity(similarity);
|
||||
}
|
||||
weight = searcher.createNormalizedWeight(query);
|
||||
} finally {
|
||||
|
@ -78,7 +81,9 @@ public class DeleteByQueryWrappingFilter extends Filter {
|
|||
if (!contains(indexReader, context)) {
|
||||
IndexReader multiReader = new MultiReader(new IndexReader[]{indexReader, context.reader()}, false);
|
||||
try {
|
||||
Similarity similarity = searcher.getSimilarity();
|
||||
searcher = new IndexSearcher(multiReader);
|
||||
searcher.setSimilarity(similarity);
|
||||
weight = searcher.createNormalizedWeight(query);
|
||||
} finally {
|
||||
multiReader.close();
|
||||
|
|
|
@ -87,6 +87,7 @@ public class ParentConstantScoreQuery extends Query {
|
|||
parentQuery = rewrittenParentQuery = originalParentQuery.rewrite(searcher.getIndexReader());
|
||||
}
|
||||
IndexSearcher indexSearcher = new IndexSearcher(searcher.getIndexReader());
|
||||
indexSearcher.setSimilarity(searcher.getSimilarity());
|
||||
indexSearcher.search(parentQuery, collector);
|
||||
|
||||
if (parents.v().isEmpty()) {
|
||||
|
|
|
@ -129,6 +129,7 @@ public class ParentQuery extends Query {
|
|||
parentQuery = rewrittenParentQuery;
|
||||
}
|
||||
IndexSearcher indexSearcher = new IndexSearcher(searcher.getIndexReader());
|
||||
indexSearcher.setSimilarity(searcher.getSimilarity());
|
||||
indexSearcher.search(parentQuery, collector);
|
||||
|
||||
if (uidToScore.v().isEmpty()) {
|
||||
|
|
|
@ -124,6 +124,7 @@ public class TopChildrenQuery extends Query {
|
|||
}
|
||||
|
||||
IndexSearcher indexSearcher = new IndexSearcher(searcher.getIndexReader());
|
||||
indexSearcher.setSimilarity(searcher.getSimilarity());
|
||||
while (true) {
|
||||
parentDocs.v().clear();
|
||||
TopDocs topChildDocs = indexSearcher.search(childQuery, numChildDocs);
|
||||
|
|
Loading…
Reference in New Issue