Getting started with advanced queries
While Logseq queries are powerful out of the box, sometimes you may want more control. The answer? Advanced queries.
Last updated on Invalid Date
Queries are a powerful tool to search your Logseq graph. Under the hood, Logseq uses Datascript for the database and Datalog as the query engine. The built-in queries of Logseq are all written in Datalog, and you can write your own using the language.
Is this all confusing to you? Check out simple queries first.
The resources below provide a quick introduction into Logseq's advanced queries. Just start at the top and move down as you become more proficient with Datalog.
Learn the basics of advanced queries in 10 minutes
Bas from Tools on Tech explains in just 10 minutes the basic structure of Logseq's advanced queries:
You can find more examples in Bas's public Logseq graph:
Advanced queries in five examples
Hit the ground running with this written tutorial by Logseq power user qwxlea. In it, he shows five common use cases for queries, written using Datalog:
Learn Datalog today
Now that you have an idea of what's possible with advanced queries, it's time to dive deeper into Datalog. Master everything you need to know using this free resource:
Official documentation on advanced queries
Once you have a grasp of Datalog, get some inspiration from the official Logseq documentation on advanced queries:
Logseq's database schema
Want to know what else is possible with Datalog in Logseq? Check out Logseq's database schema: