2016-05-17 73 views
0

我想用一个查询中logstash的elasticsearch输入滤波这些参数>筛选查询对于Elasticsearch从Logstash

**host.raw = host 1 OR host 2 
& 
code != "123"** 

我怎么会做查询?我一直在尝试了一段时间没有成功 ES版本的几件事情是1.7.1

input{ 
elasticsearch { 
     host=> 
     query => '{ "query": .... }' 

回答

0

你可以试试这个查询:

{ 
    "query": { 
    "bool": { 
     "should": [ 
     { 
      "term": { 
      "host.raw": "host 1" 
      } 
     }, 
     { 
      "term": { 
      "host.raw": "host 2" 
      } 
     } 
     ], 
     "must_not": { 
     "term": { 
      "code": "123" 
     } 
     } 
    } 
    } 
} 

设置上面的查询到你的配置会产生这样的:

input{ 
    elasticsearch { 
     host => "..." 
     query => '{"query": {"bool":{"should":[{"term":{"host.raw":"host 1"}},{"term":{"host.raw":"host 2"}}], "must_not":{"term":{"code":"123"}}}}}'