记一次嵌套sum聚合的排序DSL
场景:根据nested_gs2Entity.kw_entity聚合,filter对聚合结果过滤类型是产品,实体是需要关心的产品列表,在结果中sum互动量long_interaction,和花费long_paidPrice
然后在结果中根据sum的结果排序
{ "aggregations": { "agg_entity_a": { "aggregations": { "filter_product_agg": { "aggregations": { "agg_entity_b": { "aggregations": { "reverse_nested_agg": { "aggregations": { "sum_long_interaction": { "sum": { "field": "long_interaction" } }, "sum_long_paidPrice": { "sum": { "field": "long_paidPrice" } } }, "reverse_nested": {} }, "bucket_agg_a": { "bucket_sort": { "sort": [ { "reverse_nested_agg>sum_long_interaction": "desc" } ] } } }, "terms": { "field": "nested_gs2Entity.kw_entity", "size": 10 } } }, "filter": { "bool": { "must": [ { "term": { "nested_gs2Entity.kw_type": { "value": "product" } } }, { "terms": { "nested_gs2Entity.kw_entity": [ "欧莱雅男士劲能焕亮青春精华露", "欧莱雅金致臻颜花蜜奢养精华蜜", "欧莱雅金致臻颜牡丹奢养粉妍精华液", "欧莱雅青春密码酵素精华肌底液" ] } } ] } } } }, "nested": { "path": "nested_gs2Entity" } } }