TLT  •   @One  •   Special Collections  •   Basque  •   DeLaMare  •   Savitt

Using AND, OR, and NOT (Boolean Operators)

The examples on this page illustrate the use of the Boolean operators OR, AND, and NOT (or AND NOT) in indexes, databases, and search engines that support Boolean type searches.

TipIn our library catalog, you can use AND, OR, and AND NOT in Subject searches, which look for matches in the title, author, subject headings, and note fields of each catalog record. The most important note field is Contents, which may list individual chapters, essays, short stories, or other parts of a book, anthology or recording.

This page discusses four basic search techniques:

  1. Simple searches with one Boolean operator
  2. Parentheses in searches with more than one Boolean operator
  3. Truncation
  4. Boolean NOT

I. Simple searches with one Boolean operator

Imagine that you need to find several books about jazz or blues music for a class assignment. To get an overview of what is available before focusing on some aspect of jazz or blues music, you perform three Keyword searches in an index to periodicals, such as RILM Abstracts of Music Literature.

  • jazz OR blues
    • This search finds articles that discuss either jazz or blues.
      OR always broadens a search.
  • jazz AND blues
    • This search finds articles that compare jazz and blues.
      AND
      always narrows a search.
  • jazz NOT blues
    • This search finds articles that are exclusively about jazz.
      NOT always excludes records with the specified term.
      Note: In the library catalog, type jazz AND NOT blues.

TipVenn diagrams use circles to visually represent Boolean search results. On this page, each large circle represents a group, or set, of article "records" in the music periodical index that contain one search term. Each dot represents a single record in our hypothetical search.

Black dots = 
White dots = 
Black/White dots = 
records that contain the word jazz
records that contain the word blues
records that contain both jazz and blues

Keyword search for: Jazz OR blues

This search locates articles that are about either jazz or blues, or that compare both forms of music.

Venn Diagram
jazz
blues

<---- jazz or blues ---->
(the entire turquoise area)

Count the records (dots) retrieved by this search:

jazz set

blues set

jazz or blues set
21

20

32

Every record in the jazz or blues set contains at least one of the search terms jazz or blues. 9 records that contain both terms appear where the sets overlap.

These search results demonstrate that you should use OR if you want to retrieve either this term or that term. (Of course, you can OR more than two terms together.) OR always broadens a search.

Keyword search for: jazz AND blues

This search locates articles that discuss or compare both jazz and blues.

Venn Diagram
jazz
blues

jazz and blues
(Where the sets overlap)

Count the records (dots) retrieved by this search:

jazz set

blues set

jazz and blues set
21

20

9

The result of this search is jazz and blues, the intersection of the jazz set and the blues set. Every record must contain both jazz and blues.

Use AND when you want to combine search terms. AND always narrows a search.

Tip"Implied AND"

Some databases and search engines assume Boolean "AND" between adjacent words in a keyword search. Implied AND means that a search for body piercing will retrieve body AND piercing not the phrase "body piercing". (Be aware that many Web search engines have an implied OR rather than AND!).

Keyword search for: jazz NOT blues

This search excludes records that contain the term blues.

Venn Diagram
jazz
blues

jazz NOT blues
(Turquoise area)

Count the records (dots) retrieved by this search:

jazz set

blues set

jazz not blues set
21

20

12

The part of the jazz set that does not contain records in the blues set is retrieved as the jazz not blues set.

This last search eliminates all records that contain the term blues. If an article compares jazz with blues, you might lose it from your search. Therefore, use NOT with restraint and be aware of the consequences.

TipWhen to use NOT and when not to use NOT!

NOT is appropriate when a word is used in different contexts. For example, the search vikings not minnesota retrieves records about Vikings but not the Minnesota Vikings. If you are studying Medieval Viking sagas, this is good. If you are researching pro football, it's not.

II. Using parentheses in searches with more than one Boolean operator

Sometimes a focused search must combine several related words for one idea with another word or words, as in the search: (logging or clearcutting) and rainforests.

In this search, we used Boolean OR to combine the related words: logging OR clearcutting. Then we used Boolean AND to combine these words with rainforests. The parentheses ensure that results are what we expect.

TipParentheses indicate relationships between search terms. They force the computer to process your search terms in the order you intend and to combine them in the way you want. Read more about computer search order below.

Computer search order

A database or search engine processes your search terms from left to right, but it processes all the Boolean AND operators BEFORE processing any Boolean OR operators. To change this order, group synonyms (or terms that belong together) with parentheses. Anything enclosed in parentheses is evaluated first. To see how this works, compare the two hypothetical library catalog searches below:

lacrosse or soccer and history Retrieves about 80 items
Combines soccer and history
Retrieves all books about lacrosse
This is not what you wanted!
(lacrosse or soccer) and history Retrieves about 60 items
Combines lacrosse or soccer
"ANDs" those results with history
This is exactly what you wanted!

Of course, you can use more than one OR in a search, as in: (tobacco or smoking) and (cancer or health)

III. Using truncation

If you want to search for part of a word or a whole word that may have several endings, use a "wildcard," commonly an asterisk (*), though some search engines use other symbols. It will improve search results and save you time. For example:

To Find: To Use:
university or universities universit*
legislate, legislates, legislator, legislators,
legislation, or legislating
legislat*

IV. Using Boolean NOT

How should you use Boolean NOT? Very Carefully!

NOT eliminates all catalog records that contain the term preceded by NOT, but it is a useful tool when a search word has several unrelated meanings. You also can use NOT to exclude some commonly discussed aspect of a subject.

For example, if you are doing a term paper on the epic poem Beowulf, and you keep getting titles about Linux Beowulf Clusters in computing, you could tighten up your search by using NOT or AND NOT. In the library catalog, you could use this subject search to eliminate books about Linux or computing.

beowulf and not (linux or computing)

If you are researching salamanders but do not want to look at anything about newts, you could do this:

salamanders and not newts

However, you should be aware that any book with chapters about both salamanders and newts will be eliminated from your search results. So, NOT is a very risky operator to use in this search!