apache / apache/lucene

Make sure to account for ScoreMode.TOP_DOCS in queries [LUCENE-9628]

Open
#10,668 4 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Minor module:core/search type:test
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

I noticed a few places where we are directly check the `ScoreMode` type that should perhaps be generalized. These could affect whether numeric sort optimization is applied:
- In `BooleanWeight#bulkScorer`, we check if score mode is `TOP_SCORES` and if so, force non-bulk scoring. Should we expand this to include modes like `TOP_DOCS`?
- In `ConstantScoreQuery`, we create the delegate weight with a hardcoded `COMPLETE_NO_SCORES`. I'm not sure it actually causes problems, but it seems like this doesn't handle `TOP_DOCS` correctly.

Apologies this issue isn’t more precise – I am not up-to-speed on the numeric sort optimization but wanted to raise these in case they’re helpful.

---
Migrated from [LUCENE-9628](https://issues.apache.org/jira/browse/LUCENE-9628) by Julie Tibshirani (@jtibshirani), 1 vote, updated Dec 15 2020
Pull requests: https://github.com/apache/lucene-solr/pull/2126

Contributor guide

Open the contributing guide

Research direction

Start by reviewing ScoreMode handling in BooleanWeight#bulkScorer and ConstantScoreQuery, then inspect the numeric sort optimization paths and the linked pull request 2126. Determine the expected behavior for TOP_DOCS and verify it with the relevant existing or added tests; done means the affected query paths handle the mode consistently without regressing other score modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.