mirror of https://github.com/apache/lucene.git
LUCENE-6510: take path boosts into account when polling TopNSearcher queue
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1682290 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bc636dea84
commit
40f3361338
|
@ -273,7 +273,7 @@ public final class Util {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "input=" + input + " cost=" + cost + "context=" + context + "boost=" + boost;
|
||||
return "input=" + input.get() + " cost=" + cost + "context=" + context + "boost=" + boost;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,8 @@ public final class Util {
|
|||
|
||||
private final FST.Arc<T> scratchArc = new FST.Arc<>();
|
||||
|
||||
final Comparator<T> comparator;
|
||||
private final Comparator<T> comparator;
|
||||
private final Comparator<FSTPath<T>> pathComparator;
|
||||
|
||||
TreeSet<FSTPath<T>> queue = null;
|
||||
|
||||
|
@ -329,7 +330,7 @@ public final class Util {
|
|||
this.topN = topN;
|
||||
this.maxQueueDepth = maxQueueDepth;
|
||||
this.comparator = comparator;
|
||||
|
||||
this.pathComparator = pathComparator;
|
||||
queue = new TreeSet<>(pathComparator);
|
||||
}
|
||||
|
||||
|
@ -343,7 +344,7 @@ public final class Util {
|
|||
|
||||
if (queue.size() == maxQueueDepth) {
|
||||
FSTPath<T> bottom = queue.last();
|
||||
int comp = comparator.compare(cost, bottom.cost);
|
||||
int comp = pathComparator.compare(path, bottom);
|
||||
if (comp > 0) {
|
||||
// Doesn't compete
|
||||
return;
|
||||
|
|
|
@ -478,7 +478,7 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
@Test
|
||||
public void testRandomContextQueryScoring() throws Exception {
|
||||
Analyzer analyzer = new MockAnalyzer(random());
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"));
|
||||
try(RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"))) {
|
||||
int numSuggestions = atLeast(20);
|
||||
int numContexts = atLeast(5);
|
||||
|
||||
|
@ -518,7 +518,7 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
}
|
||||
});
|
||||
|
||||
DirectoryReader reader = iw.getReader();
|
||||
try(DirectoryReader reader = iw.getReader()) {
|
||||
SuggestIndexSearcher suggestIndexSearcher = new SuggestIndexSearcher(reader);
|
||||
ContextQuery query = new ContextQuery(new PrefixCompletionQuery(analyzer, new Term("suggest_field", "sugg")));
|
||||
for (int i = 0; i < contexts.size(); i++) {
|
||||
|
@ -526,8 +526,7 @@ public class TestContextQuery extends LuceneTestCase {
|
|||
}
|
||||
TopSuggestDocs suggest = suggestIndexSearcher.suggest(query, 4);
|
||||
assertSuggestions(suggest, Arrays.copyOfRange(expectedResults, 0, 4));
|
||||
|
||||
reader.close();
|
||||
iw.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue