类似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"//重点是这里
}
}
}
}
}
}
}
}
}
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"//重点是这里
}
}
}
}
}
}
}
}
}