I am new to Logseq and this query langauge is very confusing to me.
Goal: To have a query on each page for a person that has a list of discussion topics collected from notes around my graph. I am very close, and I have something worked up that seems to work okay for looking for TODO items, but it’s not quite right and I believe there are some index caching issues with my use of :current-page. I want to adjust this to also include blocks that have a #discuss tag on them, because i realize I don’t want to make TODO items for all of my dicussion topics as it makes my other task tracking messy.
Here is what I have going on right now:
First, I have a testing page that has a references a couple of people, has a tagged discussion item, and a TODO discussion item.
Here is the query I am using for both the John Doe and Jane Doe pages:
For John Doe, it shows my TODO item for “Jane Doe”, even though “John Doe” is not in that TODO block. I am not sure why this happens other than to assume it’s being pulled from the parent block? I don’t know how to fix this.
For Jane Doe, the current query appears to work as expected, except I do not know how to also add in the block with the #discuss tag.
With all things remaining the same (besides the query of course) I want to get to where my “John Doe” page has nothing listed (I don’t have any discussion items for him) and my “Jane Doe” page has two items listed (the tagged item and the TODO item).
I think that (hopefully) gets you everything you need to know about what I am trying to do, and where I am currently at. Thanks for any assistance you may have for me!
Your example doesn’t properly follow your requirements.
If your actual requirement is to get “all topics to discuss with the current person”, you just need the parent of the block that contains #discuss and [[current person]] :
The parent may not be related at all to the actual block that I have flagged to discuss with someone. In fact, that is specifically the use case I am trying to address here.
So in your query, John Doe’s seems right, because there is nothing for him, but when I put it on the Jane Doe page, I get the parent bullet regarding John Doe, which does not belong here. It does get me the two discussion items for Jane tho, so this is definetely an improvement. However it also puts in any block that even mentions Jane Doe even if there is no TODO or #discuss tag.
I have tried to find a simple reference for how to do advanced queries, but I have yet to find one where someone goes through the syntax. I thought I found one, then it got confusing because it seems like there are two different types of syntax for queries and I was ending up mixing and matching them in a way that wasn’t productive for learning.
If I wrote this in pseudo code - which I am way better at - this is what I am trying to do
Find any block on any page
Get the current-page title and assign it to the variable for “current name”
Then list any blocks that have “current name” and ALSO #discuss OR TODO in the same block.
Does that better explain what I am trying to do? There is no association to parent/child in my requirement.
But this is the topic to #discuss in the scheduled TODO, since the title of the query is “Discussion Topics”! Besides, if we query only the children, their parent block will appear anyway (unless shown in table view). Try this one:
I don’t know what the title of the query has to do with anything. Of course I am calling it Discussion Topics because that is the entire point of the query… to bring up the items I flagged for discussion. But that doesn’t have anything to do with the parent of the topics I flagged.
EDIT: Oh I see what is happening. My screenshot shows the result of the query… that’s why it says “Discussion Topics” in there. That’s the query title. The page that the result comes from is “testing.”
Regardless, this version seems to work! (with one exception)
My original query only showed opened tasks, but your version doesn’t clear them when they are checked. How do I incorporate this into your version? (task ?b #{“NOW” “LATER” “TODO” “DOING”})
So based on your statement, there is no way to hide the parent bullet shown in the results?
Now that it works. can you help me understand how?
I would love to understand exactly what each where statement is doing so I can start to learn this.
For instance I went here: https://docs.logseq.com/#/page/advanced%20queries to look for a definition of what a “marker” or “refs” represents, but they are not defined there. I do see them used in examples so I am trying to extrapolate what they mean.
Do refs = tags? so then does [?discuss :block/name “discuss”] combined with [?b :block/refs ?discuss] basically mean “if #discuss is present”?
Does marker = task item? If so why does my original code use “task”?
Is this stuff clearly defined somewhere that you can point me to?
Appreciate the help! Sorry to be a bother, I just want to learn how to be self-sufficient vs having to have someone write queries for me much longer. lol