我有这个映射:
...
[products_categories_id] => Array
(
[type] => object
)
...
使用这组数据:
"products_categories_id": [
{
"id": 164,
"value": "Flight Case e Accessori - Supporti per Chitarra e Basso",
"singular_value": "Flight Case e Accessorio - Supporto per Chitarra e Basso"
},
{
"id": 443,
"value": "Chitarre - Supporti per Chitarra",
"singular_value": "Chitarra - Supporto per Chitarra"
},
{
"id": 450,
"value": "Bassi - Accessori per Basso - Supporti per Basso",
"singular_value": "Basso - Accessorio per Basso - Supporto per Basso"
}
]
这是产品的总和:
"hits": {
"total": 67,
当我汇总我的搜索结果时,聚合次数不正确,因为引擎会返回我的类别编号以及在我的finded类别中对象内的类别数量(443)
这是聚合部分:
"aggs": {
"filter_category": {
"terms": {
"script": "doc['products_categories_id.id'].value",
"size": "20",
"order": {
"max_score": "desc"
}
},
"aggs": {
"max_score": {
"max": {
"script": "_score"
}
}
}
}
}
这是查询的结果:
"aggregations": {
"filter_category": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "443",
"doc_count": 24,
"max_score": {
"value": 62.1923942565918
}
},
{
"key": "164",
"doc_count": 40,
"max_score": {
"value": 50.844512939453125
}
},
{
"key": "65",
"doc_count": 2,
"max_score": {
"value": 41.21534729003906
}
},
{
"key": "153",
"doc_count": 1,
"max_score": {
"value": 30.362688064575195
}
}
]
}
}
我期待这样的结果:
{
"key": "443",
"doc_count": 67,
"max_score": {
"value": 62.1923942565918
}
有人可以帮助我,谢谢:)