24

How can I exclude a given label from a search, effectively finding all the email that do not have that label applied? I've searched Google, SuperUser, and the Gmail Advanced search support page to no avail.

Here are the searches I've tried, none of which work:

  1. !label:work
  2. NOT label:work
  3. not label:work
  4. -label:work

The reason this may not be a duplicate: After some more experimentation it seems that the - operator would work, except that it doesn't exclude entire conversations if any one message in the conversation has the label. I need my search to exclude any conversation in which one or more messages has the specified label.

How can I achieve this behavior?


Per Gianni Di Noia's advice, I tried making a filter that matches emails labeled work and then re-applies the label work. Unfortunately, after some testing with another email account I have I found that this does not work because it is never triggered. Filters are triggered based on the properties of the incoming email, not on the conversation to which Gmail assigns that email. Google warned me of this even before I did my testing:

enter image description here

migrated from superuser.com Jun 26 '14 at 19:07

This question came from our site for computer enthusiasts and power users.

  • Labels in gmail is associated to the threads (conversations). The -label: operator work exactly as you want. – Giovanni Di Noia Jun 26 '14 at 20:04
  • 1
    @Gianni Di Noia: You're probably right, but this isn't the behavior I've been experiencing. For instance, a conversation tagged with work is properly excluded until someone replies to the thread, at which time I have to retag the conversation, even though it still looks like it's tagged, in order for it to again be excluded from the search. – Nathan Arthur Jun 26 '14 at 20:06
  • if one of your filters add the tag "work" to the thread the behavior is normal. – Giovanni Di Noia Jun 26 '14 at 20:13
  • Intriguing thought... So I'd filter for label work and then apply label work? – Nathan Arthur Jun 26 '14 at 20:23
  • I mean the filters in the setting page: setting > filters. – Giovanni Di Noia Jun 26 '14 at 20:30
25

You can do searches that exclude certain labels. That is, searches like this will do what you expect: (label:MyLabel1 AND NOT label:inbox AND NOT label:MyBadLabel1)

That search will show you only messages that:

  1. Do have MyLabel1
  2. And do not have label inbox
  3. And do not have label MyBadLabel1

The tricks are:

  • to get yourself out of conversation mode! (As @Ruben says above.)
  • to use UPPER CASE for the logic operators (AND NOT will work, and not won't)

If you leave "conversation mode" on, you will get confusing results. For example, doing that search above (with conversation mode on), will likely return messages that do NOT match your search.

It may be a bit weird.

Here's the deal:

  • Conversations are collections of messages that all have the same Subject.
  • When "conversation mode" is on, searches return entire conversations as results.
  • So what should gmail search do if a conversation contains both a message that matches, and a message that does not match your search?
  • You are probably expecting it to return conversations only if all messages in that conversation match.
  • But that is not correct. Instead, Gmail search will return conversations even if only a single message in that conversation matches.
  • So that means that if you do the same search above with "conversation mode" on, the results are likely to include messages that do not match your search!
  • 1
    I typed in the search bar (label:account and not label:Waiting-For-Feedback) but the first message I get back from gmail is tagged with exactly both labels! So, it does not seems to work properly. I'm using Gmail for business. Obviously I turned off "conversation mode". I discovered then that the case of the logic operators is important! With AND NOT it works. With and not it doesn't. – danidemi Dec 17 '16 at 11:51
  • Just NOT label:work also works, without needing an 'included' keyword – Zom-B Nov 14 '17 at 13:09
2

As was already explained in the question, filters apply labels to individual incoming messages, so a conversation could have messages with and without the label that the user is looking to exclude from the search results.

To search for individual messages, first turn off the conversation view, then search for the messages without the label.

To search for conversations that don't include any of its messages have certain label, first search for the conversations that include the label and re-apply it, then search for conversations without the corresponding label.

References

1

You can try -(label:labelname) enter your search here for more labels to be excluded just continue the following syntax:

  1. -(label:Inbox) -(label:Updates) -(label:Social) enter your search criteria
  2. Hit enter
0

I was facing the same issue that -label:'label name' was not working. Then I realized that the issue was the label was nested. So if you have label name y nested under label name x,if you want to filter out just y then put this: -label:x-y. Use the - dash between different levels of labels. Maybe other keywords like NOT etc. could work as well.

-1

As I've tried the following search works pretty well for what you need:

label:MyLabel1 !label:inbox !label:MyBadLabel1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.