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

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?

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