From 15e69f7b20b6596b9148030acce5b59993b95a45 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Dec 2015 06:00:00 +0100 Subject: Update to MediaWiki 1.25.4 --- .../Elastica/Aggregation/AbstractAggregation.php | 88 ++++++++++++++++++++ .../Aggregation/AbstractSimpleAggregation.php | 33 ++++++++ .../elastica/lib/Elastica/Aggregation/Avg.php | 14 ++++ .../lib/Elastica/Aggregation/Cardinality.php | 14 ++++ .../lib/Elastica/Aggregation/DateHistogram.php | 82 ++++++++++++++++++ .../lib/Elastica/Aggregation/DateRange.php | 21 +++++ .../lib/Elastica/Aggregation/ExtendedStats.php | 13 +++ .../elastica/lib/Elastica/Aggregation/Filter.php | 41 +++++++++ .../lib/Elastica/Aggregation/GeoDistance.php | 90 ++++++++++++++++++++ .../lib/Elastica/Aggregation/GeohashGrid.php | 61 ++++++++++++++ .../lib/Elastica/Aggregation/GlobalAggregation.php | 13 +++ .../lib/Elastica/Aggregation/Histogram.php | 55 ++++++++++++ .../elastica/lib/Elastica/Aggregation/IpRange.php | 66 +++++++++++++++ .../elastica/lib/Elastica/Aggregation/Max.php | 13 +++ .../elastica/lib/Elastica/Aggregation/Min.php | 13 +++ .../elastica/lib/Elastica/Aggregation/Missing.php | 31 +++++++ .../elastica/lib/Elastica/Aggregation/Nested.php | 31 +++++++ .../elastica/lib/Elastica/Aggregation/Range.php | 45 ++++++++++ .../lib/Elastica/Aggregation/ReverseNested.php | 50 +++++++++++ .../elastica/lib/Elastica/Aggregation/Stats.php | 13 +++ .../elastica/lib/Elastica/Aggregation/Sum.php | 13 +++ .../elastica/lib/Elastica/Aggregation/Terms.php | 97 ++++++++++++++++++++++ .../lib/Elastica/Aggregation/ValueCount.php | 31 +++++++ 23 files changed, 928 insertions(+) create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php (limited to 'vendor/ruflin/elastica/lib/Elastica/Aggregation') 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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 @@ +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 -- cgit v1.2.3-54-g00ecf