Throughout my database I “tag” certain lines of text with people’s names using links to a note for that particular person. For example:
- call [[Peter Parker]] tomorrow about the weekend
Now I’d like to collect all such lines of text, within the individual people’s files. I found a great post by @Craig below which I adapted and got to work 99%.
What I’m trying to do
Given the following dataview snippet, that currently works, I’m wanting to tweak it slightly to not only check for the string of the file name, but for the actual link, including the opening and clossing brackets [[ in the WHERE clause.
LIST Item
FROM [[]]
FLATTEN file.lists.text as Item
WHERE contains(Item, this.file.name)
Things I have tried
I’ve tried a few options incl: WHERE contains(Item, this.file.link) WHERE contains(Item, [[this.file.name]]) WHERE contains(Item, "[[this.file.name]]") WHERE contains(Item, link(this.file.name)) WHERE contains(Item, link(this.file.path))
I’m sure it’s super obvious and I’m just missing something!
Links in a list item, if you use FLATTEN file.lists as Item, are found within the Item.outlinks list, so you could use contains(Item.outlinks, [[]]). If you flatten just the text like you did, you’ve lost that list of links.
Do however note that if you want to both include any list item with just a text reference to the current file name (or person), and links to the same file, you need to remove the FROM [[]] requirement. Removing that requirement has the side effect of opening up the FLATTEN file.lists to actually expand all lists in every file you’ve got, so this could be a rather expensive operation.
This side effect could possibly be be countered if you add a WHERE contains(file.lists.text, this.file.name)before the FLATTEN command, as it is slightly cheaper to check the list first instead of fully flattening. This might only affect your query if you got a somewhat large vault, with not that many lists, but be fore warned that this might an issue.
Don’t think there is any difference in those two, no. Haven’t looked into the particular details, but I do consider them identical and as such a matter of preference as to which to use.
They’re both generic, and preferable over hard coding a file name.