Query note title and alias from a property

friends im trying to make a query to know if a note that the query goes was mentioned in the -zoom:: property of the other notes.

Example:
Note A
-zoom:: Note B

Note C
-zoom:: Note B (alias instead of the title)

Note B
query

On note B i would like to have a query to know which notes linked to note B (alias or title) in the -zoom:: property

What i have tried to do :
{{query (page-property -zoom <% current page %> )}}
the problem with the query above is that it only gets the notes linked to note B title, but the ones linked to note B alias do not show

Get more specific:

  • How exactly have you defined the alias of Note B?
  • What exactly have you typed to produce -zoom:: Note B (alias instead of the title) ?
  • Where is the advanced query from the other thread?

alias::

in the note A, after the -zoom:: property, i typed the exactly alias of note B, i also confirmed clicking on it leading me to the note B.

Yes, i though it was working since i was testing with one note only , but then i tested to other notes and it didnt work

It works to me. If you want a solution, should share here a combination of notes that doesn’t work, for us to see what’s going on.

sure you gonna notice a weird behaviour , that i dont why is causing this.

Steps to Reproduce

create “note A” with “test” property , test:: [[note B]]
image
create “note B” with alias:: [[notes b]]
image
create “note C” with “test” property , test:: [[notes b]]
image

Paste that query on note B

#+BEGIN_QUERY
{
 :query [:find ?p-name  
   :in $ ?current-name
   :where
[?b :block/page ?p]
[?p :block/name ?p-name] 
     [?current :block/name ?current-name]
     (or-join [?name]
       [?current :block/name ?name]
       (and
         [?current :block/alias ?alias]
         [?alias :block/name ?name]
       )
     )
     (property ?b :test ?name)
 ]
 :inputs [:current-page]
}
#+END_QUERY

On note B it will appears to work for now … (thats why i though it worked before)

create “note d” with “test” property , test:: [[note e]]
image
create “note e” (with no properties or alias)
paste the same query before on note e:

#+BEGIN_QUERY
{
 :query [:find ?p-name  
   :in $ ?current-name
   :where
[?b :block/page ?p]
[?p :block/name ?p-name] 
     [?current :block/name ?current-name]
     (or-join [?name]
       [?current :block/name ?name]
       (and
         [?current :block/alias ?alias]
         [?alias :block/name ?name]
       )
     )
     (property ?b :test ?name)
 ]
 :inputs [:current-page]
}
#+END_QUERY

Results of the query in note b:
image
which is wrong since the note A or C was the only one that linked to note b

Results of the query in note e:
image

same result.
which is also wrong .

Replace line (or-join [?name] with: (or-join [?current ?name]

i replace with your suggestion,
the query that goes on note b and note e, updated:

#+BEGIN_QUERY
{
 :query [:find ?p-name  
   :in $ ?current-name
   :where
[?b :block/page ?p]
[?p :block/name ?p-name] 
     [?current :block/name ?current-name]
    (or-join [?current ?name]
       [?current :block/name ?name]
       (and
         [?current :block/alias ?alias]
         [?alias :block/name ?name]
       )
     )
     (property ?b :test ?name)
 ]
 :inputs [:current-page]
}
#+END_QUERY

“note e” with the query looks correct
image

Note B otherwise only show note C in the query (missing the note A)

This is because in note A the value [[note B]] is with capital b. I don’t have a way to address all possible cases, because most clojure functions are not currently available in queries. Here are some options:

  • manually fix the case to be consistent
  • cover the most common case by adding [?current :block/original-name ?name] inside or-join

but the note title is also with capitalize letter, “note B” as seem in the picture below

but adding this looks like work here, gonna make more tests

By design, internally all names are converted to lower-case. This is the reason of existence for :block/original-name. But other cases (e.g. NOTE b) won’t work.

thanks and just to see if get, the recommendation is to always write with lower case in logseq, even if is not related to query stuff ? I ussually write some of my tags with camel case

  • The technical recommendation is just to be consistent.
  • For what to be consistent with, the non-technical recommendation is to follow the conventions of the used language. Some examples:
    • For English, keep everything lower case, except of the first letter of proper names.
    • For Javascript, use camel case.

bro i see that you are very active here in logseq forum. You are aware of that bug:

?