lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1025781 - in /lucene/dev/trunk/solr: CHANGES.txt src/java/org/apache/solr/spelling/suggest/Suggester.java src/test/org/apache/solr/spelling/suggest/SuggesterTest.java
Date Wed, 20 Oct 2010 22:16:14 GMT
Author: ab
Date: Wed Oct 20 22:16:14 2010
New Revision: 1025781

URL: http://svn.apache.org/viewvc?rev=1025781&view=rev
Log:
SOLR-2173 Suggester should always rebuild Lookup data if Lookup.load fails.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1025781&r1=1025780&r2=1025781&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Oct 20 22:16:14 2010
@@ -529,6 +529,8 @@ Bug Fixes
 
 * SOLR-1794: Dataimport of CLOB fields fails when getCharacterStream() is 
   defined in a superclass. (Gunnar Gauslaa Bergem via rmuir)
+
+* SOLR-2173 Suggester should always rebuild Lookup data if Lookup.load fails. (ab)
   
 Other Changes
 ----------------------

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java?rev=1025781&r1=1025780&r2=1025781&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/spelling/suggest/Suggester.java Wed Oct
20 22:16:14 2010
@@ -129,20 +129,10 @@ public class Suggester extends SolrSpell
       if (lookup.load(storeDir)) {
         return;  // loaded ok
       }
+      LOG.debug("load failed, need to build Lookup again");
     }
-    // dictionary based on the current index may need refreshing
-    if (dictionary instanceof HighFrequencyDictionary) {
-      reader = reader.reopen();
-      dictionary = new HighFrequencyDictionary(reader, field, threshold);
-      try {
-        lookup.build(dictionary);
-        if (storeDir != null) {
-          lookup.store(storeDir);
-        }
-      } catch (Exception e) {
-        throw new IOException(e);
-      }
-    }
+    // loading was unsuccessful - build it again
+    build(core, searcher);
   }
 
   public void add(String query, int numHits) {

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java?rev=1025781&r1=1025780&r2=1025781&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java Wed
Oct 20 22:16:14 2010
@@ -62,6 +62,20 @@ public class SuggesterTest extends SolrT
         "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/arr[@name='suggestion']/str[2][.='accommodate']"
     );
   }
+  
+  @Test
+  public void testReload() throws Exception {
+    addDocs();
+    assertU(commit());
+    assertQ(req("qt","/suggest", "q","ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR,
"true"),
+        "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/int[@name='numFound'][.='2']");
+    assertU(adoc("id", "4",
+        "text", "actually"
+       ));
+    assertU(commit());
+    assertQ(req("qt","/suggest", "q","ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR,
"true"),
+    "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/int[@name='numFound'][.='2']");
+  }
 
   
   private TermFreqIterator getTFIT() {



Mime
View raw message