# Custom sorting in Elastic search

**URL:** <https://discuss.elastic.co/t/custom-sorting-in-elastic-search/50552>\
**Category:** Elasticsearch\
**Created:** [May 20, 2016, 12:09pm UTC](https://discuss.elastic.co/t/custom-sorting-in-elastic-search/50552 "2016-05-20T12:09:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamil](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@tamil](https://discuss.elastic.co/u/tamil)\
**Post date:** [May 20, 2016, 12:09pm UTC](https://discuss.elastic.co/t/custom-sorting-in-elastic-search/50552/1 "2016-05-20T12:09:55Z")

</div>

Im trying to find and sort the values in a customized way

search term - "tamil"  
**below is the desired result sort order**  
tamila  
tamilba  
tamilbd  
tamilc  
atamil  
bcctamil  
oootamilh  
vtamil  
wstamil

**mapping:**  
"column name": {  
"type": "string",  
"index\_options": "offsets"  
}

**query used:**

POST content\_es/\_search  
{  
"query": {  
"function\_score": {  
"query": {  
"match": {  
"content": "tamil"  
}  
},  
"script\_score": {  
"script": "termInfo=\_index['content'].get('tamil',\_OFFSETS);for(pos in termInfo){return pos.startOffset};"  
},  
"boost\_mode": "replace"  
}  
},  
"sort": [{ "\_score": "asc" }]  
}

**But the above is not working**.  
**Can someone please share your vision on this scenario?**

Thanks in Advance!!!

---

<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 5, 2017, 10:50pm UTC](https://discuss.elastic.co/t/custom-sorting-in-elastic-search/50552/2 "2017-07-05T22:50:07Z")

</div>


