Skip to content

LIFT-2099: Rework wildcard relevance scoring using rescore API#218

Merged
wes-maszk-rp merged 5 commits into
release-0.3.6.xfrom
LIFT-2099/rescore-based-relevance
May 5, 2026
Merged

LIFT-2099: Rework wildcard relevance scoring using rescore API#218
wes-maszk-rp merged 5 commits into
release-0.3.6.xfrom
LIFT-2099/rescore-based-relevance

Conversation

@wes-maszk-rp

Copy link
Copy Markdown

The previous approach (MatchQuery in should + automatic _score desc sort) forced every shard to score every filter-matched document, defeating early-termination on the primary sort and causing timeouts on large indices. It also silently demoted sort=id because _score was injected ahead of the caller's sort.

Revert w/sw/ew to plain wildcards in should. Add a new rank(field, "query text" [, windowSize]) RQL function that attaches a top-level Elasticsearch rescore block. Rescore runs BM25 scoring only against the top window_size docs each shard returns from the primary sort, so cost is bounded and callers that don't opt in pay nothing.

No behavior change for any existing caller unless they add rank(...).

The previous approach (MatchQuery in should + automatic _score desc sort)
forced every shard to score every filter-matched document, defeating
early-termination on the primary sort and causing timeouts on large
indices. It also silently demoted sort=id because _score was injected
ahead of the caller's sort.

Revert w/sw/ew to plain wildcards in should. Add a new rank(field,
"query text" [, windowSize]) RQL function that attaches a top-level
Elasticsearch rescore block. Rescore runs BM25 scoring only against
the top window_size docs each shard returns from the primary sort, so
cost is bounded and callers that don't opt in pay nothing.

No behavior change for any existing caller unless they add rank(...).
- Restore the `_score` guard in Order.java. A caller that opts into
  score-based ordering via sort=_score,desc must produce valid ES
  sort JSON; ES rejects `missing` on _score.
- Reject nested rank() with a clear error message. rank() attaches
  a top-level rescore block and cannot be nested inside and()/or().
- Document the intentional pure-rerank weighting in Rescore.java
  (query_weight=0, rescore_query_weight=1).
- Fix stale javadoc on withWildCardPopulater to include WITHOUT.
- Add tests for the two correctness fixes.
0.3.6.19 was already published to the package registry from PR #214's
earlier version-bump commit.
Comment thread build.gradle Outdated
Comment thread src/main/java/io/rcktapp/rql/elastic/BoolQuery.java Outdated
Comment thread Changelog.md Outdated
- Remove MatchQuery class and its serialization branch in BoolQuery.
  Nothing constructs a MatchQuery anymore; the rescore block builds
  its match clause directly in Rescore.toMap(). (connor-brown-rp)
- Update changelog header to match build.gradle (0.3.6.19) and
  set the release date to today.
@wes-maszk-rp wes-maszk-rp merged commit db8171a into release-0.3.6.x May 5, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants