Make search facets fully asynchronous#12262
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
Adds an async Solr-backed search helper and wires it into the /partials/SearchFacets.json path so facets can be generated without relying on synchronous Solr query execution.
Changes:
- Introduces
do_search_async(async) and keepsdo_searchas a sync wrapper viaasync_bridge. - Updates
SearchFacetsPartialto perform the facets Solr query usingawait do_search_async(...). - Removes the “TODO: Make this fully async” note from the FastAPI partial endpoint docstring.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| openlibrary/plugins/worksearch/code.py | Adds do_search_async and wraps it with do_search for sync callers. |
| openlibrary/plugins/openlibrary/partials.py | Makes SearchFacetsPartial.generate async and awaits the async search call. |
| openlibrary/fastapi/partials.py | Removes the async TODO comment from the SearchFacets partial endpoint docstring. |
…thub.com:Sadashii/openlibrary into 12256/feat/make-partials-searchfacets-full-async
|
See the other PR I opened we can just make the function have a different
name
…On Wed, Apr 1, 2026, 10:50 PM Tanishq Sangwan ***@***.***> wrote:
*Sadashii* left a comment (internetarchive/openlibrary#12262)
<#12262?email_source=notifications&email_token=AAHA5AP7FXQYN3E3P5QGA7T4TX5SJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJXGQ4DGMJZGM42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4174831939>
@RayBB <https://github.com/RayBB> The failing test is because the parent
@generate <https://github.com/generate> function for partials is
synchronous, as we made the SearchFacets partial async there is a mismatch.
Once all the partials are made async, the parent can be updated and then
the test will pass.
—
Reply to this email directly, view it on GitHub
<#12262?email_source=notifications&email_token=AAHA5AP7FXQYN3E3P5QGA7T4TX5SJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJXGQ4DGMJZGM42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4174831939>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHA5AJNZXNHD3QI7RBV25L4TX5SJAVCNFSM6AAAAACXKAOMHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCNZUHAZTCOJTHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
…thub.com:Sadashii/openlibrary into 12256/feat/make-partials-searchfacets-full-async
for more information, see https://pre-commit.ci
…thub.com:Sadashii/openlibrary into 12256/feat/make-partials-searchfacets-full-async
|
At first glance it looks good. Can you try to remove the Infogami change? I think you have to run MakeGit or something like that. It's a weird little thing that sneaks in there sometimes, but I'm pretty sure you don't need that and it'll have to be removed before we can merge. |
|
Fixed |
RayBB
left a comment
There was a problem hiding this comment.
Confirmed this is working as expected on testing.
I did this by checking the solr and non-solr versions of search results (json and html) are the same between testing and production.
|
Great job on this one thanks for the help! |
Closes #12256
feature -> Make /partials/SearchFacets.json full async to free up worker
Technical
Testing
Screenshot
Stakeholders
@RayBB