Elastic Search Case Insensitive for key

Hi,

I have a requirement where I need to do the Elasticsearch search case insensitivity, but need on both key and value field.

Sample Documents

POST test-index21/_doc
{
  "Name": "something"
}
POST test-index21/_doc
{
  "name": "something"
}

Need for query like below to return the above both documents

GET test-index21/_search
{
  "query": {
    "match": {
      "name": "something"
    }
  }
}

HI @Harinder_Singh,

Welcome back. Setting fields names as case insensitive at query time isn't possible as covered in this post. It would be best to normalise your field names to be consistent across all of your documents.

Are you using the standard analyzer on your documents? If so it makes use of a lowercase filter to convert text to all lowercase, giving you the case insensitive search you need on the values.

Hope that helps!

Another option would be to use field aliases but definitely @carly.richmond's recommandation about normalizing your schemas is the best way.

1 Like

Thanks for you response. Yes for Values, we are using the lowercase filter