mirror of https://github.com/apache/lucene.git
LUCENE-5354: BlendedInfixSuggester: fix wrong return (0 instead of -1) from the LookupResult comparator
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1558100 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fd3a43e32a
commit
20461c9010
|
@ -276,7 +276,7 @@ public class BlendedInfixSuggester extends AnalyzingInfixSuggester {
|
||||||
if (o1.value > o2.value) {
|
if (o1.value > o2.value) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (o1.value < o2.value) {
|
} else if (o1.value < o2.value) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise on alphabetic order
|
// otherwise on alphabetic order
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
BytesRef ret = new BytesRef("ret");
|
BytesRef ret = new BytesRef("ret");
|
||||||
|
|
||||||
Input keys[] = new Input[]{
|
Input keys[] = new Input[]{
|
||||||
new Input("top of the lake", 15, lake),
|
new Input("top of the lake", 18, lake),
|
||||||
new Input("star wars: episode v - the empire strikes back", 12, star),
|
new Input("star wars: episode v - the empire strikes back", 12, star),
|
||||||
new Input("the returned", 10, ret),
|
new Input("the returned", 10, ret),
|
||||||
};
|
};
|
||||||
|
@ -152,13 +152,19 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
return newFSDirectory(path);
|
return newFSDirectory(path);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
suggester.build(new InputArrayIterator(keys));
|
suggester.build(new InputArrayIterator(keys));
|
||||||
|
|
||||||
long w0 = getInResults(suggester, "the", ret, 2);
|
|
||||||
assertTrue(w0 < 1);
|
|
||||||
|
|
||||||
|
// we don't find it for in the 2 first
|
||||||
|
assertEquals(2, suggester.lookup("the", 2, true, false).size());
|
||||||
|
long w0 = getInResults(suggester, "the", ret, 2);
|
||||||
|
assertTrue(w0 < 0);
|
||||||
|
|
||||||
|
// but it's there if we search for 3 elements
|
||||||
|
assertEquals(3, suggester.lookup("the", 3, true, false).size());
|
||||||
long w1 = getInResults(suggester, "the", ret, 3);
|
long w1 = getInResults(suggester, "the", ret, 3);
|
||||||
assertTrue(w1 > 1);
|
assertTrue(w1 > 0);
|
||||||
|
|
||||||
suggester.close();
|
suggester.close();
|
||||||
|
|
||||||
|
@ -172,11 +178,13 @@ public class BlendedInfixSuggesterTest extends LuceneTestCase {
|
||||||
};
|
};
|
||||||
suggester.build(new InputArrayIterator(keys));
|
suggester.build(new InputArrayIterator(keys));
|
||||||
|
|
||||||
|
// we have it
|
||||||
long w2 = getInResults(suggester, "the", ret, 2);
|
long w2 = getInResults(suggester, "the", ret, 2);
|
||||||
assertTrue(w2 > 1);
|
assertTrue(w2 > 0);
|
||||||
|
|
||||||
|
// but we don't have the other
|
||||||
long w3 = getInResults(suggester, "the", star, 2);
|
long w3 = getInResults(suggester, "the", star, 2);
|
||||||
assertTrue(w3 < 1);
|
assertTrue(w3 < 0);
|
||||||
|
|
||||||
suggester.close();
|
suggester.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue