Elasticsearch正则表达式搜索

时间:2018-05-24 10:07:51

标签: regex elasticsearch nginx

我尝试在regex日志中使用html tags查找nginx。我的疑问:

GET my-index/_search
{
  "query": {
    "regexp": {
       "request": "script"
      }
    }
 }

它按照我的预期返回每个script个单词。

1.1.1.1 - - [18/Feb/2018:18:24:00 +0300] "GET /some/path/script-writing-i HTTP/1.1" 200 31712 0.085 0.085 ."-" "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)" "-"

1.1.1.1 - - [09/Feb/2018:00:44:15 +0300] "GET /some/path\x22><script>alert(303);</script>=1 HTTP/1.1" 200 64183 0.104 0.104 ."-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)" "-"

我希望找到带有某些html标记的表达式,特别是script标记。当我尝试使用Regex101 (=)[^\n]*(<)[^\n]+(>)时,我可以找到我想要的内容,但它来自Elasticsearch,它会抛出query_shard_exception

任何建议或帮助都会很棒!

0 个答案:

没有答案