How to create normalizer to make case in sensitive on ElasticSearch
Muhamad Reza Abdul Rohim
Posted on June 6, 2023
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"
}
}
}
}
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*"
}
}
}
💖 💪 🙅 🚩
Muhamad Reza Abdul Rohim
Posted on June 6, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.