三张表:客户表cust,借据表card,抵押表append。客户表与借据表一对多的关系,借据表与第押镖也是一对多的关系
mapping是这样的:
"properties"{
"cust其它字段",{},
"customer_no":{},
cards:{
"type":"nested",
"properties":{
"card其它字段"{},
"owe_amt":{"type":"scaled_float","scaling_factor":100},
"contract_no":{"type":"keyword"},
" appends:"{
"append其它字段":{},
"area_code":{"type":"keyword"}
}
}
}
}
要实现的sql:
select append.area_code,count(distinct cust.customer_no),count(distinct card.contract_no),sum(card.owe_amt) from cust,card,append where cust.customer_no=card.customer_no and card.contract_no=append.contract_no group by append.aread_code
用es的curl怎么打到这个sql分组统计的效果了,搞了很久没搞出来
mapping是这样的:
"properties"{
"cust其它字段",{},
"customer_no":{},
cards:{
"type":"nested",
"properties":{
"card其它字段"{},
"owe_amt":{"type":"scaled_float","scaling_factor":100},
"contract_no":{"type":"keyword"},
" appends:"{
"append其它字段":{},
"area_code":{"type":"keyword"}
}
}
}
}
要实现的sql:
select append.area_code,count(distinct cust.customer_no),count(distinct card.contract_no),sum(card.owe_amt) from cust,card,append where cust.customer_no=card.customer_no and card.contract_no=append.contract_no group by append.aread_code
用es的curl怎么打到这个sql分组统计的效果了,搞了很久没搞出来
0 个回复