# Having problem retrieving child documents with their IDs

**URL:** <https://discuss.elastic.co/t/having-problem-retrieving-child-documents-with-their-ids/11099>\
**Category:** Elasticsearch\
**Created:** [March 11, 2013, 4:15pm UTC](https://discuss.elastic.co/t/having-problem-retrieving-child-documents-with-their-ids/11099 "2013-03-11T16:15:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Walsh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_walsh/32/2447_2.png) [@Paul\_Walsh](https://discuss.elastic.co/u/Paul_Walsh)\
**Post date:** [March 11, 2013, 4:15pm UTC](https://discuss.elastic.co/t/having-problem-retrieving-child-documents-with-their-ids/11099/1 "2013-03-11T16:15:00Z")

</div>

I have an index with a parent type and a child type. The parent type gets  
stored just fine and I haven't seen any issues searching or retrieving it  
using it's ID. However I've just noticed some issues with SOME, not all, of  
the child type documents.

[http://localhost:9200/sample\_index/sample\_child\_type/\_search](http://localhost:9200/sample_index/sample_child_type/_search)

Shows all the children as expected:

{"took": 5,"timed\_out": false,"\_shards": {"total": 5,"successful": 5,"failed  
": 0},"hits": {"total": 28,"max\_score": 11.905941,"hits": [{"\_index": "  
sample\_index","\_type": "sample\_child\_type","\_id": "FfuRaL-WRWWutdglmV3gBg","  
\_score": 11.905941,"\_source": {}},{"\_index": "sample\_index","\_type": "  
sample\_child\_type","\_id": "ZoofwbnwQuKnJiElwsIVoA","\_score": 11.905941,"  
\_source": {}}

The problem can be shown with the top two results given back. They both are  
children with different parents.

If I go directly to the first child ID I get the data back:

[http://localhost:9200/sample\_index/sample\_child\_type/FfuRaL-WRWWutdglmV3gBg](http://localhost:9200/sample_index/sample_child_type/FfuRaL-WRWWutdglmV3gBg)

{"\_index": "sample\_index","\_type": "sample\_child\_type","\_id": "  
FfuRaL-WRWWutdglmV3gBg","\_version": 1,"exists": true,"\_source": {}}  
But if I go directly to the second child ID, it says it doesn't exist:

[http://localhost:9200/sample\_index/sample\_child\_type/ZoofwbnwQuKnJiElwsIVoA](http://localhost:9200/sample_index/sample_child_type/ZoofwbnwQuKnJiElwsIVoA)

{"\_index": "sample\_index","\_type": "sample\_child\_type","\_id": "  
ZoofwbnwQuKnJiElwsIVoA","exists": false}

Weirdly searching for the \_id shows the result:

[http://localhost:9200/sample\_index/sample\_child\_type/\_search?q=\_id:ZoofwbnwQuKnJiElwsIVoA](http://localhost:9200/sample_index/sample_child_type/_search?q=_id:ZoofwbnwQuKnJiElwsIVoA)

{"took": 7,"timed\_out": false,"\_shards": {"total": 5,"successful": 5,"failed  
": 0},"hits": {"total": 1,"max\_score": 1,"hits": [{"\_index": "sample\_index",  
"\_type": "sample\_child\_type","\_id": "ZoofwbnwQuKnJiElwsIVoA","\_score": 1,"  
\_source": {}}]}}  
And requesting the \_parent field shows that it is definitely a child  
document:

[http://localhost:9200/sample\_index/sample\_child\_type/\_search?q=\_id:ZoofwbnwQuKnJiElwsIVoA&fields=\_parent](http://localhost:9200/sample_index/sample_child_type/_search?q=_id:ZoofwbnwQuKnJiElwsIVoA&fields=_parent)

{"took": 2,"timed\_out": false,"\_shards": {"total": 5,"successful": 5,"failed  
": 0},"hits": {"total": 1,"max\_score": 1,"hits": [{"\_index": "sample\_index",  
"\_type": "sample\_child\_type","\_id": "ZoofwbnwQuKnJiElwsIVoA","\_score": 1,"  
fields": {"\_parent": "e15996a6d791742af47477d594c36cdb"}}]}}

The parent with that ID does exist, just in case that matters.

Does anyone know what's going wrong here, or even know where it could be  
going wrong?

Thanks in advance.

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 11, 2013, 6:53pm UTC](https://discuss.elastic.co/t/having-problem-retrieving-child-documents-with-their-ids/11099/2 "2013-03-11T18:53:38Z")

</div>

On Mon, 2013-03-11 at 09:15 -0700, Paul W wrote:

> I have an index with a parent type and a child type. The parent type  
> gets stored just fine and I haven't seen any issues searching or  
> retrieving it using it's ID. However I've just noticed some issues  
> with SOME, not all, of the child type documents.

You need to specify the parent ID when you GET the child. The parent ID  
determines which shard the child is on. If you don't specify the parent  
ID, then is uses the child ID, which will be wrong 80% of the time  
(assuming 5 primary shards)

clint

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:47am UTC](https://discuss.elastic.co/t/having-problem-retrieving-child-documents-with-their-ids/11099/3 "2017-07-06T02:47:07Z")

</div>


