From 61341ab023899085fbe536b1c93491a7afcaf65b Mon Sep 17 00:00:00 2001 From: Aivaras Gotovskis <aivaras.gotovskis@ongr.io> Date: Thu, 2 Jul 2015 11:48:07 +0300 Subject: [PATCH] Add has child query doc. --- docs/Query/HasChild.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs/Query/HasChild.md diff --git a/docs/Query/HasChild.md b/docs/Query/HasChild.md new file mode 100644 index 0000000..7124bf3 --- /dev/null +++ b/docs/Query/HasChild.md @@ -0,0 +1,36 @@ +# Has child Query + +> More info about has child query is in the [official elasticsearch docs][1] + +The has child query accepts a query and the child type to run against, and results in parent documents that have child +docs matching the query. + +## Simple example + +```JSON +{ + "has_child" : { + "type" : "blog_tag", + "query" : { + "term" : { + "tag" : "something" + } + } + } +} +``` + +In DSL: + +```php +$termQuery = new TermQuery('tag', 'something'); + +$hasChildQuery = new HasChildQuery('blog_tag', $termQuery); + +$search = new Search(); +$search->addQuery($hasChildQuery); + +$queryArray = $search->toArray(); +``` + +[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html -- GitLab