I need to add products by category
The body of the products is:
p1 = [ ... "categories": ["1","2","3","4"] ];
p2 = [ ... "categories": ["2","1","9","10"] ];
p3 = [ ... "categories": ["2","22","13","14"] ];
p4 = [ ... "categories": ["14","52","36","41"] ];
The aggregation query corresponds to:
{
"aggregations": {
"categories.raw": {
"terms": {
"field": "categories.raw"
}
}
}
,"from" : 0, "size" : 0
}
However, buckets do not work with all product categories.
I need to count for all categories, for example:
categoria1 = 2
categoria2 = 3
...
Can anyone help?