【发布时间】:2017-10-23 21:12:45
【问题描述】:
我想获取一个人在 5 月份在一个城镇停留的天数(Month 等于 5)。
这是我的查询,但它给出了 myindex 中 PersonID 等于 111 和 Month 等于 5 的条目数。例如,这个查询可能给我一个类似 90 的输出,但每月最多有 31 天。
GET myindex/_search?
{
"size":0,
"query": {
"bool": {
"must": [
{ "match": {
"PersonID": "111"
}},
{ "match": {
"Month": "5"
}}
]
} },
"aggs": {
"stay_days": {
"terms" : {
"field": "Month"
}
}
}
}
在myindex 我有像DateTime 这样的字段,其中包含一个人被相机注册的日期和时间,例如2017-05-01T00:30:08"。因此,同一个人在一天内可能会多次经过相机,但应计为 1。
如何更新我的查询以计算每月的天数而不是相机的拍摄次数?
【问题讨论】:
-
你能提供你的映射吗?
标签: elasticsearch elasticsearch-plugin