Blocks in Advanced Query Disappear

Hi there! I have been using Logseq for organizing my todos, and generally it works really well. However, occasionally I’ll find that some of the older blocks in the query result will disappear, and only reappear again once I go and edit the blocks. I know I have a bit of an odd query, so I’m not sure if that’s the issue (it’s finding todo blocks with priority A where either the block has block property area of “work” or the page where the block exists has page property area of “work”). Any help would be greatly appreciated - I’m still trying to figure out the query language. Thank you so much!

#+BEGIN_QUERY
{
    :title [:h3 "Tasks"]
    :query [
            :find (pull ?b [*])
            :where
     
            [?b :block/marker "TODO"]
            [?b :block/priority "A"]
            
	    [?b :block/properties ?bp]
            [?b :block/page ?p]

            (or-join [?bp ?p]
            	(and
                   [(get ?bp :area) ?barea]
            	   [(contains? ?barea "work")]
                 )
                 (and
                    [?p :block/properties ?pp]
                    [(get ?pp :area) ?parea]
                    [(contains? ?parea "work")]
                )
            )
     ]
    :breadcrumb-show? false
    :collapsed? false
   }
#+END_QUERY
1 Like

Welcome.

  • If you have created:
    • some blocks
    • a query that returns those blocks
  • and for some days:
    • you have not changed the query
    • you have not changed the blocks
    • you have merely added more blocks that the query also returns
  • but suddenly at the end of those days:
    • the unchanged query stops returning the unchanged old blocks
  • it would mean that there is a bug

Next time you notice this behavior:

  • copy the blocks’ markdown both:
    • before editing the blocks, i.e. when they no more appear in the query
    • after editing the blocks, i.e. when they reappear in the query
  • share here the two copies, for us to check if there is a different explanation than the bug

Hi @mentaloid! Some of the blocks disappeared from one of my queries this morning. Below is the block data before and after. All I did to get the block showing in the query again was to click “DOING” > “TODO” then back to “DOING”. The markdown was the exact same between the before and after.

Before:

{:block/uuid #uuid "663c3960-e44b-47c9-b9e0-52a554754adf",
 :block/priority "A",
 :block/left {:db/id 4532},
 :block/refs [{:db/id 8} {:db/id 15}],
 :block/format :markdown,
 :block/content
 "DOING [#A] <redacted>.\n:LOGBOOK:\nCLOCK: [2025-04-16 Wed 14:15:32]\n:END:",
 :db/id 4615,
 :block/path-refs [{:db/id 4} {:db/id 8} {:db/id 15} {:db/id 340}],
 :block/parent {:db/id 340},
 :block/page {:db/id 340}, 
 :block/marker "DOING"}

After:

{:block/uuid #uuid "663c3960-e44b-47c9-b9e0-52a554754adf",
 :block/priority "A",
 :block/properties {},
 :block/updated-at 1745336778191,
 :block/left {:db/id 4532},
 :block/refs [{:db/id 8} {:db/id 15}],
 :block/created-at 1745336778191,
 :block/format :markdown,
 :block/content
 "DOING [#A] <redacted>.\n:LOGBOOK:\nCLOCK: [2025-04-16 Wed 14:15:32]--[2025-04-22 Tue 08:46:16] =>  138:30:44\nCLOCK: [2025-04-22 Tue 08:46:18]\n:END:",
 :db/id 4615,
 :block/path-refs [{:db/id 8} {:db/id 15} {:db/id 340}],
 :block/parent {:db/id 340},
 :block/page {:db/id 340}, 
 :block/marker "DOING"}
  • I can see a few differences:
    • :block/properties
    • :block/updated-at
    • :block/created-at
    • {:db/id 4}
      • This is the important one, as it corresponds to TODO.
  • The question is what caused these differences before the change from/to DOING.
    • Did you perform a re-indexing?
  • On the other hand, the block’s status is DOING both before and after.
    • Therefore, try changing the query
      • from:
        [?b :block/marker "TODO"]
        
      • to:
        [?b :block/marker ?marker]
        [(contains? #{"TODO" "DOING"} ?marker)]
        

Thanks for the response!

Did you perform a re-indexing?

No, at least not intentionally. I’m not sure if having the Git auto-commit causes a re-index.

On the other hand, the block’s status is DOING both before and after.

Sorry, I should have been more clear! This is for a similar query as the one I originally posted, but specifically for high priority DOING tasks. That’s why changing it from DOINGTODODOING meant it came back into the query results.

Looks like a bug. But I cannot reproduce it.