Can't retrieve a document with its _id?


can someone explain me how it is possible, when i make this request :

GET /myindex/mytype/_search
 "query": {
   "match": {
     "_id": "55448282"

I've got an answer like this :

  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
        "_index": "myindex",
        "_type": "mytype",
        "_id": "55448282",
        "_score": 1,
        "_source": {...}

But when I make this request I can't find the document :

GET /myindex/mytype/55448282 :
  "_index": "myindex",
  "_type": "mytype",
  "_id": "55448282",
  "found": false

It seems to work for some documents but not all documents, how is it possible ?
I verified that the cluster is yellow (no replica) and all shards are available for this index, my version of elasticsearch is 2.1.1.

(Nik Everett) #2

Please use ``` around anything that should have whitespace preserved. The forum doesn't detect that stuff and I can't read json without it!

Routing and parent/child. When you use routing the type and id no longer control which shard gets the document. Instead Elasticsearch just hashes the routing. Parent/child just uses the parent as the routing. Do you use any of those?

It makes sense that a plain GET would work for some documents. It should work in about one out of every number_of_shards documents.


Yes you're right I've got a parent/child association.
And effectively it works for about 25% of documents and I've got 4 shards.
I encountered this problem because I'm trying to add child documents and it only works with about 25% of my documents, my logstash configuration is :

filter {
    mutate {
        add_field => { "_parent" => "%{_id}" }
        remove_field => ["@timestamp","message","@version","host","path"]
        convert => [ "goals", "integer" ]
output {
    elasticsearch {
        hosts => ["localhost:9202"]
        index => "myindex"
        document_type => "mychildtype"
        document_id => "%{_id}"
    stdout { codec => rubydebug }

Is there a solution to solve this problem ?

(Nik Everett) #4

I suspect you'll do better on the logstash subforum. I'm not familiar with logstash configuration, sadly.


Thanks I'm going to try the logstash subforum.

(system) #6