# Is it possible to sort by values of different children?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-sort-by-values-of-different-children/119989
**Category:** Elasticsearch
**Created:** [February 15, 2018, 1:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-by-values-of-different-children/119989 "2018-02-15T13:14:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mpritsch](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@mpritsch](https://discuss.elastic.co/u/mpritsch)
#### Post date: [February 15, 2018, 1:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-by-values-of-different-children/119989/1 "2018-02-15T13:14:12Z")

</div>

We already managed to sort the parent by values of a single child using this workaround ([https://www.elastic.co/guide/en/elasticsearch/reference/6.2/query-dsl-has-child-query.html#\_sorting](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/query-dsl-has-child-query.html#_sorting)).  
Now we want to sort the parent entries by values of 2 different child types as follows:

parent\_score = value\_of\_child\_1 / value\_of\_child\_2

Is it be possible to temporarily store the values of the children (maybe via painless scripts) and use them both in a function\_score query later?

We know that storing the pre-calculated values of the children in a new child type would solve this. But this is a bad solution for our use-case, as it introduces a big synchronization and management overhead on the application side.

---

<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: [March 15, 2018, 1:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-by-values-of-different-children/119989/2 "2018-03-15T13:14:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
