# \_parent not returned by search

**URL:** <https://discuss.elastic.co/t/-parent-not-returned-by-search/3833>\
**Category:** Elasticsearch\
**Created:** [January 27, 2011, 6:35pm UTC](https://discuss.elastic.co/t/-parent-not-returned-by-search/3833 "2011-01-27T18:35:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![byuva](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@byuva](https://discuss.elastic.co/u/byuva)\
**Post date:** [January 27, 2011, 6:35pm UTC](https://discuss.elastic.co/t/-parent-not-returned-by-search/3833/1 "2011-01-27T18:35:43Z")

</div>

I am performing a search on objects which have parents. I don't actually need the parent object just its id (and the contents of the child). I expected this to be returned in the query results (along with \_id) and can't seem to find an alternative way of obtaining it.

-b

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 28, 2011, 9:31pm UTC](https://discuss.elastic.co/t/-parent-not-returned-by-search/3833/2 "2011-01-28T21:31:13Z")

</div>

If you ask the \_parent in the fields (and possibly \_source), you should get it back, no?  
On Thursday, January 27, 2011 at 8:35 PM, byuva wrote:

> I am performing a search on objects which have parents. I don't actually  
> need the parent object just its id (and the contents of the child). I  
> expected this to be returned in the query results (along with \_id) and can't  
> seem to find an alternative way of obtaining it.
> 
> -b
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/parent-not-returned-by-search-tp2363469p2363469.html](http://elasticsearch-users.115913.n3.nabble.com/parent-not-returned-by-search-tp2363469p2363469.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![byuva](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@byuva](https://discuss.elastic.co/u/byuva)\
**Post date:** [January 30, 2011, 5:46pm UTC](https://discuss.elastic.co/t/-parent-not-returned-by-search/3833/3 "2011-01-30T17:46:53Z")

</div>

Yes, it seems to be working now that I specified \_parent in "fields". My initial reaction was that when no fields are specified I would expect "\_parent" to be returned just like \_id and \_source. I viewed fields as a way to restrict what is returned, not add to it. It is certainly not difficult to specify this in fields although I note that pyes doesn't currently allow fields to be specified everywhere (eg get). I'll see if I can create a pull request for this for aparo.

-brian

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 30, 2011, 5:48pm UTC](https://discuss.elastic.co/t/-parent-not-returned-by-search/3833/4 "2011-01-30T17:48:24Z")

</div>

By default, only \_id, \_type and \_source are returned. Parent is not on the same level as \_id, so you need to explicitly ask for it.  
On Sunday, January 30, 2011 at 7:46 PM, byuva wrote:

> Yes, it seems to be working now that I specified \_parent in "fields". My  
> initial reaction was that when no fields are specified I would expect  
> "\_parent" to be returned just like \_id and \_source. I viewed fields as a  
> way to restrict what is returned, not add to it. It is certainly not  
> difficult to specify this in fields although I note that pyes doesn't  
> currently allow fields to be specified everywhere (eg get). I'll see if I  
> can create a pull request for this for aparo.
> 
> ## -brian
> 
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/parent-not-returned-by-search-tp2363469p2384351.html](http://elasticsearch-users.115913.n3.nabble.com/parent-not-returned-by-search-tp2363469p2384351.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![byuva](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@byuva](https://discuss.elastic.co/u/byuva)\
**Post date:** [February 4, 2011, 11:28pm UTC](https://discuss.elastic.co/t/-parent-not-returned-by-search/3833/5 "2011-02-04T23:28:30Z")

</div>

I am a bit surprised as it seems most of the other fields submitted  
with the record are returned by default (although I can also see the  
argument that it is not always present). Are there any other fields  
that can be added? Perhaps a bit more in the documentation would  
help. It can be a bit confusing knowing what field to use when parent  
is "parent" when url\_encoded and "\_parent" when posted.

-brian

On Jan 30, 12:48 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> By default, only \_id, \_type and \_source are returned. Parent is not on the same level as \_id, so you need to explicitly ask for it.
> 
> On Sunday, January 30, 2011 at 7:46 PM, byuva wrote:
> 
> > Yes, it seems to be working now that I specified \_parent in "fields". My  
> > initial reaction was that when no fields are specified I would expect  
> > "\_parent" to be returned just like \_id and \_source. I viewed fields as a  
> > way to restrict what is returned, not add to it. It is certainly not  
> > difficult to specify this in fields although I note that pyes doesn't  
> > currently allow fields to be specified everywhere (eg get). I'll see if I  
> > can create a pull request for this for aparo.
> 
> > ## -brian
> > 
> > View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/parent-not-returned-b](http://elasticsearch-users.115913.n3.nabble.com/parent-not-returned-b)...  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 7, 2011, 6:08pm UTC](https://discuss.elastic.co/t/-parent-not-returned-by-search/3833/6 "2011-02-07T18:08:53Z")

</div>

Its done for performance reasons, you don't want the \_parent all the times. The other one that is also automatically stored and is fetchable is \_routing (if used).  
On Saturday, February 5, 2011 at 1:28 AM, merrellb wrote:

> I am a bit surprised as it seems most of the other fields submitted  
> with the record are returned by default (although I can also see the  
> argument that it is not always present). Are there any other fields  
> that can be added? Perhaps a bit more in the documentation would  
> help. It can be a bit confusing knowing what field to use when parent  
> is "parent" when url\_encoded and "\_parent" when posted.
> 
> -brian
> 
> On Jan 30, 12:48 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > By default, only \_id, \_type and \_source are returned. Parent is not on the same level as \_id, so you need to explicitly ask for it.
> > 
> > On Sunday, January 30, 2011 at 7:46 PM, byuva wrote:
> > 
> > > Yes, it seems to be working now that I specified \_parent in "fields". My  
> > > initial reaction was that when no fields are specified I would expect  
> > > "\_parent" to be returned just like \_id and \_source. I viewed fields as a  
> > > way to restrict what is returned, not add to it. It is certainly not  
> > > difficult to specify this in fields although I note that pyes doesn't  
> > > currently allow fields to be specified everywhere (eg get). I'll see if I  
> > > can create a pull request for this for aparo.
> > 
> > > ## -brian
> > > 
> > > View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/parent-not-returned-b](http://elasticsearch-users.115913.n3.nabble.com/parent-not-returned-b)...  
> > > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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, 4:12am UTC](https://discuss.elastic.co/t/-parent-not-returned-by-search/3833/7 "2017-07-06T04:12:29Z")

</div>


