# How to sort multiple value search

**URL:** <https://discuss.elastic.co/t/how-to-sort-multiple-value-search/68555>\
**Category:** Elasticsearch\
**Created:** [December 9, 2016, 12:02pm UTC](https://discuss.elastic.co/t/how-to-sort-multiple-value-search/68555 "2016-12-09T12:02:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thanigaivelan19](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@thanigaivelan19](https://discuss.elastic.co/u/thanigaivelan19)\
**Post date:** [December 9, 2016, 12:02pm UTC](https://discuss.elastic.co/t/how-to-sort-multiple-value-search/68555/1 "2016-12-09T12:02:46Z")

</div>

Hi,

I have array of values, i want to search show the result in the same array order, how to sort it showing the result in same array format

Example my array value  
$myarray=array('84790','19162002','74739','86439','88820','19560020','19634461','19624154','19624091','19577228');

{  
"query":{  
"filtered":{  
"filter":{  
"bool":{  
"should":[  
{  
"term":{  
"podcast\_id":"84790"  
}  
},  
{  
"term":{  
"podcast\_id":"19162002"  
}  
},  
{  
"term":{  
"podcast\_id":"74739"  
}  
},  
{  
"term":{  
"podcast\_id":"86439"  
}  
},  
{  
"term":{  
"podcast\_id":"88820"  
}  
},  
{  
"term":{  
"podcast\_id":"19560020"  
}  
},  
{  
"term":{  
"podcast\_id":"19634461"  
}  
},  
{  
"term":{  
"podcast\_id":"19624154"  
}  
},  
{  
"term":{  
"podcast\_id":"19624091"  
}  
},  
{  
"term":{  
"podcast\_id":"19577228"  
}  
}  
]  
}  
}  
}  
}  
}

I am using php, curl and post method.

Thanks

Thanigaivelan

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [December 9, 2016, 12:33pm UTC](https://discuss.elastic.co/t/how-to-sort-multiple-value-search/68555/2 "2016-12-09T12:33:36Z")

</div>

Hi, the cost less is to run a multisearch, with one podcast\_id per search, and loop results, they'll be in the same order 😉

Here is a library:  
[http://elastica.io/api/latest/classes/Elastica.Multi.Search.html](http://elastica.io/api/latest/classes/Elastica.Multi.Search.html)

---

<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:** [January 6, 2017, 12:33pm UTC](https://discuss.elastic.co/t/how-to-sort-multiple-value-search/68555/3 "2017-01-06T12:33:49Z")

</div>

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