# Can't retrieve a document with its \_id?

**URL:** <https://discuss.elastic.co/t/cant-retrieve-a-document-with-its--id/37763>\
**Category:** Elasticsearch\
**Created:** [December 22, 2015, 2:36pm UTC](https://discuss.elastic.co/t/cant-retrieve-a-document-with-its--id/37763 "2015-12-22T14:36:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fchantrel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fchantrel/32/6204_2.png) [@fchantrel](https://discuss.elastic.co/u/fchantrel)\
**Post date:** [December 22, 2015, 2:36pm UTC](https://discuss.elastic.co/t/cant-retrieve-a-document-with-its--id/37763/1 "2015-12-22T14:36:31Z")

</div>

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

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

```

I've got an answer like this :

```auto
  "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 :

```auto
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.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 22, 2015, 2:53pm UTC](https://discuss.elastic.co/t/cant-retrieve-a-document-with-its--id/37763/2 "2015-12-22T14:53:36Z")

</div>

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

> [@fchantrel](#):
>
> It seems to work for some documents but not all documents, how is it possible ?

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.

---

<div class="post-metadata">

**Author:** ![fchantrel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fchantrel/32/6204_2.png) [@fchantrel](https://discuss.elastic.co/u/fchantrel)\
**Post date:** [December 22, 2015, 3:12pm UTC](https://discuss.elastic.co/t/cant-retrieve-a-document-with-its--id/37763/3 "2015-12-22T15:12:19Z")

</div>

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 :

```auto
...
filter {
    mutate {
        add_field => { "_parent" => "%{_id}" }
        remove_field => ["@timestamp","message","@version","host","path"]
        convert => ["goals", "integer"]
    }
}

```

```auto
output {
    elasticsearch {
        hosts => ["localhost:9202"]
        index => "myindex"
        document_type => "mychildtype"
        document_id => "%{_id}"
    }
    stdout { codec => rubydebug }
}

```

Is there a solution to solve this problem ?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 22, 2015, 3:25pm UTC](https://discuss.elastic.co/t/cant-retrieve-a-document-with-its--id/37763/4 "2015-12-22T15:25:26Z")

</div>

> [@fchantrel](#):
>
> Is there a solution to solve this problem ?

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

---

<div class="post-metadata">

**Author:** ![fchantrel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fchantrel/32/6204_2.png) [@fchantrel](https://discuss.elastic.co/u/fchantrel)\
**Post date:** [December 22, 2015, 3:30pm UTC](https://discuss.elastic.co/t/cant-retrieve-a-document-with-its--id/37763/5 "2015-12-22T15:30:28Z")

</div>

Thanks I'm going to try the logstash subforum.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:29pm UTC](https://discuss.elastic.co/t/cant-retrieve-a-document-with-its--id/37763/6 "2017-07-05T23:29:15Z")

</div>


