Resolve series-volume book queries (e.g. "Polican 4")#11
Merged
Conversation
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>
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.
Problem
Searching the item-search box for
Polican 4returned junk (a 1687 surgery book) instead of the expected workOL17844203W("Dog Man and Cat Kid", aka Policán 4 in Spanish).Open Library ANDs query tokens, and no Dog Man record carries
4as 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)searchBooksnow detects a trailing volume number and resolves it through the series: base-text search → discover the dominant series → fetch its seeds → match each member'sseries[].position(seed order is unreliable, so it matches on the position field, not seed order).searchBooksText; the multi-hop resolution runs on a dedicated longer-timeout client.api.go,dto.go, movies/music, and the frontend are untouched.Verification
gofmtclean,go build ./...,go vet, and unit tests pass.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