You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jd...@apache.org on 2013/07/25 18:04:04 UTC

svn commit: r1507042 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/spelling/SpellCheckCollator.java core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java

Author: jdyer
Date: Thu Jul 25 16:04:03 2013
New Revision: 1507042

URL: http://svn.apache.org/r1507042
Log:
SOLR-4489: fix StringIndexOutOfBoundsException in SpellCheckComponent

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1507042&r1=1507041&r2=1507042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Thu Jul 25 16:04:03 2013
@@ -69,6 +69,10 @@ Bug Fixes
 
 * SOLR-3633 - web UI reports an error if CoreAdminHandler says there are no 
   SolrCores (steffkes)
+  
+* SOLR-4489 - SpellCheckComponent can throw StringIndexOutOfBoundsException
+  when generating collations involving multiple word-break corrections.
+  (James Dyer)
 
 Optimizations
 ----------------------

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java?rev=1507042&r1=1507041&r2=1507042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/SpellCheckCollator.java Thu Jul 25 16:04:03 2013
@@ -202,7 +202,7 @@ public class SpellCheckCollator {
       //then be sure all of the new words have the same optional/required/prohibited status in the query.
       while(indexOfSpace>-1 && indexOfSpace<corr.length()-1) {
         addParenthesis = true;
-        char previousChar = tok.startOffset()>0 ? collation.charAt(tok.startOffset()-1) : ' ';
+        char previousChar = tok.startOffset()>0 ? origQuery.charAt(tok.startOffset()-1) : ' ';
         if(previousChar=='-' || previousChar=='+') {
           corrSb.insert(indexOfSpace + bump, previousChar);
           if(requiredOrProhibited==null) {

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java?rev=1507042&r1=1507041&r2=1507042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java Thu Jul 25 16:04:03 2013
@@ -44,6 +44,7 @@ public class WordBreakSolrSpellCheckerTe
     assertNull(h.validateUpdate(adoc("id", "4", "lowerfilt", "printable in pointable paint able")));
     assertNull(h.validateUpdate(adoc("id", "5", "lowerfilt", "printable in puntable paint able ")));
     assertNull(h.validateUpdate(adoc("id", "6", "lowerfilt", "paint able in pintable plantable")));
+    assertNull(h.validateUpdate(adoc("id", "7", "lowerfilt", "zxcvqwtp fg hj")));
     assertNull(h.validateUpdate(commit()));    
     //docfreq=7:  in
     //docfreq=5:  able
@@ -277,6 +278,21 @@ public class WordBreakSolrSpellCheckerTe
         SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true",
         SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1"),
         "//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:((+printable +in +puntable +plantable))'"
-    );    
+    );
+    assertQ(req(
+        "q", "zxcv AND qwtp AND fghj", 
+        "qt", "spellCheckWithWordbreak",
+        "defType", "edismax",
+        "qf", "lowerfilt",
+        "indent", "true",
+        SpellCheckComponent.SPELLCHECK_BUILD, "true",
+        SpellCheckComponent.COMPONENT_NAME, "true", 
+        SpellCheckComponent.SPELLCHECK_ACCURACY, ".75", 
+        SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true",
+        SpellCheckComponent.SPELLCHECK_COLLATE, "true",
+        SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true",
+        SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "10"),
+        "//lst[@name='collation'][1 ]/str[@name='collationQuery']='zxcvqwtp AND (fg AND hj)'"
+    ); 
   }
 }