How to search for head tags without sub tags

In past versions I was able to search tag:"Example" -tag:"Example"::* and this would give me cards that just had “Example” but I’m not able to do that on 2.1.49. Anyone know how?

I don’t believe the syntax changed at any point. It’s got to be one of:

  • tag:Example::*
  • tag:"Example::*"
  • "tag:Example::*"
1 Like

I’m not able to get any of those to work. Here’s the card with tags and I tried all three combos your recommended trying to find just the #SGU card

To be absolutely clear, you are searching for tag:#SGU -tag:#SGU::*? What’s the result?

Correct. The result is 0 cards

What am I looking at in your screenshot? Are these tags of the same card? If so, the search wouldn’t match, because it means “cards with the parent tag or its child tags, and none of its child tags”.
I don’t think there is a way to match cards that have the parent tag, and may or may not have any of its child tags.


Yes these are tags of the same card. In the past I swear I was able to do that but I guess it makes sense that it’s excluding the card because it also has a child tag. I think I just used tag:#SGU in the past because you had to do tag:#SGU::* as well in order to include all children

When I said the syntax didn’t change, I was only talking about the quotes. As for the child tag matching, I’m sure you’re right.

So essentially this used to be possible but isn’t anymore?

This has changed when Anki got native support for hierarchical tags.

1 Like

@dae any chance we can get something built back in that will allow for this?

I’m not sure I understand the problem?


1 Like

If a card has #tag and #tag::subtag and another car has #tag::subtag, there’s not a way to isolate the first card and find cards that have the head tag but not the subtags

…is that not what the screenshot above is doing?

You just have “parent” tag. If you had “parent” and “parent::child” on the same card, it wouldn’t work

Sorry, I still don’t understand. There are three cards in the screenshot above, each with different tags. Which of the three are you trying to isolate with a search?

The parent and child note edit: AND the parent note. Both notes that have the “parent” tag

Ok, I finally get you :slight_smile: This indeed does not seem possible with our current search syntax, but one workaround you could use is to find&replace tags with the regex ‘^parent$’, replacing it with a temporary other name, which you can then search on.

I suppose that’s doable for now. Is there a way to fix this in the future? Seems like a small, but pertinent bug

I wouldn’t say it’s a bug. Not only in this scenario, the search engine anticipates the common use case and adds additional qualifiers to the user input. This makes searching more convenient, because the user doesn’t have to do it themself, but also less powerful, because it’s impossible to search without these qualifiers.
I’d usually trade in convenience for power, but removing the implicit wrapping would be a breaking change for a lot of users. The only way is to extend the functionality: Either add a new syntax for exact matching (like tag=:parent) or, simplest and most powerful, support regex for tags (tag:re:parent( |$). Using the latter requires some knowledge about how Anki stores tags though.