The new bases filter tags.contains("...") doesn’t support nested tags (can’t insert links but its in the docs). For example, if you use tags.contains("recipe") as a filter then files with the tag #recipe/snack or #recipe/cookies won’t show up.
Proposed solution
The filter tags.contains("...") behaves like an array search. Adding support for nested tags can be done by “expanding out” a file’s list of tags. Using the example above, a file with #recipe/snack tag would be treated by the bases plugin as an array with both #recipe and #recipe/snack tags.
Current workaround
While the bases syntax is very powerful and allows for many smartly crafted workarounds, many have their own set of downsides or issues. In my opinion having to figure out any of these workarounds kinda defeats the point of nested tags. Its in the Obsidian docs so it is an official feature all things considered. It only makes sense that all core functionality treat nested tags how the user would expect.
The downside to that workaround is it also includes files that contain that tag inside the body of the file. tags.contains("...") only accounts for frontmatter/properties, which is much more desirable for most.
I can image some potential circumstances in which I wouldn’t want my Bases to reveal all nested tags, but it could still be a pain to exclude each one of them individually - perhaps some syntax like tags.contains(recipe/**) to indicate the tag and all nested tags vs without the asterisks just returning the tag itself, as is current behavior. Although I’d love for nested tags to be included as the default, I’m not sure what the syntax would be to exclude all nested tags if that is the case.
Unique syntax is a good potential solution. Maybe a unique function for when you do (or don’t) want to use nested tags? Like tags.containsNested("...") or tags.containsExact("...")?
Negative lookbehind makes sure there are no non-whitespace preceeding “area” (this allows it to be the in the beginning or middle since multi tags are space delimited). It also eliminates partial matches like “subarea/fish”
The part after area makes it so it matches on just “area” but also matches for anything “area/xxxxxx”.
Just encountered the same situation with my nested-tags → I totally agree with you that the expected behaviour would be to see all sub-tags when filtering for the parent-tag!
file.hasTag()is the solution regarding supporting nested tags in bases.
tags.contains only targets the tags property on the frontmatter as a list, which is what it is. So I don’t think we should We will not make contains have a special behavior just for tags.
You can open I opened a FR asking to extend List.contains() so that it also searches for substrings within an element of the List. This should address the specific use case highlighted in this thread (search only within the tag property in frontmatter).
Alternatively, this FR will also enable the same thing:
The tags property isn’t the same thing as every other list property. All we are asking is that tags gets treated as expected based on its unique status. Nested tags are an officially supported part of tags and its confusing and jarring to new users that bases doesn’t support nested tags properly.
You haven’t added anything new to the conversation and I don’t want to begin a circular argument.
The special treatment of tags is file.hasTags().
What I wrote above stands.
Besides the addition of file.hasTag(),
From Obsidian v1.9.14, (note.)tags.contains*() and file.tags.contains*() will be aware of nested tags and will also be case-insensitive.