mirror of https://github.com/apache/lucene.git
LUCENE-1299: Properly handle when IndexReader is not null and Field is in the spell checker
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@663649 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f89cda6dde
commit
8c97e9b87b
|
@ -117,6 +117,8 @@ Bug fixes
|
|||
11. LUCENE-1189: Fixed the QueryParser to handle escaped characters within
|
||||
quoted terms correctly. (Tomer Gabel via Michael Busch)
|
||||
|
||||
12. LUCENE-1299: Fixed NPE in SpellChecker when IndexReader is not null and field is (Grant Ingersoll)
|
||||
|
||||
New features
|
||||
|
||||
1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about a Token through the analysis
|
||||
|
|
|
@ -224,7 +224,7 @@ public class SpellChecker {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (ir != null) { // use the user index
|
||||
if (ir != null && field != null) { // use the user index
|
||||
sugWord.freq = ir.docFreq(new Term(field, sugWord.string)); // freq in the index
|
||||
// don't suggest a word that is not present in the field
|
||||
if ((morePopular && goalFreq > sugWord.freq) || sugWord.freq < 1) {
|
||||
|
|
|
@ -109,6 +109,14 @@ public class TestSpellChecker extends TestCase {
|
|||
|
||||
similar = spellChecker.suggestSimilar("tousand", 10, r, "field2", false);
|
||||
assertEquals(1, similar.length); // there is the term thousand in the field field2
|
||||
|
||||
try {
|
||||
similar = spellChecker.suggestSimilar("tousand", 10, r, null, false);
|
||||
} catch (NullPointerException e) {
|
||||
assertTrue("threw an NPE, and it shouldn't have", false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addwords(IndexReader r, String field) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue