airborne12 opened a new pull request, #60784:
URL: https://github.com/apache/doris/pull/60784

   ### What problem does this PR solve?
   
   Issue Number: close DORIS-24536
   
   Problem Summary:
   
   When using `search('*', ...)` with multi-field options (`fields` parameter), 
the query fails with:
   ```
   only inverted index queries are supported
   ```
   
   The root cause is in `SearchDslParser.java`: the multi-field parsing methods 
(`parseDslMultiFieldMode` and `parseDslMultiFieldLuceneMode`) collect field 
bindings by calling `collectFieldNames()` on the expanded AST. When the query 
is `*` (match all), the AST node is `MATCH_ALL_DOCS` which has no field set — 
by design it matches all documents regardless of field. This caused 
`collectFieldNames` to return an empty set, resulting in no field bindings. 
Without field bindings, `RewriteSearchToSlots` couldn't create slot references, 
so the search expression was never pushed down to the inverted index path, and 
BE fell back to `execute_impl()` which returns the error.
   
   **Fix**: After `collectFieldNames()`, if the result is empty, fall back to 
using the original `fields` list as field bindings. This ensures the push-down 
mechanism works for `MATCH_ALL_DOCS` queries.
   
   **Reproducing queries** (from bug report):
   ```sql
   select count(*) from wikipedia where search('*', '{"fields":["title", 
"content"], "type": "best_fields", "default_operator":"AND","mode":"lucene", 
"minimum_should_match": 0}');
   
   select count(*) from wikipedia where search('*', '{"default_field": "title", 
"default_operator":"AND","mode":"lucene", "minimum_should_match": 0}');
   ```
   
   ### Release note
   
   Fix search('*', ...) with multi-field mode failing with "only inverted index 
queries are supported" error.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason
   
   - Behavior changed:
       - [x] Yes. `search('*', ...)` with `fields` parameter now correctly 
matches all documents instead of erroring.
   
   - Does this need documentation?
       - [x] No.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label


-- 
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]

Reply via email to