mirror of https://github.com/apache/lucene.git
SOLR-10323: fix to SpellingQueryConverter to properly strip out colons in field-specific queries
This commit is contained in:
parent
53aeffade5
commit
e75a2e6b86
|
@ -160,6 +160,9 @@ Bug Fixes
|
|||
* SOLR-10387: zkTransfer normalizes destination path incorrectly if source is a windows directory
|
||||
(gopikannan venugopalsamy, Erick Erickson)
|
||||
|
||||
* SOLR-10323: fix to SpellingQueryConverter to properly strip out colons in field-specific queries.
|
||||
(Amrit Sarkar via James Dyer)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class SpellingQueryConverter extends QueryConverter {
|
|||
NMTOKEN = "([" + sb.toString() + "]|" + SURROGATE_PAIR + ")+";
|
||||
}
|
||||
|
||||
final static String PATTERN = "(?:(?!(" + NMTOKEN + ":|[\\^.]\\d+)))[^^.\\s][\\p{L}_\\-0-9]+";
|
||||
final static String PATTERN = "(?:(?!(" + NMTOKEN + ":|[\\^.]\\d+)))[^^.:(\\s][\\p{L}_\\-0-9]+";
|
||||
// previous version: Pattern.compile("(?:(?!(\\w+:|\\d+)))\\w+");
|
||||
protected Pattern QUERY_REGEX = Pattern.compile(PATTERN);
|
||||
|
||||
|
|
|
@ -94,6 +94,16 @@ public class SpellingQueryConverterTest extends LuceneTestCase {
|
|||
assertTrue("tokens is null and it shouldn't be", tokens != null);
|
||||
assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
|
||||
assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
|
||||
|
||||
String firstKeyword = "value1";
|
||||
String secondKeyword = "value2";
|
||||
original = "field-with-parenthesis:(" + firstKeyword + " " + secondKeyword + ")";
|
||||
tokens = converter.convert(original);
|
||||
assertTrue("tokens is null and it shouldn't be", tokens != null);
|
||||
assertEquals("tokens Size: " + tokens.size() + " is not 2", 2, tokens.size());
|
||||
assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
|
||||
assertTrue("first Token is not " + firstKeyword, new ArrayList<>(tokens).get(0).toString().equals(firstKeyword));
|
||||
assertTrue("second Token is not " + secondKeyword, new ArrayList<>(tokens).get(1).toString().equals(secondKeyword));
|
||||
}
|
||||
|
||||
private boolean isOffsetCorrect(String s, Collection<Token> tokens) {
|
||||
|
|
Loading…
Reference in New Issue