Filtering the Query

Use the optional where filter to limit the query to only those documents that match the criteria you specify. Available fields are specific to the dataset you selected in from.

Use these rules when constructing the where statement:

  • Join separate filters with the default and optional AND operator or a space. For example, the following two where statements are identical:

    • country=us and language=en
    • country=us language=en
  • You cannot join separate filters with the OR operator.
  • To negate a filter, precede the definition with - (minus sign).
  • If you leave this control empty, IQL considers all documents.

The following filters are available:

Filter Syntax Examples
Field/term pairs field=term
country=”great britain”
location:”“returns the queries with an empty value for the string field
Regular expressions
IQL uses Java 7 Pattern syntax
field=~regex query=~".online marketing." returns the top queries that contain the substring online marketing.
Metric/integer pairs metric=integer
IN construction for including more than one term field in (term,term)
field in (“term”,term)
field not in (term,term)
country in (greatbritain,france)
country in ("great britain",france)
country not in (canada,us,germany)
To construct the following two filters, you must use the lucene() function:
A logical OR of conditions on different fields.
Filter by a range of strings like field:[a TO b]
lucene(“luceneQueryStr”) lucene("(-resultA:0) OR (-resultB:0)") returns the number of documents in the dataset that result in at least one resultA or one resultB.
The sample() function allows you to retain a portion of the documents. The sampling denominator is 100 if you don’t specify a value.
By default, rerunning the query retrieves a different set of documents. Provide a consistent value for the randomSeed parameter to retrieve the same documents when you rerun the query.
sample(field, samplingRatioNumerator, [samplingRatioDenominator=100])
sample(field, samplingRatioNumerator, [samplingRatioDenominator=100], [randomSeed])
sample(accountid, 1) returns 1% of account IDs.
sample(accountid, 1, 1000) returns .1% of account IDs.