Aggregations create the ability to get summarized views and statistics about the data. It allows you build data drill downs along the structured part of your items as well as visualizations over time or other data dimensions.
Specification
Request format
...
Code Block |
---|
|
"language": {
"fields": "language"
} |
or even shorter as the label can also serve as the field:
Code Block |
---|
|
"language": {} |
over multiples fields:
Code Block |
---|
|
"multi": {
"fields": ["provider", "language"]
} |
setting the number of results you would like to get back
Code Block |
---|
|
"language": {
"size": 3
} |
Adding another dimension to the aggregation: e.g. show the number of results for each language and provider
Code Block |
---|
|
"language": {
"aggregate": {"fields": "provider"}
} |
Aggregations using a different method:
Code Block |
---|
|
"$item_created_at": {
"method": "histogram"
} |
Aggregating the languages of items over time:
Code Block |
---|
|
"$item_created_at": {
"method": "histogram",
"aggregation": {
"fields": ["language"],
}
} |