在elasticquery中添加多个must_not

时间:2017-03-21 06:33:01

标签: regex elasticsearch

我想实现以下目标:

  1. LogMessage不应包含too many connection
  2. LogMessage必须出现。
  3. LogMessage不得contain no conn
  4. 不能查询是:

     "must_not" => [
                    "regexp" =>[
                        "LogMessage" => ".*Too many connections.*"
                    ]
                  ],
                  "must_not" => [
                    "regexp" =>[
                        "LogMessage" => "^.{0,0}$"
                    ]
                  ],
    
                   "must_not" => [
                    "regexp" =>[
                        "LogMessage" => ".*no conn.*"
                    ]
                  ],
    

    但上述情况不正常。

1 个答案:

答案 0 :(得分:1)

请尝试这样:

   "must_not" => [
          [
            "regexp" =>[
                "LogMessage" => ".*Too many connections.*"
            ]
          ],
          [
            "regexp" =>[
                "LogMessage" => "^.{0,0}$"
            ]
          ],
          [
            "regexp" =>[
                "LogMessage" => ".*no conn.*"
            ]
          ]
   ]