What is Boolean Search?

Reading Time: 4 minutes

In this blog post we look at “What is Boolean Search?”, identifying its origin and the impact Boolean operators have on a search string. Hopefully by the end of this blog post you’ll have a better understanding of Boolean search and you’ll be able to improve the quality of your use of internet search engines such as Google and other search-based applications.

Defining Boolean Search

Boolean search is a method of searching and filtering data based on using “Boolean Operators” with a search string. The most well-known of these Boolean operators are the likes of ‘AND’, ‘OR’ and ‘NOT’.

This “Boolean” logic was named after English mathematician George Boole for his contribution to the area and is based on algebra in which all the values register as either TRUE or FALSE, which is closely related to the binary numbering system in which a value can only be one of two values: 1 or 0.

Depending upon the type of Boolean operators used in a search string the outcome will be completely different, for example using the ‘OR’ operator widens the search query, whilst a search string including the ‘AND’ operator acts as a filter and so limits the search query.

Boolean Operators and Examples

Boolean operators and their impact on search results are probably best understood if we take a look at CXAIR’s interactive Venn diagrams. For these examples, I am going to pretend I work as the sales manager for a global hotel chain – a nice promotion I know!

‘OR’ Boolean Operator

This will broaden your search query, returning all of the specified search string values that can be found within the index.

I want to understand how many total customers we are bringing in at our top two UK performing hotels per month – Manchester and London.

Venn Diagram displaying the "Manchester" set and "London" set

As you can see from the screenshot above, the two different variables would be represented as “Manchester” and “London”. Each of the two sets represents the number of customers who have stayed at the corresponding hotel.

Venn diagram - Combined sets: "Manchester" & "London"

These two separate visitor counts would be added together to answer the initial question. The Boolean search query that would be behind this calculation would be “Manchester ‘OR’ London”.

Boolean Search Query using 'OR' Boolean Operator

‘AND’ Boolean Operator

This narrows the search query, returning only the instances where both values are present.

In another example, let’s say I wanted to look a bit more in-depth at the Manchester branch. I’m interested in seeing a bit more about how our loyalty card scheme is performing at this branch. Is this proving successful or should we scrap it all together?

The variables we’ll be using here are “Loyalty card” and “Manchester”. The “Loyalty card” set is the total number of loyalty cards used by our customers across any of our hotels. The “Manchester” set looks at the total number of visitors coming in to the branch.

Venn Diagram - "Manchester" and "Loyalty Card" Sets

If we now overlay these two sets, we can see an intersection is created and a dynamic query calculation is applied in CXAIR. The value represented in this intersection answers our original question, showing us how many loyalty card transactions were completed by visitors to the Manchester branch.

Boolean Search Query using 'AND' Boolean Operator

When we drill through to the underlying data to gain a greater understanding, we can see from the below screenshot that the query is “Loyalty card ‘AND’ Manchester”.

‘NOT’ Boolean Operator

This excludes values from the search query, returning only the instances where the first value is present whilst excluding any instances where the second value directly follows the first.

In this last example, I want to know the amount of visitors that stayed in any room other than one of our single rooms as we are targeting families and couples in our next campaign. The variables we will use here are “Single” and “Room”. In this case we will be looking for the word “Single” to appear any time in the room type field, allowing us to capture all of the stays in a single room. And “Room” will look at every single room type that has been stayed in e.g. Double Room, Luxury Room, Executive Room, etc.

Venn diagram - "Single" set and "Room" set

Similar to before, if we overlay both of these sets then we will see an intersection created. As we now know this search query is calculated using the ‘AND’ Boolean operator and will find all instances where “Single” and “Room” is true – aka the exact opposite of what we want to do! To answer our question we need to look at the recalculated “Room” set as it is excluding any instances where there are single. This is why the “Single” set is displaying 0, because there are no instances of just the word “Single” without “Room”.

Boolean Search Query using 'NOT' Boolean Operator

After drilling through to the underlying data we can see that the query used to calculate the “Room” set (once it had been overlaid) is “Single ‘NOT’ Room”.
Hopefully this post has done a good job of explaining what we mean by performing a Boolean search using Boolean search operators and shown you some good examples of how you could apply Boolean operators to filter data not only in search engines such as Google, Bing, etc. but other applications also.

    Please enter your email address to access the specified content

    Get in touch to discuss your requirements further