【发布时间】:2020-06-23 01:16:20
【问题描述】:
我在 Elasticsearch 中的列表
[{
"index1": [{
"hour_start": "2020-03-17 14:00:00",
"hour_end": "2020-03-17 15:00:00"
}]
}, {
"index2": [{
"hour_start": "2020-03-17 10:00:00",
"hour_end": "2020-03-17 07:00:00"
}, {
"hour_start": "2020-03-18 10:00:00",
"hour_end": "2020-03-18 07:00:00"
}]
}, {
"index3": [{
"hour_start": "2020-03-17 13:00:00",
"hour_end": "2020-03-17 10:00:00"
}]
}, {
"index4": [{
"hour_start": "2020-03-17 09:00:00",
"hour_end": "2020-03-17 04:00:00"
}]
}]
如何在“2020-03-17 06:00:00”到“2020-03-17 12:00:00”范围内查找获取列表并相交?
期望输出:
[{
"index2": [{
"hour_start": "2020-03-17 10:00:00",
"hour_end": "2020-03-17 07:00:00"
}, {
"hour_start": "2020-03-18 10:00:00",
"hour_end": "2020-03-18 07:00:00"
}]
}, {
"index3": [{
"hour_start": "2020-03-17 13:00:00",
"hour_end": "2020-03-17 10:00:00"
}]
}, {
"index4": [{
"hour_start": "2020-03-17 09:00:00",
"hour_end": "2020-03-17 04:00:00"
}]
}]
我厌倦了在列表中找到相交,我不知道在弹性搜索中逻辑 OR 与编程语言流不同
【问题讨论】:
-
你能添加你的映射吗
-
您能否也检查一下您共享的数据。不确定您使用的是 12 小时还是 24 小时表示。
index1有 24 小时表示。而index2, index3 and index4的hour_start值高于hour_end,这让我想如果它是12 小时的表示,但它又不是上午或下午。 -
{ "mappings": { "properties": { "time": { "properties": { "hour_end": { "type": "date", "format": "yyyy-MM -dd HH:mm:ss" }, "hour_start": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss" } } } } } @jaspreetchahal
-
@OpsterESNinja-Kamal 我认为我的日期是 24 小时,当我尝试过滤以查找日期内的日期时,我会在 24 小时的情况下得到我的预期结果。但我不知道从底部和顶部小时得到一个迭代小时
标签: elasticsearch kibana elastic-stack elasticsearch-5 elk