mirror of
https://github.com/apache/lucene.git
synced 2025-02-09 11:35:14 +00:00
SOLR-12284: Stop adding parenthesis to word-break suggestions, unless query uses boolean operators.
This commit is contained in:
parent
871ffbe10e
commit
d92b891f95
@ -194,6 +194,9 @@ Bug Fixes
|
|||||||
* SOLR-12275: wrong caching for {!filters} as well as for `filters` local param in {!parent} and {!child}
|
* SOLR-12275: wrong caching for {!filters} as well as for `filters` local param in {!parent} and {!child}
|
||||||
(David Smiley, Mikhail Khluldnev)
|
(David Smiley, Mikhail Khluldnev)
|
||||||
|
|
||||||
|
* SOLR-12284: WordBreakSolrSpellchecker will no longer add parenthesis in collations when breaking words in
|
||||||
|
non-boolean queries. (James Dyer)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -222,7 +222,6 @@ public class SpellCheckCollator {
|
|||||||
//If the correction contains whitespace (because it involved breaking a word in 2+ words),
|
//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.
|
//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) {
|
while(indexOfSpace>-1 && indexOfSpace<corr.length()-1) {
|
||||||
addParenthesis = true;
|
|
||||||
char previousChar = tok.startOffset()>0 ? origQuery.charAt(tok.startOffset()-1) : ' ';
|
char previousChar = tok.startOffset()>0 ? origQuery.charAt(tok.startOffset()-1) : ' ';
|
||||||
if(previousChar=='-' || previousChar=='+') {
|
if(previousChar=='-' || previousChar=='+') {
|
||||||
corrSb.insert(indexOfSpace + bump, previousChar);
|
corrSb.insert(indexOfSpace + bump, previousChar);
|
||||||
@ -231,6 +230,7 @@ public class SpellCheckCollator {
|
|||||||
}
|
}
|
||||||
bump++;
|
bump++;
|
||||||
} else if ((tok.getFlags() & QueryConverter.TERM_IN_BOOLEAN_QUERY_FLAG) == QueryConverter.TERM_IN_BOOLEAN_QUERY_FLAG) {
|
} else if ((tok.getFlags() & QueryConverter.TERM_IN_BOOLEAN_QUERY_FLAG) == QueryConverter.TERM_IN_BOOLEAN_QUERY_FLAG) {
|
||||||
|
addParenthesis = true;
|
||||||
corrSb.insert(indexOfSpace + bump, "AND ");
|
corrSb.insert(indexOfSpace + bump, "AND ");
|
||||||
bump += 4;
|
bump += 4;
|
||||||
}
|
}
|
||||||
|
@ -234,13 +234,13 @@ public class WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
|
|||||||
"//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:(printable line ample goodness)'",
|
"//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'][2 ]/str[@name='collationQuery']='lowerfilt:(paintablepine ample goodness)'",
|
||||||
"//lst[@name='collation'][3 ]/str[@name='collationQuery']='lowerfilt:(printable pineapple 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'][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'][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'][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'][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'][8 ]/str[@name='collationQuery']='lowerfilt:(pintable line ample goodness)'",
|
||||||
"//lst[@name='collation'][9 ]/str[@name='collationQuery']='lowerfilt:(pintable pineapple 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='paintable']='pintable'",
|
||||||
"//lst[@name='collation'][10]/lst[@name='misspellingsAndCorrections']/str[@name='pine']='pi ne'",
|
"//lst[@name='collation'][10]/lst[@name='misspellingsAndCorrections']/str[@name='pine']='pi ne'",
|
||||||
"//lst[@name='collation'][10]/lst[@name='misspellingsAndCorrections']/str[@name='apple']='ample'",
|
"//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_COLLATE_EXTENDED_RESULTS, "true",
|
||||||
SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "10"),
|
SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "10"),
|
||||||
"//lst[@name='collation'][1 ]/str[@name='collationQuery']='lowerfilt:(+line -ample)'",
|
"//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(
|
assertQ(req(
|
||||||
"q", "lowerfilt:(+printableinpuntableplantable)",
|
"q", "lowerfilt:(+printableinpuntableplantable)",
|
||||||
@ -309,7 +309,7 @@ public class WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
|
|||||||
SpellCheckComponent.SPELLCHECK_COLLATE, "true",
|
SpellCheckComponent.SPELLCHECK_COLLATE, "true",
|
||||||
SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true",
|
SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true",
|
||||||
SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1"),
|
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(
|
assertQ(req(
|
||||||
"q", "zxcv AND qwtp AND fghj",
|
"q", "zxcv AND qwtp AND fghj",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user