# Sorting doesn't work for me

**URL:** <https://discuss.elastic.co/t/sorting-doesnt-work-for-me/5648>\
**Category:** Elasticsearch\
**Created:** [October 20, 2011, 12:17pm UTC](https://discuss.elastic.co/t/sorting-doesnt-work-for-me/5648 "2011-10-20T12:17:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vibrant](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@vibrant](https://discuss.elastic.co/u/vibrant)\
**Post date:** [October 20, 2011, 12:17pm UTC](https://discuss.elastic.co/t/sorting-doesnt-work-for-me/5648/1 "2011-10-20T12:17:30Z")

</div>

OK I've wasted a lot of time on this and can't find a solution. I'm trying  
to sort on ownerorder field in ascending order, and all the time I'm getting  
unsorted results. Here is the index mapping:

{u'tasks': {u'properties': {u'addedby': {u'include\_in\_all': False,  
u'store': u'yes',  
u'type': u'integer'},  
u'observers': {u'include\_in\_all': True,  
u'type': u'string'},  
u'owner': {u'include\_in\_all': False,  
u'store': u'yes',  
u'type': u'integer'},  
u'ownerbosses': {u'include\_in\_all': True,  
u'type': u'string'},  
u'ownerorder': {u'include\_in\_all': False,  
u'store': u'yes',  
u'type': u'long'},  
u'project': {u'include\_in\_all': False,  
u'store': u'yes',  
u'type': u'integer'},  
u'status': {u'include\_in\_all': False,  
u'store': u'yes',  
u'type': u'integer'},  
u'task\_num': {u'include\_in\_all': False,  
u'store': u'yes',  
u'type': u'integer'},  
u'title': {u'include\_in\_all': True,  
u'type': u'string'},  
u'updated': {u'include\_in\_all': False,  
u'store': u'yes',  
u'type': u'long'}}}}

here is the boolquery serialized and the whole search request:

{'bool': {'must': [{'term': {'owner': '1'}}]}}  
{'indexes': ['tasks'],  
'query': \<pyes.query.BoolQuery object at 0x105713fd0\>,  
'size': 30,  
'sort': [{'ownerorder': 'asc'}]}

and here is the result, obviously not sorted by ownerorder ascendingly:

{u'\_shards': {u'failed': 0, u'successful': 5, u'total': 5},  
u'hits': {u'hits': [{u'\_id': u'1',  
u'\_index': u'tasks',  
u'\_score': 1.0,  
u'\_source': {u'addedby': 7,  
u'observers': u'',  
u'owner': 1,  
u'ownerbosses': u'',  
u'ownerorder': 13191098250,  
u'project': 1,  
u'status': 2,  
u'task\_num': 1,  
u'title': u'NASA extends Atlantis  
mission',  
u'updated': 1319110249},  
u'\_type': u'tasks'},  
{u'\_id': u'13',  
u'\_index': u'tasks',  
u'\_score': 1.0,  
u'\_source': {u'addedby': 3,  
u'observers': u'',  
u'owner': 1,  
u'ownerbosses': u'',  
u'ownerorder': 1320233036,  
u'project': 3,  
u'status': 1,  
u'task\_num': 5,  
u'title': u'Rangers fan who died at game  
buried',  
u'updated': 1319109836},  
u'\_type': u'tasks'},  
{u'\_id': u'40',  
u'\_index': u'tasks',  
u'\_score': 1.0,  
u'\_source': {u'addedby': 1,  
u'observers': u'',  
u'owner': 1,  
u'ownerbosses': u'',  
u'ownerorder': 1319277600,  
u'project': 0,  
u'status': 1,  
u'task\_num': 13,  
u'title': u'powinien byc na samej gorze',  
u'updated': 1319111909},  
u'\_type': u'tasks'}],  
u'max\_score': 1.0,  
u'total': 3},  
u'timed\_out': False,  
u'took': 43}

any ideas?

---

<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:** [October 21, 2011, 12:47am UTC](https://discuss.elastic.co/t/sorting-doesnt-work-for-me/5648/2 "2011-10-21T00:47:48Z")

</div>

Can you gist a recreation in curl? I can't tell the actual search request  
you are executing.

On Thu, Oct 20, 2011 at 2:17 PM, vibrant [paranite@gmail.com](mailto:paranite@gmail.com) wrote:

> OK I've wasted a lot of time on this and can't find a solution. I'm trying  
> to sort on ownerorder field in ascending order, and all the time I'm getting  
> unsorted results. Here is the index mapping:
> 
> {u'tasks': {u'properties': {u'addedby': {u'include\_in\_all': False,  
> u'store': u'yes',  
> u'type': u'integer'},  
> u'observers': {u'include\_in\_all': True,  
> u'type': u'string'},  
> u'owner': {u'include\_in\_all': False,  
> u'store': u'yes',  
> u'type': u'integer'},  
> u'ownerbosses': {u'include\_in\_all': True,  
> u'type': u'string'},  
> u'ownerorder': {u'include\_in\_all': False,  
> u'store': u'yes',  
> u'type': u'long'},  
> u'project': {u'include\_in\_all': False,  
> u'store': u'yes',  
> u'type': u'integer'},  
> u'status': {u'include\_in\_all': False,  
> u'store': u'yes',  
> u'type': u'integer'},  
> u'task\_num': {u'include\_in\_all': False,  
> u'store': u'yes',  
> u'type': u'integer'},  
> u'title': {u'include\_in\_all': True,  
> u'type': u'string'},  
> u'updated': {u'include\_in\_all': False,  
> u'store': u'yes',  
> u'type': u'long'}}}}
> 
> here is the boolquery serialized and the whole search request:
> 
> {'bool': {'must': [{'term': {'owner': '1'}}]}}  
> {'indexes': ['tasks'],  
> 'query': \<pyes.query.BoolQuery object at 0x105713fd0\>,  
> 'size': 30,  
> 'sort': [{'ownerorder': 'asc'}]}
> 
> and here is the result, obviously not sorted by ownerorder ascendingly:
> 
> {u'\_shards': {u'failed': 0, u'successful': 5, u'total': 5},  
> u'hits': {u'hits': [{u'\_id': u'1',  
> u'\_index': u'tasks',  
> u'\_score': 1.0,  
> u'\_source': {u'addedby': 7,  
> u'observers': u'',  
> u'owner': 1,  
> u'ownerbosses': u'',  
> u'ownerorder': 13191098250,  
> u'project': 1,  
> u'status': 2,  
> u'task\_num': 1,  
> u'title': u'NASA extends Atlantis  
> mission',  
> u'updated': 1319110249},  
> u'\_type': u'tasks'},  
> {u'\_id': u'13',  
> u'\_index': u'tasks',  
> u'\_score': 1.0,  
> u'\_source': {u'addedby': 3,  
> u'observers': u'',  
> u'owner': 1,  
> u'ownerbosses': u'',  
> u'ownerorder': 1320233036,  
> u'project': 3,  
> u'status': 1,  
> u'task\_num': 5,  
> u'title': u'Rangers fan who died at game  
> buried',  
> u'updated': 1319109836},  
> u'\_type': u'tasks'},  
> {u'\_id': u'40',  
> u'\_index': u'tasks',  
> u'\_score': 1.0,  
> u'\_source': {u'addedby': 1,  
> u'observers': u'',  
> u'owner': 1,  
> u'ownerbosses': u'',  
> u'ownerorder': 1319277600,  
> u'project': 0,  
> u'status': 1,  
> u'task\_num': 13,  
> u'title': u'powinien byc na samej  
> gorze',  
> u'updated': 1319111909},  
> u'\_type': u'tasks'}],  
> u'max\_score': 1.0,  
> u'total': 3},  
> u'timed\_out': False,  
> u'took': 43}
> 
> any ideas?

---

<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:51am UTC](https://discuss.elastic.co/t/sorting-doesnt-work-for-me/5648/3 "2017-07-06T03:51:17Z")

</div>

Closed on July 6, 2017, 3:51am UTC


