Elasticsearch aggregations are missing categories in buckets

2

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?

    
asked by anonymous 29.11.2017 / 11:00

0 answers