要不要再翻翻文档呢?

elastic resthighlevelclient如何实现这一请求

Elasticsearch | 作者 SpiritZpr | 发布于2020年04月01日 | 阅读数:1875

resthighlevelclient实现聚合查询后求sum值
实际sql个人理解就是:
select cardNbr,month,sum(consumerPrice) from table group by cardNbr,month where cardNbr = "377650103401102" and month = "03"
POST /flinktest/_search?size=0
{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"cardNbr": {
"query": "377650103401102",
"slop": 0,
"zero_terms_query": "NONE",
"boost": 1
}
}
},
{
"match_phrase": {
"monthNbr": {
"query": "03",
"slop": 0,
"zero_terms_query": "NONE",
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"aggregations": {
"consumerPrice": {
"sum": {
"field": "consumerPrice"
}
},
"returnPrice": {
"sum": {
"field": "returnPrice"
}
},
"repayPrice": {
"sum": {
"field": "repayPrice"
}
}
}
}
已邀请:

要回复问题请先登录注册