Spider Aggregate Queries : Grouping Parameter : Composite Grouping

Composite Grouping
Doradus Spider supports a special grouping feature called composite grouping. It is meaningful only for aggregate queries with 2 or more grouping levels. It causes the metric function(s) to be computed for parent (non-leaf) groups in addition to leaf-most groups. The extra computations are returned as composite results within the corresponding parent groups.
Composite grouping is requested by using a special grouping parameter instead of the normal grouping parameter. For example, consider the following URI aggregate query:
GET /Msgs/Message/_aggregate?m=COUNT(*)&f=TRUNCATE(SendDate,DAY),Tags
Composite grouping can be requested for this 2-level query by using the &cf parameter instead of &f:
GET /Msgs/Message/_aggregate?m=COUNT(*)&cf=TRUNCATE(SendDate,DAY),Tags
A typical result for this 2-level aggregate query in XML is shown below:
<results>
<aggregate metric="COUNT(*)" group="TRUNCATE(SendDate,DAY),Tags"/>
<totalobjects>6032</totalobjects>
<summary>6032</summary>
<groups>
<group>
<summary>4753</summary>
<field name="SendDate">2010-07-17 00:00:00</field>
<groups>
<group>
<metric>1</metric>
<field name="Tags">(null)</field>
</group>
<group>
<metric>4752</metric>
<field name="Tags">AfterHours</field>
</group>
<group>
<metric>1524</metric>
<field name="Tags">Customer</field>
</group>
</groups>
</group>
<group>
<summary>1279</summary>
<field name="SendDate">2010-07-18 00:00:00</field>
<groups>
<group>
<metric>1279</metric>
<field name="Tags">AfterHours</field>
</group>
<group>
<metric>701</metric>
<field name="Tags">Customer</field>
</group>
</groups>
</group>
<group composite="true">
<field name="SendDate">*</field>
<groups>
<group>
<metric>1</metric>
<field name="Tags">(null)</field>
</group>
<group>
<metric>6031</metric>
<field name="Tags">AfterHours</field>
</group>
<group>
<metric>2225</metric>
<field name="Tags">Customer</field>
</group>
</groups>
</group>
</groups>
</results>
The same response in JSON is shown below:
{"results": {
"aggregate": {"metric": "COUNT(*)", "group": "TRUNCATE(SendDate,DAY),Tags"},
"totalobjects": "6032",
"summary": "6032",
"groups": [
{"group": {
"summary": "4753",
"field": {"SendDate": "2010-07-17 00:00:00"},
"groups": [
{"group": {
"metric": "1",
"field": {"Tags": "(null)"}
}},
{"group": {
"metric": "4752",
"field": {"Tags": "AfterHours"}
}},
{"group": {
"metric": "1524",
"field": {"Tags": "Customer"}
}}
]
}},
{"group": {
"summary": "1279",
"field": {"SendDate": "2010-07-18 00:00:00"},
"groups": [
{"group": {
"metric": "1279",
"field": {"Tags": "AfterHours"}
}},
{"group": {
"metric": "701",
"field": {"Tags": "Customer"}
}}
]
}},
{"group": {
"composite": "true",
"field": {"SendDate": "*"},
"groups": [
{"group": {
"metric": "1",
"field": {"Tags": "(null)"}
}},
{"group": {
"metric": "6031",
"field": {"Tags": "AfterHours"}
}},
{"group": {
"metric": "2225",
"field": {"Tags":"Customer"}
}}
]
}}
]
}}
As shown, composite grouping produces an extra group for non-leaf grouping levels. This group is marked with a composite property of true, and the value for its field element is “*”. Within the composite group, lower-level metric groups are provided for each lower-level grouping field value, however, these lower-level metrics are computed across all objects at the composite grouping level. In the example above, the composite group computes the metric function (COUNT(*)) for all second-level groups (Tags) across all first-level group values (SendDate).
Composite grouping is only meaningful for multi-level grouping.