You’re reading the ZotLit v2 docs. Still on v1? Read the v1 docs

ZotLit

Query file format

Every key of a .zotquery query file and a zotquery query block, with their values and defaults.

This reference lists the keys of a query file (.zotquery) and a query block (```zotquery). Both hold the same YAML text, in the shape of an Obsidian .base file.

The toolbar writes these keys for you. Write them by hand when you type a query block, or when you copy a view from one file to another.

Example

filters: collections.within("Thesis")
views:
  - type: table
    name: Reading list
    from: items
    sort:
      - property: title
        direction: ASC
    order:
      - title
      - firstAuthor
      - date
      - vault.literatureNote
      - vault.reading-status
    limit: 100
  - type: annotations
    name: Figures
    from: annotations
    filters: tags.contains("figure")
    groupBy:
      property: item.indexedKey
      direction: ASC
    limit: 100

Top-level keys

KeyValue
filtersThe filters for all views. They apply to each view that has the same from as the first view. See Filters.
formulasThe formulas of the file, by name. See Formulas.
propertiesThe display name of each property, by property path. See Display names.
viewsA list of views. Required. The first view is the default view, which an embed without #View name shows.

ZotLit keeps every other key in the file when it saves.

View keys

KeyValue
typeThe layout: annotations, table, list, or cards. Required.
nameThe view name. Required, and different from the other views of the file. When two views have the same name, the file shows a problem in place of its rows.
fromThe records of each row: annotations, attachments, or items. Required.
filtersThe filters for this view. See Filters.
sortA list of property and direction pairs. The first pair sorts first. direction is ASC or DESC; the default is ASC. An items view can also sort by a vault property.
groupByOne property and direction pair. The rows collect under one heading for each value of the property.
groupOrderA list of group values for a Manual group order. Only the listed groups show, in this order. null is the group of rows with no value.
limitA positive whole number: the most rows the view shows. Without limit, the view shows every match. After a sort or a filter on a vault property, limit still counts the rows the view shows.
orderA list of property paths that each row shows, in order. Copy and CSV export use them as columns. Without order, the layout shows the default properties of the records. For an items table, it can also include vault.literatureNote to show the literature note column. An items view can also show a vault property.
columnSizeThe width in pixels of each table column that you resized, by property path. A column without an entry takes its automatic width.

property values are property paths of the view's records, as ZotLit Query names them. For example, title is the paper title in an items view, and item.title is the paper title in an annotations view.

order also takes vault.literatureNote (in an items table), vault.<name> for a vault property (in an items view), and formula.<name> for a formula. sort and groupBy do not take a formula yet: a view that sorts or groups by one shows an error in place of its rows. groupBy does not take a vault property either.

Layouts and records

typeAllowed from
annotationsannotations
tableitems
listannotations, attachments, or items
cardsannotations, attachments, or items

A view whose type and from do not fit shows a message in place of its rows.

Layout options

LayoutKeyValueDefault
annotationscardWidthThe narrowest card width, in pixels, from 200 to 800320
annotationsshowCommenttrue or falsetrue
annotationsshowTagstrue or falsetrue
annotationsshowPagetrue or falsetrue
listmarkersbullet, number, or nonebullet
listindentPropertiestrue or falsefalse
listseparatorThe text between two properties on a line,
cardscardSizeThe narrowest card width, in pixels, from 50 to 800200

Filters

A filter is one Filter Expression, or a group of filters under and, or, or not:

filters:
  and:
    - colorName == "yellow"
    - or:
        - tags.contains("method")
        - tags.contains("result")

and matches the records that match every entry. or matches the records that match at least one. The filter editor opens a not group as one expression condition.

A filter can name the Query Context as this.item and this.attachment:

fromFilter for the records of the note's paperFilter for the records of one attachment
annotationsitem == this.itemattachment == this.attachment
attachmentsitem == this.itemindexedKey == this.attachment.indexedKey
itemsindexedKey == this.item.indexedKey

In an embed or a query block, this.item is the item that the note's zotero-key property names. In a query file's own tab, this has no value. See this: the paper of the note.

Formulas

formulas maps each formula name to a Filter Expression. A view shows the result as the property formula.<name>:

formulas:
  year: date.year
  authors: creators.length
views:
  - type: table
    name: Reading list
    from: items
    filters: formula.year >= 2020
    order:
      - title
      - formula.year
      - formula.authors
RuleValue
NameLetters, digits, and _, starting with a letter or _. Letter case counts.
ExpressionThe same language as a filter. It reads the properties of the view's records, this.item, this.attachment, and the other formulas.
Resulttrue or false, a number, a text, a date, or a list.
Used inorder and filters of any view, and other formulas.

A view computes only the formulas that its order and filters use. A formula that uses itself through other formulas is a mistake.

A formula that cannot run on the records of a view marks its property in that view only. For example, a formula colour with the expression colorName runs in an annotations view. An items view of the same file that shows formula.colour marks it, and its other properties stay on screen. A record on which a formula cannot compute its result shows an Error Value in that cell.

Vault properties

A vault property, vault.<name>, is the value of the frontmatter key <name> on the paper's Literature Note. The text after vault. is the key as the note writes it, with its letter case and hyphens. For example, vault.reading-status reads the reading-status property of each paper's note.

Vault properties work in views with from: items. Properties from your Literature Notes explains how ZotLit reads them.

KeyTakes a vault property
orderYes. The Table, List, and Cards layouts show it. The Table also edits it.
sortYes. See Sort.
filtersYes, as a condition that every row must match. See Filter.
propertiesYes. The key is vault.<name>, such as vault.reading-status.
columnSizeYes.
groupByNo.

Each cell shows one of three states:

The paperThe cell
Has no Literature NoteNo note, in faint text
Has a note without the key, or with an empty valueEmpty
Has a note with a valueThe value

When a paper has more than one Literature Note, the view reads the note that changed last. In an embed or a query block inside a Literature Note, the row of that note's own paper reads that note. Copy and CSV export write the value of each vault property. The view refreshes a cell when the note's properties change.

Names that a vault property cannot take

The Properties menu does not list these keys, and does not add them:

KeyOwner
tagsObsidian
aliasesObsidian
cssclassesObsidian
zotero-keyZotLit
zotlit-profileZotLit
zotero-note-keyZotLit
zotero-lastmodZotLit
zotlit-cslZotLit

A key that you type by hand into order, such as vault.tags, still shows as a column.

A key that the note's own profile writes with the replace merge strategy is read-only in the Table, because the next note update overwrites it. The cell shows a lock icon when you point to it. Out of the box, the Default profile writes title, related, collections, and citekey this way. Keys with keep or append stay editable.

Values that an edit writes

The Table edits a vault property by the type that Obsidian's Properties panel gives it. When the property has no type there, the Table uses the type of the values in your notes, and otherwise text.

TypeEditValue written
TextA text fieldText
List, tags, or aliasesItems in a row. Enter adds the text as an itemA list of text
NumberA text fieldA number
CheckboxA click toggles ittrue or false
DateA date fieldA date, as YYYY-MM-DD
Date and timeA date and time fieldA date and time, as YYYY-MM-DDTHH:mm:ss

An edit writes only its own key. A cleared cell keeps the key with an empty value. Text that is not a number writes nothing to a number property.

Sort

sort:
  - property: vault.reading-status
    direction: ASC
  - property: date
    direction: DESC

Empty values sort last in both directions. A sort can mix vault properties and Zotero properties.

To sort by a vault property, the view reads at most 5,000 matching papers, sorts them, and then keeps limit rows, in each group of a grouped view. When more papers match, only those 5,000 are sorted, and the result count shows both numbers. After you change a value, the rows keep their place until the view runs again.

Filter

A condition reads a vault property as vault.<name>, or as vault["<name>"] for a name with a hyphen or a space:

filters:
  and:
    - collections.within("Thesis")
    - vault["reading-status"] == "read"

A paper without a Literature Note counts as having no value. So vault["reading-status"] != "read" and vault["reading-status"] == null both match papers without a note.

A vault condition must be its own entry, and every row must match it:

  • The whole filter is one vault condition.
  • Or the condition is a direct entry under the top-level and of filters, in the file or in the view.

These conditions stop the view, and the condition's row in the filter editor shows the reason:

ConditionReason
A vault condition inside an or or not groupA condition on a vault property cannot sit inside an "or" or "not" group.
A condition that reads a vault property and a Zotero property, such as vault.rating > 3 && date.year > 2020A condition on a vault property cannot also read a Zotero field.

Split a mixed condition into two entries under and. A condition that reads this, or names the property through an expression such as vault[name], also shows the second reason.

Display names

properties gives a property its display name. Each key is the same text as an order entry: a property path, vault.literatureNote, vault.<name> for a vault property, or formula.<name> for a formula.

properties:
  title:
    displayName: Work
  formula.year:
    displayName: Year of source

The display name shows in every view of the file: the Table header, the Cards labels, the Properties menu, and the header row of copy and CSV export. ZotLit keeps the other keys under each property. A key with the Obsidian Bases prefix note., such as note.date, names no property.

A new query file

A query file that you create from the command palette or the file explorer holds this text:

views:
  - type: table
    name: Items
    from: items
    sort:
      - property: dateModified
        direction: DESC
    limit: 100
    order:
      - title
      - creators
      - date.year
      - vault.literatureNote
  - type: annotations
    name: Annotations
    from: annotations
    groupBy:
      property: item.indexedKey
      direction: ASC
    limit: 100

ZotLit writes the view names in the app's language.

See also

Last updated on

On this page