Aggregate
EYWA supports search result aggregation with most common SQL aggregate functions. These are
- AVG - calcualtes the average of a set of values
- COUNT - counts rows
- MIN - gets the minimum value in a set of values
- MAX - gets the maximum value in a set of values
- SUM - calculates sum of values
#
AggregateObjectFor each entity that contains attributes that can be aggregated EYWA will generate AggregateObject. Generated object will have camelCased name that starts with entity name and ends with suffix Aggregate.
Generated objects are consited of only attributes that can be aggregated with one additional field and that is count. Since every entity can be counted.
To allow focused aggregate queries same rules as in Search section apply here.
Lets aggregate some dataset entities.
#
Query{ aggregateDatasetEntity { count attributes (_where:{name:{_ilike:"%ac%"}}) { count } height { min max avg } width (_lt:200) { min max avg } }}
#
Response{ "data": { "aggregateDatasetEntity": { "count": 6, "attributes": { "count": 3 }, "height": { "min": 85.9302978515625, "max": 152.7505645751953, "avg": 115.38987731933594 }, "width": { "min": 123.37268829345703, "max": 178.97463989257812, "avg": 153.79167302449545 } } }}
By aggregating Dataset Entity with above query, we receive response that states that there are 6 entities that contain
attributes with name like "ac
" and for attributes height and width response returns min,max and avg values.