LIBRARY_SEARCH.md
docs/features/LIBRARY_SEARCH.md
1# Advanced library search23The existing search field now accepts shared search expressions on Android, iOS,4desktop and web. Open the library menu → Library search help for the syntax guide.56Plain text retains phrase matching across titles, alternative titles, source names7and tags. Commas retain their existing alternative-search meaning. An existing8`genre:Science Fiction` link remains an exact tag search. In compound expressions,9use `tag:"Science Fiction"`.1011Expressions support `AND` / `&&`, `OR` / `||`, `NOT` / `-`, parentheses, implicit12AND between adjacent terms, quoted phrases, and escaped quotes/backslashes inside13quoted values. AND binds more tightly than OR; negation applies to the next term14or parenthesized group. Examples:1516```text17author:"Eiichiro Oda" AND unread>018(tag:action OR tag:adventure) -status:completed19added>=2026-01-01 AND lang:en20fi=7 AND nextupdate<=2026-10-2021```2223Text fields: `title`, `author`, `artist`, `description` (`desc`), `genre` (`tag`),24`source` (`src`), `notes` (`note`), `language` (`lang`), `source_id` (`sourceid`,25`src_id`, `srcid`), `status`, and `type`. Text matching ignores case. Tags and26languages match exactly; source IDs compare exact integers. Notes are only searched27through an explicit notes field, so private note text does not change plain searches.2829Compare `id`, `total`, `read`, `unread`, and `fetchinterval` (`fi`) with `=`, `>`,30`>=`, `<`, or `<=`. Chapter counts use the library's selected release policy,31including duplicate-release handling and hidden scanlators. Compare `added` and32`nextupdate` (`nu`) with ISO dates (`YYYY-MM-DD`) using the same operators. Dates33are UTC calendar days. Next update is the last successful refresh plus the effective34automatic/manual update interval, matching the updater's existing schedule calculation.35Schedule comparisons use all known release dates, so hiding releases does not change36the estimate; count comparisons use the selected releases.37It is an estimate rather than a source's announced release date. Unknown dates do38not match date comparisons.3940Unknown field prefixes remain literal searchable text. Malformed expressions,41invalid known comparison values, and expressions exceeding 4,096 characters,42256 tokens or 24 nesting levels fall back to a whole literal search. They never43apply only a successfully parsed prefix. Quote an entire literal term to prevent its44field-like syntax from being interpreted, for example `"genre:action"`.4546The parser is a bounded linear scanner compiled once per library query. Evaluation47uses the already observed, grouped chapter index with no database reads or network48requests. Read counts and update interval calculations are shared between conditions49for one title. The library evaluates each search once per title, then reuses those50matches for ordinary filtering and the Ignore filters option.5152The grammar was compared with Animetail commit53`d0eab5d6237dd09ebdb21a63fff5b66097c91087`, particularly its54`LibrarySearchLexer`, `LibrarySearchParser`, and field aliases in `LibrarySearchAst`.55Yokan additionally retains its previous phrase/comma/genre behavior and adds bounded56parsing, explicit literal quoting, and safe fallback for invalid input.57