在elasticsearch中,我有一个数据表,其中有字段customer_id和event_date,我想按每个月计数,但不是所有数据,我想过滤掉重复的customer_id,除了第一条记录(具有最小事件日期)之前应用日期历史记录,请帮助我过滤查询。
这是我的样本数据:
"hits": [
{
"_index": "log_report",
"_id": "5",
"_score": 1.0,
"_source": {
"created_at": "2021-08-23T02:36:10+00:00",
"created_by": -1,
"updated_at": "2021-08-23T02:36:10+00:00",
"updated_by": -1,
"is_deleted": false,
"account_id": 509,
"customer_id": 1961105,
"opened_at": "2021-08-23T02:36:10+00:00",
"id": 5
}
},
{
"_index": "log_report",
"_id": "11",
"_score": 1.0,
"_source": {
"created_at": "2021-08-23T02:37:26+00:00",
"created_by": -1,
"updated_at": "2021-08-23T02:37:26+00:00",
"updated_by": -1,
"is_deleted": false,
"account_id": 509,
"customer_id": 1961105,
"opened_at": "2021-08-23T02:37:26+00:00",
"id": 11
}
},
...
]
我有字段customer_id
和created_at
,customer_id值可以在多个记录中具有相同值,但我只想处理每个customer_id第一个记录
1条答案
按热度按时间9wbgstp71#
试试这个