How to use queries and indentation in Logseq (with examples)
Based on CombiningMinds's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Indentation creates parent/child blocks, and child blocks inherit page links from their parents—this directly shapes query results.
Briefing
Logseq queries become genuinely powerful once indentation is treated as structure: parent blocks define inherited links, child blocks automatically carry those links, and queries then retrieve exactly the blocks that match the inherited page references. The practical payoff is faster, more reliable retrieval than manual filtering—especially when journal entries are nested and scattered across time.
Indentation in Logseq isn’t just formatting. Blocks form a hierarchy where a parent block holds context and child blocks nest under it. Using Tab and Shift+Tab to indent or unindent turns a block into a child of the block above, which means the child inherits backlinks/page links from its parent. This inheritance enables quick collapsing of sections like an outline—chapters under a book, paragraphs under a chapter—while keeping the underlying linked data consistent. The video also distinguishes sibling blocks: blocks at the same indentation level under the same parent don’t inherit each other’s context, which matters when linking and later when queries combine conditions.
Linking is the foundation for queries. Backlinks and hashtags both create links to pages, and the choice is largely personal preference. For multi-word page targets, square brackets (or backlinks) are needed; hashtags work for single-word page names. In practice, the core pattern is: create page links on blocks (either via hashtags or square brackets), then query those page-linked relationships.
To run a query, the forward-slash command “/query” opens the query builder, which uses curly-brace syntax: {query ...}. The simplest form returns all blocks linked to a given page name. Blocks can link directly (a block has the page link itself) or indirectly through inheritance (a child block inherits the page link from its parent). That inheritance is what makes nested journal writing usable for later retrieval.
Queries also support boolean logic, letting users treat sets of blocks like Venn diagrams. Using AND returns blocks that have both page links (e.g., {query [a] [b]} yields the overlap). Using OR returns blocks linked to either page (e.g., {query [a] or [b]} yields the union). A NOT operator enables exclusion, such as “AND a and b but not c,” implemented by nesting {query [a] [b] not [c]}-style logic.
Beyond page links, the query system extends to block types like to-dos and to properties. Properties use a similar bracketed syntax: {query property <name> <value>}, returning pages whose defined property matches. The transcript highlights a “type: books” example, where querying property type=books returns specific book pages. For habit-tracking or quantified-self use cases, properties like wake up and bedtime can be queried to produce a history of values; the results can even be arranged into a markdown table.
Finally, queries are positioned as more than search filters: they provide targeted retrieval that respects parent-block inheritance and can be saved as permanent query pages for quick reuse. The overall message is that indentation plus correct linking turns Logseq into an outline-driven database—one where structured writing and precise querying reinforce each other rather than fighting for attention.
Cornell Notes
Indentation in Logseq creates a parent/child hierarchy where child blocks inherit page links (backlinks/hashtags) from their parents. Queries then use those inherited links to retrieve the right blocks, using curly-brace syntax like {query ...} opened via “/query.” Boolean logic lets users combine link sets: AND returns the overlap of blocks linked to both tags/pages, OR returns the union, and NOT excludes blocks linked to a third page. Queries also extend to block types (like to-dos) and to properties (e.g., property type=books), enabling structured retrieval for workflows like habit tracking. This matters because it makes nested journal writing searchable in a precise, reusable way—often better than manual filtering.
Why does indentation matter for querying in Logseq, beyond visual organization?
How do backlinks and hashtags relate to pages, and what’s the practical difference?
What is the basic syntax for a Logseq query that returns blocks linked to a page?
How do AND, OR, and NOT change what a query returns?
How do properties and to-dos fit into the query system?
What’s the advantage of queries over manual searching with filters?
Review Questions
- When a child block inherits links from its parent, how would that affect the results of a {query ...} that targets the parent’s linked page?
- Write a boolean query conceptually: which blocks would you expect from an AND query vs an OR query when tags/pages are a, b, and c?
- How would you structure properties (like type: books or wake up/bedtime) so that a property query returns the intended set of pages?
Key Points
- 1
Indentation creates parent/child blocks, and child blocks inherit page links from their parents—this directly shapes query results.
- 2
Sibling blocks at the same indentation level do not inherit each other’s links, so query outcomes depend on hierarchy.
- 3
Backlinks and hashtags both create page links; square brackets are needed for multi-word page names.
- 4
Use “/query” to open the query builder and curly-brace syntax like {query ...} to retrieve blocks linked to specific pages.
- 5
Boolean logic in queries works like set operations: AND returns overlap, OR returns union, and NOT excludes a subset.
- 6
Queries can target more than links: they can filter by to-do block types and by properties such as property type=books.
- 7
Queries can be saved as permanent query pages, making repeated retrieval faster and more reliable than manual filtering.