Repository navigation
branch-4.2: [fix](inverted index) Score MATCH_PHRASE_PREFIX on the tablet idf of the terms the prefix expands to #69698 - #69801
Merged
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Member
Author
|
run buildall |
…the terms the prefix expands to (apache#69698) ### What problem does this PR solve? Issue Number: None Related PR: apache#68758 Problem Summary: score() over MATCH_PHRASE_PREFIX gave scores that ignored the prefix and differed between inverted index storage formats. 1. The prefix of a phrase prefix never entered the idf. "apple r" scored on idf(apple) alone, and a rare expansion such as "rose" ranked like a common one such as "red". Lucene's multi-phrase query, and so Elasticsearch, sum the idf of the phrase terms and of every term the prefix expands to. The statistics collector now registers the prefix; every segment expands it, counts the document frequency of each expanded term in the tablet statistics, and records which terms the prefix expanded to. The scorer adds their idf to the phrase's, so all idfs come from the same tablet statistics and the score does not depend on how rows are split into segments. With the reported table, `apple r` now scores 1.4508328, the value Elasticsearch 9.5 gives; on a 10-row table, `apple r`, `apple ro` and `apple g` match Elasticsearch to four decimals, over one segment and over three. 2. A prefix of one token scored 0 on V2/V3 (CLucene did not publish scores for expansion leaves) and 1 on SNII. It now scores 1 on every format, as the constant score of Lucene and Elasticsearch prefix queries. At 0, `score() > 0` dropped every row the prefix matched. 3. No test covered score() over MATCH_PHRASE_PREFIX across storage formats. Add unit tests for the collector, the segment expansion, the tablet idf and the constant score, and a regression suite over V2, V3 and SNII. Two existing tests asserted the old behavior and are updated: the SNII public phrase prefix scoring test (the idf now counts the expanded term) and the CLucene one-token phrase prefix test (it asserted no score). A prefix collected by a SEARCH predicate has no recorded expansion and keeps scoring the phrase terms alone. Source-PR: apache#69698 Source-Head: 24b4c54 Co-Authored-By: Claude Opus 5.5 <[email protected]>
airborne12
force-pushed
the
backport/69698-branch-4.2
branch
from
October 29, 2026 06:57
98496f3 to
370d68a
Compare
Member
Author
|
run buildall |
Contributor
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
yiguolei
approved these changes
Oct 30, 2026
Contributor
|
PR approved by anyone and no changes requested. |
Contributor
|
PR approved by at least one committer and no changes requested. |
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.
What problem does this PR solve?
Issue Number: None
Related PR: #69698, #69752
Problem Summary:
Backport of #69698 to branch-4.2. score() over MATCH_PHRASE_PREFIX ignored the prefix and
differed between inverted index storage formats:
multi-phrase query and Elasticsearch do, and all idfs come from the tablet statistics. The
statistics expand the prefix in every segment and keep the
inverted_index_max_expansionssmallest terms of the tablet that a returned row holds (a session limit of 0 keeps 50), so a
term's document frequency is counted in every segment that holds it and merge-on-write hidden
rows do not change the scores after a compaction. A term whose bytes are not valid UTF-8 is not
scored.
score() > 0dropped every row it matched.See #69698 for the full description and the review rounds.
This change builds on #69438 (BM25 statistics count only visible rows of merge-on-write tables),
whose branch-4.2 backport #69752 is merged. The PR is rebased onto the current branch-4.2 and
contains only the backport commit; its patch is identical to the one validated below.
Branch adaptations
branch-4.2 yet; on top of branch-4.2: [fix](inverted index) Count only visible rows in BM25 statistics of merge-on-write tables #69438 #69752 the change applies with one conflict, in the context of
collection_statistics_test.cpp: branch-4.2 already hasCollectConvertsAnalyzerFailureToStatuselsewhere in the file, so the copy that master showsnext to the renamed test is not added again.
Release note
score() over MATCH_PHRASE_PREFIX counts the terms the prefix expands to, and a phrase prefix of
one token scores 1 on every inverted index storage format.
Check List (For Author)
commits on top: the newest branch-4.2 calls a lance-c API that no thirdparty build on the
machine used here provides. The PR branch itself is on the current branch-4.2 and is built
by CI.
.outof master unchanged (V2, V3, SNII andthe capped two-segment case).
test_bm25_score_replica_statistics, test_bm25_score_variant, test_score_filter_matrix,
test_score_filter_usage and test_search_score_topn_predicates pass.
PrefixExpansionSetTest, SNII, InvertedIndexReaderTest, MultiSegmentCollectorTest,
BM25SimilarityTest).
🤖 Generated with Claude Code