如何在Kibana Discovery中使用斜杠('/')?

Ale*_*xey 5 elasticsearch kibana

我正在测试用于nginx访问日志的ELK堆栈.它看起来不错,除了我没有找到一种方法来搜索Kibana Discovery(v5.3.2)中的记录,其路径以"/test/a".如果我删除斜杠,搜索有效,但在这种情况下,我得到了我不需要的东西 - "/ololo/ololo?test=1"

我尝试了不同的请求:

path:/\/test\/a/
path:/\\/test\\/a/
path:"/test/a"
path:"\/test\/a"
path:"\\/test\\/a"
Run Code Online (Sandbox Code Playgroud)

但是没有任何效果如我所料.

记录:

[
{
    ...
    "path": "/test/a1"
    ...
},
{
    ...
    "path": "/test/a2"
    ...
},
{
    ...
    "path": "/ololo/ololo?test=1"
    ...
},        
]
Run Code Online (Sandbox Code Playgroud)

制图:

"path": {
  "type": "string", 
  "index": "analyzed", 
},
Run Code Online (Sandbox Code Playgroud)

有没有办法使用斜杠作为模式的一部分进行搜索?

更新:

这些模式也不起作用:

path:/.*\/test\/a.*/
path:/[\/]test[\/]a/
Run Code Online (Sandbox Code Playgroud)

Val*_*Val 7

您需要更改path字段的映射以不进行分析,否则不会将斜杠编入索引.

映射应该是这样的:

"path": {
  "type": "string", 
  "index": "not_analyzed",    <--- change this
},
Run Code Online (Sandbox Code Playgroud)

请注意,您需要删除索引并使用正确的映射重新创建索引才能使其生效.

之后,您将能够使用以下查询进行搜索 path:"/test/a"