索引較多:
index-1_t_order
index-2_t_order
index-32_t_order
根據pay_amount排序,order_no去重,最后分頁。
說明:
1、collapse:去重得到去重后的記錄,配合"from": 0, "size": 1分頁得到結果;(注意:此處查詢返回的total-hits不是去重后的結果數量,而是命中的記錄數,要獲取去重后的記錄數要使用cardinality)
2、cardinality:得到去重統計結果
GET /index-*_t_order/_search { "from": 0, "size": 1, "track_total_hits": true, "query": { "bool": { "filter": [ { "range": { "push_time": { "gte": "2022-02-08", "lte": "2022-02-09", "time_zone": "+08:00" } } }, { "terms": { "org_code.keyword": [ "00T0024", "00T0025" ] } } ] } }, "sort": [ { "pay_amount": { "order": "desc" } } ], "collapse": { "field": "order_no.keyword" }, "aggregations": { "count": { "cardinality": { "field": "order_no.keyword" } } } }
