# Sorting the response JSON

**URL:** <https://discuss.elastic.co/t/sorting-the-response-json/281532>\
**Category:** Elasticsearch\
**Created:** [August 16, 2021, 11:03am UTC](https://discuss.elastic.co/t/sorting-the-response-json/281532 "2021-08-16T11:03:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anubhav\_Singh1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anubhav_singh1/32/93213_2.png) [@Anubhav\_Singh1](https://discuss.elastic.co/u/Anubhav_Singh1)\
**Post date:** [August 16, 2021, 11:03am UTC](https://discuss.elastic.co/t/sorting-the-response-json/281532/1 "2021-08-16T11:03:19Z")

</div>

I'm using the below synonyms in my elasticsearch index.

* * *

# Road Types

avenue,ave,boulevard,blvd,circle,cir,court,ct,drive,dr,highway,hwy,lane,ln,loop,lp,parkway,pkwy,place,pl,road,rd,route,rte,street,st,terrace,ter,trail,tr

# Multi-unit addresses

apartment,apt,building,bldg,floor,flr,level,lvl,unit

# Cardinal Directions

east,e,west,w,north,n,northeast,ne,northwest,nw,south,s,southeast,se,southwest,sw

* * *

While passing the input to query as a match\_phrase\_prefix, even if I'm passing it as "southeast" I'm getting "southwest" first in JSON followed by southeast and other directions. How do I sort it in order to get the direction that is passed as query first.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 17, 2021, 1:07am UTC](https://discuss.elastic.co/t/sorting-the-response-json/281532/2 "2021-08-17T01:07:36Z")

</div>

Welcome to our community! 😃

Elasticsearch will not retain any sorting like that internally as the JSON standard doesn't require it.

---

<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:** [September 14, 2021, 1:07am UTC](https://discuss.elastic.co/t/sorting-the-response-json/281532/3 "2021-09-14T01:07:43Z")

</div>

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