What is Boolean Searching?
© 2000 by Walt Howe
(last revised 28 January 2010)
When you search for something with a search engine and search for a single term, you are likely to get thousands of hits, most of which are useless. Adding more related terms may help improve the hits at the top of the list, but it will also bring in thousands more hits, too. Boolean expressions (named after the English mathematician George Boole) give you a way to control what you do and don’t find in your hit lists.
Boolean expressions link terms by means just a few concepts: AND and OR, the value NOT, and parentheses and quotes used to group terms in various ways.
Interested in searching for edible shellfish? Consider these two expressions:
clams AND oysters
clams OR oysters
If you search for these two expressions, the first will find you only documents that include both terms. If you use the second, you will get all documents that include either clams or oysters or both.. The second will produce many more hits than the first. The AND relationship limits your hits. The OR relationship expands your number of hits.
With most search engines, you can string together more than two terms. For example, you can search for:
clams AND oysters AND scallops
This expression limits the search further than the original search. Any documents that the first search found that did not include scallops, too, will be gone from the list.
Expressions with more than two values are easy to understand if they use all ANDs or all ORs, but what happens if they are mixed? Consider this one that you might use if you are looking for a seafood restaurant::
clams OR oysters AND restaurant
This expression is ambiguous unless you know exactly how the search engine will react to it. If you read it left to right, it will first locate documents with clams or oysters and then limit it only to those that also include restaurant. That is probably what you had in mind in conducting this search. But some search engines will read right to left. In that case it will find all documents that include both oysters and restaurant, but then add in all documents that also include the word clam, whether or not restaurant is part of it. A very different result!
The usual way to handle this is to put parentheses around the terms to be evaluated together. This is the correct way to look for seafood restaurants:
(clams OR oysters) AND restaurant
Expressions can be more complex. This expression will lead you to shellfish restaurants in Boston or Cambridge:
(clams OR oysters) AND restaurant AND (Boston OR Cambridge)
The above expression will find shellfish restaurants in Cambridge, England, too. To limit this, we can add a NOT expression.
(clams OR oysters) AND restaurant AND (Boston OR Cambridge) AND NOT England
For all practical purposes, NOTs are always used with multiple terms and combined with ANDs. It would be pointless to search for any of these:
television OR NOT books
Both of the above expressions would return every document that didn’t have the word book in it. The second would add to the list all documents which had the word television in it, too, even if the word books was present. There would be millions of hits, in either case, and it would be useless.
NOT can be very useful in limiting out unwanted hits. The two expressions that follow will give you very different results:
dungeons AND dragons
dungeons AND NOT dragons
Boolean logic searching is based on Boolean Algebra. If you are interested, follow this link to mathematical basis of Boolean Algebra.