After a Topic has been created as described in my previous posts, then a way to aggregate the data would be needed next.  In this next set of posts I will discuss how that can be done. 

First it should be helpful to understand that each new Aggregate created will have a Topic as a parent. Each Aggregate can have only one parent Topic and they are otherwise unique individual entities. Other than its parent the main properties of an Aggregate are its method and the time period it will use to aggregate the data. It is not possible to change these properties after an Aggregate has been created and in fact the only property that can be changed after it has been created is its name. 

When a Topic gets new data it will send a complete copy of this data to each of its Aggregates. Each Aggregate will then aggregate this data  according to the configured options then store the aggregated data for later use.

Creating a new Aggregate is very similar to how creating a Topic was discussed earlier. Below is the JSON configuration structure with some brief descriptions for a Topic.

Aggregate {
aggregateMethod (string): The aggregation method to be applied to the Topic data at each period duration. ,
period (number): The duration of time specified in seconds to aggregate the Topic data. ,
beginDate (string, optional): The starting time and date to use as the begining aggregated Topic data. ,
aggregateName (string, optional): A name to associate with this method of aggregated Topic data.

There are two required values (aggregateMethod and period) that will need to be set in order to create a new Aggregate. If the beginDate is not set then the brokerCreate date from the Topic to which this Aggreagte belongs will be used. The aggregateName is used to store a more human readable way to identify this Aggregate and can also be be used in a search criteria to find available Aggregates. 

Here is an example using curl that will create a new Aggregate.

curl -X POST -d '{ \ 
"aggregateName": "Close", \
"aggregateMethod": "Close", \
"period": 3600 \
}' ''

The Topic that this Aggregate will belong to is in the URI path used to create it. This is why it is not necessary to declare in the configuration JSON.

The response from creating the example Aggregate is below.

"aggregateMethod": "Close",
"period": 3600,
"beginDate": "2014-05-20T21:50:32.000Z",
"aggregateName": "Close",
"id": "588be68d58a8a828986379b4",
"created": "2017-01-28T00:32:13.674Z",
"modified": "2017-01-28T00:32:13.674Z"

In a future I will discuss how actually get the data aggregated.