身安不如心安,屋宽不如心宽 。

buckets_path 如何取top_hit的值

Elasticsearch | 作者 zhyusElastic | 发布于2019年02月15日 | 阅读数:3563

"aggs": {
    "top": {
        "top_hits": {
            "sort": [{
                "@timestamp": {
                    "order": "desc"
                }
            }],
            "size": 1,
            "_source": {
                "includes": ["jsonData.hisNum", "jsonData.depNum"]
            }
        }
    },
    "buttom": {
        "top_hits": {
            "size": 1,
            "sort": [{
                "@timestamp": {
                    "order": "asc"
                }
            }],
            "_source": {
                "includes": ["jsonData.hisNum", "jsonData.depNum"]
            }
        }
    },
    "sc": {
        "bucket_script": {
            "buckets_path": {
                "a1": "top.jsonData.hisNum"
            },
            "script": "return a1"
        }
    }
}
 
我在sc中取buttom 和 top中的4个值参与计算,可是我取不出hit_top聚合中_source里面的数值
已邀请:

axxc

赞同来自:

同问,解决了吗

cxycxy

赞同来自:

可以使用collapse实现类似功能。

要回复问题请先登录注册