The ability to combine search operators

Use case or problem

The ability to combine search operators (for example, block:tag:#tag1 or block:(tag:#tag -tag:#tag/nested, or smth like this)

Proposed solution

Combined search operator queries, as already implemented with parentheses to search for multiple conditions (from the Obsidian help site)

Current workaround (optional)

Specifically, in my case, I just don’t have the ability to search strictly by tags, so I just search only by text.

Obsidian Help says about Search Operators:

  • tag: Find tag in file.
  • block: Find matches in the same block.

I read that you cannot limit tags to a block, because tag search always applies to the file.

But I also read here (and in the page’s examples) that you can group search expressions. This should only find notes that have at least one block that contains the word „dog“, but not the word „cat“.

block:(dog -cat)

Search‘s result are always whole notes. If you just want selected blocks in your result, Dataview plugin might be a better choice.

Thanks a lot for the reply. I realized that the tag function is applied to a specific file (when excluding any of the tags). I suggested this idea because the tag function indexes only the md text, and then it turns out that blocks of code with Dataview queries and so on also get into the search.

Code blocks are ignored when you search for tags. Same help page:

Note : Since tag: ignores matches in code blocks and in non-Markdown content, it’s often faster and more accurate than a normal full-text search for #work .

Yes, that’s why I thought it would be possible to combine blog and tag searches. (In my case, I have a lot of notes in which blocks are tagged and sometimes I need to look for nested tags. If I exclude the nested tag, then the search results for each note are excluded).

In this case searching for tags without the search operator „tag:“ should work:

 block:(#tag -#tag/nested)

Yes, you are right. It really works. But this searches also in dataview queries and displays an incorrect number of results with data (as you understand, I don’t have any useful information in the dataview query that I would tag)

From the responses on the Discord server, we managed to get a construct that will ignore your Dataview requests: block:(#tag -#tag/tag1 -FROM)

1 Like