Using AND and OR operators with filtering and searching

Is there any way I can specify AND and OR operators when using Advanced Find or creating more complex custom Views or Search Folders?

Perform an AND/OR Search QueryMany complex searches and filters can already be done on the Advanced tab of Advanced Find when searching for an item or creating a Search Folder or within the Filter section when creating a custom view.

However, you’ll find that when you specify multiple values for the same field, it will use the OR operator and when adding another field, it will use the AND operator. This sometimes leads to unexpected results or not being able to execute some queries.

Example

Example buttonFor instance, say that you want to find a specific email related to a certain project. Some emails you’ve already assigned the Project1 category so you want those to be included in your search results either way. Then, in order to find the rest, you specify people you’ve worked with in the project and several words that are related to the project.

So this query requires;

  1. an OR operator when specifying the names
    (as they could be or from person A or from person B or from person C or to person A, or to Person B or to person C)
  2. an OR operator when specifying the words
  3. an AND operator for the combination of persons and words
  4. an OR operator between the project category and the combination of results specified at point 3.

You cannot do this with the options that you find on the Advanced tab.

Enable the Query Builder

Registry Editor buttonIn order to still achieve the desired results, you can enable the Query Builder which does allow you to control the AND and OR relation in your searches (yes, even nesting!). Enabling it needs to be done via the Registry.

  1. Open the Registry Editor:
    Start-> type: regedit
  2. Browse to the following location in the registry
    HKEY_CURRENT_USER\Software\Microsoft\Office\<version>\Outlook\
  3. Choose: Edit-> New Key
  4. Name the key: QueryBuilder

Using the Query Builder

How? buttonWhen you now open any search or filter dialog in Outlook, you’ll also have a Query Builder tab. It works similar to the Advanced tab but now you are in control over the AND and OR operators and you can group and nest sub queries together to get the results you need.

To change the AND/OR condition, click on AND/OR and then use the “Logical Group” dropdown list to select the other operator.

To create a new AND/OR group for a specific condition, select the item and use the Move Up/Move Down button until a new group is being created.

Once you’ve created all the groups and items, you can use the Move Up/Move Down buttons to sort them accordingly.

The Query Builder tab in Advanced Find allows for complex AND/OR queries.
The Query Builder tab in Advanced Find allows for complex AND/OR queries.