Skip to content

Resolve series-volume book queries (e.g. "Polican 4")#11

Merged
dhighwayman merged 1 commit into
masterfrom
fix/series-volume-book-search
Jun 2, 2026
Merged

Resolve series-volume book queries (e.g. "Polican 4")#11
dhighwayman merged 1 commit into
masterfrom
fix/series-volume-book-search

Conversation

@dhighwayman

Copy link
Copy Markdown
Contributor

Problem

Searching the item-search box for Polican 4 returned junk (a 1687 surgery book) instead of the expected work OL17844203W ("Dog Man and Cat Kid", aka Policán 4 in Spanish).

Open Library ANDs query tokens, and no Dog Man record carries 4 as a searchable token, so every relevant result was filtered out. The target work isn't even reachable by text-searching "Polican" — it only links to the number via its series position metadata, which isn't in the search index.

Fix (backend-only, internal/search/service.go)

  • searchBooks now detects a trailing volume number and resolves it through the series: base-text search → discover the dominant series → fetch its seeds → match each member's series[].position (seed order is unreliable, so it matches on the position field, not seed order).
  • The exact volume is returned first, followed by the normal text-search results.
  • Falls back to a normal full-query search if resolution fails or times out, so titles that genuinely contain a number (e.g. "Catch 22") still work.
  • The original text search is preserved verbatim as searchBooksText; the multi-hop resolution runs on a dedicated longer-timeout client. api.go, dto.go, movies/music, and the frontend are untouched.

Verification

  • gofmt clean, go build ./..., go vet, and unit tests pass.
  • Live against Open Library:
    • Polican 4 → top result is "Dog Man and Cat Kid" → OL17844203W, followed by other Policán volumes ✅
    • Catch 22 → still finds Catch-22 via fallback ✅

🤖 Generated with Claude Code

Searching "Polican 4" returned junk instead of "Dog Man and Cat Kid"
(OL17844203W). Open Library ANDs query tokens, and no Dog Man record has
"4" as a searchable token, so every relevant result was filtered out. The
target work only links to the number via its series position metadata,
which is not in the search index.

searchBooks now detects a trailing volume number and resolves it through
the series: base-text search -> discover the dominant series -> fetch its
seeds -> match each member's series[].position (seed order is unreliable).
The exact volume is returned first, followed by the normal text results.
Falls back to a normal full-query search if resolution fails or times out,
so titles that genuinely contain a number (e.g. "Catch 22") still work.

The original text search is preserved verbatim as searchBooksText; the
multi-hop resolution runs on a dedicated longer-timeout client.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dhighwayman dhighwayman merged commit a8a0cbe into master Jun 2, 2026
2 checks passed
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.

1 participant