Add a way to exclude all subtags of a given tag in a base filter

Use case or problem

Let’s say we have tags existing in the vault like this:
#project
#project/A
#project/A/A
#project/B
#project/C

And we make it so that tag #project represents “this is exactly a project”, but tags #project/A represents “stuff about project A specifically”

In this setup, if I want to make a base to show “all project roots” but none of the specific stuff pertaining to those projects, currently it looks like this isn’t possible. Please correct me if I’m wrong though.

I’ve tried using this in the base:

filters:
  and:
    - file.tags.contains("project")
	- '!file.tags.contains("project/")'

… but this still includes everything, and does not exclude files with #project/A, #project/A/A etc.

Conjecture here, but I’m guessing this is because contains is looking for a full match in the tag name, and so !contains("project/") won't work for excluding #project/A. It seems a bit incongruous that contains(“project”)is still able to match#project/A` despite not being an exact match.

Proposed solution

I don’t know if it would be possible to change the incongruity mentioned above, even if it was desired. Would it maybe be possible to add a filter operator that specifically is able to look for root-level tags and exclude subtags?

Current workaround (optional)

This may be possible with the dataview plugin, but I’m not sure as I don’t use it.

A simple solution of course would be just to use a different tag for project roots. Still wondering what people’s thoughts on this are though.

You could use this filter:

file.tags.filter(value == "#project")
1 Like