summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Aggregation
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Aggregation')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php88
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php33
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php14
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php14
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php82
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php21
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php41
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php90
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php61
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php55
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php66
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php31
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php31
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php45
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php50
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php97
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php31
23 files changed, 928 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php
new file mode 100644
index 00000000..5ad5b17e
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php
@@ -0,0 +1,88 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+use Elastica\Param;
+use Elastica\Exception\InvalidException;
+
+abstract class AbstractAggregation extends Param
+{
+ /**
+ * The name of this aggregation
+ * @var string
+ */
+ protected $_name;
+
+ /**
+ * Subaggregations belonging to this aggregation
+ * @var array
+ */
+ protected $_aggs = array();
+
+ /**
+ * @param string $name the name of this aggregation
+ */
+ public function __construct($name)
+ {
+ $this->setName($name);
+ }
+
+ /**
+ * Set the name of this aggregation
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ $this->_name = $name;
+ }
+
+ /**
+ * Retrieve the name of this aggregation
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->_name;
+ }
+
+ /**
+ * Retrieve all subaggregations belonging to this aggregation
+ * @return array
+ */
+ public function getAggs()
+ {
+ return $this->_aggs;
+ }
+
+ /**
+ * Add a sub-aggregation
+ * @param AbstractAggregation $aggregation
+ * @throws \Elastica\Exception\InvalidException
+ * @return AbstractAggregation
+ */
+ public function addAggregation(AbstractAggregation $aggregation)
+ {
+ if(is_a($aggregation, 'Elastica\Aggregation\GlobalAggregation')) {
+ throw new InvalidException('Global aggregators can only be placed as top level aggregators');
+ }
+
+ $this->_aggs[$aggregation->getName()] = $aggregation->toArray();
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = parent::toArray();
+ if (array_key_exists('global_aggregation', $array)) {
+ // compensate for class name GlobalAggregation
+ $array = array('global' => new \stdClass);
+ }
+ if (sizeof($this->_aggs)) {
+ $array['aggs'] = $this->_aggs;
+ }
+ return $array;
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php
new file mode 100644
index 00000000..af7c1940
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+
+use Elastica\Script;
+
+abstract class AbstractSimpleAggregation extends AbstractAggregation
+{
+ /**
+ * Set the field for this aggregation
+ * @param string $field the name of the document field on which to perform this aggregation
+ * @return AbstractSimpleAggregation
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', $field);
+ }
+
+ /**
+ * Set a script for this aggregation
+ * @param string|Script $script
+ * @return AbstractSimpleAggregation
+ */
+ public function setScript($script)
+ {
+ if ($script instanceof Script) {
+ $this->setParam('params', $script->getParams());
+ $script = $script->getScript();
+ }
+ return $this->setParam('script', $script);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php
new file mode 100644
index 00000000..0d601910
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+
+/**
+ * Class Avg
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-avg-aggregation.html
+ */
+class Avg extends AbstractSimpleAggregation
+{
+
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php
new file mode 100644
index 00000000..061ddafa
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+
+/**
+ * Class Cardinality
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
+ */
+class Cardinality extends AbstractSimpleAggregation
+{
+
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php
new file mode 100644
index 00000000..889fa429
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php
@@ -0,0 +1,82 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class DateHistogram
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-datehistogram-aggregation.html
+ */
+class DateHistogram extends Histogram
+{
+ /**
+ * Set pre-rounding based on interval
+ * @param string $preZone
+ * @return DateHistogram
+ */
+ public function setPreZone($preZone)
+ {
+ return $this->setParam("pre_zone", $preZone);
+ }
+
+ /**
+ * Set post-rounding based on interval
+ * @param string $postZone
+ * @return DateHistogram
+ */
+ public function setPostZone($postZone)
+ {
+ return $this->setParam("post_zone", $postZone);
+ }
+
+ /**
+ * Set pre-zone adjustment for larger time intervals (day and above)
+ * @param string $adjust
+ * @return DateHistogram
+ */
+ public function setPreZoneAdjustLargeInterval($adjust)
+ {
+ return $this->setParam("pre_zone_adjust_large_interval", $adjust);
+ }
+
+ /**
+ * Adjust for granularity of date data
+ * @param int $factor set to 1000 if date is stored in seconds rather than milliseconds
+ * @return DateHistogram
+ */
+ public function setFactor($factor)
+ {
+ return $this->setParam("factor", $factor);
+ }
+
+ /**
+ * Set the offset for pre-rounding
+ * @param string $offset "1d", for example
+ * @return DateHistogram
+ */
+ public function setPreOffset($offset)
+ {
+ return $this->setParam("pre_offset", $offset);
+ }
+
+ /**
+ * Set the offset for post-rounding
+ * @param string $offset "1d", for example
+ * @return DateHistogram
+ */
+ public function setPostOffset($offset)
+ {
+ return $this->setParam("post_offset", $offset);
+ }
+
+ /**
+ * Set the format for returned bucket key_as_string values
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern
+ * @param string $format see link for formatting options
+ * @return DateHistogram
+ */
+ public function setFormat($format)
+ {
+ return $this->setParam("format", $format);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php
new file mode 100644
index 00000000..37aca87b
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class DateRange
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html
+ */
+class DateRange extends Range
+{
+ /**
+ * Set the formatting for the returned date values
+ * @param string $format see documentation for formatting options
+ * @return Range
+ */
+ public function setFormat($format)
+ {
+ return $this->setParam('format', $format);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php
new file mode 100644
index 00000000..4aef8a32
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class ExtendedStats
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-extendedstats-aggregation.html
+ */
+class ExtendedStats extends AbstractSimpleAggregation
+{
+
+} \ No newline at end of file
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..c2326ffe
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+
+use Elastica\Filter\AbstractFilter;
+
+/**
+ * Class Filter
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-filter-aggregation.html
+ */
+class Filter extends AbstractAggregation
+{
+ /**
+ * Set the filter for this aggregation
+ * @param AbstractFilter $filter
+ * @return Filter
+ */
+ 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;
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php
new file mode 100644
index 00000000..76c871ea
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php
@@ -0,0 +1,90 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Class GeoDistance
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-geodistance-aggregation.html
+ */
+class GeoDistance extends AbstractAggregation
+{
+ const DISTANCE_TYPE_SLOPPY_ARC = "sloppy_arc";
+ const DISTANCE_TYPE_ARC = "arc";
+ const DISTANCE_TYPE_PLANE = "plane";
+
+ /**
+ * @param string $name the name if this aggregation
+ * @param string $field the field on which to perform this aggregation
+ * @param string|array $origin the point from which distances will be calculated
+ */
+ public function __construct($name, $field, $origin)
+ {
+ parent::__construct($name);
+ $this->setField($field)->setOrigin($origin);
+ }
+
+ /**
+ * Set the field for this aggregation
+ * @param string $field the name of the document field on which to perform this aggregation
+ * @return GeoDistance
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', $field);
+ }
+
+ /**
+ * Set the origin point from which distances will be calculated
+ * @param string|array $origin valid formats are array("lat" => 52.3760, "lon" => 4.894), "52.3760, 4.894", and array(4.894, 52.3760)
+ * @return GeoDistance
+ */
+ public function setOrigin($origin)
+ {
+ return $this->setParam("origin", $origin);
+ }
+
+ /**
+ * Add a distance range to this aggregation
+ * @param int $fromValue a distance
+ * @param int $toValue a distance
+ * @return GeoDistance
+ * @throws \Elastica\Exception\InvalidException
+ */
+ public function addRange($fromValue = null, $toValue = null)
+ {
+ if (is_null($fromValue) && is_null($toValue)) {
+ throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null.");
+ }
+ $range = array();
+ if (!is_null($fromValue)) {
+ $range['from'] = $fromValue;
+ }
+ if (!is_null($toValue)) {
+ $range['to'] = $toValue;
+ }
+ return $this->addParam("ranges", $range);
+ }
+
+ /**
+ * Set the unit of distance measure for this aggregation
+ * @param string $unit defaults to km
+ * @return GeoDistance
+ */
+ public function setUnit($unit)
+ {
+ return $this->setParam("unit", $unit);
+ }
+
+ /**
+ * Set the method by which distances will be calculated
+ * @param string $distanceType see DISTANCE_TYPE_* constants for options. Defaults to sloppy_arc.
+ * @return GeoDistance
+ */
+ public function setDistanceType($distanceType)
+ {
+ return $this->setParam("distance_type", $distanceType);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php
new file mode 100644
index 00000000..840198c3
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class GeohashGrid
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-geohashgrid-aggregation.html
+ */
+class GeohashGrid extends AbstractAggregation
+{
+ /**
+ * @param string $name the name of this aggregation
+ * @param string $field the field on which to perform this aggregation
+ */
+ public function __construct($name, $field)
+ {
+ parent::__construct($name);
+ $this->setField($field);
+ }
+
+ /**
+ * Set the field for this aggregation
+ * @param string $field the name of the document field on which to perform this aggregation
+ * @return GeohashGrid
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', $field);
+ }
+
+ /**
+ * Set the precision for this aggregation
+ * @param int $precision an integer between 1 and 12, inclusive. Defaults to 5.
+ * @return GeohashGrid
+ */
+ public function setPrecision($precision)
+ {
+ return $this->setParam("precision", $precision);
+ }
+
+ /**
+ * Set the maximum number of buckets to return
+ * @param int $size defaults to 10,000
+ * @return GeohashGrid
+ */
+ public function setSize($size)
+ {
+ return $this->setParam("size", $size);
+ }
+
+ /**
+ * Set the number of results returned from each shard
+ * @param int $shardSize
+ * @return GeohashGrid
+ */
+ public function setShardSize($shardSize)
+ {
+ return $this->setParam("shard_size", $shardSize);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php
new file mode 100644
index 00000000..72b56880
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class GlobalAggregation
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-global-aggregation.html
+ */
+class GlobalAggregation extends AbstractAggregation
+{
+
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php
new file mode 100644
index 00000000..26fa7c44
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class Histogram
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-histogram-aggregation.html
+ */
+class Histogram extends AbstractSimpleAggregation
+{
+ /**
+ * @param string $name the name of this aggregation
+ * @param string $field the name of the field on which to perform the aggregation
+ * @param int $interval the interval by which documents will be bucketed
+ */
+ public function __construct($name, $field, $interval)
+ {
+ parent::__construct($name);
+ $this->setField($field);
+ $this->setInterval($interval);
+ }
+
+
+ /**
+ * Set the interval by which documents will be bucketed
+ * @param int $interval
+ * @return Histogram
+ */
+ public function setInterval($interval)
+ {
+ return $this->setParam("interval", $interval);
+ }
+
+ /**
+ * Set the bucket sort order
+ * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
+ * @param string $direction "asc" or "desc"
+ * @return Histogram
+ */
+ public function setOrder($order, $direction)
+ {
+ return $this->setParam("order", array($order => $direction));
+ }
+
+ /**
+ * Set the minimum number of documents which must fall into a bucket in order for the bucket to be returned
+ * @param int $count set to 0 to include empty buckets
+ * @return Histogram
+ */
+ public function setMinimumDocumentCount($count)
+ {
+ return $this->setParam("min_doc_count", $count);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php
new file mode 100644
index 00000000..18e60bfb
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Class IpRange
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-iprange-aggregation.html
+ */
+class IpRange extends AbstractAggregation
+{
+ /**
+ * @param string $name the name of this aggregation
+ * @param string $field the field on which to perform this aggregation
+ */
+ public function __construct($name, $field)
+ {
+ parent::__construct($name);
+ $this->setField($field);
+ }
+
+ /**
+ * Set the field for this aggregation
+ * @param string $field the name of the document field on which to perform this aggregation
+ * @return IpRange
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', $field);
+ }
+
+ /**
+ * Add an ip range to this aggregation
+ * @param string $fromValue a valid ipv4 address. Low end of this range, exclusive (greater than)
+ * @param string $toValue a valid ipv4 address. High end of this range, exclusive (less than)
+ * @return IpRange
+ * @throws \Elastica\Exception\InvalidException
+ */
+ public function addRange($fromValue = null, $toValue = null)
+ {
+ if (is_null($fromValue) && is_null($toValue)) {
+ throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null.");
+ }
+ $range = array();
+ if (!is_null($fromValue)) {
+ $range['from'] = $fromValue;
+ }
+ if (!is_null($toValue)) {
+ $range['to'] = $toValue;
+ }
+ return $this->addParam('ranges', $range);
+ }
+
+ /**
+ * Add an ip range in the form of a CIDR mask
+ * @param string $mask a valid CIDR mask
+ * @return IpRange
+ */
+ public function addMaskRange($mask)
+ {
+ return $this->addParam("ranges", array("mask" => $mask));
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php
new file mode 100644
index 00000000..25031b04
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class Max
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-max-aggregation.html
+ */
+class Max extends AbstractSimpleAggregation
+{
+
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php
new file mode 100644
index 00000000..60aabb56
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class Min
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-min-aggregation.html
+ */
+class Min extends AbstractSimpleAggregation
+{
+
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php
new file mode 100644
index 00000000..b882aba0
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class Missing
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-missing-aggregation.html
+ */
+class Missing extends AbstractAggregation
+{
+ /**
+ * @param string $name the name of this aggregation
+ * @param string $field the field on which to perform this aggregation
+ */
+ public function __construct($name, $field)
+ {
+ parent::__construct($name);
+ $this->setField($field);
+ }
+
+ /**
+ * Set the field for this aggregation
+ * @param string $field the name of the document field on which to perform this aggregation
+ * @return Missing
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', $field);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php
new file mode 100644
index 00000000..afbb8373
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class Nested
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-nested-aggregation.html
+ */
+class Nested extends AbstractAggregation
+{
+ /**
+ * @param string $name the name of this aggregation
+ * @param string $path the nested path for this aggregation
+ */
+ public function __construct($name, $path)
+ {
+ parent::__construct($name);
+ $this->setPath($path);
+ }
+
+ /**
+ * Set the nested path for this aggregation
+ * @param string $path
+ * @return Nested
+ */
+ public function setPath($path)
+ {
+ return $this->setParam("path", $path);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
new file mode 100644
index 00000000..ab70c5e4
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
@@ -0,0 +1,45 @@
+<?php
+namespace Elastica\Aggregation;
+
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Class Range
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-range-aggregation.html
+ */
+class Range extends AbstractSimpleAggregation
+{
+ /**
+ * Add a range to this aggregation
+ * @param int|float $fromValue low end of this range, exclusive (greater than)
+ * @param int|float $toValue high end of this range, exclusive (less than)
+ * @return Range
+ * @throws \Elastica\Exception\InvalidException
+ */
+ public function addRange($fromValue = null, $toValue = null)
+ {
+ if (is_null($fromValue) && is_null($toValue)) {
+ throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null.");
+ }
+ $range = array();
+ if (!is_null($fromValue)) {
+ $range['from'] = $fromValue;
+ }
+ if (!is_null($toValue)) {
+ $range['to'] = $toValue;
+ }
+ return $this->addParam('ranges', $range);
+ }
+
+ /**
+ * If set to true, a unique string key will be associated with each bucket, and ranges will be returned as an associative array
+ * @param bool $keyed
+ * @return Range
+ */
+ public function setKeyedResponse($keyed = true)
+ {
+ return $this->setParam('keyed', (bool)$keyed);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php
new file mode 100644
index 00000000..d4056f13
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Reversed Nested Aggregation
+ *
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
+ */
+class ReverseNested extends AbstractAggregation
+{
+ /**
+ * @param string $name The name of this aggregation
+ * @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document.
+ */
+ public function __construct($name, $path = null)
+ {
+ parent::__construct($name);
+
+ if ($path !== null) {
+ $this->setPath($path);
+ }
+ }
+
+ /**
+ * Set the nested path for this aggregation
+ *
+ * @param string $path
+ * @return ReverseNested
+ */
+ public function setPath($path)
+ {
+ return $this->setParam("path", $path);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function toArray()
+ {
+ $array = parent::toArray();
+
+ // ensure we have an object for the reverse_nested key.
+ // if we don't have a path, then this would otherwise get encoded as an empty array, which is invalid.
+ $array['reverse_nested'] = (object)$array['reverse_nested'];
+
+ return $array;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php
new file mode 100644
index 00000000..18c903e9
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class Stats
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-stats-aggregation.html
+ */
+class Stats extends AbstractSimpleAggregation
+{
+
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php
new file mode 100644
index 00000000..4d1ef4de
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class Sum
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-sum-aggregation.html
+ */
+class Sum extends AbstractSimpleAggregation
+{
+
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php
new file mode 100644
index 00000000..9ede855c
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php
@@ -0,0 +1,97 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class Terms
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-terms-aggregation.html
+ */
+class Terms extends AbstractSimpleAggregation
+{
+ /**
+ * Set the bucket sort order
+ * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
+ * @param string $direction "asc" or "desc"
+ * @return Terms
+ */
+ public function setOrder($order, $direction)
+ {
+ return $this->setParam("order", array($order => $direction));
+ }
+
+ /**
+ * Set the minimum number of documents in which a term must appear in order to be returned in a bucket
+ * @param int $count
+ * @return Terms
+ */
+ public function setMinimumDocumentCount($count)
+ {
+ return $this->setParam("min_doc_count", $count);
+ }
+
+ /**
+ * Filter documents to include based on a regular expression
+ * @param string $pattern a regular expression
+ * @param string $flags Java Pattern flags
+ * @return Terms
+ */
+ public function setInclude($pattern, $flags = null)
+ {
+ if (is_null($flags)) {
+ return $this->setParam("include", $pattern);
+ }
+ return $this->setParam("include", array(
+ "pattern" => $pattern,
+ "flags" => $flags
+ ));
+ }
+
+ /**
+ * Filter documents to exclude based on a regular expression
+ * @param string $pattern a regular expression
+ * @param string $flags Java Pattern flags
+ * @return Terms
+ */
+ public function setExclude($pattern, $flags = null)
+ {
+ if (is_null($flags)) {
+ return $this->setParam("exclude", $pattern);
+ }
+ return $this->setParam("exclude", array(
+ "pattern" => $pattern,
+ "flags" => $flags
+ ));
+ }
+
+ /**
+ * Sets the amount of terms to be returned.
+ * @param int $size The amount of terms to be returned.
+ * @return \Elastica\Aggregation\Terms
+ */
+ public function setSize($size)
+ {
+ return $this->setParam('size', $size);
+ }
+
+ /**
+ * Sets how many terms the coordinating node will request from each shard.
+ * @param int $shard_size The amount of terms to be returned.
+ * @return \Elastica\Aggregation\Terms
+ */
+ public function setShardSize($shard_size)
+ {
+ return $this->setParam('shard_size', $shard_size);
+ }
+
+ /**
+ * Instruct Elasticsearch to use direct field data or ordinals of the field values to execute this aggregation.
+ * The execution hint will be ignored if it is not applicable.
+ * @param string $hint map or ordinals
+ * @return Terms
+ */
+ public function setExecutionHint($hint)
+ {
+ return $this->setParam("execution_hint", $hint);
+ }
+} \ No newline at end of file
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php
new file mode 100644
index 00000000..36fb2a2c
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Elastica\Aggregation;
+
+/**
+ * Class ValueCount
+ * @package Elastica\Aggregation
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-valuecount-aggregation.html
+ */
+class ValueCount extends AbstractAggregation
+{
+ /**
+ * @param string $name the name of this aggregation
+ * @param string $field the field on which to perform this aggregation
+ */
+ public function __construct($name, $field)
+ {
+ parent::__construct($name);
+ $this->setField($field);
+ }
+
+ /**
+ * Set the field for this aggregation
+ * @param string $field the name of the document field on which to perform this aggregation
+ * @return ValueCount
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', $field);
+ }
+} \ No newline at end of file