Need help with queries in Logseq DB (test.logseq.com)

I’m trying out Logseq DB and using test.logseq.com.

I cannot seem to be able to make queries work.

I’m trying a simple one for “get all pages with title Some Page”:

  • I’m typing /query and choosing “Advanced Query”
  • in the code block, I’m typing:
{:query [:find (pull ?p [*])
         :where
         [?p :page/title "Some Page"]]}

0 Live Query results.

What am I doing wrong?

(Thanks, and sorry if this feels basic.)

You need to change “:page/title” to “:block/title” :slight_smile:

Thank you.

I’d have some more questions:

  1. right now I’m trying :block/tags "event" to retrieve pages/blocks tagged “event”, but it doesn’t seem to work
  2. does such a query for blocks/pages tagged with a tag also work with parent tags? (i.e. if I have a page/block tagged invention which extends event, would it be retrieved when querying for blocks tagged event?)
  3. while searching online I’ve found another kind of syntax that goes roughly like this (see below); is this some AI hallucination or some valid alternative? (it doesn’t seem to work)
:query {
  :block/title "Some Page"
}

I don’t know much, but I know there are Queries and Advanced Queries.

“: query” seems to imply advanced, but it is followed by an '“[“.

Lesson 1: What Are Logseq Queries and Why You Should Learn to Use Them - Questions & Help / Queries - Logseq

I found some videos on YouTube which cover something called Query Builder, which avoids having to code simple queries at all. There is also a video about advanced queries I haven’t watched yet.

I get the feeling he says the opposite of what he means sometimes, so watch what he does very closely.

Logseq Query Builder Quick Look - YouTube · Tools on Tech

Logseq Simple Queries - All the basics to filter what you need

LogSeq Advanced Query - Basics & Tips in less then 10 min

What really makes it difficult (getting queries working) is that there are two conditions that must both be satisfied for success:

1. The code for the query must be correct.

2. The data you are looking for must be in the index database to begin with.

3. Many sources say that the properties must be in the first block on the page. Actually, that is not so; they must be before the first block on the page. Then re-index.
(Maybe because I am using the old Logseq-MD, not the database version.)

Test with a minimal unfiltered advanced query, if you don’t have too much content yet.

#+BEGIN_QUERY
{
:query [:find (pull ?b [*])
:where
[?b :block/properties]]
}
#+END_QUERY