This is because the _id is a string field, so comparison is based on the lexicographical order, not numeric.
On Thu, Jan 15, 2015 at 11:04 AM, Jason Zhang <[email protected]> wrote: > What I'm confused is the 'sorted' results are still partly unordered. > > Also, if I query: > > { "range": { > "_id": { > "gt": "10000", > "lt": "19999"}}} > > the results contain "_id": 199989. > > On Thursday, January 15, 2015 at 5:48:48 PM UTC+8, Adrien Grand wrote: >> >> Making it index:not_analyzed should work, what is the issue with the >> results? >> >> Note that loading the _id in fielddata is typically very costly since the >> _id field is typically unique per document. >> >> On Thu, Jan 15, 2015 at 10:35 AM, Jason Zhang <[email protected]> wrote: >> >>> I use a query dsl like: >>> >>> { >>> "filter": { >>> "exists": { "field": "info" } >>> }, >>> "sort": { "_id": "desc" } >>> } >>> >>> And the "_id" here is an integer like '123'. >>> >>> But the result is like: >>> >>> { >>> "took": 50, >>> ... >>> "hits": { >>> ... >>> "hits": [ >>> { >>> ... >>> "sort": [ null ] >>> }] >>> } >>> } >>> >>> Also, I've tried to add "_id": { "index": "not_analyzerd" } in the >>> _mapping. >>> This time the "sort" section returns values. But I find the results are >>> still partly unordered. >>> >>> Can I sort results by _id? How? >>> >>> Thank you. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "elasticsearch" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit https://groups.google.com/d/ >>> msgid/elasticsearch/4ea45f18-847a-4b58-b78e-ddcd9ee1e9f9% >>> 40googlegroups.com >>> <https://groups.google.com/d/msgid/elasticsearch/4ea45f18-847a-4b58-b78e-ddcd9ee1e9f9%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Adrien Grand >> > -- > You received this message because you are subscribed to the Google Groups > "elasticsearch" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/b7f625dd-8afd-4603-afc8-1fd6d5b601d1%40googlegroups.com > <https://groups.google.com/d/msgid/elasticsearch/b7f625dd-8afd-4603-afc8-1fd6d5b601d1%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Adrien Grand -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6x_GN9HuZzYtgB_T69hu0y_QVUCzqxxOKciEvKubgkUw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
