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*"
}
}
}
Top comments (0)