Create an Advanced Topic Query

Updated 

With millions of conversations happening all over the web each day, it can be a long and tedious task trying to get more relevant mentions and tighten the scope of your query, but with the help of Advanced Topic Query, it can be at your fingertips.

In Social Listening, you have the option to create an advanced query that is not limited to ANY, ALL, or NONE formatting of query building. Advanced query builder can be used to form complex text queries which are not possible with a normal query builder.

What is an Advanced Topic Query?

  • Advanced topic query helps you to fetch relevant conversations by using advanced operators, nested parentheses, operators within operators, and much more. 

  • By using advanced query you can pinpoint relevant information which is not possible with basic topic query.

 It gives you the power to find the needle in a haystack.

Basic Topic Query v/s Advanced Topic Query

  • With more operators to use you can fetch conversations by language, geography, social media channel, volume, author, #listening, @account monitoring, user segment, and much more, it can give you access to more actionable insights.

  • In Basic Query, you can only use boolean operators like OR/ NOT/ AND/ along with NEAR. On the other hand, in Advanced Topic Query, it gives you access to use OR with/ inside AND, NOT (nested and within operator use cases), advanced operators, exact match operators etc.

Let's see the use cases where advanced query will help in getting more insightful mentions –

  • Use case #1: To search "pepsi" OR "drink" along with "cups".

    Basic Query

    Advancd Query

  • Use case #2: To get mentions of "pepsi" along with "coke" or "sprite" but not "miranda" with people having "follower count" between 100 to 1000 on "twitter".

    Basic Query

    Advanced Query

    Not feasible in the basic Topic query

This is where we need the advanced Topic query.​

How to create an advanced Topic query?

  1. Click the New Tab icon. Under Sprinklr Insights, Click Topics within Listening.  

  2. On the Topics window, click Add Topic in the top right corner. Fill in the required fields and click Create.

    • In the Setup Query tab of Create New Topic window, select Advanced Query in the query section.

    • Type your query in the Advanced Query field with the required operators and syntax.

    • Click Save.

Tip: While using Instagram as a Listening Source, be sure that your query keywords include hashtags.

Which operators to use for building Topic queries?

Operators for Topic queries

  1. In creation of advanced queries along with boolean operators OR/ AND/ NOT/ etc, Sprinklr also supports operator types –

    • Search Operators

    • Exact Match Operators

    • Operators for Getting Post Replies/Comments​

  2. Sprinklr provides its user edge by giving them power to use Keywords List inside advanced query along with Operators mentioned.

Create query using Topic query operators

Following are some most used operator examples and their results –

Operator

Example

Result

hello

Search for the term "hello"

social sprinklr

Search for the phrases "social" and "sprinklr"

Note: Using this will show preview but topic can not be saved as it will show error, Use "Social Sprinklr" or (Social AND/OR/ NOT/ NEAR Sprinklr) to eliminate error.

AND

social AND sprinklr

Search for "social" and "sprinklr" anywhere within the complete message, irrespective of keywords between them

OR

social OR sprinklr

Search for "social" or "sprinklr"

NOT

"social media" NOT "facebook"

Search for results that contain "social media" but not "facebook"

~

"social media"~10

Search for "social" and "media" within 10 words of each other

NEAR

social NEAR/10 media

Search for "social" and "media" within 10 words of each other

Note: This operator can be used with keyword lists.

ONEAR

social ONEAR/10 media

Search for "social" and "media" within 10 words of each other in an ordered way

Note: This operator searches social ahead of media.

title

title: ("social media")

Search for social media in the title of the message

Note: It is mostly used for News, blogs, reviews and other sites.

author

author: "social_media"

Fetches all the mentions from author name: social_media

Some other operators which are supported by Sprinklr are –

  • Proximity: It is used to define proximity or distance between 2 keywords only, whereas, NEAR can be used to define proximity between two keywords as well as keyword lists.

  • Onear (Ordered Near): It sets the order in which the keywords will appear. For example, Keyword-List1 ONEAR/10 Keyword-List2 will ensure keywords from Keyword-List1 appear first and then Keyword-List2 keywords will follow within space of maximum 10.

Step by step guide to make advanced Topic query

Use case

  1. To write query fetching mentions of ZARA – 

    (# listening is used for instagram listening)

  2. Getting mention along with clothing or fashion related terms only –

  3. Removing profanity from mention (use case specific) –

  4. Removing profanity from mention (use case specific) –

    As social media has lots of profane words you can also remove it by making a keyword list and negating it from query –

  5. Filtering Mentions in English –

  6. Applying source input as Twitter –

  7. Getting mentions of those users which have followers between 100 to 1000 – 

Advanced example showcasing use of Topic query operators and keyword list –

Best practices while using Advanced Query

Use of Parentheses 

​Parentheses are not necessary to enclose a search query but can be useful while grouping operations together for more complex queries.

For example, if you want to return results that mention Samsung or Apple phones, and also want to query content that mentions phones along with either Apple or Samsung, you could use parentheses around Apple and Samsung to group three keywords together, as shown below –

phone AND (Apple OR Samsung)

Use of parentheses within brackets, is further explained below with an example –

[(internet of things ~3) OR iot OR internetofthings) AND (robots OR robot OR #robot)] NOT [things]

Tip: You can also use parentheses within brackets to set off additional operations within the Advanced Query field. The end result should look similar to the result summary of a basic query, built using multiple operations within a single section.


As a part of the rest of the query, this will perform the following operations –

  1. Search for posts that contain the phrase "internet of things" or "#internetofthings"

  2. From within those results, keep any result that also says "robots" or "robot" or "#robot" within three words (a proximity search) of either "internet of things" or "iot" or "internetofthings".

  3. Discard any results that just have the phrase "things" within.

    1. Parentheses nested within brackets intend to set off different operations as isolated processes. In the previous example, if you build an Advanced Query that states [(internet of things OR iot OR internet of things) AND (robots OR robot OR #robot)] your query will return results that contain ANY of the first three terms and the second three terms.

    2. However, if you build an Advanced Query that states [internet of things OR iot OR internet of things AND robots OR robot OR #robot], your query will return any result that contains the phrase "internet of things" or the word "iot" or the word "robot" or the hashtag #robot or specifically the phrase "internet of things" within the same message as the word "robots". 

Note:

You cannot use a "NOT" statement with an "OR" statement.


Example:
( social OR NOT media ) ❌
( social NOT media )  ✅

(( social OR ( media NOT facebook )) ✅

Why? 

Query should not contain "NOT" terms in "OR" with other terms, "NOT" clauses should be used in "AND" with other terms, using "NOT" in "OR" will bring too much data.

Use of Quotation marks

Quotation marks can be used for phrases in which you are looking for an exact match of those particular words in a specific order. Using parentheses or quotation marks for single-word queries is not mandatory.

Use straight quotation marks ( " " ) for outlining phrases within it. The use of curved quotation marks (“ ”) will not produce your desired results.

Parentheses are generally used to group keywords or phrases joined by one or more operators together, but with other keywords involved, parentheses and quotations would act differently. For example –

Version 1: "Phil Schiller" AND "Apple Marketing" will return results for content with the exact phrase Phil Schiller (or phil schiller) and the exact phrase Apple Marketing (or apple marketing).

Note: Here exact does not mean case sensitive as in the case of exactMessage Operator.

Example: exactMessage: ("Phil Schiller" AND "Apple Marketing"), which will fetch results for phrase Phil Schiller (not phil schiller) and the exact phrase Apple Marketing (not apple marketing).


Version 2: "Phil Schiller" AND (Apple OR Marketing) will return results for content with the phrase "Phil Schiller" (together)  and at least one of the words, Apple or Marketing.

Handling for Broad & Ambiguous Keywords

It is very important to not use/reduce use of broad keywords in advanced queries. Broader keywords will fetch mentions that are unrelated to topic of interest, and eventually hinder dashboard/insights

  • For all keywords used in an advanced topic query, ensure they are directly related to the topic of interest. 

  • In case keywords are broad but relevant to topic, they should be tied to some relevant keywords related to that topic, by using NEAR Operators

Example: Robot is an important keyword for Robot Company. However just using this keyword will fetch irrelevant keywords as it’s a broad keyword used for other entities as well (Robot Street, etc). 

  • Instead of using just Robot keyword, we should use: Robot NEAR/4 (Technology OR “machine” OR # tech OR IOT OR  “Internet of things” ….)

  • Note how keywords related to Robot are used with NEAR Operator. Related keywords could be related entities, industry keywords, parent company, country keywords, etc.

Frequently asked questions

Topic will not be saved if you don’t use quotations around phrases as it will show error, Use “apple music” or (apple AND/OR/ NOT/ NEAR music) to eliminate error.

These kinds of mentions are hard to remove as they are many and unique for each post but we have got it covered.

To remove these kind of spam or irrelevant to topic made posts with many #’s or @’s follow these steps –

Step 1: Make your query granular and relevant by using advanced topic query and check it many times to remove any broad level mentions.


Step 2: Analyze mentions by seeing relevant posts or use your own intuition as to how many #’s or @’s are relevant for the mentions you want to fetch example if you want not more than 7 (#’s or @’s).

Step 3: to remove mentions/ posts with more than 7 (#’s or @’s) use proximity operator with set number of #’s or @’s : (ZARA AND NOT (“#######”~7 OR “@@@@@@@”~7))

Yes, exact match operators, advanced operators (also called search operators) and parent operators can be used in advanced query.

The preview shows the past 24 hrs data present in our repository. The topic will show data from the start of fetching on a going forward basis, to get previous data backfilling is required.

Follow steps given -

Step 1: Make your query granular and relevant by using advanced topic query and check it many times to remove any broad level mentions.

Step 2: You can use exact match operators like exactMessage: @tom (case sensitive). Or else use AND NOT (@tom_ OR @tom-)

Caution: The AND NOT method will help in removing mentions like @tom_fan, @tom_dude, @Tom_real, @tom-original but will not remove mentions like @tom123. This hack can help in getting better mentions.

Yes, it will fetch all these mentions as the tokenized word matches the string "tom" in these cases.