Nested Tag Filters on Obsidian

Hey Obsidian Community,

I’m having trouble trying to more precisely filter out my nested tags within the program. I’ve nested my tags so that it would be significantly easier for me to grouped into nested tags so that I can better organize my rags. However, I that’s prevented me from selecting only tags in that upper nested tag without selecting everything else below it. How can I resolve this??

I’m not clearly understand where you want to limit this search, but in general the trick wound be to search for #my/nested/tag and add an exclusion search for #my/nested/tag/.

1 Like

AFAIK the purpose of nested tags is precisely that an upper level includes all sub-levels. It’s not a bug, it’s a feature. :slight_smile:

If you add tags only as hashtags, you could try to limit your search with fulltext search:

tag:#test -#test/

If you also add tags as properties, you could try:

tag:#test -#test/ -[tags:test/]

The forward slash makes all the difference here.

1 Like

Following from @holroy, the specific thing that I would be looking for would be looking for, a type of exclusion search. I’m not sure why but it is not working or registering on my end so I’m uncertain if I’m handling the syntax wrong because the extra slash is not adding anything to my searches. For context, these are the nested tags that I am specifically trying to isolate from

tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area
tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area/Sub-Area

Note: The Parenthesis are only for Identification, they are not a part of the filter itself
I the case of filtering the view, I want it want it to be that I only have the files that specifically contain the “tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area” and nothing else, but because notes with the “tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area/Sub-Area” tag are nested below, it also filters to group that unintentionally.


When I attempt add the exclusion tag with the slash at he end “tag::globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area/” nothing shows as all of the files with that tag aren’t even filtered.

When I do revert the addition of the forward slash and add the hyphen in front of the filter, “-tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area”, now everything flips and everything other than the tags that I wanted are highlighted

The search operator tag: looks for tags. There are no tags that end with a forward slash.

The trick here is that you can only exclude individual tags with the search operator tag:. If you want to exclude a pattern, you need to search for text.

In your example, you could explicitly filter out all subtags individually:

tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area -tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area/Sub-Area1 -tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area/Sub-Area2

Or you could filter out by text pattern without the search operator tag: in the exclusions:

tag:#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area -#:globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area/ -[tags::globe_with_meridians:_Directory/:mag_right:_Navigation_Areas/Area/]

BTW this is a use case, where I’d use links instead of tags.

I’d create a note for each tag and model the hierarchy between these notes with links. For example a note area.md could contain this YAML frontmatter:

---
parent: "[[navigation areas]]"
---

A note sub-area.md could contain this YAML frontmatter:

---
parent: "[[area]]"
---

And the note Adventure & Exploration Sub-Area could contain this frontmatter:

---
navigation-level: "[[sub-area]]"
---

Then you could use Obsidian’s core plugin Backlinks to see all the notes with the navigation level “sub-area” simply by opening the note sub-area.md

Or you could search for the Property with [navigation-level:"[[sub-area]]"].

Another approach would be to un-nest the tags. Why not simply have a tag called #subarea?

In order to keep an overview of all those navigational tags, you could document those tags in a note. For example:

Tags for navigation:

  • :globe_with_meridians: Directory #directory
    • :mag_right: Navigation Areas
      • Area #area
        • Sub-area #subarea

The documentation might also include some comments about your thinking.

In the note Adventure & Exploration Sub-Area you would simply add the tag #subarea:

---
tags:
  - subarea
  - adventure
  - exploration
---

If you want to find all notes tagged as #subarea, you’d simply search for tag:#subarea. No nesting to worry about.

Gotcha, thanks for all the in depth explanations. I’ll just revert the nesting inside so that would specifically be specifying each of the tags instead. The main point for me putting all the hierarchy was to group together the navigation pages that lead over to all the other navigation pages. Regardless, all of this information is extremely useful for other applications moving forward!

1 Like