Searching: Mix AND, OR and NOT
Nesting Boolean operators consists of combining multiple search elements within brackets into a comprehensive search query.
Once you've defined what keywords to search with, the order in which you place AND, OR, NOT and brackets can completely change the logic of the search.
Use brackets when mixing different Boolean operators
In maths, anything in brackets (parentheses) is read first in an equation. By using this concept in our search, we can nest search phrases to really make the search work as intended.
Nesting example: radiation AND (protection OR therapy)
➡︎ The content of the brackets, "protection OR therapy" is processed first. The results for "protection" and for "therapy" are passed to "AND radiation" one at a time. The final results list documents including both "radiation protection" and "radiation therapy".
Another way to write this search is (radiation AND protection) OR (radiation AND therapy).
Precedence example: radiation AND protection OR therapy
If you remove the brackets, the lower rule of precedence applies: AND takes precedence over OR.
➡︎ "radiation AND protection" is processed first, followed by "OR therapy". The results list documents including "radiation therapy" in addition to all documents including "therapy".
In this case, placing OR before AND would not change the outcome because AND always precedes OR. Nesting OR within brackets was necessary to obtain results about "radiation therapy".
If you think back when you learned about mathematical equations, the order of the operators matters. For instance the multiplication (✖️) is always processed before the addition (➕).
Search engines use a similar concept of precedence to process AND, OR, NOT and brackets (). The order of precedence may vary depending of the database.
Library Search follows these rules:
Order: The search is processed in the same direction as the language's reading direction. i.e.: Left to Right in English, Right to Left in Arabic or Hebrew.
Brackets: The operator within brackets is processed before the operators outside the brackets. Brackets nested within brackets, are processed before the containing brackets.
AND and NOT: The first AND or NOT operator is processed before the next AND or NOT operator.
OR: The first OR operator is processed before the next OR operator. If there are AND or NOT operators in the same search phrase, OR is processed after AND and NOT. Use brackets if you want to prioritise OR.
For more advanced nesting examples, continue to Advanced Search.