mirror of https://github.com/apache/lucene.git
SOLR-4489: fix StringIndexOutOfBoundsException in SpellCheckComponent
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1507042 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
213dacd8d9
commit
e4cba1525b
|
@ -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
|
||||
----------------------
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -44,6 +44,7 @@ public class WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
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 WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
|
|||
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)'"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue