# Score asc vs desc reversed?

**URL:** <https://discuss.elastic.co/t/score-asc-vs-desc-reversed/5023>\
**Category:** Elasticsearch\
**Created:** [August 1, 2011, 10:52pm UTC](https://discuss.elastic.co/t/score-asc-vs-desc-reversed/5023 "2011-08-01T22:52:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [August 1, 2011, 10:52pm UTC](https://discuss.elastic.co/t/score-asc-vs-desc-reversed/5023/1 "2011-08-01T22:52:27Z")

</div>

Heya,  
I was playing around with score based scoring and was surprised to  
see that a sort=\_score:asc returned the scores from highest to lowest,  
while sort=\_score:desc returns the lowest score to the highest score.

Not sure what can be done at this point to have this make more sense  
without breaking a bunch of stuff, but was surprised at how this was  
reversed. Most users probably don't specify asc or desc, so get the  
correct behavior.

Thanks,  
Paul

---

<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:** [August 1, 2011, 11:53pm UTC](https://discuss.elastic.co/t/score-asc-vs-desc-reversed/5023/2 "2011-08-01T23:53:28Z")

</div>

Actually, this only happens on the URI case, and if you pass the order in  
the search body, it will work correctly. Opened an issue, will be fixed in  
0.17.3: [Sorting on \_score in the URI format / Java API is reversed · Issue #1191 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1191).

On Tue, Aug 2, 2011 at 1:52 AM, ppearcy [ppearcy@gmail.com](mailto:ppearcy@gmail.com) wrote:

> Heya,  
> I was playing around with score based scoring and was surprised to  
> see that a sort=\_score:asc returned the scores from highest to lowest,  
> while sort=\_score:desc returns the lowest score to the highest score.
> 
> Not sure what can be done at this point to have this make more sense  
> without breaking a bunch of stuff, but was surprised at how this was  
> reversed. Most users probably don't specify asc or desc, so get the  
> correct behavior.
> 
> Thanks,  
> Paul

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [August 2, 2011, 12:21am UTC](https://discuss.elastic.co/t/score-asc-vs-desc-reversed/5023/3 "2011-08-02T00:21:00Z")

</div>

FYI, I can also reproduce with the Java APIs using the SortBuilders  
object.

The call looks like:

```
		searchBuilder.addSort(SortBuilders.fieldSort(field).order(order));

```

Let me know if you need any other details

Thanks!  
Paul

On Aug 1, 5:53 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Actually, this only happens on the URI case, and if you pass the order in  
> the search body, it will work correctly. Opened an issue, will be fixed in  
> 0.17.3:[Sorting on \_score in the URI format / Java API is reversed · Issue #1191 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1191).
> 
> On Tue, Aug 2, 2011 at 1:52 AM, ppearcy [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> 
> > Heya,  
> > I was playing around with score based scoring and was surprised to  
> > see that a sort=\_score:asc returned the scores from highest to lowest,  
> > while sort=\_score:desc returns the lowest score to the highest score.
> 
> > Not sure what can be done at this point to have this make more sense  
> > without breaking a bunch of stuff, but was surprised at how this was  
> > reversed. Most users probably don't specify asc or desc, so get the  
> > correct behavior.
> 
> > Thanks,  
> > Paul

---

<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:** [August 2, 2011, 5:40am UTC](https://discuss.elastic.co/t/score-asc-vs-desc-reversed/5023/4 "2011-08-02T05:40:50Z")

</div>

Yes, you are right, this also applies to the Java API, updated the issue.

On Tue, Aug 2, 2011 at 3:21 AM, ppearcy [ppearcy@gmail.com](mailto:ppearcy@gmail.com) wrote:

> FYI, I can also reproduce with the Java APIs using the SortBuilders  
> object.
> 
> The call looks like:
> 
> searchBuilder.addSort(SortBuilders.fieldSort(field).order(order));
> 
> Let me know if you need any other details
> 
> Thanks!  
> Paul
> 
> On Aug 1, 5:53 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > Actually, this only happens on the URI case, and if you pass the order in  
> > the search body, it will work correctly. Opened an issue, will be fixed  
> > in  
> > 0.17.3:[Sorting on \_score in the URI format / Java API is reversed · Issue #1191 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1191).
> > 
> > On Tue, Aug 2, 2011 at 1:52 AM, ppearcy [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> > 
> > > Heya,  
> > > I was playing around with score based scoring and was surprised to  
> > > see that a sort=\_score:asc returned the scores from highest to lowest,  
> > > while sort=\_score:desc returns the lowest score to the highest score.
> > 
> > > Not sure what can be done at this point to have this make more sense  
> > > without breaking a bunch of stuff, but was surprised at how this was  
> > > reversed. Most users probably don't specify asc or desc, so get the  
> > > correct behavior.
> > 
> > > Thanks,  
> > > Paul

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [August 2, 2011, 3:31pm UTC](https://discuss.elastic.co/t/score-asc-vs-desc-reversed/5023/5 "2011-08-02T15:31:06Z")

</div>

Thank you!!!

On Aug 1, 11:40 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Yes, you are right, this also applies to the Java API, updated the issue.
> 
> On Tue, Aug 2, 2011 at 3:21 AM, ppearcy [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> 
> > FYI, I can also reproduce with the Java APIs using the SortBuilders  
> > object.
> 
> > The call looks like:
> 
> > searchBuilder.addSort(SortBuilders.fieldSort(field).order(order));
> 
> > Let me know if you need any other details
> 
> > Thanks!  
> > Paul
> 
> > On Aug 1, 5:53 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > Actually, this only happens on the URI case, and if you pass the order in  
> > > the search body, it will work correctly. Opened an issue, will be fixed  
> > > in  
> > > 0.17.3:[Sorting on \_score in the URI format / Java API is reversed · Issue #1191 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1191).
> 
> > > On Tue, Aug 2, 2011 at 1:52 AM, ppearcy [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> > > 
> > > > Heya,  
> > > > I was playing around with score based scoring and was surprised to  
> > > > see that a sort=\_score:asc returned the scores from highest to lowest,  
> > > > while sort=\_score:desc returns the lowest score to the highest score.
> 
> > > > Not sure what can be done at this point to have this make more sense  
> > > > without breaking a bunch of stuff, but was surprised at how this was  
> > > > reversed. Most users probably don't specify asc or desc, so get the  
> > > > correct behavior.
> 
> > > > Thanks,  
> > > > Paul

---

<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:58am UTC](https://discuss.elastic.co/t/score-asc-vs-desc-reversed/5023/6 "2017-07-06T03:58:29Z")

</div>


