From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- .../elastica/lib/Elastica/Facet/TermsStats.php | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php (limited to 'vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php') diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php b/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php new file mode 100644 index 00000000..22d284c5 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php @@ -0,0 +1,107 @@ + + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-terms-stats-facet.html + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. + */ +class TermsStats extends AbstractFacet +{ + /** + * Holds the types of ordering which are allowed + * by Elasticsearch. + * + * @var array + */ + protected $_orderTypes = array('term', 'reverse_term', 'count', 'reverse_count', + 'total', 'reverse_total', 'min', 'reverse_min', 'max', 'reverse_max', 'mean', + 'reverse_mean', ); + + /** + * Sets the key field for the query. + * + * @param string $keyField The key field name for the query. + * + * @return $this + */ + public function setKeyField($keyField) + { + return $this->setParam('key_field', $keyField); + } + + /** + * Sets a script to calculate statistical information on a per term basis. + * + * @param string $valueScript The script to do calculations on the statistical values + * + * @return $this + */ + public function setValueScript($valueScript) + { + return $this->setParam('value_script', $valueScript); + } + + /** + * Sets the ordering type for this facet. Elasticsearch + * internal default is count. + * + * @param string $type The order type to set use for sorting of the terms. + * + * @throws \Elastica\Exception\InvalidException When an invalid order type was set. + * + * @return $this + */ + public function setOrder($type) + { + if (!in_array($type, $this->_orderTypes)) { + throw new InvalidException('Invalid order type: '.$type); + } + + return $this->setParam('order', $type); + } + + /** + * Sets a field to compute basic statistical results on. + * + * @param string $valueField The field to compute statistical values for + * + * @return $this + */ + public function setValueField($valueField) + { + return $this->setParam('value_field', $valueField); + } + + /** + * 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', (int) $size); + } + + /** + * Creates the full facet definition, which includes the basic + * facet definition of the parent. + * + * @see \Elastica\Facet\AbstractFacet::toArray() + * + * @return array + */ + public function toArray() + { + $this->_setFacetParam('terms_stats', $this->_params); + + return parent::toArray(); + } +} -- cgit v1.2.3-54-g00ecf