Searching a tag while excluding nested tags issue

Scenario: looking for all instances of a root-level tag (ones which have no sub-tags)

Problem:
When searching for a non-nested tag and a note has both the root tag and a non-nested tag within it then the search will skip the non-nested tag in that file.

Steps to reproduce

  • create a note that has two top level tags in that one note
  • create another note but with a nested tag
  • search for only non-nested tags tag:#<TAG> -#<TAG>/
  • notice how only non-nested tags appear as expected
  • next, make any one of the two non-nested tags nested
  • search again and notice no results

Did you follow the troubleshooting guide? [Y/N]

Expected result

The search should show the line with the non-nested tag as it was doing earlier.

Actual result

Search returns no results.

Environment


Additional information

trim.B1FFD317-A83A-411A-B68E-164846DCB55D

I forgot to attach the debug info:

SYSTEM INFO:
Operating system: ios 17.6.1 (Apple iPhone16,2)
Obsidian version: 1.7.0 (153)
API version: v1.7.0
Login status: not logged in
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none

This is not the correct syntax, you should use -tag:#xyz for not tag xyz.

No I’m not trying to do such. What I am doing is excluding all nested references so doing -tag won’t work unless I make it overly verbose. Also I’m not trying to exclude a specific singular tag. I am rather wanting to highlight a search related issue where if I have two references of a root tag and I try to exclude any nested tag as such #reference/ it works as intended unless i change one of the two root tags to #reference/something. Then search should show at least the other reference, but it doesn’t.

I understand the misunderstanding, which is why you moved it to help but I believe it is a bug…

You cannot put boolean operators INSIDE tag:, only outside

I tried:
(tag:reference) -"#reference/"
and
(tag:reference) -line:"#reference/"

both result in the same behavior. When there are two #reference in a file they both show up. If I change just one of them to something like #reference/app then nothing shows up.

That is correct you are searching for files that have tag reference and do not contain the string #reference/

That file does not satisfy this criteria because it contains the string reference/

Oh ok. So the exclusion eliminates entire files, not sections. I understand now. So I can use something like this.

line:(#reference -#reference/)

But this also returns non-tags… I can add case sensitivity to create a better output.

If only there was something like line:(#reference -tag:#reference/) but I guess the former works if there isn’t a better way of doing it.

line:(match-case:#reference -reference/)

Ok so using both line followed by a match-case does help with tag search - ty WhiteNoise for your time

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.