You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aggregation is an easy way to aggregate your node data in different ways. ElasticSearch provides a couple of different types of
237
+
aggregations. Check `https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html` for more
238
+
info about aggregations. You can use them to get some simple aggregations like min, max or average values for
239
+
your node data. Aggregations also allows you to build a complex filter for e.g. a product search or statistics.
240
+
241
+
**Aggregation methods**
242
+
Right now there are two methods implemented. One generic `aggregation` function that allows you to add any kind of
243
+
aggregation definition and a pre-configured `fieldBasedAggregation`. Both methods can be added to your TS search query.
244
+
You can nest aggregations by providing a parent name.
245
+
246
+
*`aggregation($name, array $aggregationDefinition, $parentPath = NULL)` -- generic method to add a $aggregationDefinition under a path $parentPath with the name $name
247
+
*`fieldBasedAggregation($name, $field, $type = "terms", $parentPath = NULL)` -- adds a simple filed based Aggregation of type $type with name $name under path $parentPath. Used for simple aggregations like sum, avg, min, max or terms
248
+
249
+
250
+
### Examples
251
+
#### Add a average aggregation
252
+
To add an average aggregation you can use the fieldBasedAggregation. This snippet would add an average aggregation for
The first `fieldBasedAggregation` will add a simple terms aggregation (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html)
269
+
with the name colors. So all different colors of your nodetype will be listed here.
270
+
The second `fieldBasedAggregation` will add another sub-aggregation named avgprice below your colors-aggregation.
0 commit comments