Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

elk's elastic search dsl case sensitive

I'm doing an Elasticsearch Query DSL query on ELK such as:

{
  "query": {
    "wildcard": {
      "url.path": {
        "value": "*download*",
        "boost": 1,
        "rewrite": "constant_score"
      }
    }
  }
}

but it seems is case sensitive (so show only info with "download", not "Download" or "DOWNLOAD"). i.e. is case sensitive.

can I disable this? and search case insensitive?

Version used: 7.9.1

like image 304
markzzz Avatar asked Nov 06 '22 02:11

markzzz


1 Answers

The below query will help you perform case-insensitive search as it will fetch results for *download, *Download and *DOWNLOAD. You may replace with your index and with the field you would like to perform this search.

Search Query

   GET /<my-index>/_search
    {
     "query" : {
         "bool" : {
            "must" : {
               "query_string" : {
                   "query" : "*download",
                   "fields": ["<field1>"]
               }
            }
         }
     }
}

If you wish to perform the same search on multiple fields, you can add the same in list.

Search on multiple fields

GET /<my-index>/_search
    {
     "query" : {
         "bool" : {
            "must" : {
               "query_string" : {
                   "query" : "*download",
                   "fields": ["<field1>","<field2>","field3>"]
               }
            }
         }
     }
}
like image 183
Asmita Khaneja Avatar answered Nov 13 '22 18:11

Asmita Khaneja