How can I filter messages in Gmail using boolean OR conditions? For example, I can specify addresses in the To: or From: fields, but this only matches emails that meet both criteria. How can I match emails that meet one or both criteria?

5 Answers 5

  1. To filter Gmail messages using the boolean OR condition, use any of the following in the search field:

    1. OR (case sensitive)
    2. Braces {}
    3. Pipe | (undocumented)


    from:xyz OR to:uvw
    {from:xyz to:uvw} 
    from:xyz | to:uvw
  2. To create a filter from that search, select the little down arrow on the right side of the search field and then click create filter with this search.

See the Search Operator table in GMail help > Refine searches in Gmail.


If you are talking about searching, then @akira's answer is correct. However, it sounds like you are asking about how to use this condition in a filter.

The trick is that you can put whatever search criteria you want in the filter's Has the words field. For any other field it will prefix your criteria with the field name. For example, if you type [email protected] in the To field, it'll create the filter condition to:([email protected]). The reason it works in the Has the words field, is because it doesn't prefix it with anything. This allows you to specify your own prefixes and even mix different ones like to: and from: as you would in the normal search.

  1. Create or modify a filter.
  2. In the Has the words field, enter your OR condition. For example: to:[email protected] OR from:[email protected]

This is also the place to put any other attributes you want to match (e.g. label:, in:, etc.).

This will also work in the Show search options page, however it's easier to just use a normal search instead.


To my surprise, the solution to me was using the vertical bar | between emails instead of the comma , in the TO filed during filter creation.


[email protected] | [email protected] | [email protected]`

The search box would look like:

to:([email protected] | [email protected] | [email protected])

I got a popup message from Gmail saying that using special characters may give unexpected results. Just clicked on continue and it worked perfectly.


Gmail accepts several syntaxes:

apple OR orange
{apple orange}
apple | orange

Personally, I like to use braces {} because it is more concise:

from:{john jane joe}

The following are also equivalent:

from:(john | jane | joe)
from:(john OR jane OR joe) 

For the question asked, I would use:

{to:john from:jane} 

You can also perform boolean OR searches between groups of words.

Parentheses () group terms while quotations "" instruct Gmail to search for the exact words or phrase:

("Some Words1" "Some Words2") OR ("Some Words1" "Some Words3")

Instead of separating the groups using OR, the groups can be enclosed in braces {} to achieve the same effect:

{("Some Words1" "Some Words2")("Some Words1" "Some Words3")} 

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