Skip to content

feat: add ebook mode to search, automatically filtering for borrowable ebooks#11826

Merged
mekarpeles merged 3 commits intointernetarchive:masterfrom
ronibhakta1:fix/opds-search-borrable
Feb 23, 2026
Merged

feat: add ebook mode to search, automatically filtering for borrowable ebooks#11826
mekarpeles merged 3 commits intointernetarchive:masterfrom
ronibhakta1:fix/opds-search-borrable

Conversation

@ronibhakta1
Copy link
Copy Markdown
Contributor

Closes # ArchiveLabs/pyopds2_openlibrary#23

Fix: mode=ebooks to Open Library opds /search URL (by default) and this should update the query to include ebook_access:[borrowable TO *] if it’s not present

Technical

Testing

Screenshot

Stakeholders

@MarcCoquand @mekarpeles

Copilot AI review requested due to automatic review settings February 6, 2026 01:26
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 an ebooks mode to the Open Library OPDS /search endpoint that automatically filters search results to include only borrowable ebooks. When mode=ebooks is set (now the default), the endpoint appends ebook_access:[borrowable TO *] to the search query unless it already contains an ebook_access: filter.

Changes:

  • Added mode parameter to /opds/search endpoint with default value of "ebooks"
  • Implemented automatic query filtering to append ebook_access:[borrowable TO *] when mode is "ebooks" and the filter isn't already present
  • Modified the search query construction to use the filtered query when mode is "ebooks"

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

@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Feb 7, 2026
@mekarpeles mekarpeles self-assigned this Feb 9, 2026
@mekarpeles
Copy link
Copy Markdown
Member

As @ronibhakta1 mentions, this PR introduces a mode variable to search, which defaults to ebooks, mirroring to how openlibrary.org/search works.

This PR assumes the default is mode=ebooks.

The opds workflow, from an app's perspective, is that the app will load Open Library's opds feed, will discover that there is a search URL, and then the search URL will be used for searches.

Likely what we want is to have a search URL which also publishes that facets are available for mode whose values can be ebooks or all.

Currently, the PR open has a few problems:

  1. It always defaults to ebooks -- what @MarcCoquand wants (it's a decision; not a terrible path, assuming there's some way to get back to mode=everything
  2. If we change the mode to mode=everything, no logic exists to remove ebook_access:[borrowable TO *] from the query. (making it impossible to go from ebooks to everything.
  3. Consideration: we want to be careful to persist the mode across requests but not to change the query for the user in away that affects the opds feed, otherwise, the feed will include ebook_access:[borrowable TO *] in all future queries, which we probably don't want.

@mekarpeles
Copy link
Copy Markdown
Member

LGTM

Copy link
Copy Markdown
Member

@mekarpeles mekarpeles left a comment

Choose a reason for hiding this comment

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

Changes now LGTM w/ facet approach + mode

@mekarpeles mekarpeles merged commit 032006a into internetarchive:master Feb 23, 2026
4 checks passed
@MarcCoquand
Copy link
Copy Markdown
Contributor

Hi, is the default now that it defaults to ebooks only? @mekarpeles @ronibhakta1 .

In the PR I see {{?query,mode}} which slightly confuses me, because {?query} is there to indicate that it should be replaced by the OPDS feed. mode is not something supported to be replaced by facets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants