Red
(Red)
January 26, 2016, 8:24am
1
"aggs": {
"my_agg": {
"terms": {
"field": "product_id",
"size": 3
}
},
"aggs": {
"my_agg_sum": {
"sum": {
"field": "sku_sell_num",
"missing": 0
}
}
}
},
"size": 10
}
this is my request body, and it is always incorrect.
can anyone give me a hint?
Red
(Red)
January 26, 2016, 11:02am
2
ive solved my problem just now.
here is my request body
"filter": {
"bool": {
"must": [
{
"range": {
"start_time": {
"format": "YYYY-MM-dd",
"lte": "2016-01-26"
}
}
},
{
"range": {
"end_time": {
"format": "YYYY-MM-dd",
"gte": "2016-01-26"
}
}
},
{
"range": {
"amount": {
"gte": 0
}
}
}
]
}
},
"size":0,
"aggregations": {
"spu_group": {
"terms": {
"field": "product_id",
"size": 4,
"order" : {"sum_sku_sell_num": "desc"}
},
"aggregations": {
"sum_sku_sell_num":{
"sum": {
"field": "sku_sell_num"
}
},
"max_sku_sell_num_sku":{
"top_hits": {
"sort":[
{
"sku_sell_num": {
"order": "desc",
"missing": 0
}
}
],
"_source": {
"include": [
"sku_id"
]
},
"from": 0,
"size": 1
}
}
}
}
}