Using Boolean Operators in Search Engines

These days when looking for information for school, work, or personal use we rely on search engines to find what we need. Search engines are constantly crawling through the web, indexing pages, and ranking them based on a set of heuristics to deliver the most relevant information. Most times, when a search engine is used, searchers type in certain keywords they are trying to do research on. For the most part this works but sometimes you get irrelevant links.

To get better results we may need to tell the search engine to include all the keywords present or exclude certain keywords. How exactly can we do this? Let's take a look at this tutorial to find out how you can use certain Boolean operators.

Boolean Operators Overview

The Boolean operators AND, OR, and NOT are the fundamental basis for all desktop and web applications including search engines. Boolean logic uses these operators to create complex logic that evaluates to true or false. Based on the result of the calculation, certain actions are either taken or not taken. Let's get an overview of how these operators work before delving into how to use them with the major search engine providers.

AND Operator

One basic operator used in Boolean logic is the AND operator. A Boolean expression can have several parts within it. If the parts are joined by an AND operator, the expression will only evaluate to true if all the parts themselves are true. Here is an example of a statement which uses the AND operator:


a AND b AND c

In this simple example, the Boolean statement above will only evaluate to true if the parts, namely, a, b, and c all evaluate to true. Obviously, in search engine terms, a, b, and c would be the keywords you are looking for. Any page that has all three keywords matching will be returned.

OR Operator

Another fundamental operator for Boolean logic is the OR operator. Unlike the AND operator, parts of a Boolean expression joined by an OR operator do not all have to be true for the expression to evaluate to true. If any one of the parts joined by an OR operator is true, then the expression will evaluate to true. The following is an example of a Boolean expression using OR:


d OR e OR f

The expression above will evaluate to true if one or more of the parts, namely, d, e, or f are true.[1] For example, if just e is true, the entire statement will evaluate to true.

NOT Operator

As opposed to the AND and OR operators, the NOT operators simply negate Boolean expressions or parts of a Boolean expression. For example, in the following statement, the expression "NOT a" is only true if a itself is false to begin with:


NOT a

The NOT operator is often used in software programming to execute certain statements when a particular condition is false or to exclude certain items.

Search Engine Application

Just as Boolean operators are used in many programming languages to create desktop programs or web applications, these operators can also be used on various search engines. Let's explore how we can perform searches on major search engines using Boolean operators.

Searching with Google

Google is an immensely popular search engine that not only allows simple searches but advanced searches using or implicitly using the Boolean operators mentioned. Much of the syntax is mentioned on its Advanced Search and Search Operator pages.

If you are looking for search results that match all the terms, you are basically invoking the AND operator. Google by default looks for all the terms to match when searching for results. However, if you type in the AND operator, make sure you use upper case. For example, let's say you type in the following into Google:


horrors spider island

Google will return all the pages that have all the words on the page. They necessarily don't have to be together. This is the same as applying the AND Boolean condition:


horrors AND spider AND island

This will mostly provide results for the 1960 horror film Horrors of Spider Island. But it is actually the English language dubbed version of the German film Ein Toter Hing im Netz (roughly: "dead man hung on the net"). If you want to search for both versions of the film, you would use the OR operator:


horrors spider island | toter hing netz

The query shown will look for pages that have the words "horrors" and "spider" and "island" the words "toter" and "hing" and "netz." When you execute this query, you will also get results that include both versions of the film.

Besides the AND and OR operators, Google makes it easy to exclude certain results with the NOT operator using the minus symbol (-). Suppose you had been studying the Nazi pogrom Kristallnacht, and you wanted to search for information that did not discuss Hitler. You could enter the following search:


kristallnacht -hitler

Executing this query will result in all pages with the word "kristallnacht", but none that directly reference Hitler

Searching with Bing

Bing has its own query language called the Bing Query Language which has several operators.

All the operators used by Bing have very similar syntax as Google's. Like Google, Bing defaults to an AND operator for search. If you want, you can join multiple search terms with AND (make sure this is in all caps) or & symbols. For the OR operator, you can either use OR to join multiple search terms or the | symbol. For the NOT operator, you can either use the NOT keyword (all caps) or the - or minus symbol like Google.

Searching with Yahoo!

Yahoo! search has similar syntax to both Google and Bing. For the and operator, you can do a regular search inputting keywords without quotes or use the AND operator. To include pages that match any one of the keywords but not necessarily all of them, place the OR keyword between the keywords. Note, that Yahoo!'s Advanced Search page does not mention the | or pipe symbol as a substitute for the OR keyword. Finally, to exclude search results, you can either use the NOT keyword or - (minus) symbol.

Searching with Duck Duck Go

Though Duck Duck Go is not quite as mainstream as Google, it calls itself the search engine "that doesn't track you." Like the other search engines, the AND operator is default but you can use the AND keyword according to Duck Duck Go's search syntax page. To use the OR operator, simply insert the OR keyword (all caps) between the search terms. Finally, to implement the NOT operator, use the - or minus symbol when trying to exclude keywords with Duck Duck Go.

Conclusion

All search engines have some Boolean capabilities. Check those search engines to find out what they require. You can usually do this by going to the search engine's "advanced search" feature. Regardless, a little trial and error will go a long way. You can try "OR" and if that doesn't work, try "|." And so on. Using Boolean logic in your search queries greatly increases the power of search engines. Sometimes, it provides the only way to find the information you are looking for.

Further Reading and Resources

We have more guides, tutorials, and infographics related to using the internet:

Secrets of a Killer Blog Post

Want to know how to create a great blog post? Check out our video, Secrets of a Killer Blog Post.


[1] There is an advanced Boolean operator: XOR. It stands for "exclusive OR." It is true only if one of the conditions is true. So consider our example above:

d XOR e OR f

This would be true if d, e, or f alone were true. If d and e were both true, this would be false, unlike with a regular OR operator.