Repository navigation
fix: search and ranking handle titles with apostrophes - #469
Merged
Merged
Conversation
…ck query pass (#316) Search tries the title without its apostrophes, then without its subtitle, only when the first pass finds nothing that names it (custom search terms are sent as given, and an empty query is never sent); ranking folds apostrophes so Enders.Game and L.Intruse match their titles. Closes #316. Co-authored-by: connor2k <connormiddleton@gmail.com> Co-authored-by: Eyji <10639815+Eyji@users.noreply.github.com> Co-authored-by: thehaven <420380+thehaven@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… edited interactive titles are sent as given (#316) Ranking folds a release word with an apostrophe ending only when the request writes that word with one, so "The Lover's Dictionary" no longer matches a request for "The Lovers". The Prowlarr fallback check uses the same rule. A title edited in interactive search with no request is sent as given, and a subtitle-free base under 3 letters and digits ("Re" from "Re:Zero") is not sent. Co-authored-by: connor2k <connormiddleton@gmail.com> Co-authored-by: Eyji <10639815+Eyji@users.noreply.github.com> Co-authored-by: thehaven <420380+thehaven@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…phe (#316) Co-authored-by: connor2k <connormiddleton@gmail.com> Co-authored-by: Eyji <10639815+Eyji@users.noreply.github.com> Co-authored-by: thehaven <420380+thehaven@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kikootwo
marked this pull request as ready for review
October 27, 2026 07:48
This was referenced Oct 27, 2026
Closed
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.
Closes #316
What changed
src/lib/integrations/prowlarr.service.ts, query helpers in the newsrc/lib/integrations/prowlarr-query-variations.ts).searchWithVariations()still sends"title author"then"title". Only when none of those results names the title does it try more queries, each as"variation author"then"variation", and it stops at the first query whose results name the title. A result names the title when it holds 80% of the title's words before its subtitle. This is close to ranking's first word-coverage check, with apostrophes and numbers folded the same way, but it always uses English stop words, and a number's.also starts a subtitle there. The variations:The Dungeon Anarchist's CookbookbecomesThe Dungeon Anarchists Cookbook,L'intrusebecomesL intruse,Op-CenterbecomesOp Center. Only sent when some word has punctuation inside it.:, or before.right after a number (Primal Hunter 1. Une aventure de LitRPGbecomesPrimal Hunter 1). Not sent when it has fewer than 3 letters and digits and no non-Latin letter (Re:Zerosends noRe;三体is still sent).:gives no subtitle-free query, so no empty query is sent. The split after a number's.is @Eyji's suggestion on that PR, and the subtitle-free idea also came from @thehaven in feat(search): 3-pass subtitle search and configurable preferred search language with score penalties #254.exactTitle: truetoPOST /api/audiobooks/search-torrentswhen the title differs from the book's own. Callers pass{ exactTitle }.src/lib/utils/match-normalize.ts):normalizeForMatchingandfoldForMatchingnow fold apostrophes. Straight and typographic apostrophes count as one; before an English ending (s t d m ll re ve) the apostrophe is dropped, anywhere else it becomes a space. SoL'intrusematchesL intruseandL.Intruse.keepUnrequestedApostrophes, the first step ofscoreMatchand of the fallback check): a release word with an apostrophe ending folds only when the request writes that word with one. Any other keeps its apostrophe, asꞌ(U+A78C, a Latin letter), so it stays one word that matches no plain word, as on main. So "Ender's Game" matchesEnders.GameandEnder's Game, while "The Titans" does not matchThe Titan's Curse. The author check (G3) accepts that keptꞌsafter a name, as it accepts's.documentation/phase3/prowlarr.md(fallback pass, which searches are exact, cost, Fixed Search fails for titles containing apostrophes; add a punctuation-stripped query variation #316),phase3/ranking-algorithm.md(apostrophe fold and its release side, other consumers, known limits, Fixed Ranking rejects the right release when the title has an apostrophe or a subtitle after ". " or " - " #466 apostrophe rows),phase3/match-gates.md.Why
Indexer release names usually drop the apostrophe, so a search for "The Dungeon Anarchist's Cookbook" or "The Butcher's Masquerade" can return nothing while the same title without it finds the book. Even when such a release came back, ranking kept the apostrophe inside the word (
anarchist's,ender's,l'intruse), soAnarchists,Enders.GameandL.Intrusefailed word coverage and scored 0 in automatic and interactive search.The fold is one-way on purpose. Folding both sides the same would make
Lover'sandLoversone word, so a possessive title by the same author (The Titan's Curse) would clear automatic search for a request whose title has the plural ("The Titans").This fixes the apostrophe rows of #466 (
L.Intruse…for "L'intruse",Changer.L.Eau.Des.Fleurs…,Enders.Game…for "Ender's Game"). The subtitle rows of #466 (". " and " - " in the request title) are not changed here and stay open there.Evidence
tests/integrations/prowlarr-search-variations.test.tsruns the realsearchWithVariations()withsearch()stubbed. It covers:., and the stripped subtitle-free query;Requery forRe:Zero, while a 2-character CJK base is still sent;Mr. Mercedes, for exact custom terms, or when every first-pass query failed;: The Book,:,''and a blank title;tests/utils/ranking-match-gates.test.ts:The Lover's Dictionaryfor "The Lovers",The Titan's Cursefor "The Titans",The Handmaid's Talefor "The Handmaids",The Husband's Secretfor "The Husbands",Ender's Gamefor "Enders"), plusEnder’s Gamefor "Enders Game", score match 0 and total 40 in automatic search, as on main, and match 0 in interactive search. So do two curly possessives thatmainpicked:The Lover’s Dictionaryfor "The Lover" andThe Housemaid’s Secretfor "The Housemaid".Stephen King's The Standstill counts the author.tests/utils/match-normalize.test.ts: the fold table, the request words with an apostrophe ending, and the release side (a kept apostrophe survives every later normalization).foldForMatchingandnormalizeForMatchingagree on apostrophe text.tests/utils/bulk-import-keys.test.ts: apostrophe titles key as before (the existing all-ASCII key test also still passes).tests/integrations/audible-series-search-ranking.test.ts: series match share for apostrophe titles.exactTitlefor the processor, both ebook interactive routes, the audiobook search route (an edited title sendsexactTitle: true), its hook and the modal.main: withmain's source (08dc816) and this branch's tests, 70 failed and 347 passed in 11 files. 56 fail on assertions. The other 14 are unit tests of the two new match-normalize helpers, which do not exist onmain. On this branch, 417/417 pass.mainagainst this branch, on the Make auto-download quality score threshold configurable (currently hardcoded at 50/100) #223 right-book corpus (193 rows) and oracle (176 rows): no oracle score changes. Two right-book rows rise (Harry Potter and the Philosophers Stonefor "Harry Potter and the Philosopher's Stone", 93.1 and 91.2 to 100). TwoOp-Centerrows dip by 0.1 and 0.2 (86.9 to 86.8, 84.2 to 84.0) through fuzzy title similarity, still far above 50.Checks
vitest relatedon the changed source files, plus the new tests and the ranking suites): PASS, 115 files, 2293/2293ranking-algorithm,ranking-match-gates,ranking-non-latin,ranking-oracle-223,ranking-right-books-223,match-normalize: PASStsc --noEmitclean; ESLint reports nothing new in the touched files compared with main, and the new file is clean)src/lib, route call sites, one hook and one modal callRisk and rollback
Enders.Game,Anarchists,Philosophers), uses the other apostrophe form (curly for straight), or splits an elision (L.Intrusefor "L'intruse",O Brienfor "O'Brien") now matches. Such a request also matches the release word without the apostrophe when that is the plural (Loversfor "Lover's"), which needs the rest of the title to match too.L'Héritagefor a request "Héritage", French): the release splits intol heritage, so interactive search now shows it (match 0 to 60); automatic search still scores it 0.The Titan's Curse) is never matched by a plural request word ("The Titans").Op-Centerrows above dip a fraction of a point. A curly possessive in a release now stays one word, like a straight one, wheremainsplit it in two. That takes two wrong books thatmainpicked in automatic search to 0:The Lover’s Dictionaryfor "The Lover" (70.4) andThe Housemaid’s Secretfor "The Housemaid" (76.5), both by the requested author.Stephen King’s Itfor "It" moves from 60.3 to 60.0.Ender.s.Game) does not matchEnder's, and a request written without the apostrophe ("Enders Game") does not matchEnder’s Game, as on main.enders gamefor "Ender's Game" was 0.5, now 1); other titles rank as before.Release note
🤖 Generated with Claude Code