从Logstash过滤Elasticsearch的查询

时间:2016-05-17 14:48:37

标签: elasticsearch logstash elastic-stack

我想在logstash的elasticsearch输入>中使用过滤这些参数的查询。

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

我该怎么做查询?我一直在尝试几件事而没有成功 ES版本为1.7.1

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

1 个答案:

答案 0 :(得分: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"}}}}}'