Sort on id not working

Hi -- I have a bunch of items in a search index that look like this: '{
"item": { "id": 42 } }'
There are 100 of them with ids from 1 to 100, and their "_id" property is
also set correctly.
My problem is that when I search for them with an ids filter, I can't get
the results to sort correctly.
Here is my attempt:
curl -XGET "http://localhost:9200/items_test/items/_search?pretty=true" -d
'{"size":20,"from":0,"filter":{"ids":{"values":[11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]}},"sort":[{"id":{"order":"asc"}}]}'

I would expect this (specifying a size of 20, and a from of 0) to return ids
11 through to 30. But it doesn't -- it returns a random series of 20 of the
items in the range specified, including the one id-ed 37, in a random order.
If I call again with size = 20 and from = 20, then I'll get the rest
correctly, but I need to be able to sort these results for them to be of any
use.
Could anyone advise as to what I'm doing wrong, or what assumptions I may be
making in error?
Thanks,
Doug.

did you try "sort" :{"_uid":"desc"} as well? (btw: it is not id it is
_id ...)

On 10 Okt., 18:13, doug livesey biot...@gmail.com wrote:

Hi -- I have a bunch of items in a search index that look like this: '{
"item": { "id": 42 } }'
There are 100 of them with ids from 1 to 100, and their "_id" property is
also set correctly.
My problem is that when I search for them with an ids filter, I can't get
the results to sort correctly.
Here is my attempt:
curl -XGET "http://localhost:9200/items_test/items/_search?pretty=true" -d
'{"size":20,"from":0,"filter":{"ids":{"values":[11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]}},"sort":[{"id":{"order":"asc"}}]}'

I would expect this (specifying a size of 20, and a from of 0) to return ids
11 through to 30. But it doesn't -- it returns a random series of 20 of the
items in the range specified, including the one id-ed 37, in a random order.
If I call again with size = 20 and from = 20, then I'll get the rest
correctly, but I need to be able to sort these results for them to be of any
use.
Could anyone advise as to what I'm doing wrong, or what assumptions I may be
making in error?
Thanks,
Doug.

That did it, cheers! :slight_smile:

On Oct 11, 4:18 pm, Karussell tableyourt...@googlemail.com wrote:

did you try "sort" :{"_uid":"desc"} as well? (btw: it is not id it is
_id ...)

On 10 Okt., 18:13, doug livesey biot...@gmail.com wrote:

Hi -- I have a bunch of items in a search index that look like this: '{
"item": { "id": 42 } }'
There are 100 of them with ids from 1 to 100, and their "_id" property is
also set correctly.
My problem is that when I search for them with an ids filter, I can't get
the results to sort correctly.
Here is my attempt:
curl -XGET "http://localhost:9200/items_test/items/_search?pretty=true" -d
'{"size":20,"from":0,"filter":{"ids":{"values":[11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]}},"sort":[{ "id":{"order":"asc"}}]}'

I would expect this (specifying a size of 20, and a from of 0) to return ids
11 through to 30. But it doesn't -- it returns a random series of 20 of the
items in the range specified, including the one id-ed 37, in a random order.
If I call again with size = 20 and from = 20, then I'll get the rest
correctly, but I need to be able to sort these results for them to be of any
use.
Could anyone advise as to what I'm doing wrong, or what assumptions I may be
making in error?
Thanks,
Doug.