Query with multiple has_children clauses

I'd like to know if it's possible to have multiple has_children clauses in one query. I've not been able to get it to work. Here's an example of what I'm trying:

GET test-index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "field1": "value1"
          }
        },
        {
          "has_child": {
            "type": "joinDocValue",
            "query": {
              "match": {
                "field2": "value2"
              }
            }
          }
        },
        {
          "has_child": {
            "type": "joinDocValue2",
            "query": {
              "match": {
                "field3": "value3"
              }
            }
          }
        }
      ]
    }
  }
}

I saw this earlier topic: Has_child query with multiple type? where @jimczi mentioned you can have only one query per child type. It's not clear to me what exactly that means though.

The has_child documentation indicates that multiple has_children clauses in one query should be possible (although slow compared to not using parent child mappings). Specifically the documentation mentions:

Each has_child query that gets added to a search request can increase query time significantly

So obviously putting multiple has_child conditions together will significantly slow down the query... but it definitely sounds possible. I'd very much like to benchmark a few different mappings use cases which essentially require multi-has_child conditions in one query. Can anyone help form the multi-has_child query that the documentation indicates is possible?

Thank you!

On re-inspection this query does work as written above.... It was the document seeding that I was messing up. :confused:

Well, if anyone needs assistance forming a multi-condition has_child query, hopefully this post's query example will still be of help to you!

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