diff --git a/docs/Filter/HasParent.md b/docs/Filter/HasParent.md new file mode 100644 index 0000000000000000000000000000000000000000..23f6de0c5c894fd1d60f2bc596bffe0dbbeb660b --- /dev/null +++ b/docs/Filter/HasParent.md @@ -0,0 +1,38 @@ +# Has Parent Filter + +> More info about has parent filter is in the [official elasticsearch docs][1] + +The has parent filter accepts a query and a parent type. +The query is executed in the parent document space, which is specified by the parent type. +This filter returns child documents which associated parents have matched. + +## Simple example + +{ + "has_child" : { + "type" : "blog_tag", + "query" : { + "term" : { + "tag" : "something" + } + } + } +} +``` + +And now the query via DSL: + +```php +$termQuery = new TermQuery('tag', 'something'); +$hasParentFilter = new HasParentFilter( + 'blog', + $termQuery +); + +$search = new Search(); +$search->addFilter($hasParentFilter); + +$queryArray = $search->toArray(); +``` + +[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-filter.html