The BATCH function divides a scalar field’s values into specific ranges. Each range becomes a grouping field value, and objects contribute to the metric computation for the ranges for which it has values. The
BATCH function’s first value must be a scalar field. The remaining values must be literal values compatible with the field’s type (text, timestamp, or numeric), and they must be given in ascending order. Example:
This query counts messages grouped by specific ranges of the Size field from the shard named
2014‑06‑01. The ranges are divided at the given literal values:
100,
1000,
10000, and
100000. The lowest value implicitly creates an extra
less than group; the highest value is open-ended and creates a
greater than or equal to group. The query in the example above defines the following 5 groups:
As shown above in the <100 group, if no selected object has a value that falls into one of the specified groups, that group is still returned: the group’s metric is 0 for the
COUNT function and empty for all other metric functions. As with all grouped aggregate queries, a
summary value is returned that applies the metric function across all groups.