Data-driven applications have data pouring in continually and it is difficult to gather insights or retrieve analytics on such flowing data.
Appacitive keeps realtime computations for sum, average, min, max and count on your integer and decimal properties for connected data.
There are two kinds of aggregate properties you can have in Appacitive.
1. Relation aggregates
For the purpose of this blog we will run with an example of a restaurant search app.
The restaurant schema has properties like name (string), description (text) and location (geography).
The review schema has properties review (text) and rating (integer between 0 and 5).
The restaurant schema is connected to review schema using a relation called restaurant_review and the user schema is connected to the review schema using a relation called user_review.
So now, users can add reviews for a restaurant and give it a rating based on their experience there.
For the purpose of keeping a count of total number of reviews added for each restaurant, I add a review_count relation aggregate property to the restaurant schema, which will maintain a count of reviews added for that restaurant.
Now whenever a new connection is added for relation restaurant_review, the review_count property for that restaurant will get incremented by one.
A get call on a restaurant has a new property for the count of connections of type restaurant_review.
This way you can add more aggregate properties on a schema for a particular relation. All other such relation aggregate properties will ask you to specify a integer or decimal property in the relation to do computation like sum, min, max and average.
2. Endpoint aggregates
Now lets say you also want the average rating for every restaurant based on the reviews added for the restaurant. I add an endpoint aggregate property average_rating in the restaurant schema for maintaining the average on the rating (integer between 0 and 5) property in the review schema. This value gets updated every time a new connection is created between review and restaurant.
So now the restaurant objects contain a new property for their average rating.
All aggregate properties are prefixed with a '$'. You can perform search queries on aggregate properties by using the prefixed aggregate property name.