fix lookupWord false positive

This commit is contained in:
Peter Gromov 2021-03-08 08:49:27 +01:00
parent 7b048c5610
commit 469cfc67d4
3 changed files with 6 additions and 1 deletions

View File

@ -191,7 +191,7 @@ class WordStorage {
return i == 0;
}
}
return length == 0;
return length == 0 && dataPos == 0;
}
private void readForms(IntsRef forms, ByteArrayDataInput in, int length) {

View File

@ -50,6 +50,10 @@ public class TestDictionary extends LuceneTestCase {
assertNotNull(ordList);
assertEquals(1, ordList.length);
assertEquals('A', assertSingleFlag(dictionary, ordList));
assertNotNull(dictionary.lookupWord(new char[] {'a', 'b'}, 0, 2));
assertNotNull(dictionary.lookupWord(new char[] {'d', 'b'}, 0, 2));
assertNull(dictionary.lookupWord(new char[] {'b'}, 0, 1));
}
private static char assertSingleFlag(Dictionary dictionary, IntsRef ordList) {

View File

@ -8,3 +8,4 @@ lucene
mahout/A
moo/E
olr/B
db