lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r663649 - in /lucene/java/trunk: CHANGES.txt contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
Date Thu, 05 Jun 2008 16:12:08 GMT
Author: gsingers
Date: Thu Jun  5 09:12:08 2008
New Revision: 663649

URL: http://svn.apache.org/viewvc?rev=663649&view=rev
Log:
LUCENE-1299: Properly handle when IndexReader is not null and Field is in the spell checker

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
    lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=663649&r1=663648&r2=663649&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Thu Jun  5 09:12:08 2008
@@ -117,6 +117,8 @@
 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

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=663649&r1=663648&r2=663649&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
(original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
Thu Jun  5 09:12:08 2008
@@ -224,7 +224,7 @@
         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) {

Modified: lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=663649&r1=663648&r2=663649&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
(original)
+++ lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
Thu Jun  5 09:12:08 2008
@@ -109,6 +109,14 @@
 
     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 {



Mime
View raw message