如何过滤 kibana 查询的特定查询结果

How to filter specific query results on kibana queries

我有以下查询:

{
  "query": {
    "match": {
      "message": {
        "query": "Error",
        "type": "phrase"
      }
    }
  }
}

但是我得到的结果包含我不感兴趣的特定内容。

例如:

2017-12-05 15:51:54,012 ERROR io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager - Failed to handle memberRemoved
io.vertx.core.VertxException: java.io.InvalidClassException: io.vertx.spi.cluster.zookeeper.impl.ZKSyncMap$KeyValue; local class

所以我想将我的查询升级为 return 个包含单词的结果:ZookeeperClusterManager

如何使用当前查询执行此操作?

谢谢

您需要使用 boolean querymust_not 进行否定搜索。

查询应该是这样的

{
    "query": {
        "bool": {
            "must": {
                "match": {
                    "message": "Error"
                }
            },
            "must_not": {
                "match": {
                    "message": "io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager"
                }
            }
        }
    }
}

由于 ES 中索引的工作方式,您需要使用 io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager。 ES 使用分析器将长字符串转换为可以搜索的值列表。这样做的步骤之一是按空格拆分文本(标记化)。这就是这里发生的事情。

2017-12-05 15:51:54,012 ERROR io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager - Failed to handle memberRemoved

转换为如下列表

2017-12-05
15:51:54,012
ERROR
io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager
-
Failed 
to 
handle 
memberRemoved

这就是为什么您搜索 error 有效,但搜索 ZookeeperClusterManager 无效的原因。 ZookeeperClusterManager 本身不在列表中。有关分析如何工作的更多信息,我建议您 read this blogpost on ES website. Generally, you could fix this problem by making the tokenizer tokenize by spaces and dots instead of only spaces. How to setup custom analysis is described in this blogpost