Search code examples
elasticsearchquerydslkibana-7

How to search word with special characters in Kibana - Elasticsearch


Does anyone know how I could get the values containing that value in message? If I remove the (-) and (/) it searches, if I leave them, the query does not return anything.

Not....

GET my-index/_search
{
   "query": {
        "wildcard" : {
            "message": "*Z-01-123456-9/2020-1*"
        }
    }
}

Not....

GET my-index/_search
{
   "query": {
        "wildcard" : {
            "message": "*Z\\-01\\-123456\\-9\/2020\-1*"
        }
    }
}

Solution

  • Here is my solution

    GET my-index/_search
    {
      "query": {
        "bool": {
          "must": [
            {
              "match_phrase": {"message": "Z-01-123456-9/2020-1"}
            },
            {
              "range": {
                "@timestamp": {
                  "gte": "2020-06-16T07:00:00",
                  "lt": "2020-06-23T00:00:00"
                }
              }
            }
          ]
        }
      }
    }