How do I return *blocks* from pages that have a given page-property? ( `test:: rheumatology` )

Hi everyone :wave:

I’m stuck with an advanced-query problem:

My page header

subject:: #Medicine
specialty:: [[Rheumatology]]
Note-type:: [[Disease Profile]]
test:: rheumatology          ;; ← plain string value

What works

  • {{query (page-property test "rheumatology")}} → shows all pages with that property (so the page property itself is recognised). :white_check_mark:
  • {{query (tag treatment)}} etc. → tag queries work as expected. :white_check_mark:

What fails

I cannot get an advanced query that lists all blocks whose parent page has
test:: rheumatology.

#+BEGIN_QUERY
{:title "Blocks on pages with test:: rheumatology"
 :query [:find (pull ?b [* ])
         :where
           [?b   :block/page        ?p]
           [?p   :block/properties  ?prop]
           [(= (get ?prop :test) "rheumatology")]]
 :view :table}
#+END_QUERY

Running that returns an empty table.
I tried the “entity” pattern as well (assuming the value needed to be a page link) and still got nothing.

What I’m trying to achieve

Return every block (including descendants) that belongs to any page whose page-property line is
test:: rheumatology.

If I later want to add :block/path-refs treatment I can—but for now I just need a minimal working example.

Any ideas what I’m missing?
Thanks a lot!

Hiya,

Thanks for the post.

I’m afraid I’m not the expert but one suggestion that might help;

Try splitting up the getting of the property and the comparison.

Like this:

[(get ?prop :test) ?keyword]
[(= "rheumatology" ?keyword)]

I’m just doing this on y phone so please don’t just trust the Syntax. Double check brackets and spelling.

Fair warning, I’ve never tried to access the properties of a page as I don’t arrange my notes like this. So if that doesn’t work you might need to check accessing a page properties at all.
Maybe by removing the check to see what the property value actually is and just checking to see if it’ll find any page with that property value.

is this logseq db or md?