Social listening is a bit like finding a needle in a haystack, or, to be more accurate, many needles in a very big haystack. 

For most brands, there are dozens or hundreds of interesting mentions relating to their brand, products, or industry every day, but the problem is that they are hidden among thousands of less interesting or completely irrelevant mentions. 

The query helps you filter out the extra stuff and get to the mentions that are relevant to the questions you want to answer. Written well, it ensures that most irrelevant mentions are excluded and that you find the insights you need. 

Read on to get an overview of how to write a good query and ultimately improve your data analysis.

What is a query?

Working with social listening platforms like Brandwatch Consumer Research starts with the query. In this first step, you define what kind of data you want the platform to collect. It provides instructions to the crawlers on what to look for in a mention. 

A query is a search string made up of keywords, terms, and Boolean operators (more on this later).

Before you start writing a query, you should think about what answers you want to find with your analysis. What use case do you have? Do you want to track a particular campaign? Do you want to research an industry? Or do you want to find out what consumers are saying online about your brand or a specific product? 

Define the questions you want to answer. This will help you determine what areas you need to cover with your query and avoid an overly broad approach.

How to write a good query

Once you have the set of questions you want to answer, you can start building your query. Depending on your use case, the query you build will look different. For consumer opinion queries, you need a different approach than for tracking a brand campaign. 

In general, think about all the different terms, such as brand or product names. Also consider all the different ways people might write about them online, including common typos and misspellings. Also add relevant hashtags, account handles, or websites.

If you want to analyze consumer opinions, it may be helpful to add pronouns to your main terms, such as I, I’m, me, we, or us, to get mentions from individuals discussing their personal experiences. 

Also, think about things you are not interested in. For example, you may want to see online conversations about your brand's products, but you are not interested in mentions of offers and discounts. You can exclude these from your query.

A fundamental part of any query is the Boolean operators. Unless you’re searching for a single word, your query won’t work without operators.

What are Boolean operators?

Boolean operators are simple words or symbols that in this case give a computer some criteria to use when searching. Words such as AND, NOT, and OR are all Boolean operators. You might be familiar with Boolean logic from your high school math class. A common example is the Venn diagram.

Let's take a look at the most important Boolean operators for writing queries. 

If you have a brand name or phrase you want to track that consists of two or more words, the quotation marks operator comes in handy. Use quotation marks to group them together and indicate that you want the query to search for that exact phrase only.

mercedes benz” 

You can use the OR operator to list multiple words that you want the query to search for. For example, if you want to search for different products or brand names, including different misspellings, you can use the OR operator to list them in one search string.

holiday OR vacation

The AND operator can add context to your query string when you're looking for something that doesn't have a unique name. A common example is the brand Apple. Without adding context, the query will look for all kinds of mentions that include "apple," many of which will have nothing to do with the brand but with the fruit. 

To avoid this, you can use the AND operator and add different keywords to make clearer what you are looking for. For Apple, the search string might look like this:

Apple AND (mac OR iphone)

The AND operator searches for the two terms anywhere in the mention but, depending on the length of the quote, this may not be relevant enough. The NEAR/x operator is the smarter version of the AND operator. It defines how close the two terms should be and the maximum number of words between them. 

For example, using NEAR/10 will return mentions that contain two terms that are near each other, with a maximum of 10 words between them.

Dominos NEAR/10 pizza 

The average sentence is 10 to 15 words long. Setting the NEAR operator between 10 and 15 can be a good starting point to get mentions that are more relevant to what you’re looking for.

The NOT operator, as its name suggests, tells the query what not to include in the search. This allows you to exclude various keywords. 

For example, you may want to see mentions about your brand, but you're not interested in online conversations around discounts:

Airpods NOT (offer OR discount) 

You can save a lot of time by using the wildcard operator (*). This is useful when you want to see different variations of a phrase without having to type each variation. 

For example, you want to look at online conversations around complaints

complain OR complaint OR complaints OR complaining 

Instead, you can use the wildcard operator to shorten your query string:

complain

This saves a lot of time without having to write everything out, and it keeps the query readable and simple.

Another important operator is brackets. They help structure the query string, especially as it becomes more complex. They indicate which terms should be grouped together if the query has multiple operators. Here is an example of a query string with more than one operator:

Dominos AND pizza OR takeaway

Here you have to use brackets to make it clear which terms should be grouped because you can’t have AND and OR at the same time. The above query string will not work. Since you are interested in mentions of Dominos and pizza or Dominos and takeaway, you need to put the parentheses around pizza OR takeaway:

Dominos AND (pizza OR takeaway)

There are other operators you can use to define your queries, such as location or language operators. You can be very specific about what mentions you want to find, so take a look at the other operators available to see if some might be useful to make your query string more relevant.

Quick query writing checklist

Now you know what Boolean operators are and how to use them. Here is a quick checklist before we take a look at writing queries with Brandwatch. 

  1. Define your research question(s). What do you want to answer with your query? What is your use case?
  2. Add keywords. Don't forget common typos and misspellings or relevant hashtags, account handles, websites, and products.
  3. Add context. Use Boolean operators such as OR and NEAR/x to add context to your keywords.
  4. Add exclusions. Exclude keywords, hashtags, sites, etc, that are not relevant to your search
  5. Test and repeat. Test your query for relevance and adjust your search string. This might include setting the NEAR/x operator to a lower number or adding more exclusions.

Pro Tip

Tip 1: Keep it simple. If the simple query works, don't try to overcomplicate it. Some brands have unique names that aren't used elsewhere, so there's no need for a lot of exclusions and context words.

Tip 2: If your exclusions list more keywords than your main keywords, you may want to add more context, as this could be a sign that your main keywords aren't yet relevant enough.

Tip 3: Even if the query is complicated with a lot of operators, it's usually best to have a simple structure consisting of 3 parts: [main term] NEAR/x [context terms] NOT [excluded terms].

Tip 4: You can use <<<Notes>>> to structure a longer query to make it easier to read.

The most common query-writing errors

Writing queries takes practice, but you will learn from your mistakes. And you will make them, as we all do. Here are some of the most common mistakes to keep in mind: 

  • Write operators incorrectly: Operators must be written exactly, including the correct capitalization. Watch out for operators written in lowercase, with too much space, or that have typos.
  • Forget to add quotation marks: Without the quotes, the system doesn't know that these words should be grouped together, and the query string as a whole won't work as intended.
  • Missing brackets or not closing them: Missing brackets can be an easy mistake to make, especially if you need to use multiple brackets in a query. Without the correct brackets, the system will be confused about what to look for and won't work.

Writing a query in Brandwatch Consumer Research

There are two ways to create a query in Brandwatch Consumer Research. You can choose a brand query template or write a query from scratch. With the brand query template, all you have to do is fill in some brand details and the query is ready to go.

  • Query Editor – Brand Query Template: This provides you with a high-quality brand query template that can be quickly customized with your brand details. It saves time and can give you inspiration for future queries.
  • Query Editor – Blank Query: Clicking on the Blank Query option opens a blank query where you can write your query from scratch with the full list of operators and some query writing tips. It will also highlight any mistakes you make in your search string, such as forgetting brackets.

Pro Tip

In the Query Editor, you can enable AI-powered keyword suggestions. This can help suggest useful keywords to make your search more relevant.

With Brandwatch Consumer Research, users have a variety of options for how to build a good query, depending on their expertise and resources. 

From simple campaign tracking to complex market research, brands can use Consumer Research to answer any type of question they have about their customers, competitors, or markets.

That’s a wrap

For beginners, writing queries can seem daunting at first, especially if you have never worked with Boolean operators. Start by thinking about your research questions. They will be your golden thread for building a good query. 

With this blog, you now have an overview of the basics of query building. Start practicing, and soon you will master the art of query writing.