Skip to Main Content

LS 102 Course Materials: Boolean Operators & Nesting

Introduction to Information Research

Intro to Boolean Logic

Boolean logic is used in databases during their searches to decide what to include or exclude from the search. It is based off of the ideas behind deductive reasoning.

For example, if you search for dog you get many results. If you are looking for a specific type of dog, then it makes sense to narrowly specify which you want: black dog. Results for blue dog would be illogical and excluded.

Boolean Operators redux

Boolean Operators (AND, OR, NOT) are a search technique that allows you to tell the database how you want your keywords to be connected in the search. You can use them to narrow, broaden, or exclude in your results. You choose which to use based on what is logical to include or exclude for your specific need.

Since you cannot use full sentences or questions, the Boolean Operators (AND, OR, NOT) allow you to communicate your need in a way the database understands.

The Boolean Operators you use impact your results heavily. Look at the difference in the number of results in the following three searches using the keywords yoga, stress, all done in the database Research Library (ProQuest):

   yoga AND stress

Shows 989 results for search phrase yoga AND stress in database Research Library (ProQuest)

   yoga OR stress

Shows 240,636 results for search phrase yoga OR stress in database Research Library (ProQuest)

  yoga NOT stress

Shows 13,333 results for search phrase yoga NOT stress in database Research Library (ProQuest)

Each Boolean Operator performs a different action, which means they each would be used in a particular situation. Note the Boolean Operators should be in all caps; many databases will not recognize them otherwise.

Boolean operator "AND"    

AND retrieves records that contain all the search terms entered. All the results you see will contain all of the keywords you specified. Thus, AND narrows a search. The more terms you connect with AND, the narrower and more focused your search becomes. For this reason, you want to use AND when connecting different ideas.

Here are some examples:

art therapy AND children

hacking AND security

lead AND drinking water


Boolean operator AND; Venn diagram shows two overlapping circles. One circle has the text "hacking"; the other circle has the text "security." The small overlapping portion is highlighted to show how AND narrows to only a smaller area that includes both terms.

Boolean Operator "OR"

OR retrieves all records that contain at least one of the search terms entered. If any of the terms are found, that item will show up in your list of results. Thus, OR broadens your search. In other words: OR is more! For this reason, you want to use OR when connecting similar ideas.

Here are some examples:

lawyers OR attorneys

teenagers OR adolescents

drug abuse OR substance abuse

Boolean operator OR; Venn diagram shows two overlapping circles. One circle has the text "teeangers"; the other circle has the text "adolescents." Both circles and the small overlapping section are the same color to show how OR broadens to encompass results that feature both terms separately, either term individually, or both terms together.

Boolean operator "NOT"

NOT excludes a term from your search. If that term is found, the item will not show up in your list of results. Thus, NOT can narrow your search.

NOT should be used cautiously! It can sometimes eliminate desired records from your results if a record happens to contain both terms in a way you may not anticipate.

NOT is commonly used when a word has more than one definition and you would like to exclude meanings not relevant to your search.

Here are some examples:

mine NOT explosive

bat NOT baseball

kid NOT goat

Boolean operator NOT; Venn diagram shows two overlapping circles. One circle is blue and has the text "bat." The other circle is yellow and has the text "baseball." The overlapping portion of the two circles is blue and has the text "NOT." The overlapping area is the same color as the first circle to indicate that results will only include the term "bat." If the results mention both terms, they will be excluded.

Nesting redux

Nesting is an advanced search technique that allows you to group your search terms and to dictate the order in which the Boolean operators will be carried out. Specifically, everything within the parentheses is searched first.

 

Most databases carry out your search terms moving from left to right unless you say otherwise.  This can lead to many unwanted items.

It is especially important to use nesting when your search statement contains similar terms connected by the OR operator.

For example, here is a search for smoking AND teenagers OR adolescents in Academic Search Complete. Look at the total number of results – over 240 thousand!

Search results from search: smoking AND teenagers OR adolescents in Academic Search Complete. The total number of results is 241,624.


At first, that may not seem too bad. However, when we look at the most recent articles from this search some talk about adolescents without mentioning smoking. Those aren’t relevant to our need.

Example of result mentioning adolescents, but not smoking


Here’s a search for smoking AND (teenagers OR adolescents). Now the computer will search first for the items within the parentheses.  It will find all records containing the terms “teenagers” or “adolescents.”  Next, it will take those results and only retrieve the records that also contain the term “smoking.”

You can see the number of results have decreased dramatically to just over 8 thousand.

Search results from search: smoking AND (teenagers OR adolescents) in Academic Search Complete. The total number of results is 8,393. Adding nesting (the parentheses) reordered the search and reduced the total number of results.


Even the most recent articles connect smoking with either teenagers or adolescents, making the results more relevant.

Result that includes keywords smoking, adolescents,and teenagers

If you want to use multiple search boxes, you should keep your nested terms together in the same box, as in the example below.  Some databases will automatically nest the search terms placed in a single box, but others won’t. It’s good to include the parentheses just in case!

Search screen in Academic Search Complete demonstrating how to connect words with nesting. Any words joined with OR must be put in parentheses to nest them. That is true whether you put the entire search into one box or split it between multiple boxes.