Add test for parsing brackets in range queries (#13323)

This commit is contained in:
Ben Chaplin 2024-05-27 14:34:05 -04:00 committed by GitHub
parent 6efce2189e
commit c06fff6a52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 0 deletions

View File

@ -1020,6 +1020,29 @@ public abstract class QueryParserTestBase extends LuceneTestCase {
// iw.addDocument(d);
// }
public void testParsesBracketsIfQuoted() throws Exception {
Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
assertQueryEquals("[\"a[i]\" TO \"b[i]\"]", a, "[a[i] TO b[i]]");
assertQueryEquals("{\"a[i]\" TO \"b[i]\"}", a, "{a[i] TO b[i]}");
assertQueryEquals("[\"a[i]\" TO \"b[i]\"}", a, "[a[i] TO b[i]}");
assertQueryEquals("{\"a[i]\" TO \"b[i]\"]", a, "{a[i] TO b[i]]");
assertQueryEquals("[\"a[i\\]\" TO \"b[i\\]\"]", a, "[a[i] TO b[i]]");
assertQueryEquals("[\"a\\[i\\]\" TO \"b\\[i\\]\"]", a, "[a[i] TO b[i]]");
assertQueryEquals("[\"a[i][j]\" TO \"b[i][j]\"]", a, "[a[i][j] TO b[i][j]]");
assertQueryEquals(
"[ \"2024-01-01T01:01:01+01:00[Europe/Warsaw]\" TO \"2025-01-01T01:01:01+01:00[Europe/Warsaw]\" ]",
null,
"[2024-01-01t01:01:01+01:00[europe/warsaw] TO 2025-01-01t01:01:01+01:00[europe/warsaw]]");
// If the range terms aren't wrapped in quotes, a closing bracket will throw
assertParseException("[a[i] TO b[i]]");
assertParseException("[a\\[i\\] TO b\\[i\\]]");
}
public abstract void testStarParsing() throws Exception;
public void testEscapedWildcard() throws Exception {