作者:zhanglj-qiucm | 来源:互联网 | 2023-05-30 13:54
1、创建indexPUTmy_index{settings:{number_of_shards:1,number_of_replicas:1},mappings:{
1、创建index
PUT /my_index
{
"settings":{
"number_of_shards":1,
"number_of_replicas":1
},
"mappings":{
"properties":{
"trans_count":{"type":"long"},
"trans_amount":{"type":"long"},
"trans_date":{"type":"long"},
"team_field":{"type":"keyword"}
}
}
}
2、新增记录
POST my_index/_doc
{
"trans_count": 123,
"trans_amount": 123,
"trans_date": 20200202,
"team_field": "1"
}
3、修改记录
POST my_index1/_doc/id/_update
{
"doc": {
"cust_count": 14,
"ret_code":"00000000"
}
}
4、查询
GET my_index3/_search
{
"query": {
"match_all": {}
},
"aggs": {
"group_by_place": {
"terms": {"field": "success_name"}, //先根据success_name分组
"aggs" : {
"sum_price" : {
"sum": { "field": "trans_count" } //每一组再根据trans_count求和
}
}
}
}
}