Sorting doesn't work for me


(vibrant) #1

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?


(Shay Banon) #2

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 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?


(system) #3