(zettel (meta (back "00001007700000") (backward "00001007700000") (box-number "1") (created "20220810144539") (modified "20240219155949") (published "20240219155949") (role "manual") (syntax "zmk") (tags "#manual #reference #search #zettelstore") (title "Formal syntax of query expressions")) (rights 4) (encoding "") (content "```\nQueryExpression := ZettelList? QueryDirective* SearchExpression ActionExpression?\nZettelList := (ZID (SPACE+ ZID)*).\nZID := '0'+ ('1' .. '9'') DIGIT*\n | ('1' .. '9') DIGIT*.\nQueryDirective := ContextDirective\n | IdentDirective\n | ItemsDirective\n | UnlinkedDirective.\nContextDirective := \"CONTEXT\" (SPACE+ ContextDetail)*.\nContextDetail := \"FULL\"\n | \"BACKWARD\"\n | \"FORWARD\"\n | \"COST\" SPACE+ PosInt\n | \"MAX\" SPACE+ PosInt.\nIdentDirective := IDENT.\nItemsDirective := ITEMS.\nUnlinkedDirective := UNLINKED (SPACE+ PHRASE SPACE+ Word)*.\nSearchExpression := SearchTerm (SPACE+ SearchTerm)*.\nSearchTerm := SearchOperator? SearchValue\n | SearchKey SearchOperator SearchValue?\n | SearchKey ExistOperator\n | \"OR\"\n | \"RANDOM\"\n | \"PICK\" SPACE+ PosInt\n | \"ORDER\" SPACE+ (\"REVERSE\" SPACE+)? SearchKey\n | \"OFFSET\" SPACE+ PosInt\n | \"LIMIT\" SPACE+ PosInt.\nSearchValue := Word.\nSearchKey := MetadataKey.\nSearchOperator := '!'\n | ('!')? ('~' | ':' | '[' | '}').\nExistOperator := '?'\n | '!' '?'.\nPosInt := '0'\n | ('1' .. '9') DIGIT*.\nActionExpression := '|' (Word (SPACE+ Word)*)?\nAction := Word\n | 'ATOM'\n | 'KEYS'\n | 'N' NO-SPACE*\n | 'MAX' PosInt\n | 'MIN' PosInt\n | 'REDIRECT'\n | 'REINDEX'\n | 'RSS'\n | 'TITLE' (SPACE Word)* .\nWord := NO-SPACE NO-SPACE*\n```"))