# Sorting string field ordering case insensitive

**URL:** https://discuss.elastic.co/t/sorting-string-field-ordering-case-insensitive/9955
**Category:** Elasticsearch
**Created:** [December 5, 2012, 4:57pm UTC](https://discuss.elastic.co/t/sorting-string-field-ordering-case-insensitive/9955 "2012-12-05T16:57:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rob\_Aldred](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rob_aldred/32/2589_2.png) [@Rob\_Aldred](https://discuss.elastic.co/u/Rob_Aldred)
#### Post date: [December 5, 2012, 4:57pm UTC](https://discuss.elastic.co/t/sorting-string-field-ordering-case-insensitive/9955/1 "2012-12-05T16:57:34Z")

</div>

Hi All.  
I have a multi\_field index for document titles,  
one is analyzed the other is not.

"title":{  
"type":"multi\_field",  
"fields":{  
"title":{  
"type":"string",  
"analyzer":"snowball",  
"boost":100  
},  
"title\_std":{  
"type":"string",  
"index":"not\_analyzed"  
}  
}  
}

When I sort by "title\_std" it's sorting case aswell  
So for example results are coming out as:

0 =\> Apple  
1 =\> Orange  
2 =\> Strawberry  
3 =\> Watermelon  
4 =\> banana  
5 =\> mango  
6 =\> nectarine

Any idea how I fix this... I need sorting regardless of case:

0 =\> Apple  
1 =\> banana  
2 =\> mango  
3 =\> nectarine  
4 =\> Orange  
5 =\> Strawberry  
6 =\> Watermelon

Thanks in advance for your help.

--

---

<div class="post-metadata">

### Author: ![Rob\_Aldred](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rob_aldred/32/2589_2.png) [@Rob\_Aldred](https://discuss.elastic.co/u/Rob_Aldred)
#### Post date: [December 5, 2012, 5:17pm UTC](https://discuss.elastic.co/t/sorting-string-field-ordering-case-insensitive/9955/2 "2012-12-05T17:17:13Z")

</div>

On Wednesday, 5 December 2012 16:57:34 UTC, Rob Aldred wrote:

> Hi All.  
> I have a multi\_field index for document titles,  
> one is analyzed the other is not.
> 
> "title":{  
> "type":"multi\_field",  
> "fields":{  
> "title":{  
> "type":"string",  
> "analyzer":"snowball",  
> "boost":100  
> },  
> "title\_std":{  
> "type":"string",  
> "index":"not\_analyzed"  
> }  
> }  
> }
> 
> When I sort by "title\_std" it's sorting case aswell  
> So for example results are coming out as:
> 
> 0 =\> Apple  
> 1 =\> Orange  
> 2 =\> Strawberry  
> 3 =\> Watermelon  
> 4 =\> banana  
> 5 =\> mango  
> 6 =\> nectarine
> 
> Any idea how I fix this... I need sorting regardless of case:
> 
> 0 =\> Apple  
> 1 =\> banana  
> 2 =\> mango  
> 3 =\> nectarine  
> 4 =\> Orange  
> 5 =\> Strawberry  
> 6 =\> Watermelon
> 
> Thanks in advance for your help.

It's Ok, I managed to find some more information posted in another thread  
about filtering the field as lowercase with a custom analyzer

analysis: {  
analyzer: {  
sortable: {  
tokenizer: "keyword",  
filter: ["lowercase"]  
}  
}  
}

My mapping is now as follows:

"title":{  
"type":"multi\_field",  
"fields":{  
"title":{  
"type":"string",  
"analyzer":"snowball",  
"boost":100  
},  
"title\_std":{  
"type":"string",  
"analyzer":"sortable"  
}  
}  
}

Thanks  
Rob

--

---

<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: [July 6, 2017, 3:01am UTC](https://discuss.elastic.co/t/sorting-string-field-ordering-case-insensitive/9955/3 "2017-07-06T03:01:13Z")

</div>


