Surface matching subjects in search results#11366
Merged
mekarpeles merged 7 commits intointernetarchive:masterfrom Oct 23, 2025
Merged
Surface matching subjects in search results#11366mekarpeles merged 7 commits intointernetarchive:masterfrom
mekarpeles merged 7 commits intointernetarchive:masterfrom
Conversation
ac43468 to
0ae8016
Compare
cbb5536 to
be7ffb3
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
Surfaces matching subjects in book search results by enabling Solr highlighting and rendering highlighted subject tags in the UI.
- Plumbs a highlight flag through the search pipeline, adds SearchResponse.highlighting, and cleans highlight snippets (stopword filtering and sorting).
- Renders highlighted subject tags in SearchResultsWork and styles them with new CSS.
- Adds a reusable subject_name_to_key helper and adopts it in SubjectTags.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| static/css/components/search-result-item.less | Adds styles for highlighted subject chips and emphasis styling. |
| openlibrary/templates/work_search.html | Passes per-work Solr highlighting into SearchResultsWork. |
| openlibrary/plugins/worksearch/schemes/works.py | Adds highlight support to Solr params for works (hl.* settings). |
| openlibrary/plugins/worksearch/schemes/subjects.py | Aligns q_to_solr_params signature to accept highlight flag. |
| openlibrary/plugins/worksearch/schemes/lists.py | Aligns q_to_solr_params signature to accept highlight flag. |
| openlibrary/plugins/worksearch/schemes/authors.py | Aligns q_to_solr_params signature to accept highlight flag. |
| openlibrary/plugins/worksearch/schemes/init.py | Base scheme q_to_solr_params signature updated with highlight flag. |
| openlibrary/plugins/worksearch/code.py | Implements highlighting plumbing, stopword loading, highlight cleaning, and response shaping. |
| openlibrary/plugins/upstream/utils.py | Introduces subject_name_to_key helper (DRYs subject URL construction). |
| openlibrary/macros/SubjectTags.html | Switches to subject_name_to_key for subject links. |
| openlibrary/macros/SearchResultsWork.html | Displays highlighted subjects under results and links to subject pages. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
1cd1d07 to
efc1b2e
Compare
cdrini
commented
Oct 19, 2025
Collaborator
Author
There was a problem hiding this comment.
Note this file has a few indenting changes; you can view the diff with whitespace changes excluded by clicking the settings cog in the top just above the diff.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First piece of #9898 pulled out, so we can monitoring the impact of highlighting on performance and merge a good chunk of that code in first.
Adds ability to show matching subjects in book search results to:
Technical
Testing
Screenshot
https://testing.openlibrary.org/search?q=horror+short+stories&mode=everything&sort=trending
Stakeholders