Hi, I am using tag MYTAG in my journals to create my tasks list every day:
#MYTAG
TODO task1
TODO task2
I also have notes from meetings and I am using MYTAG as page-tags. Now, I would like to have all todos at one place so I am trying to create query that will filter it for me. I used to filter just by page tag
{{query (and (task TODO NOW LATER DOING) [[MYTAG]] )}}
This works fine, except I find out, it not filter tasks from my meetings, where I am using page-tags. I would like to filter all TODOs where is tag MYTAG or page-tag MYTAG. I am trying this:
{{query (and (task TODO NOW LATER DOING) (or [[MYTAG]] (page-tags MYTAG)) )}}
But this results zero tasks. The logic looks OK with the or statement but I am not sure if this is some limitation of logseq queries or where could be a problem. I also tried Advanced queries but it looks quiet complicated to understand how to implement basically any query.
How can I filter my TODO tasks properly with simple query and what am I doing wrong?
Hi, thank you for your response. As I wrote in the description, it works fine when queriing only for tags or page tags but not together with or condition. So tasks with all states upper case or lower case, does not matter. That is not an issue.
Hi, thank you but this does not work at all, result is zero again. Is there any good tutorial for understanding this queries? For me it looks quiet hard to understand how does it work. Of course, there is some examples in doc, but nothing more.
@starryveshch this query does not work, number of results is zero.
I have to say that from the documentation of logseq is quiet hard to understand syntax. Thank you for tutorial, it looks good. I am missing knowledge of where section, what does question mark with character at the beginning and end of line means.
It works but only if I set block with tag on the same journal - tested on today date. Other TODOs with tag does not work… Also, when I test it with testing graph, I find out tag name is case sensitive.
That’s where the issue is; the :block/name stores the page name in lower case, i.e., MYTAG is stored as mytag. So if you want to use the exact page name in the query, then replace the :block/name with :block/original-name.
I upgraded to latest version 0.7.0 and queries started working, the problem was probably with the version of logseq I did not mention here.
Also this
@starryveshch could you explain how does the query is processed? I understand that ?p, ?b and ?r are variables, but even after reading some tutorial, I am not able to understand the logic of queries. Can you describe step by step what each line do, where it stores and how is it passed to the next clause? What if I want to filter based on multiple tags not just MYTAG but also MYTAG2? Thank you.
Could this queries make logseq slow? It is extreamly slow since I jump to version 0.7.0, response time on click is basically in seconds. Also, I find out, some TODO is not filtered by the query. This is in my todays journal:
#aaa
- #migration #othertag
- TODO Task one
- TODO Task two
Interesting is, task one is filtered but task two does not. But when I moved task two on other page:
- tags:: migration
- TODO Task two
it somehow works… I am quiet lost how does this even works. I do not see there any logic what is filtered and what is not and why.
Hi Dorinand,
First: Logseq is slow. Because it uses files instead of a database. At first it is nice because of the text files but the more files you have the slower it gets. This is why i am really thinking about it whether this will be my further way or not.
To get around with your tag - i wouldn’t setup the query with the tag. I would choose the clojure string to catch them:
So play around with #myTAG or only myTAG or anotherTAG and so on and it will pull them.
All the above methods will not work if you do inconsequent tagging like this: myTAG or #myTAG or [[myTAG]] or #[[myTAG]] or [[#myTag]] (…exaggeration…).
But they all get catched with clojure string.
Hi Yupp1018, thanks for the closure string technique.
However, was trying to use your multi tag closure string code and couldn’t get it to work for a use case scenario as below
[(clojure.string/includes? ?c "Company)]
[(clojure.string/includes? ?c “company”)]
to make query case insensitive, but no results show up.
If only one of the above is used it works but not when combined. Would you be knowing why this is, I’m using 0.8.7 version
Also the [h] what does that refer to?