針對日銷量索引,需要分析品牌、品類等日銷量趨勢,以及近7天,近30天等銷量靠前的品牌、品類等。涉及到 nested 聚合,以及聚合排序。
指定日期範圍**趨勢,銷量趨勢查詢排序
//品類近7天銷量
post /goods_sku_sales2_v20200109/_search
},"aggs":
},"aggs": ,
"aggs": }},
"aggs": }}
}}}}
}}}
//品牌日銷量趨勢
post /goods_sku_sales2_v20200615/_search
},"aggs": ,
"aggs": }},
"aggs": ,
"aggs": }}
}}}}
}}}
get /goods_sku_sales2_v20200305/_search?pretty}}
]}
},"inner_hits":
},"size": 10}}
},}]}
}}
}},
}},}}
],"properties": ,
"declareingredientnames": ,
"goodsname":
},"analyzer": "ik_max_word",
"search_analyzer": "ik_smart_synonym",
"fielddata": true
},"goodspk": ,
"salesinfo": ,
"sales": ,
"salesvolume": }},
"shoppk": ,
"skupk": ,
"standardbrandname": ,
"standardcategorynames": ,
"standardcategoryparentname": ,
"standardconceptnames": ,
"standardefficacynames": ,
"standardefficacyparentnames": ,
"standardgoodsname":
},"analyzer": "ik_max_word",
"search_analyzer": "ik_smart_synonym",
"fielddata": true
},"standardingredientnames": ,
"tagnames": }}
}}
,
"hits": ,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
,,,,
],"goodsname": "iope天才水青春煥妍精華液補水保濕滋潤***官方** 非亦博",
"skupk": "01_534144856955_3917259493034"}}
]}}
elasticsearch 【聚合排序參考】
elasticsearch 【nested聚合參考】
ES中使用nested型別的內嵌物件
put articles name 這樣articles就有了payment這個nested型別的字段,payment裡面的物件有amount和name,表示金額和姓名。產生如下資料,表示jack給文章1讚賞了29元,ross給文章1讚賞30元,ross給文章2讚賞31元。post articles...
ES聚合查詢例項
disable coord false adjust pure negative true boost 1 explain false,aggregations view code disable coord false adjust pure negative true boost 1 expla...
ES 學習8 聚合1
參考資料 特定概念 桶 buckets 滿足特定條件的文件的集合 指標 metrics 對桶內的文件進行統計計算 select count color from table group by color count color 相當於指標。group by color相當於桶。聚合例子 curl x...