- 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}}
- By using
- How to write simple queries?
- Queries are for asking questions from your knowledge base and the outside world.
- **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
andall-page-tags
.-
between The format
(between start end)
will only support blocks on the journal pages.There're several built-in symbols:
today|yesterday|tomorrow|now
+|-
numbery|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 propertiescreated-at
andupdated-at
order
:desc
orasc
, omit meansdesc
.(and (task now later) (sort-by created-at desc))
-
- More query examples
-
- Find the blocks containing page "tag1"
{{query [[tag1]]}}{{query [[tag1]]}}
-
- Find the blocks containing both
tag1
andtag2
{{query (and [[tag1]] [[tag2]])}}{{query (and [[tag1]] [[tag2]])}}
- Find the blocks containing both
-
- Find the blocks containing either
tag1
ortag2
{{query (or [[tag1]] [[tag2]])}}{{query (or [[tag1]] [[tag2]])}}
- Find the blocks containing either
-
- Find the blocks containing
tag2
but nottag1
{{query (and [[tag2]] (not [[tag1]]))}}
- Find the blocks containing
-
- Find journal blocks created between [[Dec 5th, 2020]] to [[Dec 7th, 2020]] {{query (between [[Dec 5th, 2020]] [[Dec 7th, 2020]] )}}
-
- Find all the blocks created today (you need to enable [[block timestamps]] before using this query) ``` {{query (between created-at today tomorrow)}}
-
Created
December 5, 2022 04:44
-
-
Save tiensonqin/ba5c35b2c3d1445eed69045bcab9a20b to your computer and use it in GitHub Desktop.
Initial input for chatgpt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment