elasticsearch:是否可以订购聚合?

elasticsearch: is it possible to order aggregations?

我可以为每个聚合添加权重以确保它们 return 以特定顺序排列,例如:category, manufacturer, color 而不是如下所示的顺序:

{
    "aggs": {
        "category": { "terms": { "field": "category" } },
        "manufacturer": { "terms": { "field": "manufacturer" } },
        "color": { "terms": { "field": "color" } }
    }
}

// results

"color": {
    "buckets": [ ... ]
}
"category": {
    "buckets": [ ... ]
}
"manufacturer": {
    "buckets": [ ... ]
}

如果您查看文档 here。 ,它揭示了一些关于如何根据聚合对结果进行排序的见解。

Can I add weight to each aggregation to make sure that they return in certain order, for example: category, manufacturer, color instead of in the order shown below

响应是 JSON 并且 JSON/JavaScript 对象键顺序未定义。

来源:http://www.json.org/

An object is an unordered set of name/value pairs.