Sorting on _id in 0.17.8 does not appear to work

Just moved from 0.15.2 to 0.17.8 and appears that sorting on _id no
longer works as expected. Have verified this from command line and in
a test case using the java apis.

Below are the results from two queries executed from command line, one
with sort on my own id (myId) and other with sort on _id. Sort on _id
does not work as expected but the other one does. Also, noticed that
the results for the sort on _id have no values populated in the "sort"
output (as in "sort" : [ null ])

--------------- Data Setup ----------------

curl -XPUT 'http://localhost:9200/sorttest/' -d '{
"index":{
"standard":{
"type":"standard"
}
}
}
}}';

curl -XPUT 'http://localhost:9200/sorttest/data/_mapping' -d '
{
"asset" : {
"properties" : {
"myId" : {"type" : "long"},
"text" : {"type" : "string", "index" : "analyzed",
"analyzer":"standard"}
}
}
}';

curl -XPUT 'http://localhost:9200/sorttest/data/1' -d '{
"text" : "test rec 1",
"myId" : 1
}';

curl -XPUT 'http://localhost:9200/sorttest/data/2' -d '{
"text" : "test rec 2",
"myId" : 2
}';

curl -XPUT 'http://localhost:9200/sorttest/data/3' -d '{
"text" : "test rec 3",
"myId" : 3
}';

---------- Query with sort on _id (not working, sort is [null] in
results) -------------

curl -XGET 127.0.0.1:9200/sorttest/_search?pretty=true -d '{
"query" : {
"match_all":{}
},
"sort" : {
"_id":"desc"
}
}';

{
"took" : 78,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : null,
"hits" : [ {
"_index" : "sorttest",
"_type" : "data",
"_id" : "1",
"_score" : null, "_source" : {
"text" : "test rec 1",
"myId" : 1
},
"sort" : [ null ]
<======== ????, _id values do not appear
}, {
"_index" : "sorttest",
"_type" : "data",
"_id" : "2",
"_score" : null, "_source" : {
"text" : "test rec 2",
"myId" : 2
},
"sort" : [ null ]
}, {
"_index" : "sorttest",
"_type" : "data",
"_id" : "3",
"_score" : null, "_source" : {
"text" : "test rec 3",
"myId" : 3
},
"sort" : [ null ]
} ]
}
}

---------- Query with sort on myId (working) -------------

curl -XGET 127.0.0.1:9200/sorttest/_search?pretty=true -d '{
"query" : {
"match_all":{}
},
"sort" : {
"myId":"desc"
}
}';

{
"took" : 74,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : null,
"hits" : [ {
"_index" : "sorttest",
"_type" : "data",
"_id" : "3",
"_score" : null, "_source" : {
"text" : "test rec 3",
"myId" : 3
},
"sort" : [ 3 ]
}, {
"_index" : "sorttest",
"_type" : "data",
"_id" : "2",
"_score" : null, "_source" : {
"text" : "test rec 2",
"myId" : 2
},
"sort" : [ 2 ]
}, {
"_index" : "sorttest",
"_type" : "data",
"_id" : "1",
"_score" : null, "_source" : {
"text" : "test rec 1",
"myId" : 1
},
"sort" : [ 1 ]
} ]
}
}

use _uid

http://groups.google.com/group/elasticsearch/browse_thread/thread/b7568b6caa2ed55/

On 13 Okt., 13:48, dmcclure duane.mccl...@gmail.com wrote:

Just moved from 0.15.2 to 0.17.8 and appears that sorting on _id no
longer works as expected. Have verified this from command line and in
a test case using the java apis.

Below are the results from two queries executed from command line, one
with sort on my own id (myId) and other with sort on _id. Sort on _id
does not work as expected but the other one does. Also, noticed that
the results for the sort on _id have no values populated in the "sort"
output (as in "sort" : [ null ])

--------------- Data Setup ----------------

curl -XPUT 'http://localhost:9200/sorttest/'-d '{
"index":{
"standard":{
"type":"standard"
}
}
}

}}';

curl -XPUT 'http://localhost:9200/sorttest/data/_mapping'-d '
{
"asset" : {
"properties" : {
"myId" : {"type" : "long"},
"text" : {"type" : "string", "index" : "analyzed",
"analyzer":"standard"}
}
}

}';

curl -XPUT 'http://localhost:9200/sorttest/data/1'-d '{
"text" : "test rec 1",
"myId" : 1

}';

curl -XPUT 'http://localhost:9200/sorttest/data/2'-d '{
"text" : "test rec 2",
"myId" : 2

}';

curl -XPUT 'http://localhost:9200/sorttest/data/3'-d '{
"text" : "test rec 3",
"myId" : 3

}';

---------- Query with sort on _id (not working, sort is [null] in
results) -------------

curl -XGET 127.0.0.1:9200/sorttest/_search?pretty=true -d '{
"query" : {
"match_all":{}
},
"sort" : {
"_id":"desc"
}

}';

{
"took" : 78,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : null,
"hits" : [ {
"_index" : "sorttest",
"_type" : "data",
"_id" : "1",
"_score" : null, "_source" : {
"text" : "test rec 1",
"myId" : 1},

  "sort" : [ null ]

<======== ????, _id values do not appear
}, {
"_index" : "sorttest",
"_type" : "data",
"_id" : "2",
"_score" : null, "_source" : {
"text" : "test rec 2",
"myId" : 2},

  "sort" : [ null ]
}, {
  "_index" : "sorttest",
  "_type" : "data",
  "_id" : "3",
  "_score" : null, "_source" : {
"text" : "test rec 3",
    "myId" : 3},

  "sort" : [ null ]
} ]

}

}

---------- Query with sort on myId (working) -------------

curl -XGET 127.0.0.1:9200/sorttest/_search?pretty=true -d '{
"query" : {
"match_all":{}
},
"sort" : {
"myId":"desc"
}

}';

{
"took" : 74,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : null,
"hits" : [ {
"_index" : "sorttest",
"_type" : "data",
"_id" : "3",
"_score" : null, "_source" : {
"text" : "test rec 3",
"myId" : 3},

  "sort" : [ 3 ]
}, {
  "_index" : "sorttest",
  "_type" : "data",
  "_id" : "2",
  "_score" : null, "_source" : {
"text" : "test rec 2",
    "myId" : 2},

  "sort" : [ 2 ]
}, {
  "_index" : "sorttest",
  "_type" : "data",
  "_id" : "1",
  "_score" : null, "_source" : {
"text" : "test rec 1",
    "myId" : 1},

  "sort" : [ 1 ]
} ]

}

}

Hi

On Thu, 2011-10-13 at 04:48 -0700, dmcclure wrote:

Just moved from 0.15.2 to 0.17.8 and appears that sorting on _id no
longer works as expected. Have verified this from command line and in
a test case using the java apis.

As of version 0.16, the _id field is no longer indexed by default:

You can turn set {_id: { index: "not_analyzed"}} in your mapping if you
want to turn it back on.

clint

On Thu, 2011-10-13 at 05:02 -0700, Karussell wrote:

use _uid

_uid includes the type, which may produce different results than
expected

clint

Appreciate the responses, thanks.

On Oct 13, 10:30 am, Clinton Gormley cl...@traveljury.com wrote:

On Thu, 2011-10-13 at 05:02 -0700, Karussell wrote:

use _uid

_uid includes the type, which may produce different results than
expected

clint