# Case insensitive sort doesn't work

**URL:** https://discuss.elastic.co/t/case-insensitive-sort-doesnt-work/143192
**Category:** Elasticsearch
**Created:** [August 6, 2018, 4:36pm UTC](https://discuss.elastic.co/t/case-insensitive-sort-doesnt-work/143192 "2018-08-06T16:36:06Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)
#### Post date: [August 16, 2018, 9:18pm UTC](https://discuss.elastic.co/t/case-insensitive-sort-doesnt-work/143192/7 "2018-08-16T21:18:03Z")

</div>

To sort case-insensitively on a keyword field, you can apply a [normalizer](https://www.elastic.co/guide/en/elasticsearch/reference/current/normalizer.html) 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:

```auto
PUT /testindex
{
  "settings": {
    "analysis": {
      "normalizer": {
        "case_insensitive": {
          "filter": "lowercase"
        }
      }
    }
  }
}

```

Next, apply that normalizer to your keyword field in your mapping:

```auto
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.

---

_[View the full topic](https://discuss.elastic.co/t/case-insensitive-sort-doesnt-work/143192)._
