Hello,
Let's say I have a date histogram over a terms aggregation :
{
"size": 0,
"aggs": {
"my_date_histo": {
"date_histogram": {
"field": "date",
"interval": "month"
},
"aggs": {
"categories": {
"terms": {
"field": "category"
}
}
}
}
}
}
With returns something like:
"aggregations": {
"my_date_histo": {
"buckets": [
{
"key_as_string": "2018-02-01T00:00:00.000Z",
"categories": {
"buckets": [
{
"key": "A",
"doc_count": 10
},
{
"key": "B",
"doc_count": 5
},
{
"key": "C",
"doc_count": 0
}
],
}
},
{
"key_as_string": "2018-03-01T00:00:00.000Z",
"categories": {
"buckets": [
{
"key": "A",
"doc_count": 10
},
{
"key": "B",
"doc_count": 4
},
{
"key": "C",
"doc_count": 3
}
],
}
}
],
}
I would like to know the top terms variations (positive and negation) between the two dates, something like:
"categories": {
"buckets": [
{
"key": "C",
"doc_count": 3
},
{
"key": "A",
"doc_count": 0
},
{
"key": "B",
"doc_count": -1
}
]
}
Any idea of how to do such aggregation?