Skip to content

MB-71971: Add explain to custom score queries#2340

Merged
capemox merged 2 commits into
masterfrom
custom_expl
Jun 1, 2026
Merged

MB-71971: Add explain to custom score queries#2340
capemox merged 2 commits into
masterfrom
custom_expl

Conversation

@capemox
Copy link
Copy Markdown
Member

@capemox capemox commented Jun 1, 2026

  • Custom score queries with explain: true now have a simple "custom_score function result" message
  • Cleaned up custom queries unit tests to use scorch indexes rather than upsidedown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Explain support to custom score queries by emitting a simple explanation node for the post-mutation score, and updates related unit tests to use a scorch-backed index instead of NewMemOnly.

Changes:

  • Thread options.Explain into CustomScoreSearcher and, when enabled, replace the hit explanation with "custom_score function result" (value = final mutated score).
  • Refactor CustomScoreSearcher scoring into a helper (applyScore) used by both Next and Advance.
  • Update custom query tests to use temporary scorch indexes and add a new explain-focused test.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
search/searcher/search_custom_score.go Adds an explain flag and wraps the final score in a single explanation node when enabled.
search/query/custom_score.go Passes options.Explain into the custom score searcher construction.
search_test.go Switches custom-query test indexes to scorch-backed on-disk indexes and adds an explain test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread search_test.go Outdated
Comment thread search_test.go
@coveralls
Copy link
Copy Markdown

coveralls commented Jun 1, 2026

Coverage Status

coverage: 52.292% (-0.01%) from 52.304% — custom_expl into master

@capemox capemox self-assigned this Jun 1, 2026
@capemox capemox merged commit c1e621b into master Jun 1, 2026
10 checks passed
@capemox capemox deleted the custom_expl branch June 1, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants