Problem
When I search for a tag like #politics/germany, Obsidian also shows all notes with subtags such as #politics/germany/elections. This makes it impossible to find only the notes that contain the parent tag itself. I am aware that current search behaviour is similar to how searching for simple text like head also finds heading, which is usually expected. But with tags, the use case is different, so a more precise search option would be very helpful.
What I want
I would like a way to search only for the exact parent tag, without automatically including subtags.
Example
- Notes with
#politics/germany → should be shown.
- Notes with both
#politics/germany and #politics/germany/elections → should also be shown.
- Notes with only
#politics/germany/elections → should not be shown.
Feature request
It would be great to have an additional search syntax (for example something like tagexact:#politics/germany or tag:!#politics/germany or any other syntax), that only matches the parent tag itself and not its subtags. Obsidian pays a lot of attention to details, so this feels like an essential feature that many users would naturally expect.
If your tags are all in properties (not in the body text of the note), you could use properties search with regular expressions.
If regular expressions could be used in tag searches, you could do that. Unfortunately they can’t, but there is a feature request for it. Let regex work with tag: and section: search operators
I changed this request’s title to more exactly describe it (was “Obsidian Search Plugin: Need exact tag match in search”).
I actually write most tags in the body text. I only use the properties to set tags that describe the entire file. My workflow mainly consists of placing most tags under the headings of my longer notes. Each tag then describes the content of the following section. That’s why such a fine distinction between tags/subtags from a nested tag is so important to me.
My suggestion was more of a simple solution. Regular expressions are not for everyone. For example, I find them overwhelming. Above all, I was also thinking of a general approach to enable simple interaction between different plugins. Take Obsidian’s search plugin, for example. A toggle option to include or exclude subtags in the note count would be useful. And depending on which option is activated, the plugin tag wrangler then could pass the normal expression to the search plugin in one case and the other expression, which excludes sub-tags, in the other case.
You can see from the requests, including those for some plugins, that both approaches to tag search are undoubtedly valid, which is why I consider an extended syntax to be important. And Obsidian, as the swiss army knife of note-taking and writing apps, would benefit greatly from such a differentiated approach to nested tags.