To sort case-insensitively on a keyword field, you can apply a normalizer to that field. You can think of normalizers as analyzers for keyword fields instead of text fields. So, instead of defining an analyzer in your settings, define a normalizer:
PUT /testindex
{
"settings": {
"analysis": {
"normalizer": {
"case_insensitive": {
"filter": "lowercase"
}
}
}
}
}
Next, apply that normalizer to your keyword field in your mapping:
PUT /testindex/_mapping/testmapping
{
"properties": {
"Id": {
"type": "keyword"
},
"Name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"normalizer": "case_insensitive"
}
}
}
}
}
Now, you will be able to sort case-insensitively on Name.keyword
without using fielddata.