# Advanced library search

The existing search field now accepts shared search expressions on Android, iOS,
desktop and web. Open the library menu → Library search help for the syntax guide.

Plain text retains phrase matching across titles, alternative titles, source names
and tags. Commas retain their existing alternative-search meaning. An existing
`genre:Science Fiction` link remains an exact tag search. In compound expressions,
use `tag:"Science Fiction"`.

Expressions support `AND` / `&&`, `OR` / `||`, `NOT` / `-`, parentheses, implicit
AND between adjacent terms, quoted phrases, and escaped quotes/backslashes inside
quoted values. AND binds more tightly than OR; negation applies to the next term
or parenthesized group. Examples:

```text
author:"Eiichiro Oda" AND unread>0
(tag:action OR tag:adventure) -status:completed
added>=2026-01-01 AND lang:en
fi=7 AND nextupdate<=2026-10-20
```

Text fields: `title`, `author`, `artist`, `description` (`desc`), `genre` (`tag`),
`source` (`src`), `notes` (`note`), `language` (`lang`), `source_id` (`sourceid`,
`src_id`, `srcid`), `status`, and `type`. Text matching ignores case. Tags and
languages match exactly; source IDs compare exact integers. Notes are only searched
through an explicit notes field, so private note text does not change plain searches.

Compare `id`, `total`, `read`, `unread`, and `fetchinterval` (`fi`) with `=`, `>`,
`>=`, `<`, or `<=`. Chapter counts use the library's selected release policy,
including duplicate-release handling and hidden scanlators. Compare `added` and
`nextupdate` (`nu`) with ISO dates (`YYYY-MM-DD`) using the same operators. Dates
are UTC calendar days. Next update is the last successful refresh plus the effective
automatic/manual update interval, matching the updater's existing schedule calculation.
Schedule comparisons use all known release dates, so hiding releases does not change
the estimate; count comparisons use the selected releases.
It is an estimate rather than a source's announced release date. Unknown dates do
not match date comparisons.

Unknown field prefixes remain literal searchable text. Malformed expressions,
invalid known comparison values, and expressions exceeding 4,096 characters,
256 tokens or 24 nesting levels fall back to a whole literal search. They never
apply only a successfully parsed prefix. Quote an entire literal term to prevent its
field-like syntax from being interpreted, for example `"genre:action"`.

The parser is a bounded linear scanner compiled once per library query. Evaluation
uses the already observed, grouped chapter index with no database reads or network
requests. Read counts and update interval calculations are shared between conditions
for one title. The library evaluates each search once per title, then reuses those
matches for ordinary filtering and the Ignore filters option.

The grammar was compared with Animetail commit
`d0eab5d6237dd09ebdb21a63fff5b66097c91087`, particularly its
`LibrarySearchLexer`, `LibrarySearchParser`, and field aliases in `LibrarySearchAst`.
Yokan additionally retains its previous phrase/comma/genre behavior and adds bounded
parsing, explicit literal quoting, and safe fallback for invalid input.
