Boolean logic has its own long history behind it — it is first mentioned as far back as the mid-19th century. Even so, it is absolutely crucial in the modern information world. In this article we will explain the basics of Boolean operators and their use in searching.
We use a specific type of language to explain to modern information (search & retrieval) systems what we need to search for. Some systems allows us to search in natural language, and others require us to know special query or command languages that take a specific form. So, is there some common characteristic of all search engines? Yes: Boolean logic. This sounds alarming, but actually should be quite familiar to you as its principles apply to sets and other aspects of logic more generally.
Let’s begin with a very simple example. You need to find out something (your information requirement) about cars and motorbikes. The first Boolean operator AND enables you to search through the whole set of information (web pages, magazines, documents, presentations, videos,…) that contain both the required key words (a condition).
For our example we’ll phrase the question like this:
cars AND motorbikes
Keep in mind that the system will return results that must contain both words, i.e cars AND motorcycles. In terms of sets, this is how it looks:
Another Boolean operator helps us to extend the number of results if we don’t end up with enough. This is OR and it enables us to search for both keywords together, or for documents that contain both.
Here’s our question:
cars OR motorbikes
The search results will contain documents containing cars OR motorbikes, as well as both words together. Let’s have a look at this set:
The third Boolean operator is NOT and its main function is to exclude certain keywords from our search. So, we can redefine our example in as follows: we want information about cars, but we DON’T want information about motorcycles. Here’s how we write it:
cars NOT motorcycles
Now our set looks like this.
Careful how you write your operators
Writing Boolean operators can differ between information systems. For example, Google considers AND with a trailing space to be an operator. In the Patentscope system, you can write NOT or ANDNOT to exclude keywords, and so on. You need to look at the relevant documentation before you search to see the correct form for writing these operators. The principles, however, are the same.
- We can use three basic Boolean operators in information systems.
- AND generates results containing both linked keywords.
- OR generates at least one of the searched words in the results.
- NOT excludes the specified word from the results.
Photo by patchtok