Elasticsearch范围查询不使用匹配查询

时间:2018-02-13 15:02:55

标签: elasticsearch

我正在尝试将匹配查询和范围查询结合起来,但它无法正常工作。

GET file*/_search
{  
   "query":{  
      "bool":{  
         "should":[  
            {  
               "match":{  
                  "message":"timeout"
               }
            },
            {  
               "match":{  
                  "message":"java.lang.IllegalStateException"
               }
            },
            {  
               "range":{  
                  "@timestamp":{  
                     "gt":"now-1h",
                     "lte":"now",
                     "time_zone":"+01:00"
                  }
               }
            }
         ]
      }
   }
}

日期过滤器在这里工作不正常,我在这里做错了吗?

由于

1 个答案:

答案 0 :(得分:2)

},替换为],,然后添加过滤器进行查询。例如:

{
  "query": { 
    "bool": { 
      "should": [
        { "match":{ "message":"timeout" }},
        { "match":{ "message":"java.lang.IllegalStateException"}}  
      ],
      "filter": [ 
        { "range": { "@timestamp": { "gt": "now-15m", "lte": "now", "time_zone":"+01:00" }}} 
      ]
    }
  }
}
相关问题