elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.58k stars 24.63k forks source link

unable to get/delete by ID when saved with routing #1983

Closed bictorman closed 12 years ago

bictorman commented 12 years ago

Hi,

It seems like if you save a document by specifying the route in the URL you can not address the document by it's ID. I found the problem in debian squeeze and then made the following test with a fresh installation in OSX 10.7.4, with both 0.19.4 and the latest snapshot.

Without routing everything is fine:

% curl -XPOST 'http://localhost:9200/test/test/1' -d '{"foo":"bar"}'
{"ok":true,"_index":"test","_type":"test","_id":"1","_version":1}
% curl -XGET 'http://localhost:9200/test/test/1'
{"_index":"test","_type":"test","_id":"1","_version":1,"exists":true, "_source" : {"foo":"bar"}}

With routing it saves fine:

% curl -XPOST 'http://localhost:9200/test/test/2?routing=test' -d '{"foo":"bar"}'
{"ok":true,"_index":"test","_type":"test","_id":"2","_version":1}

can not get by id:

% curl -XGET 'http://localhost:9200/test/test/2'
{"_index":"test","_type":"test","_id":"2","exists":false}

can not delete by id:

% curl -XDELETE 'http://localhost:9200/test/test/2'
{"ok":true,"found":false,"_index":"test","_type":"test","_id":"2","_version":1}

but the document is there:

% curl -XGET 'http://localhost:9200/test/test/_search?pretty=1&q=*'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test",
      "_type" : "test",
      "_id" : "1",
      "_score" : 1.0, "_source" : {"foo":"bar"}
    }, {
      "_index" : "test",
      "_type" : "test",
      "_id" : "2",
      "_score" : 1.0, "_source" : {"foo":"bar"}
    } ]
  }
}
kimchy commented 12 years ago

Its not really a bug, you need to specify the routing when you do a GET, otherwise the id is used to route the request to the relevant shard. Btw, questions on the mailing list, if its a problem, we then open specific issue(s) for it.

bictorman commented 12 years ago

I see. thanks.