summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
new file mode 100644
index 00000000..fc83419e
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
@@ -0,0 +1,53 @@
+<?php
+namespace Elastica\Aggregation;
+
+use Elastica\Filter\AbstractFilter;
+
+/**
+ * Class Filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
+ */
+class Filter extends AbstractAggregation
+{
+ /**
+ * @param string $name
+ * @param AbstractFilter $filter
+ */
+ public function __construct($name, AbstractFilter $filter = null)
+ {
+ parent::__construct($name);
+
+ if ($filter !== null) {
+ $this->setFilter($filter);
+ }
+ }
+
+ /**
+ * Set the filter for this aggregation.
+ *
+ * @param AbstractFilter $filter
+ *
+ * @return $this
+ */
+ public function setFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('filter', $filter->toArray());
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = array(
+ 'filter' => $this->getParam('filter'),
+ );
+
+ if ($this->_aggs) {
+ $array['aggs'] = $this->_aggs;
+ }
+
+ return $array;
+ }
+}