# Has Parent and sorting on a parent's properties

**URL:** <https://discuss.elastic.co/t/has-parent-and-sorting-on-a-parents-properties/12906>\
**Category:** Elasticsearch\
**Created:** [July 23, 2013, 4:35pm UTC](https://discuss.elastic.co/t/has-parent-and-sorting-on-a-parents-properties/12906 "2013-07-23T16:35:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [July 23, 2013, 4:35pm UTC](https://discuss.elastic.co/t/has-parent-and-sorting-on-a-parents-properties/12906/1 "2013-07-23T16:35:58Z")

</div>

With a Has Parent filter or query, is there a way to sort on one or more of  
the parent's properties?

I've tried using a sorting script, but all of my attempts generated errors.  
E.g.  
"script": "doc.\_parent['number'].value",  
"script": "doc.parent['number'].value",

```
"script": "doc['_parent']['number'].value",
"script": "doc['parent']['number'].value",

```

Thanks!  
Nick

--  
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:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [July 24, 2013, 9:36am UTC](https://discuss.elastic.co/t/has-parent-and-sorting-on-a-parents-properties/12906/2 "2013-07-24T09:36:06Z")

</div>

This isn't possible via script sorting. However this possible via the  
custom\_score query:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

I'll need to include this query as inner query in the has\_parent query.

On 23 July 2013 18:35, Nick Hoffman [nick@deadorange.com](mailto:nick@deadorange.com) wrote:

> With a Has Parent filter or query, is there a way to sort on one or more  
> of the parent's properties?
> 
> I've tried using a sorting script, but all of my attempts generated  
> errors. E.g.  
> "script": "doc.\_parent['number'].value",  
> "script": "doc.parent['number'].value",
> 
> ```
> "script": "doc['_parent']['number'].value",
> "script": "doc['parent']['number'].value",
> 
> ```
> 
> Thanks!  
> Nick
> 
> --  
> 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).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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:24am UTC](https://discuss.elastic.co/t/has-parent-and-sorting-on-a-parents-properties/12906/3 "2017-07-06T02:24:48Z")

</div>


