Computing Metrics

Use the optional select clause to compute metrics for your aggregated groups. Use these rules when constructing the select statement:

  • Separate metric statements or distinct() function calls by commas.
  • If you leave this control empty, IQL returns a count of all documents in each group.

The following metrics are available:

Metric Syntax Examples
Simple metric name metric revenue
Arithmetic expression of two metrics (+, -, *, %) executed on each document.
The divide operation (/) is executed in aggregate after everything else is computed. If you require a per document divide, use a reverse slash (\\).
metric+metric
metric\-metric
metric\*metric
metric%metric
metric/metric
clicks/impressions
revenue-expenses
Function calls:
  • count() returns the number of documents in the group. Each document has an implicit value of 1.
  • exp(...) applies the Math.exp() function to the specified metric. The scalingFactor defaults to 1.
  • floatscale(...) converts floating point numbers stored in strings to scaled integers.
count()
exp(metric,scalingFactor)
floatscale(field,scale,offset)
count()
floatscale(float,10,5) multiplies each value in float by 10 and then adds 5 to each product.
distinct() distinct(field) distinct(country) returns a count of distinct terms for the country field in each grouping.
percentile() percentile(field, N) percentile(totaltime, 50) returns the median value of totaltime.
Return a count of all of the documents that match the expression. Adding /count() returns the average. You must include "" around a string term. field="term"
field=integer
metric!=integer
metric\<integer
metric<=integer
metric>integer
metric>=integer
lucene("luceneQueryStr")
country="us" returns the number of documents with a value of us for country.

clicks=1 returns the number of documents with a value of 1 for clicks.

revenue>500
group="mobile"/count()