Boolean Query Writing: Everything You Need to Know
By Joakim Nilsson on January 4th 2018Read this article on our full site
Boolean can seem like massive headache - which is why we've compiled a handy how-to guide on how to create different types of queries. Get crafting!
If you’re new to Brandwatch Analytics, Boolean query writing may seem a bit scary to you. All those intimidating characters!
I understand. It’s inviting to just go for that Query Wizard button. If that’s how you feel, I want you to keep on reading.
It’s my secret mission here at Brandwatch to turn you into a black-belt Boolean query writer. I’m not going to let you get intimidated by those operators. They are, in fact, our best friends. I’m going to introduce you to each one of them.
When you master the basics of Boolean query writing you will feel a sense of being able to own every tweet, every Instagram hashtag, every blog post published.
In this post I’m going to teach you about the few quirks that you need to understand when writing Boolean in Brandwatch Analytics. I’m going to take you through three basic types of queries:
- The “catch all” brand query
- The Instagram hashtag query
- The author query
I’m assuming that you are slightly familiar with the various Boolean operators that Brandwatch offer and what they do. If not, I invite you to read the blog post Smooth Operators and have a look at our operators in the feature list.
Boolean query writing: Say hello to the “catch all” brand query
This is probably the most important query to learn how to write, and if you only need to know one query type, this is the one.
The purpose of the catch all brand query is to catch any mention of your brand (or competitors) across all sources.
In order to construct the catch all brand query we’ll need to know about the following operators (if you skipped reading about the operators, please jump back here):
The brand we’d like to search for in this example is Starbucks.
What we need to start with is simply writing variations of the Starbucks brand name, such as people could refer to it. Including common misspellings.
The wildcard operator allows for any ending of the word meaning that starbuck* will find things like: “starbucks”, “starbucksing” or even “starbuckssssss!!”.
The above line of Boolean will search for mentions in any text across any source except if the part of the mention is considered a title of an article.
In order to make sure that we also get those mentions where “Starbucks” is only mentioned in the title of an article (typically news, blogs or forums) but not in the body text, we’ll need to include a copy of our brand variations using the title: operator.
There’s just one little thing here, the way we get the data from common social networks such as Twitter, Facebook and Instagram means that we treat the social media user name (author) as a title.
In effect, that means that the above Boolean will return all of Starbuck’s own social media posts even if they don’t make a mention of “starbucks” in the post.
As in the “catch all” brand query we’re only interested in earned mentions and not things that we’re publishing ourselves we’ll need to remove the Twitter, facebook and Instagram site from the title: part, but ONLY, the title part of the query:
Now we have a pretty solid query that will catch most of the mentions online related to Starbucks. But there a couple of more things we can do to get even more mentions that we’d otherwise missed.
Adding the hashtags: operator is not only useful for catching, segmenting or filtering Twitter hashtags, it’s also mandatory to include in order to make sure that we’re getting the best possible coverage from Instagram posts.
Mind that the hashtags: operator doesn’t support the asterix operator so we will need to type in all hashtags variation:
The next thing we want to do is to include @mentions of Twitter accounts related to Starbucks, but that don’t match anything that we currently have in the query.
Our query already contains “starbucks*” so there’s no need to include @starbucks using at_mentions:starbucks – it won’t hurt the query, but it also won’t add any additional mentions.
What we need to add are @mentions of accounts that are related to Starbucks and that we consider a Starbucks mention but that do not match the current query.
As a last thing we could add tweets that include links to the Starbucks website, but don’t necessarily mention Starbucks in the tweet. This is often the case of Tweets using URL shorteners.
When reviewing your results in the query editor you’re also likely to find things that you want to exclude for whatever reason. It may be spammy Tweeters, sites you do not want to consider or just certain topics that you deem irrelevant. An example of such exclusion for our Starbucks “catch all” brand query could be:
When we’ve done all of the above our final query would look like this:
The Instagram hashtag query
Whilst the “Catch all” query will include mentions from Instagram using primarily the hashtags operator there’s a small caveat; the language setting.
Setting one or multiple languages for your query will reduce the number of mentions your query will collect from Instagram. Normally this is what you want, but sometime the most important thing is to collect any mention from a hashtag on Instagram regardless of language (you can always filter by language later on within the dashboard components.)
The reason this is happening is that sometime the Instagram post just doesn’t include enough text for Brandwatch accurately assign a language to the post. Even worse, sometime the post just contains a few emojis and a hashtag, i.e. no spoken language is used. In order to collect these mentions we need to create a language agnostic query.
Let’s say we want to measure the results of a campaign that we recently ran, for the purpose of this example I’ll chose a football related hashtag called #TotalCAFCL which is Total sponsoring the CAF Champions league.
A typical Instagram hashtag query would look like this:
This query will return all Instagram posts matching the hashtag and in any language.
Social Media Trends 2018: What to Expect
What are social platforms going to do in 2018? How will this affect brands and publishers? We've got six predictions for social media in 2018 to help you prepare.
The Author query
Sometimes we’re not interested in knowing what people say about a particular brand, campaign or a certain topic but we simply want to understand the overall conversation from an audience or a specific group of people.
With Brandwatch you can do this by creating what we call “Author queries” and it’s super simple and extremely useful.
Maybe you already have a list of the social media handles for a number of your most important customers that you want to follow the conversations of, or maybe you have identified an audience in Brighton interested in Cycling that you are keen on following their general conversations of.
The query part is really easy, where you need some creativity is how to get the social media handles of the people in your audience that you want to monitor.
Here are a few options:
- My prefered way is to use Brandwatch Audiences to search for an exact audience and then export a number author names
- Look at top authors for any query that you have in Brandwatch Analytics
- Manually compiled lists of social media handles
In my below example I’m looking at what Audiophiles are generally talking about online. I’ve used Brandwatch Audiences to gather 1,000 influential Tweeters (your author query doesn’t need to contain Twitter usernames, it could be any author name for any site however typically Twitter, Instagram and popular forums such as Reddit works best).
Simply use the author operator followed by the social media handles separated by the OR operator and put everything between brackets and decide wheter you want your author query to be language agnostic or not.
Since each query only can contain 4,095 characters I’ve split the 1,000 tweeters into 4 author queries that I’ve then put into a group called “Audiophiles”.
I will then use this Query Group in my dashboards in order to understand everything that this audience is talking about, not just related to a certain topic or brand.
So there you have it – the step by step guide to Boolean query writing.
Do you have any top tips on making the most of Brandwatch Analytics? Drop us a comment, or tweet us @brandwatch!