Search code examples
javaelasticsearchelasticsearch-high-level-restclient

How to use "has_child" in the Rest High Level Client of ElasticSearch


I want to issue the following search query in ElasticSearch.

GET /example1/_search
{
  "query": {
    "has_child": {
      "type": "schedule",
      "query": {
        "bool": {}
      },
      "inner_hits": {},
      "max_children": 10,
      "min_children": 1,
      "score_mode": "min"
    }
  }
}

How do I write the above query in the Rest High Level Client in Java?


Solution

  • Use HasChildQueryBuilder.

    Official documentation.