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.php37
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php97
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php36
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php102
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php15
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php36
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php59
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php66
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php41
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php42
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php38
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Percentiles.php59
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php41
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php15
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ScriptedMetric.php82
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/SignificantTerms.php27
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php96
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php156
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php17
29 files changed, 862 insertions, 327 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php
index 5ad5b17e..4cbb6b74 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php
@@ -1,21 +1,18 @@
<?php
-
namespace Elastica\Aggregation;
-use Elastica\Param;
use Elastica\Exception\InvalidException;
+use Elastica\Param;
abstract class AbstractAggregation extends Param
{
/**
- * The name of this aggregation
- * @var string
+ * @var string The name of this aggregation
*/
protected $_name;
/**
- * Subaggregations belonging to this aggregation
- * @var array
+ * @var array Subaggregations belonging to this aggregation
*/
protected $_aggs = array();
@@ -28,16 +25,22 @@ abstract class AbstractAggregation extends Param
}
/**
- * Set the name of this aggregation
+ * Set the name of this aggregation.
+ *
* @param string $name
+ *
+ * @return $this
*/
public function setName($name)
{
$this->_name = $name;
+
+ return $this;
}
/**
- * Retrieve the name of this aggregation
+ * Retrieve the name of this aggregation.
+ *
* @return string
*/
public function getName()
@@ -46,7 +49,8 @@ abstract class AbstractAggregation extends Param
}
/**
- * Retrieve all subaggregations belonging to this aggregation
+ * Retrieve all subaggregations belonging to this aggregation.
+ *
* @return array
*/
public function getAggs()
@@ -55,18 +59,22 @@ abstract class AbstractAggregation extends Param
}
/**
- * Add a sub-aggregation
+ * Add a sub-aggregation.
+ *
* @param AbstractAggregation $aggregation
+ *
* @throws \Elastica\Exception\InvalidException
- * @return AbstractAggregation
+ *
+ * @return $this
*/
public function addAggregation(AbstractAggregation $aggregation)
{
- if(is_a($aggregation, 'Elastica\Aggregation\GlobalAggregation')) {
+ if ($aggregation instanceof GlobalAggregation) {
throw new InvalidException('Global aggregators can only be placed as top level aggregators');
}
$this->_aggs[$aggregation->getName()] = $aggregation->toArray();
+
return $this;
}
@@ -78,11 +86,12 @@ abstract class AbstractAggregation extends Param
$array = parent::toArray();
if (array_key_exists('global_aggregation', $array)) {
// compensate for class name GlobalAggregation
- $array = array('global' => new \stdClass);
+ $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
index af7c1940..02a0fddb 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php
@@ -1,16 +1,16 @@
<?php
-
namespace Elastica\Aggregation;
-
use Elastica\Script;
abstract class AbstractSimpleAggregation extends AbstractAggregation
{
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return AbstractSimpleAggregation
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -18,16 +18,20 @@ abstract class AbstractSimpleAggregation extends AbstractAggregation
}
/**
- * Set a script for this aggregation
+ * Set a script for this aggregation.
+ *
* @param string|Script $script
- * @return AbstractSimpleAggregation
+ *
+ * @return $this
*/
public function setScript($script)
{
if ($script instanceof Script) {
- $this->setParam('params', $script->getParams());
- $script = $script->getScript();
+ $params = array_merge($this->getParams(), $script->toArray());
+
+ return $this->setParams($params);
}
+
return $this->setParam('script', $script);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php
new file mode 100644
index 00000000..57b56964
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php
@@ -0,0 +1,97 @@
+<?php
+namespace Elastica\Aggregation;
+
+/**
+ * Class AbstractTermsAggergation.
+ */
+abstract class AbstractTermsAggregation extends AbstractSimpleAggregation
+{
+ /**
+ * Set the minimum number of documents in which a term must appear in order to be returned in a bucket.
+ *
+ * @param int $count
+ *
+ * @return $this
+ */
+ 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 $this
+ */
+ 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 $this
+ */
+ 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 $this
+ */
+ 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 $this
+ */
+ 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 $this
+ */
+ public function setExecutionHint($hint)
+ {
+ return $this->setParam('execution_hint', $hint);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php
index 0d601910..abc2f7a1 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php
@@ -1,14 +1,11 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
index 061ddafa..72b2e3aa 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php
@@ -1,14 +1,38 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
*/
class Cardinality extends AbstractSimpleAggregation
{
+ /**
+ * @param int $precisionThreshold
+ *
+ * @return $this
+ */
+ public function setPrecisionThreshold($precisionThreshold)
+ {
+ if (!is_int($precisionThreshold)) {
+ throw new \InvalidArgumentException('precision_threshold only supports integer values');
+ }
+
+ return $this->setParam('precision_threshold', $precisionThreshold);
+ }
+
+ /**
+ * @param bool $rehash
+ *
+ * @return $this
+ */
+ public function setRehash($rehash)
+ {
+ if (!is_bool($rehash)) {
+ throw new \InvalidArgumentException('rehash only supports boolean values');
+ }
-}
+ return $this->setParam('rehash', $rehash);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php
index 889fa429..8636f34c 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php
@@ -1,82 +1,130 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
*/
class DateHistogram extends Histogram
{
/**
- * Set pre-rounding based on interval
+ * Set pre-rounding based on interval.
+ *
+ * @deprecated Option "pre_zone" is deprecated as of ES 1.5. Use "time_zone" instead
+ *
* @param string $preZone
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPreZone($preZone)
{
- return $this->setParam("pre_zone", $preZone);
+ return $this->setParam('pre_zone', $preZone);
}
/**
- * Set post-rounding based on interval
+ * Set post-rounding based on interval.
+ *
+ * @deprecated Option "post_zone" is deprecated as of ES 1.5. Use "time_zone" instead
+ *
* @param string $postZone
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPostZone($postZone)
{
- return $this->setParam("post_zone", $postZone);
+ return $this->setParam('post_zone', $postZone);
+ }
+
+ /**
+ * Set time_zone option.
+ *
+ * @param string
+ *
+ * @return $this
+ */
+ public function setTimezone($timezone)
+ {
+ return $this->setParam('time_zone', $timezone);
}
/**
- * Set pre-zone adjustment for larger time intervals (day and above)
+ * Set pre-zone adjustment for larger time intervals (day and above).
+ *
+ * @deprecated Option "pre_zone_adjust_large_interval" is deprecated as of ES 1.5
+ *
* @param string $adjust
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPreZoneAdjustLargeInterval($adjust)
{
- return $this->setParam("pre_zone_adjust_large_interval", $adjust);
+ return $this->setParam('pre_zone_adjust_large_interval', $adjust);
}
/**
- * Adjust for granularity of date data
+ * Adjust for granularity of date data.
+ *
* @param int $factor set to 1000 if date is stored in seconds rather than milliseconds
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setFactor($factor)
{
- return $this->setParam("factor", $factor);
+ return $this->setParam('factor', $factor);
}
/**
- * Set the offset for pre-rounding
+ * Set the offset for pre-rounding.
+ *
+ * @deprecated Option "pre_offset" is deprecated as of ES 1.5. Use "offset" instead
+ *
* @param string $offset "1d", for example
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPreOffset($offset)
{
- return $this->setParam("pre_offset", $offset);
+ return $this->setParam('pre_offset', $offset);
}
/**
- * Set the offset for post-rounding
+ * Set the offset for post-rounding.
+ *
+ * @deprecated Option "post_offset" is deprecated as of ES 1.5. Use "offset" instead
+ *
* @param string $offset "1d", for example
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPostOffset($offset)
{
- return $this->setParam("post_offset", $offset);
+ return $this->setParam('post_offset', $offset);
+ }
+
+ /**
+ * Set offset option.
+ *
+ * @param string
+ *
+ * @return $this
+ */
+ public function setOffset($offset)
+ {
+ return $this->setParam('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
+ * Set the format for returned bucket key_as_string values.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern
+ *
* @param string $format see link for formatting options
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setFormat($format)
{
- return $this->setParam("format", $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
index 37aca87b..deb5881d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php
@@ -1,21 +1,22 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
*/
class DateRange extends Range
{
/**
- * Set the formatting for the returned date values
+ * Set the formatting for the returned date values.
+ *
* @param string $format see documentation for formatting options
- * @return Range
+ *
+ * @return $this
*/
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
index 4aef8a32..2b108bd1 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php
@@ -1,13 +1,11 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
index c2326ffe..fc83419e 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
@@ -1,25 +1,38 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
*/
class Filter extends AbstractAggregation
{
/**
- * Set the filter for this aggregation
+ * @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 Filter
+ *
+ * @return $this
*/
public function setFilter(AbstractFilter $filter)
{
- return $this->setParam("filter", $filter->toArray());
+ return $this->setParam('filter', $filter->toArray());
}
/**
@@ -28,14 +41,13 @@ class Filter extends AbstractAggregation
public function toArray()
{
$array = array(
- "filter" => $this->getParam("filter")
+ 'filter' => $this->getParam('filter'),
);
- if($this->_aggs)
- {
+ if ($this->_aggs) {
$array['aggs'] = $this->_aggs;
}
return $array;
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php
new file mode 100644
index 00000000..e0fbf060
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php
@@ -0,0 +1,59 @@
+<?php
+namespace Elastica\Aggregation;
+
+use Elastica\Filter\AbstractFilter;
+
+/**
+ * Class Filters.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
+ */
+class Filters extends AbstractAggregation
+{
+ /**
+ * Add a filter.
+ *
+ * If a name is given, it will be added as a key, otherwise considered as an anonymous filter
+ *
+ * @param AbstractFilter $filter
+ * @param string $name
+ *
+ * @return $this
+ */
+ public function addFilter(AbstractFilter $filter, $name = '')
+ {
+ if (empty($name)) {
+ $filterArray[] = $filter->toArray();
+ } else {
+ $filterArray[$name] = $filter->toArray();
+ }
+
+ return $this->addParam('filters', $filterArray);
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = array();
+ $filters = $this->getParam('filters');
+
+ foreach ($filters as $filter) {
+ // Detect between anonymous filters and named ones
+ $key = key($filter);
+
+ if (is_string($key)) {
+ $array['filters']['filters'][$key] = current($filter);
+ } else {
+ $array['filters']['filters'][] = current($filter);
+ }
+ }
+
+ if ($this->_aggs) {
+ $array['aggs'] = $this->_aggs;
+ }
+
+ return $array;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php
index 76c871ea..c50018a0 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php
@@ -1,23 +1,22 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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";
+ 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 $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)
@@ -27,9 +26,11 @@ class GeoDistance extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return GeoDistance
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -37,54 +38,67 @@ class GeoDistance extends AbstractAggregation
}
/**
- * Set the origin point from which distances will be calculated
+ * 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
+ *
+ * @return $this
*/
public function setOrigin($origin)
{
- return $this->setParam("origin", $origin);
+ return $this->setParam('origin', $origin);
}
/**
- * Add a distance range to this aggregation
+ * Add a distance range to this aggregation.
+ *
* @param int $fromValue a distance
- * @param int $toValue a distance
- * @return GeoDistance
+ * @param int $toValue a distance
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
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.");
+ 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);
+
+ return $this->addParam('ranges', $range);
}
/**
- * Set the unit of distance measure for this aggregation
+ * Set the unit of distance measure for this aggregation.
+ *
* @param string $unit defaults to km
- * @return GeoDistance
+ *
+ * @return $this
*/
public function setUnit($unit)
{
- return $this->setParam("unit", $unit);
+ return $this->setParam('unit', $unit);
}
/**
- * Set the method by which distances will be calculated
+ * Set the method by which distances will be calculated.
+ *
* @param string $distanceType see DISTANCE_TYPE_* constants for options. Defaults to sloppy_arc.
- * @return GeoDistance
+ *
+ * @return $this
*/
public function setDistanceType($distanceType)
{
- return $this->setParam("distance_type", $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
index 840198c3..e7a40471 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php
@@ -1,16 +1,15 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html
*/
class GeohashGrid extends AbstractAggregation
{
/**
- * @param string $name the name of this aggregation
+ * @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field)
@@ -20,9 +19,11 @@ class GeohashGrid extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return GeohashGrid
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -30,32 +31,38 @@ class GeohashGrid extends AbstractAggregation
}
/**
- * Set the precision for this aggregation
+ * Set the precision for this aggregation.
+ *
* @param int $precision an integer between 1 and 12, inclusive. Defaults to 5.
- * @return GeohashGrid
+ *
+ * @return $this
*/
public function setPrecision($precision)
{
- return $this->setParam("precision", $precision);
+ return $this->setParam('precision', $precision);
}
/**
- * Set the maximum number of buckets to return
+ * Set the maximum number of buckets to return.
+ *
* @param int $size defaults to 10,000
- * @return GeohashGrid
+ *
+ * @return $this
*/
public function setSize($size)
{
- return $this->setParam("size", $size);
+ return $this->setParam('size', $size);
}
/**
- * Set the number of results returned from each shard
+ * Set the number of results returned from each shard.
+ *
* @param int $shardSize
- * @return GeohashGrid
+ *
+ * @return $this
*/
public function setShardSize($shardSize)
{
- return $this->setParam("shard_size", $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
index 72b56880..523844d2 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php
@@ -1,13 +1,11 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
index 26fa7c44..79a8e517 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php
@@ -1,18 +1,17 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
+ * @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)
{
@@ -21,35 +20,40 @@ class Histogram extends AbstractSimpleAggregation
$this->setInterval($interval);
}
-
/**
- * Set the interval by which documents will be bucketed
+ * Set the interval by which documents will be bucketed.
+ *
* @param int $interval
- * @return Histogram
+ *
+ * @return $this
*/
public function setInterval($interval)
{
- return $this->setParam("interval", $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
+ * 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
+ *
+ * @return $this
*/
public function setOrder($order, $direction)
{
- return $this->setParam("order", array($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
+ * 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
+ *
+ * @return $this
*/
public function setMinimumDocumentCount($count)
{
- return $this->setParam("min_doc_count", $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
index 18e60bfb..7a4ef7c8 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php
@@ -1,19 +1,17 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html
*/
class IpRange extends AbstractAggregation
{
/**
- * @param string $name the name of this aggregation
+ * @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field)
@@ -23,9 +21,11 @@ class IpRange extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return IpRange
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -33,16 +33,19 @@ class IpRange extends AbstractAggregation
}
/**
- * Add an ip range to this aggregation
+ * 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
+ * @param string $toValue a valid ipv4 address. High end of this range, exclusive (less than)
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
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.");
+ throw new InvalidException('Either fromValue or toValue must be set. Both cannot be null.');
}
$range = array();
if (!is_null($fromValue)) {
@@ -51,16 +54,19 @@ class IpRange extends AbstractAggregation
if (!is_null($toValue)) {
$range['to'] = $toValue;
}
+
return $this->addParam('ranges', $range);
}
/**
- * Add an ip range in the form of a CIDR mask
+ * Add an ip range in the form of a CIDR mask.
+ *
* @param string $mask a valid CIDR mask
- * @return IpRange
+ *
+ * @return $this
*/
public function addMaskRange($mask)
{
- return $this->addParam("ranges", array("mask" => $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
index 25031b04..fc0294ca 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php
@@ -1,13 +1,11 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
index 60aabb56..d5c5c31b 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php
@@ -1,13 +1,11 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
index b882aba0..11a6bdf9 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php
@@ -1,16 +1,15 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html
*/
class Missing extends AbstractAggregation
{
/**
- * @param string $name the name of this aggregation
+ * @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field)
@@ -20,12 +19,14 @@ class Missing extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return Missing
+ *
+ * @return $this
*/
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
index afbb8373..76407bc8 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php
@@ -1,11 +1,10 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html
*/
class Nested extends AbstractAggregation
{
@@ -20,12 +19,14 @@ class Nested extends AbstractAggregation
}
/**
- * Set the nested path for this aggregation
+ * Set the nested path for this aggregation.
+ *
* @param string $path
- * @return Nested
+ *
+ * @return $this
*/
public function setPath($path)
{
- return $this->setParam("path", $path);
+ return $this->setParam('path', $path);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Percentiles.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Percentiles.php
new file mode 100644
index 00000000..22079634
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Percentiles.php
@@ -0,0 +1,59 @@
+<?php
+namespace Elastica\Aggregation;
+
+/**
+ * Class Percentiles.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html
+ */
+class Percentiles extends AbstractSimpleAggregation
+{
+ /**
+ * @param string $name the name of this aggregation
+ * @param string $field the field on which to perform this aggregation
+ */
+ public function __construct($name, $field = null)
+ {
+ parent::__construct($name);
+
+ if (!is_null($field)) {
+ $this->setField($field);
+ }
+ }
+
+ /**
+ * Set compression parameter.
+ *
+ * @param float $value
+ *
+ * @return $this
+ */
+ public function setCompression($value)
+ {
+ return $this->setParam('compression', (float) $value);
+ }
+
+ /**
+ * Set which percents must be returned.
+ *
+ * @param float[] $percents
+ *
+ * @return $this
+ */
+ public function setPercents(array $percents)
+ {
+ return $this->setParam('percents', $percents);
+ }
+
+ /**
+ * Add yet another percent to result.
+ *
+ * @param float $percent
+ *
+ * @return $this
+ */
+ public function addPercent($percent)
+ {
+ return $this->addParam('percents', (float) $percent);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
index ab70c5e4..becafb28 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
@@ -1,45 +1,58 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
+ * Add a range to this aggregation.
+ *
+ * @param int|float $fromValue low end of this range, exclusive (greater than or equal to)
+ * @param int|float $toValue high end of this range, exclusive (less than)
+ * @param string $key customized key value
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
- public function addRange($fromValue = null, $toValue = null)
+ public function addRange($fromValue = null, $toValue = null, $key = null)
{
if (is_null($fromValue) && is_null($toValue)) {
- throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null.");
+ 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;
}
+
+ if (!is_null($key)) {
+ $range['key'] = $key;
+ }
+
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
+ * 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
+ *
+ * @return $this
*/
public function setKeyedResponse($keyed = true)
{
- return $this->setParam('keyed', (bool)$keyed);
+ 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
index d4056f13..5216ae85 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php
@@ -1,12 +1,10 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Reversed Nested Aggregation
+ * Reversed Nested Aggregation.
*
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
*/
class ReverseNested extends AbstractAggregation
{
@@ -24,14 +22,15 @@ class ReverseNested extends AbstractAggregation
}
/**
- * Set the nested path for this aggregation
+ * Set the nested path for this aggregation.
*
* @param string $path
- * @return ReverseNested
+ *
+ * @return $this
*/
public function setPath($path)
{
- return $this->setParam("path", $path);
+ return $this->setParam('path', $path);
}
/**
@@ -43,7 +42,7 @@ class ReverseNested extends AbstractAggregation
// 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'];
+ $array['reverse_nested'] = (object) $array['reverse_nested'];
return $array;
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ScriptedMetric.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ScriptedMetric.php
new file mode 100644
index 00000000..3e51f056
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ScriptedMetric.php
@@ -0,0 +1,82 @@
+<?php
+namespace Elastica\Aggregation;
+
+/**
+ * Class ScriptedMetric.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html
+ */
+class ScriptedMetric extends AbstractAggregation
+{
+ /**
+ * @param string $name the name if this aggregation
+ * @param string|null $initScript Executed prior to any collection of documents
+ * @param string|null $mapScript Executed once per document collected
+ * @param string|null $combineScript Executed once on each shard after document collection is complete
+ * @param string|null $reduceScript Executed once on the coordinating node after all shards have returned their results
+ */
+ public function __construct($name, $initScript = null, $mapScript = null, $combineScript = null, $reduceScript = null)
+ {
+ parent::__construct($name);
+ if ($initScript) {
+ $this->setInitScript($initScript);
+ }
+ if ($mapScript) {
+ $this->setMapScript($mapScript);
+ }
+ if ($combineScript) {
+ $this->setCombineScript($combineScript);
+ }
+ if ($reduceScript) {
+ $this->setReduceScript($reduceScript);
+ }
+ }
+
+ /**
+ * Set the field for this aggregation.
+ *
+ * @param string $script the name of the document field on which to perform this aggregation
+ *
+ * @return $this
+ */
+ public function setCombineScript($script)
+ {
+ return $this->setParam('combine_script', $script);
+ }
+
+ /**
+ * Set the field for this aggregation.
+ *
+ * @param string $script the name of the document field on which to perform this aggregation
+ *
+ * @return $this
+ */
+ public function setInitScript($script)
+ {
+ return $this->setParam('init_script', $script);
+ }
+
+ /**
+ * Set the field for this aggregation.
+ *
+ * @param string $script the name of the document field on which to perform this aggregation
+ *
+ * @return $this
+ */
+ public function setMapScript($script)
+ {
+ return $this->setParam('map_script', $script);
+ }
+
+ /**
+ * Set the field for this aggregation.
+ *
+ * @param string $script the name of the document field on which to perform this aggregation
+ *
+ * @return $this
+ */
+ public function setReduceScript($script)
+ {
+ return $this->setParam('reduce_script', $script);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/SignificantTerms.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/SignificantTerms.php
new file mode 100644
index 00000000..fa394791
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/SignificantTerms.php
@@ -0,0 +1,27 @@
+<?php
+namespace Elastica\Aggregation;
+
+use Elastica\Filter\AbstractFilter;
+
+/**
+ * Class SignificantTerms.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html
+ */
+class SignificantTerms extends AbstractTermsAggregation
+{
+ /**
+ * The default source of statistical information for background term frequencies is the entire index and this scope can
+ * be narrowed through the use of a background_filter to focus in on significant terms within a narrower context.
+ *
+ * @param AbstractFilter $filter
+ *
+ * @return $this
+ *
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html#_custom_background_context
+ */
+ public function setBackgroundFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('background_filter', $filter->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php
index 18c903e9..f512628c 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php
@@ -1,13 +1,11 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
index 4d1ef4de..5172a684 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php
@@ -1,13 +1,11 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
index 9ede855c..8d0d6bef 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php
@@ -1,97 +1,23 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
*/
-class Terms extends AbstractSimpleAggregation
+class Terms extends AbstractTermsAggregation
{
/**
- * Set the bucket sort order
- * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
+ * 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
+ *
+ * @return $this
*/
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);
+ return $this->setParam('order', array($order => $direction));
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php
new file mode 100644
index 00000000..91a48a48
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php
@@ -0,0 +1,156 @@
+<?php
+namespace Elastica\Aggregation;
+
+use Elastica\Script;
+use Elastica\ScriptFields;
+
+/**
+ * Class TopHits.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
+ */
+class TopHits extends AbstractAggregation
+{
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = parent::toArray();
+
+ // if there are no params, it's ok, but ES will throw exception if json
+ // will be like {"top_hits":[]} instead of {"top_hits":{}}
+ if (empty($array['top_hits'])) {
+ $array['top_hits'] = new \stdClass();
+ }
+
+ return $array;
+ }
+
+ /**
+ * The maximum number of top matching hits to return per bucket. By default the top three matching hits are returned.
+ *
+ * @param int $size
+ *
+ * @return $this
+ */
+ public function setSize($size)
+ {
+ return $this->setParam('size', (int) $size);
+ }
+
+ /**
+ * The offset from the first result you want to fetch.
+ *
+ * @param int $from
+ *
+ * @return $this
+ */
+ public function setFrom($from)
+ {
+ return $this->setParam('from', (int) $from);
+ }
+
+ /**
+ * How the top matching hits should be sorted. By default the hits are sorted by the score of the main query.
+ *
+ * @param array $sortArgs
+ *
+ * @return $this
+ */
+ public function setSort(array $sortArgs)
+ {
+ return $this->setParam('sort', $sortArgs);
+ }
+
+ /**
+ * Allows to control how the _source field is returned with every hit.
+ *
+ * @param array $fields
+ *
+ * @return $this
+ */
+ public function setSource(array $fields)
+ {
+ return $this->setParam('_source', $fields);
+ }
+
+ /**
+ * Returns a version for each search hit.
+ *
+ * @param bool $version
+ *
+ * @return $this
+ */
+ public function setVersion($version)
+ {
+ return $this->setParam('version', (bool) $version);
+ }
+
+ /**
+ * Enables explanation for each hit on how its score was computed.
+ *
+ * @param bool $explain
+ *
+ * @return $this
+ */
+ public function setExplain($explain)
+ {
+ return $this->setParam('explain', (bool) $explain);
+ }
+
+ /**
+ * Set script fields.
+ *
+ * @param array|\Elastica\ScriptFields $scriptFields
+ *
+ * @return $this
+ */
+ public function setScriptFields($scriptFields)
+ {
+ if (is_array($scriptFields)) {
+ $scriptFields = new ScriptFields($scriptFields);
+ }
+
+ return $this->setParam('script_fields', $scriptFields->toArray());
+ }
+
+ /**
+ * Adds a Script to the aggregation.
+ *
+ * @param string $name
+ * @param \Elastica\Script $script
+ *
+ * @return $this
+ */
+ public function addScriptField($name, Script $script)
+ {
+ $this->_params['script_fields'][$name] = $script->toArray();
+
+ return $this;
+ }
+
+ /**
+ * Sets highlight arguments for the results.
+ *
+ * @param array $highlightArgs
+ *
+ * @return $this
+ */
+ public function setHighlight(array $highlightArgs)
+ {
+ return $this->setParam('highlight', $highlightArgs);
+ }
+
+ /**
+ * Allows to return the field data representation of a field for each hit.
+ *
+ * @param array $fields
+ *
+ * @return $this
+ */
+ public function setFieldDataFields(array $fields)
+ {
+ return $this->setParam('fielddata_fields', $fields);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php
index 36fb2a2c..8706a1be 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php
@@ -1,16 +1,15 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html
*/
class ValueCount extends AbstractAggregation
{
/**
- * @param string $name the name of this aggregation
+ * @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field)
@@ -20,12 +19,14 @@ class ValueCount extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return ValueCount
+ *
+ * @return $this
*/
public function setField($field)
{
return $this->setParam('field', $field);
}
-} \ No newline at end of file
+}