Expand description
Relevance ranking for search results.
Both search paths (the SQLite FTS cache and the Jellyfin server) return items in an order that ignores where in the name the query matched: a server substring hit like “Sparks of Love” can outrank “Parks and Recreation” for the query “parks”. Neither backend is going to change, so the app imposes its own ordering on the union.
Ranking is domain logic, not presentation: it encodes what a “better match” means and which media kinds outrank which. The frontend only renders the order it is given.
Two rules, in priority order:
- Match position — a prefix match beats a word-start match, which beats a mid-word substring match. This is what makes “parks” find “Parks and Recreation” before “Sparks of Love”.
- Kind — containers before their contents at equal match quality, so a series outranks its own episodes.
Ties fall back to the input order, so a backend’s own relevance signal (FTS
rank) still breaks ties it was never overruled on.
Enums§
- Match
Quality - How well a query matched an item’s name — better matches sort first.
Functions§
- kind_
rank 🔒 - Rank of a media kind when match quality ties — lower sorts first.
- match_
quality - Classify how
querymatchesname, case-insensitively. - rank_
search_ results - Sort search results by relevance to
query, in place.