elasticsearch使用“now”功能

时间:2016-01-26 15:03:39

标签: elasticsearch

我用奇迹中的日期值当前日期时间索引文档。

{
               "category": "27",
               "action": "BLOCKED",
               "url": "https://www.deneme.com/favicon.ico",
               "loggingdate": "26/01/2016 16:50:55",
               "clientip": "10.6.1.155"
}

“26/01/2016 16:59:55”,此刻的时间...... 并希望通过此查询获取此文档:

{  
  "size":"10",
  "query":{  
    "filtered":{  
      "filter":{  
        "bool":{  
          "must":[  
            {  
              "exists":{  
                "field":"category"
              }
            },
            {  
              "term":{  
                "action":"BLOCKED"
              }
            },
            {  
              "range":{  
                "loggingdate":{  
                  "gt":"now-20s"
                }
              }
            }
          ]
        }
      }
    }
  }
}

但是没有什么可以继续下去的原因......

如果我用id获得它:

{
   "_index": "webproxylog",
   "_type": "accesslog",
   "_id": "AVJ-iNlwfezuz1HM981V",
   "_version": 2,
   "found": true,
   "_source": {
      "category": "27",
      "action": "BLOCKED",
      "url": "https://www.deneme.com/favicon.ico",
      "loggingdate": "26/01/2016 16:50:55",
      "clientip": "10.6.1.155"
   }
}

0 个答案:

没有答案