Skip to content

branch-4.0: [fix](search) inject MATCH_ALL_DOCS for multi-MUST_NOT queries in lucene mode #60891#61001

Closed
github-actions[bot] wants to merge 1 commit intobranch-4.0from
auto-pick-60891-branch-4.0
Closed

branch-4.0: [fix](search) inject MATCH_ALL_DOCS for multi-MUST_NOT queries in lucene mode #60891#61001
github-actions[bot] wants to merge 1 commit intobranch-4.0from
auto-pick-60891-branch-4.0

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 3, 2026

Cherry-picked from #60891

@github-actions github-actions bot requested a review from yiguolei as a code owner March 3, 2026 12:27
@Thearas
Copy link
Contributor

Thearas commented Mar 3, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring dataroaring closed this Mar 3, 2026
@dataroaring dataroaring reopened this Mar 3, 2026
@Thearas
Copy link
Contributor

Thearas commented Mar 3, 2026

run buildall

…ene mode (#60891)

### What problem does this PR solve?

Related PR: #60814

Problem Summary:
In search() lucene mode, when all terms in a boolean query are MUST_NOT
(e.g., `NOT a AND NOT b` or `NOT a NOT b` with default_operator=AND),
the query incorrectly returns all documents instead of returning all
documents EXCEPT those matching the negated terms.

Root cause: Lucene's BooleanQuery with only MUST_NOT clauses matches
nothing (by design). ES handles this by injecting a MatchAllDocsQuery
with SHOULD occur. Doris only handled the single-term MUST_NOT case
but not multi-term all-MUST_NOT queries.

Fix: After `applyLuceneBooleanLogic()`, detect if ALL terms are MUST_NOT
and inject `MATCH_ALL_DOCS(SHOULD)` with `minimum_should_match=1`.
@airborne12 airborne12 force-pushed the auto-pick-60891-branch-4.0 branch from d60dc26 to 768e12b Compare March 3, 2026 16:36
@airborne12
Copy link
Member

run buildall

@yiguolei yiguolei closed this Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants