How to filter for "(tag1 OR tag2) NOT tag3"

As Drafts only autocompletes for tags which it has notes for, I have a set of notes with tags assigned. They are tagged with a special tag “do not show” and now I want to exclude them from my workspace filters, but can’t figure out how. The !tag syntax seems to work for ALL, but not for ANY.

There is the Drafts.query function, but I can’t find how I can use scripts for Workspace definition?

I feel like I’m missing something obvious, but after having searched the documentation and the forum, I still couldn’t find the answer.

  • -Omit: A word or phrase from the results by prefixing with a “-“ hyphen character. e.g. green -blue will find drafts with the word green but NOT the word blue. Can be combined with exact phrase markup, like: -"red parachute".

Change your exclamation mark for a hyphen, like you would for a search on Google, etc. Where you want to exclude a term.

The “!” Is supported and interchangeable with “-“ in tag filters just for compatibility. Parenthetical expressions are not.

You want “any” selected, and a tag filter of “tag1, tag2, -tag3” to get what you describe.

2 Likes

Yeeeah, so that’s not quite working.
Here are my steps:

  • Add and omit tags via UI
  • Observe that it works
  • Reproduce the very same filter string in the workspace definition
  • Observe that the tag being omitted shows up in the list of POSITIVE tags, with the first symbol being “-” (dash)

So the negation filter syntax seems to be ignored when used for workspace definition, and the dash symbol is understood by the system as part of the tag name.

Tried both, please see my explanation and screenshot

Also, tried with quotes and without. Even when the tag is one word, simply “template”, it doesn’t work, it’s translated by the system to “-template”

Alright, seems like I’ve discovered a combination that works (surprisingly, it’s one that I’ve tried before, but didn’t notice that it worked): !template do not use.

If somebody encounters this issue later and finds this post, here is what will NOT work when doing filtering with workspace definitions:

  • minus/dash prefix -template do not use (the string will be recognized as a tag name, with the dash prefix)
  • dash and quotes -"template do not use" (the string will be recognized as a tag name, with all the dashes and quote marks)
  • quotes !"template do not use" (the string will be negated, but recognized as a tag name, with quote marks)

And here is what WILL work (notice it’s exactly what the UI does, d-uh!):

  • exclamation mark prefix !template do not use

Thanks everybody!

1 Like