# How to sort with case insensitive in elasticsearch

**URL:** <https://discuss.elastic.co/t/how-to-sort-with-case-insensitive-in-elasticsearch/251420>\
**Category:** Elasticsearch\
**Created:** [October 8, 2020, 10:59am UTC](https://discuss.elastic.co/t/how-to-sort-with-case-insensitive-in-elasticsearch/251420 "2020-10-08T10:59:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mak\_Mak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mak_mak/32/76867_2.png) [@Mak\_Mak](https://discuss.elastic.co/u/Mak_Mak)\
**Post date:** [October 8, 2020, 10:59am UTC](https://discuss.elastic.co/t/how-to-sort-with-case-insensitive-in-elasticsearch/251420/1 "2020-10-08T10:59:15Z")

</div>

My index name is data\_new

Below is the code to insert into index

```auto
test = [{'id':1,'name': 'Cost Accounting 400', 'professor': ['Bill Cage', 'accounting']},
    { 'id':2, 'name': 'Computer Internals 250', 'professor': ['Gregg Payne', 'engineering']},
    {'id':3, 'name': 'Accounting Info Systems 350', 'professor': ['Bill Cage', 'accounting']},
    {'id':4,'name': 'Tax Accounting 200', 'professor': ['Thomas Baszo', 'finance']},
    {'id':5,'name': 'Capital Markets 350', 'professor': ['Thomas Baszo', 'finance']},
    {'id':6,'name': 'Theatre 410', 'professor': ['Sebastian Hern', 'art']},
    {'id':7,'name': 'Accounting 101', 'professor': ['Thomas Baszo', 'finance']},
    {'id':8,'name': 'Marketing 101', 'professor': ['William Smith', 'finance']},
    {'id':8,'name': 'Anthropology 230', 'professor': ['Devin Cranford', 'history']},
    {'id':10, 'name': 'Computer Science 101',
        'professor': ['Gregg Payne', 'engineering']}]
from elasticsearch import Elasticsearch
import json
es = Elasticsearch()
es.indices.create(index='data_new', ignore=400)
for e in test:
        es.index(index="data_new", body=e, id=e['id'])
search = es.search(index="data_new", body={"from" : 0, "size" : 2,"query": {"match_all": {}}})
search['hits']['hits']

```

Right now

for input `["a", "b", "B", "C", "c", "A"] ` the result is : ` ["A", "B", "C", "a", "b", "c"]`

I want output as `["A", "a", "B", "b", "C", "c"]`

Expected out

My first Expected output \> I need to sort the output with respect to name only in {Case insensitive}. I need to normalise name keyword and sort

I am able to sort only \>` search = es.search(index="data_new", body={ "sort" : [{"name.keyword" : {"order" : "asc"}}], "from":0, "size":2, "query":{ "match_all":{}}})`

How to do the modification on `search = es.search(index="data_new", body={"from" : 0, "size" : 2,"query": {"match_all": {}}})`

I have updated the code with below `search = es.search(index="data_new", body={ "sort" : [{"name.keyword" : {"order" : "asc","normalizer": "case_insensitive"}}], "from":0, "size":2, "query":{ "match_all":{}}})` I got the error

`RequestError: RequestError(400, 'x_content_parse_exception', '[1:41] [field_sort] unknown field [normalizer]') `

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 5, 2020, 10:59am UTC](https://discuss.elastic.co/t/how-to-sort-with-case-insensitive-in-elasticsearch/251420/2 "2020-11-05T10:59:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
