SOLR-12284: Stop adding parenthesis to word-break suggestions, unless query uses boolean operators.

This commit is contained in:
jdyer1 2018-04-30 13:47:19 -05:00
parent 871ffbe10e
commit d92b891f95
3 changed files with 12 additions and 9 deletions

View File

@ -194,6 +194,9 @@ Bug Fixes
* SOLR-12275: wrong caching for {!filters} as well as for `filters` local param in {!parent} and {!child}
(David Smiley, Mikhail Khluldnev)
* SOLR-12284: WordBreakSolrSpellchecker will no longer add parenthesis in collations when breaking words in
non-boolean queries. (James Dyer)
Optimizations
----------------------

View File

@ -222,7 +222,6 @@ public class SpellCheckCollator {
//If the correction contains whitespace (because it involved breaking a word in 2+ words),
//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 ? origQuery.charAt(tok.startOffset()-1) : ' ';
if(previousChar=='-' || previousChar=='+') {
corrSb.insert(indexOfSpace + bump, previousChar);
@ -231,6 +230,7 @@ public class SpellCheckCollator {
}
bump++;
} else if ((tok.getFlags() & QueryConverter.TERM_IN_BOOLEAN_QUERY_FLAG) == QueryConverter.TERM_IN_BOOLEAN_QUERY_FLAG) {
addParenthesis = true;
corrSb.insert(indexOfSpace + bump, "AND ");
bump += 4;
}

View File

@ -234,13 +234,13 @@ public class WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
"//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:(printable line ample goodness)'",
"//lst[@name='collation'][2 ]/str[@name='collationQuery']='lowerfilt:(paintablepine ample goodness)'",
"//lst[@name='collation'][3 ]/str[@name='collationQuery']='lowerfilt:(printable pineapple goodness)'",
"//lst[@name='collation'][4 ]/str[@name='collationQuery']='lowerfilt:((paint able) line ample goodness)'",
"//lst[@name='collation'][5 ]/str[@name='collationQuery']='lowerfilt:(printable (pi ne) ample goodness)'",
"//lst[@name='collation'][6 ]/str[@name='collationQuery']='lowerfilt:((paint able) pineapple goodness)'",
"//lst[@name='collation'][7 ]/str[@name='collationQuery']='lowerfilt:((paint able) (pi ne) ample goodness)'",
"//lst[@name='collation'][4 ]/str[@name='collationQuery']='lowerfilt:(paint able line ample goodness)'",
"//lst[@name='collation'][5 ]/str[@name='collationQuery']='lowerfilt:(printable pi ne ample goodness)'",
"//lst[@name='collation'][6 ]/str[@name='collationQuery']='lowerfilt:(paint able pineapple goodness)'",
"//lst[@name='collation'][7 ]/str[@name='collationQuery']='lowerfilt:(paint able pi ne ample goodness)'",
"//lst[@name='collation'][8 ]/str[@name='collationQuery']='lowerfilt:(pintable line ample goodness)'",
"//lst[@name='collation'][9 ]/str[@name='collationQuery']='lowerfilt:(pintable pineapple goodness)'",
"//lst[@name='collation'][10]/str[@name='collationQuery']='lowerfilt:(pintable (pi ne) ample goodness)'",
"//lst[@name='collation'][10]/str[@name='collationQuery']='lowerfilt:(pintable pi ne ample goodness)'",
"//lst[@name='collation'][10]/lst[@name='misspellingsAndCorrections']/str[@name='paintable']='pintable'",
"//lst[@name='collation'][10]/lst[@name='misspellingsAndCorrections']/str[@name='pine']='pi ne'",
"//lst[@name='collation'][10]/lst[@name='misspellingsAndCorrections']/str[@name='apple']='ample'",
@ -297,7 +297,7 @@ public class WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true",
SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "10"),
"//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:(+line -ample)'",
"//lst[@name='collation'][2 ]/str[@name='collationQuery']='lowerfilt:((+pi +ne) -ample)'"
"//lst[@name='collation'][2 ]/str[@name='collationQuery']='lowerfilt:(+pi +ne -ample)'"
);
assertQ(req(
"q", "lowerfilt:(+printableinpuntableplantable)",
@ -309,7 +309,7 @@ public class WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
SpellCheckComponent.SPELLCHECK_COLLATE, "true",
SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true",
SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1"),
"//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:((+printable +in +puntable +plantable))'"
"//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:(+printable +in +puntable +plantable)'"
);
assertQ(req(
"q", "zxcv AND qwtp AND fghj",