You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e3dfddb
Browse filesBrowse the repository at this point in the historyBrowse files
[fix](inverted index) Score MATCH_PHRASE_PREFIX on the tablet idf of the terms the prefix expands to
### What problem does this PR solve?
Issue Number: None
Related PR: #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.
### 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)
- Test: Unit Test, Regression test
- BE unit tests: 3158 related tests pass; the new idf and segment
expansion tests fail without the change.
- Regression test test_match_phrase_prefix_score on a local cluster.
- Behavior changed: Yes (scores of MATCH_PHRASE_PREFIX change)
- Does this need documentation: No
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
0 commit comments