branch-4.0: [fix](inverted index) Fix empty string MATCH on keyword index returning wrong results #60500#60516
Merged
yiguolei merged 1 commit intobranch-4.0from Feb 5, 2026
Merged
Conversation
…ng wrong results (#60500) ## Proposed changes Fix empty string MATCH on keyword index returning wrong results. The multi-analyzer feature commit (2c950e1) incorrectly added an empty string check that prevented `MATCH ''` from finding rows with empty string values in keyword indexes. For keyword index (no tokenization), empty string is a valid exact match value and should be matchable. The previous code incorrectly skipped empty strings with the comment "empty query should match nothing", which is wrong for keyword indexes. ## Problem ```sql -- Table with keyword index (no parser) CREATE TABLE test (id INT, col TEXT, INDEX idx(col) USING INVERTED); INSERT INTO test VALUES (1, ''), (2, 'data'); -- Before fix: returns 0 (WRONG!) -- After fix: returns 1 (CORRECT!) SELECT count() FROM test WHERE col MATCH ''; ``` ## Changes This fix removes the empty string check for keyword index paths in: - `be/src/vec/functions/match.cpp` (slow path) - `be/src/olap/rowset/segment_v2/inverted_index_reader.cpp` (index path) - `be/src/olap/rowset/segment_v2/inverted_index/analyzer/analyzer.cpp` Added regression test `test_empty_string_match.groovy` to cover: - Empty string match on keyword index (both index and slow paths) - Empty string match on tokenized index (should return 0) - match_any and match_all with empty string ## Check List (For Author) - Test - [x] Regression test - [x] Unit Test - [ ] Manual test - [ ] No need to test - Behavior changed: - [x] Yes. `MATCH ''` on keyword index now correctly matches rows with empty string values. - Does this need documentation? - [ ] No.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
yiguolei
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #60500