summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php63
1 files changed, 40 insertions, 23 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php b/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
index e8c6ab96..2c4cc0d6 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
@@ -1,22 +1,20 @@
<?php
-
namespace Elastica\Filter;
/**
- * Returns parent documents having child docs matching the query
+ * Returns parent documents having child docs matching the query.
*
- * @category Xodoa
- * @package Elastica
* @author Fabian Vogler <fabian@equivalence.ch>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/has-child-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html
*/
class HasChild extends AbstractFilter
{
/**
- * Construct HasChild filter
+ * Construct HasChild filter.
*
* @param string|\Elastica\Query|\Elastica\Filter\AbstractFilter $query Query string or a Elastica\Query object or a filter
- * @param string $type Parent document type
+ * @param string|\Elastica\Type $type Child document type
*/
public function __construct($query, $type = null)
{
@@ -29,10 +27,11 @@ class HasChild extends AbstractFilter
}
/**
- * Sets query object
+ * Sets query object.
*
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Filter\HasChild Current object
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
*/
public function setQuery($query)
{
@@ -43,36 +42,54 @@ class HasChild extends AbstractFilter
}
/**
- * Sets the filter object
+ * Sets the filter object.
*
* @param \Elastica\Filter\AbstractFilter $filter
- * @return \Elastica\Filter\HasChild Current object
+ *
+ * @return $this
*/
public function setFilter($filter)
{
- $data = $filter->toArray();
- return $this->setParam('filter', $data);
+ return $this->setParam('filter', $filter->toArray());
}
/**
- * Set type of the parent document
+ * Set type of the child document.
*
- * @param string $type Parent document type
- * @return \Elastica\Filter\HasChild Current object
+ * @param string|\Elastica\Type $type Child document type
+ *
+ * @return $this
*/
public function setType($type)
{
- return $this->setParam('type', $type);
+ if ($type instanceof \Elastica\Type) {
+ $type = $type->getName();
+ }
+
+ return $this->setParam('type', (string) $type);
}
/**
- * Sets the scope
+ * Set minimum number of children are required to match for the parent doc to be considered a match.
+ *
+ * @param int $count
+ *
+ * @return $this
+ */
+ public function setMinimumChildrenCount($count)
+ {
+ return $this->setParam('min_children', (int) $count);
+ }
+
+ /**
+ * Set maximum number of children are required to match for the parent doc to be considered a match.
+ *
+ * @param int $count
*
- * @param string $scope Scope
- * @return \Elastica\Filter\HasChild Current object
+ * @return $this
*/
- public function setScope($scope)
+ public function setMaximumChildrenCount($count)
{
- return $this->setParam('_scope', $scope);
+ return $this->setParam('max_children', (int) $count);
}
}