Query absence of a tag

What I’m trying to do

I’m trying to make a simple query where I search for all the line having a special tag, but missing the #done✅ tag.

Pretty simple right ?

tag:#project_x -tag:#done✅

The issue is that as soon as I type the absence of the #done✅ tag, and that I mark one line with this tag, all the lines in a that given file that contain the tag #project_x are now missing from my query results.

Example:
FIle_A

- #project_x sync with Sandra
- #project_x UI design feedback #done✅
- #project_x security analysis

Here, the simple presence of the #done✅ tag on the second line will cancel all the results in that file from the query.

Things I have tried

I’ve look at the Obsidian Search documentation:

Maybe because the query is oriented toward returning files results, and i want line results ?

In that case how to filter on a given line with the presence of a tag and the absence of another ?

I tried this form, but it doesn’t seem to work:

line:tag:#project_x -tag:#done✅

Thanks !

Just tried a similar one at my end:
tag:#titleandheadingonedontmatch -tag:#formatted🟢

It looks to be working fine with emoji here.
Are you installed with the latest versions (app, installer)?

Hi @gino_m !

I can confirm that I have the latest verison (1.4.12)

I don’t think the emoji is the issue here, but more the search itself.
The search works, but only for files results.
When you want to get the granularity of a line, it gets more complicated.

I cannot express the idea that I want to search for a line (with the line: operator), that matches a set of tags (with tag: operator).
Is it possible to nest operators in Obsidian search ?

Are you sure the tags are on the same line?
Since Properties, multi-line key values are enforced.
Don’t take the Live Preview rendering into account. See the Source View.

As for line:, I hardly ever use it. I use regex, like /search.*terms/.

I have not used the new [Property:] queries, either (yet).

Have you tried line:(tag:#project_x -tag:#done✅)?
I think that without the brackets, it would look for tag:#project_x on the same line but not -tag:#done✅ on the same line.

You can use the normal query and set ‘Show more context’ in Search pane.
Like so:

  • Query was: tag:#titleandheadingonedontmatch -tag:#formatted🟢

Ok, thank you for your answers so far !

This is what i’ve tried:

First I opened a new daily note with the following content:

And opened a second note, to query the project_x tag:
image

Okay, that works as expected :white_check_mark: !

Now we will add a #done :white_check_mark: tag, like this:
image

Coming back to my query and updating it to filter on the absence of #done :white_check_mark: :
image
now doesn’t produce any more results:
image

Testing @Anwen 's idea:
image

Same here:
image

@gino_m I’m not exactly sure what you meant with the extra context ?
Furthermore i’m only using tags inside the file content, not as file metadata.

Thanks !

First of all, it’s better to show lines with code blocks (which are the source code equivalent of your file).
Secondly, if Properties changed the tags to multi-line, they won’t be found on the same line anymore.
Thirdly, the original query seemed sufficient (for me, but I’m not a tag wrangler), but you can open up the “Search Pane” a bit in the way I showed in the screenshot. Clich on Search Settings in the right corner and toggle on “Show more context”.

As for more regex and logical operator stuff, you can try and install the Vantage - Advanced Search Builder plugin.

It seems like this is working : line:(#test -test2) But it can also show results if they are not really tags . But actually we cannot use the tag operator inside a Line operator.

Oh, my mistake. I expect proper YAML/Properties everywhere. You have inline tags.
But still, each tag on the list are on different lines…

Oh wow !
image

image

I confirm this is a working solution @Anwen ! :100:

Ike and Mike think alike. :slight_smile:

Good night.

1 Like

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