fix(search): match combined "Title: Subtitle" author+title queries; page author lookups at max size#689
Open
rknall wants to merge 2 commits into
Open
fix(search): match combined "Title: Subtitle" author+title queries; page author lookups at max size#689rknall wants to merge 2 commits into
rknall wants to merge 2 commits into
Conversation
added 2 commits
June 15, 2026 08:33
… search The author+title search branch filtered the author's catalogue by requiring the query to be a substring of a result's Title OR Subtitle individually. Audible splits a book name across Title + Subtitle (e.g. Title="A Dance with Dragons", Subtitle="A Song of Ice and Fire, Book 5"), while callers and Library Import pass the combined "Title: Subtitle" string -- which matched neither field, so every author result was filtered out (0 results). Normalize punctuation/whitespace and also match the combined "Title Subtitle" form. Verified: "A Dance with Dragons: A Song of Ice and Fire, Book 5" by George R.R. Martin now returns the book (0 -> 2) in the de region.
The author and author+title aggregation loops derived their page size from
the result cap: `pageSize = Math.Min(50, Math.Max(10, candidateLimit))`.
That conflates two unrelated concerns:
* candidateLimit is a *result-set* bound — how many results we ultimately
keep/return to the caller.
* page size is a *transport* concern — how many items we ask Audible for
per HTTP round-trip.
The loop already aggregates *every* page until Audible returns a short page
(it deliberately does NOT stop at candidateLimit — see the surrounding
comment). So page size has no effect on which or how many items end up in the
aggregated set; it only changes how many sequential API calls that takes.
The old formula therefore had exactly one effect: when a caller passed a
small cap it made pages *smaller*. The Advanced search sends `cap=5`, which
drove pageSize down to 10, so a 127-item author catalogue (Elfie Donnelly)
was fetched in 13 sequential Audible calls instead of 3 — pure added latency,
no benefit.
Hardcoding 50 (Audible's maximum page size) is strictly better:
* Fewer round-trips: ~ceil(N/50) instead of ~ceil(N/min(...)). Never more.
* Identical results — same items aggregated, same final cap applied later.
* No larger value is possible (50 is the API max) and any smaller value
only adds latency, so there is no reason to make it configurable.
Measured: the Elfie Donnelly author+title search drops from 13 to 3 Audible
requests with an unchanged result set.
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.
Summary
Two related improvements to the author+title search path.
Title: Subtitlequeries (the form Library Import emits) returned zero results. Audible splits a book name acrossTitle+Subtitle; the filter required the query to be a substring of one field individually, so the combined string matched neither and every result was dropped.Changes
Changed
min(50, max(10, candidateLimit)). The aggregation loop already fetches every page until the catalogue ends, so page size never affected which results are considered — only the number of round-trips. Result: ~4× fewer Audible requests (Elfie Donnelly author+title: 13 → 3), identical result set.Fixed
Title: Subtitlequeries. Matching normalizes punctuation/whitespace and also tests the combinedTitle Subtitleform, so a query likeA Dance with Dragons: A Song of Ice and Fire, Book 5(authorGeorge R.R. Martin) returns the book (0 → 2 in thederegion) instead of nothing.Testing
Notes
candidateLimitis a result-set bound (how many results we keep), while page size is a transport concern (items per HTTP round-trip). The loop deliberately aggregates all pages regardless of the cap, so page size has no effect on the result set — only on latency. The old formula's only effect was to make pages smaller when a caller passed a small cap (the Advanced search sendscap=5→ pageSize 10). 50 is the API maximum, any smaller value only adds round-trips, and no larger value is possible — so there is nothing worth making configurable.debut notus) are a separate regional-search concern, not addressed here.