How to exclude all tags from the search tag:#joke, but include the #joke?

What I’m trying to do

I collect jokes and tag them with the #joke tag. I recently logged into the tag panel and I had 59 joke tags. But then I tried to find just all the tags #joke and obsidian found all the occurrences, of which there were 60. I recognized with my hands that I had a dataview request to search for all the tags #joke, however, I would not want to manually search for something like this in the future. I tried to make a fairly simple query “-tag:#joke #joke”, but obsidian did not find anything. Although separately by “tag:#joke” I get 59 search results, and by “#joke” I get 60 results.
On the help website.obsidian I found that the search tag:#the joke won’t index it in code blocks. Then the question is, how can I compose a query “-tag:#joke #joke” so that it works? Is this some kind of bug?

An estimated guess says you’ve got something either tagged as #jokes or similar, or have that as part of a text or code block. Maybe even a query?

Try searching for something like /#joke\S/. Iirc, that would search for #joke followed by anything not being a whitespace character.

I’m sorry, but you misunderstood me.
First, I have nesting tags like, for example, #joke/pun.
Secondly, your regular expression finds just all my nested tags, but it still cannot find everything that is in the dataview query (in my case).
But the question (or problem) is different: the built-in Obsidian search with the query tag:#tag1 does not search or show results in code blocks, but a simple tag search (#tag1) shows absolutely all matches. I would like to just exclude all search results strictly by construction tag:#tag1 (as I tried to do with the construction #joke -tag:#joke).
Also, only I checked a query like “#joke -#joke/fun” (by tags in obsidian #joke – 62, #joke/fun – 13 results), but the search result gave only 27 :confused:

I don’t understand how it works. It seems to me that this is very similar to a bug.

I do believe I understood you correctly, and I do believe the way forward is to find the one not conforming to the basic syntax of your tag usage.

Using nested tags makes a regex a little harder, but maybe this one could find the one not found by the other queries: /joke[^ \/]/ This should in theory find all tags, not being followed by a space nor the forward slash starting a nested tags. I removed the hash sign in front of joke to also consider stuff in the properties, but try with/without if you get too many false positives from the search result.

It’s still most likely that the one you can’t find is within a code block, and sadly some of the combination searches by Obsidian don’t do what you expect them to do. This is partially due to some strangeness in fuzzy matching, and partially due to where it looks for answers in the various operators. Hence my suggestion on using a regex and eliminate the “common” tags.

Sorry again, but again it didn’t find what I wanted to find (it found only 4 results) (I also don’t understand what exactly it found :frowning: ). It seems to me that we still need to move this to bugs. Because you also say that it is unclear how it searches, and seemingly logical queries do not work either. Anyway, thanks for your willingness to help.

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