API: Search syntax (simple)

00001012051890 · Info · (manual) · #api #manual #zettelstore

If the search string starts with the exclamation mark character (!, U+0021), it will be removed and the query matches all values that do not match the search string.

In the next step, the first character of the search string will be inspected. If it contains one of the characters :, =, >, <, or ~, this will modify how the search will be performed. The character will be removed from the start of the search string.

For example, assume the search string is def:

The colon character (:, U+003A) (or none of these characters)

This is the default comparison. The comparison depends on the type of the underlying values. For a content search, it is equal to the tilde character ~, which returns true if a word within the content just contains the search string. For metadata, it depends on the key type.

It you omit the the comparison character, the default comparison is also used.

The tilde character (~, U+007E)
The inspected text1 contains the search string. def, defghi, and abcdefghi are matching the search string.
The equal sign character (=, U+003D)
The inspected text must contain a word that is equal to the search string. Only the word def matches the search string.
The greater-than sign character (>, U+003E)
The inspected text must contain a word with the search string as a prefix. A word like def or defghi matches the search string.
The less-than sign character (<, U+003C)
The inspected text must contain a word with the search string as a suffix. A word like def or abcdef matches the search string.

If you want to include an initial ! into the search string, you must prefix that with the escape character \. For example \!abc will search for the string !abc. A similar rule applies to the characters that specify the way how the search will be done. For example, !\=abc will search for content that does not contains the string =abc.

  1. Either all words of the zettel content and/or some metadata values ↩︎