Advanced Query Builder

Updated 

​Within Listening, you have the option to create an advanced query which 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 normal query builder.​

To create Advance Query

  1. Go to the Insights icon from the left navigation pane. Now, go to the Topics window and click Add New Topic in the top right corner.


  2. Now, go to Advance Query tab under the Setup Query section. Type your query in the ​​Advanced Query​​ field with the required ​​operators​​ and ​​syntax​​. For example, ​​you can type in search options using “OR” statements and parentheses. ​ Click Save Topic after entering the Advance query.


  3. You can view Conditional Operators for Advance Query as well by clicking the Conditional Operator option at the top of Enter Query.

  4. The list of Advance Query Operators will appear on the right.

  5. You can search for the specific operator in the search bar.

​Operators for Topic Queries​

​ Following are some operator examples and their results:​


​Operator​

​Example​

​Find Messages​

​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".​

​NEAR​

​"social media"~10​

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

​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​ ​

​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. For more information, see ​​Apply Proximity Settings in Keywords​​.​

  • ​Onear​​ (Ordered Near) - It sets the order in which the keywords will appear. For example: Keyword-List1 ONEAR Keyword-List2 will ensure keywords from Keyword-List1 appear first and then Keyword-List2 keywords will follow.​

Syntax for Topic ​ ​Queries

Use of Parenthesis: ​

​ ​

​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 parenthesis 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.​​ ​

  4. ​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.​

  5. ​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 within an “OR” statement.​