Things I have tried
I spent countless hours on this the last two days, trying a million things, reading the dataview user guides, and also a ton of forum and web posts, and I’ve finally thrown my hands up as I’m just not understanding the coding. (I’m not so technically-minded).
I posted a version of this as a reply to another very long thread and it might have gotten lost in the shuffle or it was just getting too convoluted. So I thought I’d break out this particular part of the question and simplify it in the hopes some fresh eyes can figure out what I’m doing wrong.
What I’m trying to do
I’m creating a workflow where I am aggregating snippets of text from various articles. In those articles I’m flagging/tagging quotes, talking-points, facts, etc. and then using dataview to return the results in a table. It’s working great and am very excited at how powerful this will be in my research.
The only problem that I’m running into is that I use a lot of subtags. There are times that I want to see results only with the exact tag and none of the subtags, and there are other times where I want to see the opposite—I want to see results of all tags and all the subtags.
Another case is when I’m trying to limit my results based on two tags in and “AND” situation. I want to see only results that have both tags, but when the tag has a subtag, it seems to treat it as an “OR” situation. When the tags are not direct, neighboring subtags, it works correctly.
I was able to solve the problem in some use-cases with “econtains(file.etags, “#pin/topic/test”)”, but in other cases, it doesn’t work.
The following are examples of my results. Thank you in advance for any advice on solving this.
- Here, I want to limit the results so that dataview doesn’t return subtags. The following code still returns #pin/topic/test/subcategory. I tried various placements of the “econtains” line as well. I also tried replacing “file” with “item” and other guesses.
This code works when I have the following type of use-case (it doesn’t return any subtags of #note/type/person), but I need it to work with more complex use-cases.
TABLE WITHOUT ID link(file.link, Title) AS "Title", Aliases, Occupation, Employment, Born, Death, Birthplace, Note
FROM #note/type/person AND -"Templates"
WHERE econtains(file.etags, "#note/type/person")
SORT file.link ASC
Here it doesn’t work—I don’t want to see the subcategory.
-
Relatedly, when I’m wanting to return only the quotes that have BOTH tags, it only works if one of the quotes is not a direct subtag of the other (even though they are both still subtags of the previous level down). This case works because one of the tags was changed to “test2” (which I don’t want).
-
But, if they are direct subtags of each other, then I get both quotes (which I don’t want). I will want to see subtags sometimes and sometimes not, and if so, is this the proper way?
I tried the above w/ a number of “econtains” variations as well, but that gave me no results at all. e.g. I get no results with this.
Table
item.Quote as Quote,
item.Source as Source,
item.Topic as Topic
FROM -"Templates" AND -"_Inbox"
FLATTEN file.lists as item
WHERE item.Quote
AND econtains(file.etags, "#pin/topic/test/science")
AND econtains(file.etags, "#pin/topic/test")
Sort item.source ASC
Thanks again, I know this is a lot, but I’m determined to solve this so I can move on to the actual article markup!
R