elasticsearch吧 关注:1,519贴子:5,327
  • 3回复贴,共1

万能的大牛啊,求仿SQLGroupBy脚本写法

只看楼主收藏回复

类似sql结构中
select sum(a.price * b.count) as total from details b left join info a on b.bid = a.aid
重点在于利用ES的parent-child的关系进行聚合该如何编写脚本,代码片段:
aggs : {
info : {
filter:{},
aggs:{
details :{
children : { type : "details"},
aggs : {
details : {
filter : {},
aggs : {
total: {
sum : {
script : "doc.count * 父.price"//重点是这里
}
}
}
}
}
}
}
}
}


IP属地:天津1楼2020-05-22 19:18回复


    IP属地:天津2楼2020-05-22 19:19
    回复
      你刚才回复我的es sql 我已经写出来了 看了下源码


      IP属地:山西来自iPhone客户端3楼2020-05-22 19:25
      收起回复