Skip to content

The MySQL search backend can now properly sort and annotate results with their relevance scores #13157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

coredumperror
Copy link
Contributor

@coredumperror coredumperror commented Jun 10, 2025

Because the original code did a database query to get the object IDs that match the search keywords, and then used just the object_ids from that query to do a completely separate query to get the search results it ultimately returned, all relevance data was being lost. This made sort_by_relevance not work at all, and also left score_field completely ignored, meaning the search results could not be sorted by or annotated with their relevance scores.

The new code retains the relevance scores calculated from the IndexEntry model, and makes it possible to sort by them and add them as annotations to the search results (if callers request that).

Because the original code did a database query to get the object IDs that match the search keywords, and then used the results of that query to do a completely separate query to get the search results, all relevance data was being lost. This made sort_by_relevance not work at all, and also left score_field completely ignored, meaning the search results could not be annotated with their relevance scores.

The new code retains the relevance scores calculated from the IndexEntry model, and makes it possible to sort by them and add them as annotations to the search results (if callers request that).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants