eldenmoon opened a new pull request, #69460:
URL: https://github.com/apache/doris/pull/69460
### What problem does this PR solve?
Fixes three SEARCH DSL parsing problems reported in Jira (labels
`search-dsl`):
- **DORIS-23194**: `AND`/`OR`/`NOT` were uppercase-only operators. A field
value such as `SEARCH('ch:AND')` failed with `mismatched input 'AND'`, and
lowercase `or` was parsed as an ordinary term instead of an operator.
- **DORIS-23236**: a quoted value in `ANY(...)`/`ALL(...)` was terminated at
the first `)`, so `SEARCH('ch:ANY("All Quiet on the Western Front (2022
film)")')` silently truncated the clause and the combined query failed with `No
field specified and no default_field configured`.
- **DORIS-23239**: `EXACT`/`ANY`/`ALL` content kept DSL escapes, so
`SEARCH('ch:exact(ABC\))')` and `SEARCH('ch:exact(\"ABC\")')` looked up terms
containing a literal backslash and never matched.
### What changes were proposed?
- `SearchLexer.g4`
- `AND`/`OR`/`NOT` are case-insensitive, matching Lucene/ES query string
syntax.
- `STRING_MODE` consumes a quoted section atomically, so parentheses
inside quotes no longer pop the mode early.
- `SearchParser.g4`
- New `fieldValue : searchValue | AND | OR | NOT` rule for field-value
position. Keeping these tokens out of `searchValue`/`bareQuery` avoids the
ambiguity where lowercase `or` between two clauses could be parsed as a bare
term.
- `SearchDslParser.java`
- `fieldQuery` uses `fieldValue`; keyword tokens in value position become
ordinary `TERM` nodes in both standard and Lucene mode.
- `EXACT`/`ANY`/`ALL` content is unescaped before the term is built.
- Tests
- New FE unit tests in `SearchDslParserTest`.
- New regression suite `test_search_dsl_keyword_quoted_syntax` covering
keyword values (`ch:AND`, `ch:and`, `ch:And`, ...) against a `MATCH_ANY`
control, lowercase `or`, quoted parentheses in `ANY`/`ALL`, and escaped exact
terms.
### Verification
Built FE from this branch and ran the regression suite on a
single-FE/single-BE cluster at master `5e3ed84abb0`:
```
kw_AND 4 (MATCH_ANY 'AND' control: 4)
kw_and 1 (MATCH_ANY 'and' control: 1)
kw_and_or 1,2
any_paren 1
all 2
any_or_all_upper 1,2
any_or_all_lower 1,2
exact_quoted 1
exact_paren 2
```
`mvn test` / `SearchDslParserTest`: new cases pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]