diff --git a/Search.md b/Search.md index b836183..c650cd9 100644 --- a/Search.md +++ b/Search.md @@ -1,14 +1,35 @@ -Trilium supports searching in notes. In essence it consists of +Trilium supports searching in notes. There are several ways to search notes: -* [[attribute|Attributes]] search - you can e.g. search for notes having certain label - see *Attribute query syntax* below. * full text search - search in text and [[code note|code notes]] content. Since this is implemented as a database search, this works only for not protected notes (doesn't matter if you're in protected session or not) +* [[attribute|Attributes]] search - you can e.g. search for notes having certain label - see *Attribute query syntax* below. + +* you can save search string (composed of either fulltext or attribute search) into so-called "saved search" note. If you expand this note, you will see the search results as child notes. + * saved search can also reference [[scripts|script]] through relation - upon expanding, the script will provide a list of results + You can activate search by clicking on magnifier icon on the left or pressing `CTRL-S` keyboard [[shortcut|keyboard shortcuts]]. +## Fulltext + +Fulltext search is triggered whenever search string doesn't start with `@` (used in attribute search) or `=` (saved search with script). You can enter any text, but only alpha numeric words are being searched. + +Fulltext searches on undeleted, unprotected text and code notes which are not archived. + +Fulltext is implemented using Sqlite's [FTS5](https://www.sqlite.org/fts5.html). This provides some advanced functionality, e.g. "NEAR(heavy metal)" will match notes only if a word "heavy" is close to "metal". But since this syntax is quite specific and easy to get it wrong, it is accessible only via `@text` virtual attribute. Such query would then look like this: `@text="NEAR(heavy metal)"` + ## Attribute query syntax Following examples demonstrates syntax: +
  • Just enter any text for full text search
  • +
  • @abc - returns notes with label abc
  • +
  • @year=2019 - matches notes with label year having value 2019
  • +
  • @rock @pop - matches notes which have both rock and pop labels
  • +
  • @rock or @pop - only one of the labels must be present
  • +
  • @year<=2000 - numerical comparison (also >, >=, <).
  • +
  • @dateCreated>=MONTH-1 - notes created in the last month
  • +
  • =handler - will execute script defined in handler relation to get results
  • + * ```@abc``` - matches notes with label abc * ```@!abc``` - matches notes without abc label (maybe not the best syntax) * ```@abc=true``` - matches notes with label abc having value true