From 1a365e77dfb8825136626202b1df462731b42060 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 16 Aug 2015 08:22:05 +0200 Subject: Update to MediaWiki 1.25.2 --- .../elastica/lib/Elastica/Facet/Histogram.php | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php (limited to 'vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php') diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php new file mode 100644 index 00000000..68be6757 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php @@ -0,0 +1,90 @@ + + * @link http://www.elasticsearch.org/guide/reference/api/search/facets/histogram-facet.html + */ +class Histogram extends AbstractFacet +{ + /** + * Sets the field for histogram + * + * @param string $field The name of the field for the histogram + * @return \Elastica\Facet\Histogram + */ + public function setField($field) + { + return $this->setParam('field', $field); + } + + /** + * Set the value for interval + * + * @param string $interval + * @return \Elastica\Facet\Histogram + */ + public function setInterval($interval) + { + return $this->setParam('interval', $interval); + } + + /** + * Set the fields for key_field and value_field + * + * @param string $keyField Key field + * @param string $valueField Value field + * @return \Elastica\Facet\Histogram + */ + public function setKeyValueFields($keyField, $valueField) + { + return $this->setParam('key_field', $keyField)->setParam('value_field', $valueField); + } + + /** + * Sets the key and value for this facet by script. + * + * @param string $keyScript Script to check whether it falls into the range. + * @param string $valueScript Script to use for statistical calculations. + * @return \Elastica\Facet\Histogram + */ + public function setKeyValueScripts($keyScript, $valueScript) + { + return $this->setParam('key_script', $keyScript) + ->setParam('value_script', $valueScript); + } + + /** + * Set the "params" essential to the a script + * + * @param array $params Associative array (key/value pair) + * @return \Elastica\Facet\Histogram + */ + public function setScriptParams(array $params) + { + return $this->setParam('params', $params); + } + + /** + * Creates the full facet definition, which includes the basic + * facet definition of the parent. + * + * @see \Elastica\Facet\AbstractFacet::toArray() + * @throws \Elastica\Exception\InvalidException When the right fields haven't been set. + * @return array + */ + public function toArray() + { + /** + * Set the range in the abstract as param. + */ + $this->_setFacetParam('histogram', $this->_params); + + return parent::toArray(); + } +} -- cgit v1.2.3-54-g00ecf