我正在查询Elasticsearch(2.0)集群,想获取时间戳比特定时间戳早的事件(在以下情况下为2015年8月30日):
POST /constant_scan/vulnerability/_search
{
"query":{
"filtered":{
"filter":{
"range":{
"HOST_START_iso":{
"lt":"2015-08-30"
}
}
}
}
}
}
该搜索返回
{
"took": 44,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
DB有相关记录。对所有元素的查询将返回带有时间戳记的条目(其中包括8月20日(早于8月30日))
{
"took": 241,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 58517,
"max_score": 1,
"hits": [
{
"_index": "scan_constant",
"_type": "vulnerability",
"_id": "10.89.0.103",
"_score": 1,
"_source": {
"private": true,
"authenticated": false,
"HOST_START_iso": "2015-08-20T10:19:24+00:00"
}
},
(...)
我尝试使用完整的ISO日期作为分隔符,尝试使用
lte
而不是lt
-相同的结果。搜索日期与日期相同的事件(该日期的两边都有事件)
最佳答案
您正在查询constant_scan
索引
POST /constant_scan/vulnerability/_search
文档存储在
scan_constant
索引中时(根据您提供的示例文档)尝试将查询发布到此URL:
POST /scan_constant/vulnerability/_search
关于elasticsearch - 为什么此范围查询返回空结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33147592/