Boolean Search Operators

Basic Boolean Search Operators

Searching for a keyword or group of keywords is too general for most searches. Just imagine if you wanted to find social mentions of a business name like Coach House Apartments. A simple query that looks for any of the keywords coach, house, or apartments would open a fire hose of mentions. We need to be able to specify which words we should have, which we must have and which we don’t want at all.

A Boolean search is a type of search that lets you combine keywords with operators like AND, OR and NOT to limit, widen or further define your search for more relevant results.

bullet OR- Use of theORoperator looks for mentions of any of the keywords in a list.

bulletAND- theANDoperator specifies which words in a list must be included in the
search results.

bulletNOT- Any words specified by theNOToperator would exclude results if they appear.

A Venn diagram shows the possible relations between sets. So if the set of all mentions of term A are in the first circle, all mentions of term B are in the second circle, and all mentions of term C are in the bottom circle, we can study the result sets of combining or excluding mentions.


If we are looking for any mentions of keywords A, Bor C, we would get a result that includes all the mentions for all three keywords – every result colored in red (everything).

Venn diagram demonstrating the Boolean operator, OR, with three circles labeled A, B, C with their union represented by the Boolean search string A OR B OR C.

Let’s use sets of numbers to also illustrate this. If A={1,2,3,4,5} and B={1,3,5,7} and C={4,5,6,7}, then A OR B OR C would be all of these numbers {1,2,3,4,5,6,7}.

For our Coach House Apartments example, if we did a Boolean search of coach OR house OR apartments, we would get every mention that included the word coach or the word house or the word apartments. That would be a huge amount of mentions! Every recent mention of a sports team that used the word coach could show up in the results, along with every real estate mention for any house for sale or the TV show House, as well as anyone talking on twitter about how small the apartments are in their building. Clearly this is not the way to find mentions of Coach House Apartments.


If we are looking only for mentions that include all three keywords, A, B, and C, we would get a set of results that includes only any mentions that are found in all 3 circles – colored in blue.

Venn diagram demonstrating the Boolean operator, AND, with three circles labeled A, B, C and their intersection, represented by the Boolean search string A AND B AND C.

Using our sets of numbers to illustrate this again, if A={1,2,3,4,5} and B={1,3,5,7} and C={4,5,6,7}, then AANDBANDC would only be the numbers appearing in all three sets, which would only be {5}.

Venn diagram demonstrating the Boolean operator, AND, with three circles labeled A, B, C filed with numbers and their intersection, represented by the Boolean search string A AND B AND C.

So for our Coach House Apartments example, we must have the words coach and house and apartments. But we would want to exclude words like condos, and condominiums. However, we still would get a fire hose of mentions because coach, house and apartments are commonly used words, and may still miss variations in spelling. Theoretically is not unreasonable that somewhere there could be a blog post or a social mention where someone left the house to attend a baseball game, thought the coach misjudged their opponents and the pitcher allowed a home run that went out of the ball field to the nearby apartments.


One way to try to narrow the search and eliminate unwanted mentions in the results is to use the Boolean operator, NOT. The NOT operator excludes any results with the specified term. Using a Venn diagram to demonstrate this, if we wanted all the results that are in setsA andB, but not those in C, the results would include everything that includes bothA and B but excludes any of those which have C, as pictured in the following diagram.

<href=”/wp-content/uploads/2013/07/venn-a-or-b-not-c.png”>Venn diagram demonstrating the Boolean operator, NOT, with three circles labeled A, B, C and their intersection, represented by the Boolean search string A OR B with the contents of C excluded as represented by A OR B NOT C

If we are looking for mentions of apartments, but don’t want any mentions that include condominiums, the Boolean search string would look like:

Venn diagram representing the Boolean search string, apartments NOT condominiums.

We would only want the mentions that have the word apartments but not any that also have condominiums.

Advanced Boolean Search Operators

There are additional Boolean search operators that are often used and associated with any kind of search query in software, but are not always implemented in social media monitoring tools. These additional operators help refine your search to make it more accurate and powerful.

Quotes – ” “

Quotes specify a string of characters that should be searched for exactly as specified. That allows related words to be kept together so you can search for an exact phrase, instead of separate words. Therefore we could search on

“coach house apartments”

(with quotes) and only results with those 3 words in that exact order will show up. Whether or not each of the three words is capitalized or not usually doesn’t matter, it’s not case sensitive. However if the apartments were referred to as coach houseapts, coach houseapartment, coach house luxury apartmentsorcoach house rental apartments, we would miss that mention. So it’s not the best solution if there is ever any variation in your brand name or keywords.

Combining quotes with our basic Boolean search operators could be used to keep the coach house brand name words together since the name of the apartments will always be those two words in that exact order. Then we can add our apartments word as an additional term to search for, which will take care of the case of mentions such as coach house rental apartments.

“coach house” AND apartments

Grouping with Parentheses – ()

One important and often overlooked operator in search expressions is the humble but powerful parentheses. The way in which you group search terms together and the order that they are performed can make the difference between
good results and junk.

Here is an example of the d ifference parentheses can make. In the first diagram, we first perform the OR operation to select any mentions that are both in circle B or circle C (shown in light blue). Then from that set, we want only the intersection of that set that is included within circleA (shown in purple). We can express that with:


Using the parentheses to perform the (BORC) function first followed by selecting only those results that also includeA, our final result is fairly small.

Venn diagram highlighting the intersection of circle A with the union of circle B with C, representing the Boolean search string A AND (B OR C) Venn diagram highlighting the union of 2 out of 3 circles, representing the Boolean search string B or C.

But if we moved the parentheses to perform the AND operation first (shown below in light blue), and then add anything in theC circle, you combine both and it’s a much larger set of mentions.

Venn diagram highlighting the union of circle C with the intersection of circles labeled A and B, representing the Boolean search string (A AND B) OR C. Venn diagram highlighting the intersection of 2 out of 3 circles labled A, B, and C, representing the Boolean search string A AND B

This is a common problem with social media monitoring tools which do not allow the use of parentheses to specify the order of the Boolean operations. If the order is only from left to right, the A ANDB functionality will go first, which we cannot assume is what we need.

Let’s say some people spell the apartment brand name as two words, and some combine them. We would want to search for Coach House or Coachhouse. Also, people often abbreviate apartments, and may use the singular instead of the plural. The parentheses lets us choose between any variations of these words and then lets us combine them with the rest of the string.

(“coach house” OR coachhouse) AND (apartments OR apartment OR apt OR apts OR rental OR rentals)

This query may return coach house apartments, coachhouse apartment, coach house apt, coach house rentals,etc., but not necessarily next to each other, they could be scattered about the web page or social mention.

How Parentheses Change Search Results

To help better illustrate the value of parenthesis, let’s create a celebrity persona we want to track named Melissa White, who changed her name to Melissa Jackson after marrying. In this example, we would look for mentions of either the last names WhiteorJackson:

white OR jackson

There would be a huge amount of mentions, including anything mentioning the color white, or any references to Michael Jackson.

Then from those results, we’d only include mentions that also included the name Melissa, which can be done with the AND operator.

Venn diagram highlighting the intersection of the name Melissa with the union of last names either White or Jackson to represent the Boolean search string, Melissa AND (White OR Jackson)

This basic example would give us results (anything in color) that includes mentions of Melissa and White (in blue) or Melissa and Jackson (in red) or both (in purple), a much narrower set.

Now let’s use our example to demonstrate what happens when the parentheses are moved around (or if there are no parentheses allowed so the query is performed by default from left to right). The first operation performed would be to select mentions that included Melissa and White.

melissa AND white

Then we would add to the set any mentions of the name Jackson. This would give us a much bigger set of results with many useless mentions of the name Jackson without any reference to Melissa White(the yellow area). This is represented in the diagram below by ANY colored areas.

Venn diagram highlighting the intersection of the name Melissa with the last name of White, then combined with instances of the name Jackson to represent the Boolean search string, (Melissa AND White) OR Jackson.

Clearly the use of the parentheses is imperative to ensure the Boolean operator functions are performed in the correct order.

Using Parenthesis to Combine Tasks

Parentheses are also useful for combining a bunch of search tasks together and specifying the order. For example, what if you were monitoring people discussing apple pies and peach pies (plural or singular) on social networks, but you don’t want to capture any results that mention frozen pies. You can combine a Boolean query to find the two types of fruit combined with plural or singular forms of pie, and then remove any frozen mentions.

((apple OR peach) AND (pie OR pies)) NOT frozen

Set 1: (apple OR peach) = results containing the words apple or peach

Set 2: (pie OR pies) = results containing the words pie or pies

Set 3: ((apple OR peach) AND (pie OR pies)) = results with both sets of words in them (e.g., apple pie, apple pies, apple cobbler pie, peach pie, peach pies, peach homemade pie, frozen apple pies)

Final set: NOT frozen = results in set 3 and any page that has the word frozen in it is removed.

Wildcards and Truncation – *, ?

Wildcards provide the ability to specify that some characters can be substituted for anything in your search query. There are usually two types of wildcards – a single character wildcard, or a truncation wildcard.

Truncation Wildcard – *

Sometimes there are variations with the word tense that you want to account for in your search. Most tools which support wildcard functionality will use the “*” symbol to indicate truncation. Truncation expands the search to include any words that begin with same characters, but could end in anything of any size. So searching for house* would include house, houses, housed, household… but not housing because all 5 characters of house is required to start the word. In some platforms, the “*” symbol represents a multiple character wildcard which can be used in the middle of a word, which allows for zero or more characters to be represented by the “*”.

Single Character Wildcard – ?

The “?” symbol usually acts as a single character wildcard, replacing only 1 character in the word. So apartment? would include apartments, but not apartmentalize. Note that it requires a character to exist where the “?” symbol is. So Jet?Blue will find Jet-Blue and JetsBlue, but not JetBlue.

In this case, the “*” symbol would work better, because zero or more characters could be represented by the “*”, so Jet*Blue would include mentions of
JetBlue. Just be careful that it doesn’t include too many irrelevant variations. A search on toys*us would find Toys”R”Us, toysrus, toys-r-us and ToysЯUs, but will also find Toysaurus (which includes a World of WarCraft character, a gun store and a Japanese dinosaur sculpture), or mentions with other random words like
Toys4Us, toysareus, toysrlikeus.

Here is an example of the variations of words that could be represented
by using wildcards:

Boolean search wildcard example

Let’s go back to our Coach House Apartments example to see how we can use wildcards to expand our search or condense the length of our Boolean search strings.

Will coach*house find results with mentions of coach house and coachhouse? In most cases, only coachhouse because the use of the “*” wildcard will find zero or any number of non-space characters between coach and house. So it won’t find coach house because the wildcard cannot represent a space. So coach*house will not find results with a space between the words, i.e., coach house, but could find coacheshouse, coach2house,,etc. Just imagine if it did, then any number of words between coach and house in an entire social mention or web page could be found.

So instead of explicitly including each variation of the word apartment or rental with and without plurals as in:

(“coach house” OR coachhouse) AND (apartments OR apartment OR apt OR apts OR rental OR rentals)

We can shorten the second part of query string using wildcards to pull in singular or plural terms.

(“coach house” OR coachhouse) AND (apartment* OR apt*
OR rental*)

Shortening it even further, it is possible (but not recommended in this example) to combine apartment(s) and apt(s) together could be done, as in:

(“coach house” OR coachhouse) AND (ap*t* OR rental*)

but that will include many other mentions that are likely unwanted, expanding ap*t* to include words such as application, appointment,
apparently and Aphrodite.

Proximity with ~ or NEAR

Just finding coach and house existing on the same page will likely bring us results that we do not want. Often two or more words are associated with each other and will be in close proximity with each other, however, in some cases may not always be exactly next to each other.

In our example, we would like the 3 words which make up the name of our apartments to be close to each other. A proximity operator can solve this problem. Some tools use the tilde (~) character to represent proximity. It will find mentions of the words within the quotes within the specified number of words from each other in any order. For example,

“coach house apartments”~7

Will find mentions of the exact phrase coach house apartments, as well as any time those 3 words are within 7 words of each other. So mentions like coach house luxury apartments or John House is a life coach at the apartments will be included in the results.

However, what’s in the quotes is taken literally, so we can’t include other Boolean operators within the quotes or specify wildcards, such as apartment? to indicate we’ll take any mention that starts with apartment and an additional character (so we could include the plural, apartments).

If the words you are searching for have multiple variations, some monitoring tools offer a NEAR style operator that can be used in combination with Boolean expressions instead of limiting it to the words within the quotes as with the “~” operator. NEAR is like AND in that both words must appear. However, NEAR says the two words must be within a certain number of words near each other. So we could change that part of our search query to be

(“coach house” OR coachhouse) NEAR/2 apartments

In this example, every mention will have to have the phrase coach houseat most two words apart from the word apartments. We use parenthesis because we want to find mentions of coach houseor coachhouse first, and then see that the phrase is near to apartments. However, since it works with Boolean expressions, we can use it for when people abbreviate apartments or change from plural to singular:

(“coach house” OR coachhouse) NEAR/2 (apartment* OR apt*
OR rental*)

With this granularity, we could find even more mentions such as coachhouse apartment, coach house luxury apts, coach house has apartments, coach house rentals. So having proximity operators helps us fine tune our query by specifying that the words only have meaning when they are next to each other, yet also find more relevant mentions when we can account for variations within
our proximity requirements.

To fine tune it even further, some social media monitoring tools may expand the NEAR operator to specify if one word should always follow the other, not just be in close proximity before or after. So (coachhouse NEAR/1 apartments) may find coachhouse apartments or apartments at coachhouse, but including the f character with the NEAR operator requires the second word to follow the first. Therefore, (coachhouse NEAR/1f apartments) will only find coachhouse apartments, but not apartments coachhouse.

Your thoughts? Please comment below.