# Has child query with multiple clauses to be performed on the same child

**URL:** <https://discuss.elastic.co/t/has-child-query-with-multiple-clauses-to-be-performed-on-the-same-child/84388>\
**Category:** Elasticsearch\
**Created:** [May 3, 2017, 9:52am UTC](https://discuss.elastic.co/t/has-child-query-with-multiple-clauses-to-be-performed-on-the-same-child/84388 "2017-05-03T09:52:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LiorY89](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@LiorY89](https://discuss.elastic.co/u/LiorY89)\
**Post date:** [May 3, 2017, 9:52am UTC](https://discuss.elastic.co/t/has-child-query-with-multiple-clauses-to-be-performed-on-the-same-child/84388/1 "2017-05-03T09:52:15Z")

</div>

I have a generic code which takes my own ConditionTree class and parse it into an Elasticsearch query. For that, and because I don't know the tree's hierarchy, each condition (leaf on the tree) is parsed into an individual indices query. for example, if I have a person index, and i filter on 2 of it's properties - name and address, so the tree will look like: AND ----person.name, equals, "Dave" ----person.address, contains, "London"

and it will parsed into something like:  
GET persons/\_search  
{  
"query": {  
"bool": {  
"must": [  
{  
"indices": {  
"indices": [  
"persons"  
],  
"query": {  
"term": {  
"name": {  
"value": "Dave"  
}  
}  
},  
"no\_match\_query": "none"  
}  
},  
{  
"indices": {  
"indices": [  
"persons"  
],  
"query": {  
"term": {  
"address": {  
"value": "London"  
}  
}  
},  
"no\_match\_query": "none"  
}  
}  
]  
}  
}  
}

so far so good, the issue start with my parent-child index. I have relations index, which each parent has 2 children. if i'll do the same thing here, if one child match for one condition and the second child in the relation match another, those 2 children will be returned.

of course, if I'm putting those conditions under the same "has\_child" block so it works, but it will cause me ALOT of changes in my code because of the way i'm doing the parsing.

Is there a way in my current way to tell Elasticsearch to perform all those blocks on the SAME child?

---

<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:** [May 31, 2017, 10:01am UTC](https://discuss.elastic.co/t/has-child-query-with-multiple-clauses-to-be-performed-on-the-same-child/84388/2 "2017-05-31T10:01:52Z")

</div>

Closed on May 31, 2017, 10:01am UTC

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