Get AI summaries of any video or article — Sign up free
How to use queries in Logseq thumbnail

How to use queries in Logseq

CombiningMinds·
5 min read

Based on CombiningMinds's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Logseq queries are a directed retrieval method that can be saved as blocks, enabling repeatable workflows.

Briefing

Logseq queries turn note retrieval into repeatable, parameter-driven “database questions,” letting users pull exactly the blocks they need—then save those searches as blocks for quick reuse. That matters because the real payoff in Logseq comes from fast, targeted resurfacing of information; when retrieval is precise, notes shift from a one-way feed into a feedback loop that supports writing, planning, and review.

At the core, queries are Logseq’s most directed retrieval method. Instead of relying only on Control K search, queries can specify criteria such as tags, backlinks, task status, priority, and date ranges. They also save the query as a block, so the same retrieval workflow can be repeated later without rebuilding the logic.

A query returns three categories of results: (1) blocks linked to a backlink or tag, (2) blocks indented under those linked blocks—making indentation crucial for structuring data—and (3) all blocks on the page where the query runs (if any exist). This behavior is demonstrated using tags/backlinks, where a query for a hashtag returns the linked blocks and their indented children, while the page-level results can be empty depending on setup.

Query syntax is built around typing “/query” and then entering parameters. The transcript highlights built-in parameters that map to common workflows: task status via task (using parentheses rather than square brackets), priority via priority (with Logseq’s three priority levels A, B, and C), and time filtering via between (including relative ranges like “yesterday” to “today,” and offsets such as “minus one day” or “minus one year”). For more complex retrieval, Boolean logic—using operators like and, or, not, and all—lets users combine conditions. A practical example pairs task status “to do” with priority “A,” using nested parentheses to keep the logic unambiguous.

Several usage tips focus on making queries maintainable and fast. Users are encouraged to add a user-friendly description block above each query and collapse it so the database reads like documentation. Text queries are especially valuable when information isn’t linked: wrapping terms in inverted commas returns matching blocks quickly, and the transcript warns that text queries are case sensitive. Performance is another constraint: queries that return too many blocks can slow Logseq dramatically, so broad queries should be used carefully.

For readability, query results can be pivoted into tables when block properties are used consistently, enabling structured “index” pages such as an articles namespace populated via properties. The transcript also gives concrete dashboard-style examples: a task dashboard that filters high/medium priority tasks, a “query while writing” setup that surfaces prior feedback tagged to a colleague for reference during drafting, and code-focused text querying for CodeMirror blocks (with an emphasis on consistent lowercase naming due to case sensitivity).

Finally, queries are positioned as a complement to search rather than a replacement. They’re most useful for aggregating information into a consistent place (like compiling feedback), building dashboards and repeatable pipelines, finding text across unlinked references, and creating index-style views over time—such as revisiting the same date across the last 12 months or last 10 years using date-range queries. The transcript closes by noting that Boolean logic is covered in more depth elsewhere, while properties/metadata are a natural next topic for deeper, table-friendly indexing.

Cornell Notes

Logseq queries provide precise, parameter-based retrieval and can be saved as blocks for repeatable workflows. A query returns three result types: blocks linked to a tag/backlink, indented blocks under those linked items (so indentation matters), and blocks on the page itself. Built-in parameters support tasks (task status), priority (A/B/C), and date ranges (between with relative offsets like “yesterday” or “minus one year”). Boolean logic (and/or/not/all) combines conditions, enabling targeted dashboards such as “to do” tasks with priority A. Queries are especially powerful for text retrieval when items aren’t linked, but they’re case sensitive and can slow performance if they return too many blocks.

What exactly does a Logseq query return, and why does indentation matter?

A query returns three categories: (1) blocks linked to a backlink or tag, (2) blocks indented underneath those linked blocks, and (3) blocks on the page where the query is placed (if present). Because indented children are included, structuring results with indentation becomes essential—otherwise the query may return only the parent blocks and miss the nested information meant to “bubble up.”

How do built-in query parameters support common workflows like tasks and time windows?

Task filtering uses the task parameter with normal parentheses to specify status (e.g., task in a query to pull “to do” items). Priority filtering uses priority with Logseq’s three levels A, B, and C. Date filtering uses between with relative expressions such as “yesterday” to “today,” and offsets like “minus one day” or “minus one year,” returning only blocks whose dates fall within the specified range.

How does Boolean logic change what a query can retrieve?

Boolean logic lets users combine conditions beyond a single filter. Using operators like and/or/not/all, a query can require multiple constraints simultaneously—for example, tasks where status is “to do” AND priority is “A.” Parentheses keep the logic readable and prevent bracket confusion when conditions get more complex.

When should someone use text queries instead of relying on links or unlinked references?

Text queries are useful when the needed information isn’t linked to a page or tag. By using inverted commas around a term (e.g., “testing”), Logseq can search across blocks and return matches quickly. The transcript also warns that text queries are case sensitive, so consistent capitalization matters.

What practical steps keep query dashboards readable and maintainable?

Add a user-friendly description block above each query and collapse it so the database behaves like documentation. Indent the query under that description and use collapse/expand shortcuts (e.g., Tab and control/command up/down) to keep the page clean. For large result sets, consider pivoting results into tables using block properties for consistent structure.

What are the main performance and correctness pitfalls mentioned for queries?

Two key pitfalls: (1) case sensitivity—especially for text queries and naming consistency in CodeMirror-style blocks—and (2) overly broad queries that return too many blocks, which can slow Logseq performance dramatically. Keeping queries targeted and structured helps avoid both issues.

Review Questions

  1. How does the query result behavior differ between linked blocks and indented child blocks, and how would you structure notes to take advantage of that?
  2. Create a query plan (in words) for a dashboard that shows tasks with status “to do” and priority “B” due between two relative dates—what parameters and Boolean operators would you use?
  3. Why might a text query return nothing even though the term exists in the database, and what detail about casing could explain the mismatch?

Key Points

  1. 1

    Logseq queries are a directed retrieval method that can be saved as blocks, enabling repeatable workflows.

  2. 2

    A query returns linked blocks, indented child blocks under those linked items, and page-level blocks where applicable—so indentation is a functional requirement.

  3. 3

    Built-in parameters support task status (task), priority (priority with A/B/C), and time filtering (between with relative date expressions).

  4. 4

    Boolean logic (and/or/not/all) plus parentheses allows precise multi-condition retrieval, such as “to do” tasks with priority A.

  5. 5

    Text queries (using inverted commas) are ideal for finding unlinked information, but they are case sensitive.

  6. 6

    Avoid queries that return extremely large result sets because they can slow Logseq performance.

  7. 7

    Use collapsing, user-friendly description blocks, and table pivots (via consistent block properties) to keep query dashboards readable.

Highlights

Queries return three result types—linked blocks, their indented children, and page blocks—making indentation a core part of how results “bubble up.”
Text queries search across blocks without requiring links, but they’re case sensitive and can be dramatically faster than hunting through unlinked references.
Boolean logic plus built-in parameters lets users build dashboards like “task status to do AND priority A,” turning note retrieval into a structured pipeline.
Date-range queries can recreate “same date last month” or “same date across the last 10 years” retrieval patterns for journaling and review.

Topics