# How to add Alphabetical Sorting

**URL:** <https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427>\
**Category:** Elasticsearch\
**Created:** [March 25, 2016, 9:03am UTC](https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427 "2016-03-25T09:03:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shivendra.Singh](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shivendra.Singh](https://discuss.elastic.co/u/Shivendra.Singh)\
**Post date:** [March 25, 2016, 9:03am UTC](https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427/1 "2016-03-25T09:03:15Z")

</div>

Hi Team,

I am quite new in elastic search and trying to query a data where i need to add filters based on  
fields where sorting will also be there which will be in A-Z / Z-A sorting.

here is the request  
{  
"query": {  
"bool": {  
"must": [  
{"match\_phrase": {"categories\_filter": "hollywood"}},  
{"match\_phrase": {"sub\_categories\_filter": "Sub-Category 7"} },  
------ Want to add sorting here--------------  
]  
}

}  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 25, 2016, 9:20am UTC](https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427/2 "2016-03-25T09:20:09Z")

</div>

Please format your code.

Are you searching for this? [https://www.elastic.co/guide/en/elasticsearch/reference/2.2/search-request-sort.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/search-request-sort.html)

---

<div class="post-metadata">

**Author:** ![Shivendra.Singh](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shivendra.Singh](https://discuss.elastic.co/u/Shivendra.Singh)\
**Post date:** [March 25, 2016, 9:32am UTC](https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427/3 "2016-03-25T09:32:08Z")

</div>

Thanks for the reply David,

if i can tell you in mysql query, my data will be fetched like below given query

select \* from movies where categories\_filter='hollywood' AND  
sub\_categories\_filter='sub-category7' AND genre='Drama' and so on ORDER BY (A-Z / Z-A) DESC...SO the whole set of record come in alphabetically ordered.

Kindly let me know if your given URL will work as per my requirement.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 25, 2016, 9:52am UTC](https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427/4 "2016-03-25T09:52:58Z")

</div>

Yes it will. Just give it a try. It's super easy to start with elasticsearch.

---

<div class="post-metadata">

**Author:** ![Shivendra.Singh](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shivendra.Singh](https://discuss.elastic.co/u/Shivendra.Singh)\
**Post date:** [March 25, 2016, 9:56am UTC](https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427/5 "2016-03-25T09:56:26Z")

</div>

Thanks Alot.. I will try now and will let u know about the outcome...Thanks again

---

<div class="post-metadata">

**Author:** ![Shivendra.Singh](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shivendra.Singh](https://discuss.elastic.co/u/Shivendra.Singh)\
**Post date:** [March 28, 2016, 5:58am UTC](https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427/6 "2016-03-28T05:58:51Z")

</div>

Hi David,

So here is the issue which I am facing right now, which is having 'AND' search as given below example..

Suppose I have selected

1. Category - Hollywood
2. Sub-Category - Bond Special
3. Genre - Action & Drama & Comedy ( as multiple selection will be there )
4. Language - English, Russian and Hindi ( as multiple selection will be there)
5. Release Year - 1990,1999,2000 ( as multiple selection will be there)
6. 3D Movie - True OR False (any one will be selected)  
and in last
7. SortBy - “A-Z”OR “Z-A” OR “Date”

Can you help me in making this bulk query for elastic-search. I will use "match\_phrase" for making AND condition but the issue is matching parameters are multiple and will be in comma separated (u can say).

---

<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, 11:04pm UTC](https://discuss.elastic.co/t/how-to-add-alphabetical-sorting/45427/7 "2017-07-05T23:04:48Z")

</div>


