Skip to content

Instantly share code, notes, and snippets.

@tiensonqin
Created December 5, 2022 04:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiensonqin/ba5c35b2c3d1445eed69045bcab9a20b to your computer and use it in GitHub Desktop.
Save tiensonqin/ba5c35b2c3d1445eed69045bcab9a20b to your computer and use it in GitHub Desktop.
Initial input for chatgpt
  • What are "Queries" in Logseq?
    • Queries are for asking questions from your knowledge base and the outside world.
      • How to write simple queries?
        • By using {{query }}, the format is something like this:
        {{query Something you're looking for}}
        
  • **Query Operators ** These three operators can be applied around any query filters.
    • and Examples:

      (and [[page 1]] [[page 2]])
      
      (and (task now later done) [[page]])
      
    • or Examples:

      (or [[page 1]] [[page 2]])
      
    • not Examples:

      (not [[page 1]] [[page 2]])
      
  • Query filters Most filters apply to blocks. Some filters only apply to pages. The following page-only filters cannot be mixed with block filters: page, page-property, page-tags and all-page-tags.
    • between The format (between start end) will only support blocks on the journal pages.

      There're several built-in symbols:

      1. today|yesterday|tomorrow|now
      2. +|- number y|m|w|d|h|min

      Examples:

      (between -7d +7d)
      (between -2w today)
      
      
    • Page Examples: [[questions]] {{query (page "term/alias")}}

    • property [[Block properties]] Examples: {{query (property type book)}}

    • Full-text query #+BEGIN_NOTE It's only enabled on the desktop app at the moment. #+END_NOTE Examples: Query blocks with word "alias" in content

      {{query "alias"}}
      
    • task (used to be todo) Examples: All NOW tasks

      (task now)
      

      All NOW and LATER tasks

      (task now later)
      
      • To be noticed, there are many task marks in Logseq: "NOW" "LATER" "DOING" "DONE" "TODO" "A" "B" "C"
      • And some deprecated marks: "CANCELED" "CANCELLED" "IN-PROGRESS" "WAIT" "WAITING"
    • priority Examples:

      (priority a)
      (priority a b c)
      
    • page-property Example: {{query (page-property related "Block embed")}}

    • page-tags Example: {{query (page-tags embed)}}

    • all-page-tags Example: {{query (all-page-tags)}}

    • sort-by Format: (sort-by property-name order) or (sort-by property-name) key: Can be any user property as well as built-in properties created-at and updated-at order: desc or asc, omit means desc.

      (and (task now later) (sort-by created-at desc))
      
  • More query examples
      1. Find the blocks containing page "tag1"
      {{query [[tag1]]}}
      
      {{query [[tag1]]}}
      1. Find the blocks containing both tag1 and tag2
      {{query (and [[tag1]] [[tag2]])}}
      
      {{query (and [[tag1]] [[tag2]])}}
      1. Find the blocks containing either tag1 or tag2
      {{query (or [[tag1]] [[tag2]])}}
      
      {{query (or [[tag1]] [[tag2]])}}
      1. Find the blocks containing tag2 but not tag1 {{query (and [[tag2]] (not [[tag1]]))}}
      1. Find journal blocks created between [[Dec 5th, 2020]] to [[Dec 7th, 2020]] {{query (between [[Dec 5th, 2020]] [[Dec 7th, 2020]] )}}
      1. Find all the blocks created today (you need to enable [[block timestamps]] before using this query) ``` {{query (between created-at today tomorrow)}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment