DEV Community

Cover image for How to create normalizer to make case in sensitive on ElasticSearch
Muhamad Reza Abdul Rohim
Muhamad Reza Abdul Rohim

Posted on

How to create normalizer to make case in sensitive on ElasticSearch

By default if you add field on index elasticsearch with keyword data type, you cannot querying or sorting the field with case insensitive, because it is not supported by default, the solution is you can add normalizer like this using kibana:

PUT your_awesome_index_name
{
  "settings": {
    "analysis": {
      "normalizer": {
        "lowercase_normalizer": {
          "type": "custom",
          "filter": ["lowercase"]
        }
      }
    }
  },
  "mappings": {
      "properties": {
        "name": {
          "type": "keyword",
          "normalizer": "lowercase_normalizer"
        }
      }
  }
}
Enter fullscreen mode Exit fullscreen mode

And now you can querying the index data with case insensitive keyword:

GET your_awesome_index_name/_search
{
  "query": {
    "query_string": {
      "default_field": "name.keyword",
      "query": "*reza*"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)