Archive for November 21st, 2006

21
Nov

Booleans in Googlemail Filters

Just a quick tip, if you’re a heavy user of Gmail then you probably have quite a few labels setup, and also a fair few filters.

A lot of my filters were very similar:

Matches: from:(friend1@example.com)
Do this: Apply label "Friends"

Matches: from:(friend2@example.com)
Do this: Apply label "Friends"

You can end up with a confusing number of filters this way. But there is help, Google have a little known about power-user feature in that the filters can use Boolean search syntax to combine multiple clauses within one pattern.

Matches: from:(friend1@example.com OR friend2@example.com)
Do this: Apply label "Friends"

Using Booleans you can reduce the number of filters that you need to create and maintain to the bare minimum. One filter to label all friends, rather than one filter per friend.

It’s possible to get pretty clever with combining several types of query in one:

Matches: from:(subscription1@example.com) OR to:(mailinglist1@example.com) OR subject:(Mailing List Name)
Do this: Apply label "Subscriptions"

The trickery here is how to enter that query into Gmail given that Gmail doesn’t give you an interface to enter advanced filters. The answer is to recognise that when you fill in a field in the filter form the filter automatically has the field name and brackets wrapped around it.

So… if you took the above example and entered the “from” field, anything you enter in that field will be surrounded by “from:(” and “)”. With that in mind, you would enter the following in the “from” field providing your filter started with a “from” criteria:

subscription1@example.com) OR to:(mailinglist1@example.com) OR subject:(Mailing List Name

Now when you click “Test Search”, Gmail wraps the above in “from:(” and “)” and completes the syntax to make the search:

from:(subscription1@example.com) OR to:(mailinglist1@example.com) OR subject:(Mailing List Name)

Which means you now have multi-field filters and boolean searches.

The full guide to advanced operators is available here on the Gmail help site:
http://mail.google.com/support/bin/answer.py?answer=7190

With the above tips you should be able to perform most queries you could imagine.

Give it a try :)