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

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #59394
   
   Problem Summary:
   
   This PR adds a `fields` parameter to the SEARCH function, allowing queries 
to search across multiple fields with a single query term. This is similar to 
Elasticsearch's query_string `fields` parameter.
   
   #### Multi-Field Search Support
   
   ```sql
   -- Single term across multiple fields
   SELECT * FROM docs WHERE search('hello', '{"fields":["title","content"]}');
   -- Equivalent to: (title:hello OR content:hello)
   
   -- Multi-term with AND operator
   SELECT * FROM docs WHERE search('hello world', 
     '{"fields":["title","content"],"default_operator":"and"}');
   -- Equivalent to: (title:hello OR content:hello) AND (title:world OR 
content:world)
   
   -- Combined with Lucene mode
   SELECT * FROM docs WHERE search('machine AND learning', 
     '{"fields":["title","content"],"mode":"lucene","minimum_should_match":0}');
   ```
   
   **Key features:**
   - Each term without field prefix is expanded to OR across all specified 
fields
   - Compatible with both standard mode and Lucene boolean mode
   - `fields` and `default_field` are mutually exclusive
   - Supports functions (EXACT, ANY, ALL) across fields
   - Supports wildcard queries across fields
   
   **Behavior examples:**
   
   | Query | Fields | Expanded DSL |
   |-------|--------|--------------|
   | `hello` | `["title","content"]` | `(title:hello OR content:hello)` |
   | `hello world` (AND) | `["title","content"]` | `(title:hello OR 
content:hello) AND (title:world OR content:world)` |
   | `EXACT(foo bar)` | `["title","content"]` | `(title:EXACT(foo bar) OR 
content:EXACT(foo bar))` |
   | `hello AND category:tech` | `["title","content"]` | `(title:hello OR 
content:hello) AND category:tech` |
   
   ### Release note
   
   - Add multi-field search support for SEARCH function (`fields` parameter)
   - Allows searching across multiple fields with a single query term
   - Compatible with Lucene mode for MUST/SHOULD/MUST_NOT semantics
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [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 <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. <!-- New `fields` parameter added to SEARCH function -->
   
   - Does this need documentation?
       - [ ] No.
       - [x] Yes. <!-- Need to document the new fields parameter -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->


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