# Sorting the resultset

**URL:** <https://discuss.elastic.co/t/sorting-the-resultset/6450>\
**Category:** Elasticsearch\
**Created:** [January 20, 2012, 1:17pm UTC](https://discuss.elastic.co/t/sorting-the-resultset/6450 "2012-01-20T13:17:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valentin\_Pletzer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/valentin_pletzer/32/105548_2.png) [@Valentin\_Pletzer](https://discuss.elastic.co/u/Valentin_Pletzer)\
**Post date:** [January 20, 2012, 1:17pm UTC](https://discuss.elastic.co/t/sorting-the-resultset/6450/1 "2012-01-20T13:17:04Z")

</div>

Hi,

I am using filters to get a result which I sort by field A and then  
limit with size. What I would like is to do is to sort the result by  
field B. Is that possible? Both fields (A and B) have the type long.

Thanks  
Valentin

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 20, 2012, 3:02pm UTC](https://discuss.elastic.co/t/sorting-the-resultset/6450/2 "2012-01-20T15:02:57Z")

</div>

Yea, just sort on B instead of A, or are you asking if you can sort on  
both? If so, then yes, just have both fields in the sorting part.

On Fri, Jan 20, 2012 at 3:17 PM, Valentin [pletzer@gmail.com](mailto:pletzer@gmail.com) wrote:

> Hi,
> 
> I am using filters to get a result which I sort by field A and then  
> limit with size. What I would like is to do is to sort the result by  
> field B. Is that possible? Both fields (A and B) have the type long.
> 
> Thanks  
> Valentin

---

<div class="post-metadata">

**Author:** ![Valentin\_Pletzer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/valentin_pletzer/32/105548_2.png) [@Valentin\_Pletzer](https://discuss.elastic.co/u/Valentin_Pletzer)\
**Post date:** [January 21, 2012, 11:07am UTC](https://discuss.elastic.co/t/sorting-the-resultset/6450/3 "2012-01-21T11:07:05Z")

</div>

Sorry. I didnt explain it well it enough. What I want is to sort only  
the resulting 10 records by field B.

On Jan 20, 4:02 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Yea, just sort on B instead of A, or are you asking if you can sort on  
> both? If so, then yes, just have both fields in the sorting part.
> 
> On Fri, Jan 20, 2012 at 3:17 PM, Valentin [plet...@gmail.com](mailto:plet...@gmail.com) wrote:
> 
> > Hi,
> 
> > I am using filters to get a result which I sort by field A and then  
> > limit with size. What I would like is to do is to sort the result by  
> > field B. Is that possible? Both fields (A and B) have the type long.
> 
> > Thanks  
> > Valentin

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [January 21, 2012, 8:52pm UTC](https://discuss.elastic.co/t/sorting-the-resultset/6450/4 "2012-01-21T20:52:47Z")

</div>

why not sort them in-memory on your own? it shouldn't make a  
difference

Peter.

---

<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:41am UTC](https://discuss.elastic.co/t/sorting-the-resultset/6450/5 "2017-07-06T03:41:54Z")

</div>


