diff options
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Facet')
11 files changed, 230 insertions, 171 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php b/vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php index 25cee812..743cefe1 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php @@ -1,30 +1,27 @@ <?php - namespace Elastica\Facet; -use Elastica\Param; -use Elastica\Filter\AbstractFilter; use Elastica\Exception\InvalidException; +use Elastica\Filter\AbstractFilter; +use Elastica\Param; /** - * Abstract facet object. Should be extended by all facet types + * Abstract facet object. Should be extended by all facet types. * - * @category Xodoa - * @package Elastica * @author Nicolas Ruflin <spam@ruflin.com> * @author Jasper van Wanrooy <jasper@vanwanrooy.net> + * + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ abstract class AbstractFacet extends Param { /** - * Holds the name of the facet. - * @var string + * @var string Holds the name of the facet. */ protected $_name = ''; /** - * Holds all facet parameters. - * @var array + * @var array Holds all facet parameters. */ protected $_facet = array(); @@ -42,9 +39,11 @@ abstract class AbstractFacet extends Param * Sets the name of the facet. It is automatically set by * the constructor. * - * @param string $name The name of the facet. - * @throws \Elastica\Exception\InvalidException - * @return \Elastica\Facet\AbstractFacet + * @param string $name The name of the facet. + * + * @throws \Elastica\Exception\InvalidException If name is empty + * + * @return $this */ public function setName($name) { @@ -69,8 +68,9 @@ abstract class AbstractFacet extends Param /** * Sets a filter for this facet. * - * @param \Elastica\Filter\AbstractFilter $filter A filter to apply on the facet. - * @return \Elastica\Facet\AbstractFacet + * @param \Elastica\Filter\AbstractFilter $filter A filter to apply on the facet. + * + * @return $this */ public function setFilter(AbstractFilter $filter) { @@ -82,8 +82,9 @@ abstract class AbstractFacet extends Param * current search query. When not set, it defaults to the * Elasticsearch default value. * - * @param bool $global Flag to either run the facet globally. - * @return \Elastica\Facet\AbstractFacet + * @param bool $global Flag to either run the facet globally. + * + * @return $this */ public function setGlobal($global = true) { @@ -91,10 +92,11 @@ abstract class AbstractFacet extends Param } /** - * Sets the path to the nested document + * Sets the path to the nested document. * - * @param string $nestedPath Nested path - * @return \Elastica\Facet\AbstractFacet + * @param string $nestedPath Nested path + * + * @return $this */ public function setNested($nestedPath) { @@ -102,10 +104,11 @@ abstract class AbstractFacet extends Param } /** - * Sets the scope + * Sets the scope. + * + * @param string $scope Scope * - * @param string $scope Scope - * @return \Elastica\Facet\AbstractFacet + * @return $this */ public function setScope($scope) { @@ -128,9 +131,10 @@ abstract class AbstractFacet extends Param * Sets a param for the facet. Each facet implementation needs to take * care of handling their own params. * - * @param string $key The key of the param to set. - * @param mixed $value The value of the param. - * @return \Elastica\Facet\AbstractFacet + * @param string $key The key of the param to set. + * @param mixed $value The value of the param. + * + * @return $this */ protected function _setFacetParam($key, $value) { diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php b/vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php index 803f54a3..c47eddab 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php @@ -1,23 +1,23 @@ <?php - namespace Elastica\Facet; /** * Implements the Date Histogram facet. * - * @category Xodoa - * @package Elastica * @author Raul Martinez Jr <juneym@gmail.com> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-date-histogram-facet.html * @link https://github.com/elasticsearch/elasticsearch/issues/591 + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ class DateHistogram extends Histogram { /** - * Set the time_zone parameter + * Set the time_zone parameter. + * + * @param string $tzOffset * - * @param string $tzOffset - * @return \Elastica\Facet\DateHistogram + * @return $this */ public function setTimezone($tzOffset) { @@ -25,16 +25,30 @@ class DateHistogram extends Histogram } /** + * Set the factor parameter. + * + * @param int $factor + * + * @return $this + */ + public function setFactor($factor) + { + return $this->setParam('factor', $factor); + } + + /** * 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('date_histogram', $this->_params); diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php index ed6f28b7..26f032b4 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php @@ -1,24 +1,24 @@ <?php - namespace Elastica\Facet; use Elastica\Filter\AbstractFilter; /** - * Filter facet + * Filter facet. * - * @category Xodoa - * @package Elastica * @author Nicolas Ruflin <spam@ruflin.com> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/filter-facet.html + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-filter-facet.html + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ class Filter extends AbstractFacet { /** * Set the filter for the facet. * - * @param \Elastica\Filter\AbstractFilter $filter - * @return \Elastica\Facet\Filter + * @param \Elastica\Filter\AbstractFilter $filter + * + * @return $this */ public function setFilter(AbstractFilter $filter) { diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php b/vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php index a6f5e9ed..71fa5094 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php @@ -1,41 +1,49 @@ <?php - namespace Elastica\Facet; /** * Implements the Geo Cluster facet. * - * @category Xodoa - * @package Elastica * @author Konstantin Nikiforov <konstantin.nikiforov@gmail.com> + * * @link https://github.com/zenobase/geocluster-facet + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ -class GeoCluster extends AbstractFacet { - +class GeoCluster extends AbstractFacet +{ /** * @param string $fieldName + * * @return $this */ - public function setField($fieldName) { + public function setField($fieldName) + { $this->setParam('field', $fieldName); + return $this; } /** - * @param double $factor + * @param float $factor + * * @return $this */ - public function setFactor($factor){ + public function setFactor($factor) + { $this->setParam('factor', $factor); + return $this; } /** - * @param boolean $showIds + * @param bool $showIds + * * @return $this */ - public function setShowIds($showIds) { + public function setShowIds($showIds) + { $this->setParam('showIds', $showIds); + return $this; } @@ -44,11 +52,15 @@ class GeoCluster extends AbstractFacet { * 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(){ - $this->_setFacetParam ('geo_cluster', $this->_params); + public function toArray() + { + $this->_setFacetParam('geo_cluster', $this->_params); + return parent::toArray(); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php index 35537986..664d33a6 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php @@ -1,14 +1,13 @@ <?php - namespace Elastica\Facet; /** * Implements the Geo Distance facet. * - * @category Xodoa - * @package Elastica * @author Gerard A. Matthew <gerard.matthew@gmail.com> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/geo-distance-facet.html + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-geo-distance-facet.html + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ class GeoDistance extends AbstractFacet { @@ -20,10 +19,11 @@ class GeoDistance extends AbstractFacet * array('from' => 20, 'to' => 70), * array('from' => 70, 'to' => 120), * array('from' => 150) - * ) + * ). + * + * @param array $ranges Numerical array with range definitions. * - * @param array $ranges Numerical array with range definitions. - * @return \Elastica\Facet\GeoDistance + * @return $this */ public function setRanges(array $ranges) { @@ -33,16 +33,17 @@ class GeoDistance extends AbstractFacet /** * Set the relative GeoPoint for the facet. * - * @param string $typeField index type and field e.g foo.bar - * @param float $latitude - * @param float $longitude - * @return \Elastica\Facet\GeoDistance + * @param string $typeField index type and field e.g foo.bar + * @param float $latitude + * @param float $longitude + * + * @return $this */ public function setGeoPoint($typeField, $latitude, $longitude) { return $this->setParam($typeField, array( - "lat" => $latitude, - "lon" => $longitude, + 'lat' => $latitude, + 'lon' => $longitude, )); } @@ -51,15 +52,17 @@ class GeoDistance extends AbstractFacet * 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 geo_distance in the abstract as param. */ - $this->_setFacetParam ('geo_distance', $this->_params); + $this->_setFacetParam('geo_distance', $this->_params); return parent::toArray(); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php index 68be6757..1b76ea89 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php @@ -1,22 +1,22 @@ <?php - namespace Elastica\Facet; /** * Implements the Histogram facet. * - * @category Xodoa - * @package Elastica * @author Raul Martinez Jr <juneym@gmail.com> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/histogram-facet.html + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-histogram-facet.html + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ class Histogram extends AbstractFacet { /** - * Sets the field for histogram + * Sets the field for histogram. + * + * @param string $field The name of the field for the histogram * - * @param string $field The name of the field for the histogram - * @return \Elastica\Facet\Histogram + * @return $this */ public function setField($field) { @@ -24,10 +24,11 @@ class Histogram extends AbstractFacet } /** - * Set the value for interval + * Set the value for interval. * - * @param string $interval - * @return \Elastica\Facet\Histogram + * @param string $interval + * + * @return $this */ public function setInterval($interval) { @@ -35,11 +36,12 @@ class Histogram extends AbstractFacet } /** - * Set the fields for key_field and value_field + * Set the fields for key_field and value_field. + * + * @param string $keyField Key field + * @param string $valueField Value field * - * @param string $keyField Key field - * @param string $valueField Value field - * @return \Elastica\Facet\Histogram + * @return $this */ public function setKeyValueFields($keyField, $valueField) { @@ -49,9 +51,10 @@ class Histogram extends AbstractFacet /** * 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 + * @param string $keyScript Script to check whether it falls into the range. + * @param string $valueScript Script to use for statistical calculations. + * + * @return $this */ public function setKeyValueScripts($keyScript, $valueScript) { @@ -60,10 +63,11 @@ class Histogram extends AbstractFacet } /** - * Set the "params" essential to the a script + * Set the "params" essential to the a script. + * + * @param array $params Associative array (key/value pair) * - * @param array $params Associative array (key/value pair) - * @return \Elastica\Facet\Histogram + * @return $this */ public function setScriptParams(array $params) { @@ -75,12 +79,14 @@ class Histogram extends AbstractFacet * 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); diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Query.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Query.php index d43a2375..522090d5 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/Query.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Query.php @@ -1,24 +1,24 @@ <?php - namespace Elastica\Facet; use Elastica\Query\AbstractQuery; /** - * Query facet + * Query facet. * - * @category Xodoa - * @package Elastica * @author Nicolas Ruflin <spam@ruflin.com> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/query-facet.html + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-query-facet.html + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ class Query extends AbstractFacet { /** * Set the query for the facet. * - * @param \Elastica\Query\AbstractQuery $query - * @return \Elastica\Facet\Query + * @param \Elastica\Query\AbstractQuery $query + * + * @return $this */ public function setQuery(AbstractQuery $query) { diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Range.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Range.php index 194f611a..f81caf3d 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/Range.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Range.php @@ -1,5 +1,4 @@ <?php - namespace Elastica\Facet; use Elastica\Exception\InvalidException; @@ -7,18 +6,19 @@ use Elastica\Exception\InvalidException; /** * Implements the range facet. * - * @category Xodoa - * @package Elastica * @author Jasper van Wanrooy <jasper@vanwanrooy.net> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/range-facet.html + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-range-facet.html + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ class Range extends AbstractFacet { /** * Sets the field for the range. * - * @param string $field The name of the field for range. - * @return \Elastica\Facet\Range + * @param string $field The name of the field for range. + * + * @return $this */ public function setField($field) { @@ -28,9 +28,10 @@ class Range extends AbstractFacet /** * Sets the fields by their separate key and value fields. * - * @param string $keyField The key_field param for the range. - * @param string $valueField The key_value param for the range. - * @return \Elastica\Facet\Range + * @param string $keyField The key_field param for the range. + * @param string $valueField The key_value param for the range. + * + * @return $this */ public function setKeyValueFields($keyField, $valueField) { @@ -44,7 +45,7 @@ class Range extends AbstractFacet * @param string $keyScript Script to check whether it falls into the range. * @param string $valueScript Script to use for statistical calculations. * - * @return \Elastica\Facet\Range + * @return $this */ public function setKeyValueScripts($keyScript, $valueScript) { @@ -59,10 +60,11 @@ class Range extends AbstractFacet * array('from' => 20, 'to' 70), * array('from' => 70, 'to' => 120), * array('from' => 150) - * ) + * ). * - * @param array $ranges Numerical array with range definitions. - * @return \Elastica\Facet\Range + * @param array $ranges Numerical array with range definitions. + * + * @return $this */ public function setRanges(array $ranges) { @@ -72,9 +74,10 @@ class Range extends AbstractFacet /** * Adds a range to the range facet. * - * @param mixed $from The from for the range. - * @param mixed $to The to for the range. - * @return \Elastica\Facet\Range + * @param mixed $from The from for the range. + * @param mixed $to The to for the range. + * + * @return $this */ public function addRange($from = null, $to = null) { @@ -99,12 +102,14 @@ class Range extends AbstractFacet * 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() { - /** + /* * Check the facet for validity. * There are three ways to set the key and value field for the range: * - a single field for both key and value; or @@ -128,7 +133,7 @@ class Range extends AbstractFacet throw new InvalidException('Either field, key_field and key_value or key_script and value_script should be set.'); } - /** + /* * Set the range in the abstract as param. */ $this->_setFacetParam('range', $this->_params); diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php index 71507b8f..bb4eef8b 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php @@ -1,22 +1,22 @@ <?php - namespace Elastica\Facet; /** * Implements the statistical facet. * - * @category Xodoa - * @package Elastica * @author Robert Katzki <robert@katzki.de> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/statistical-facet.html + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-statistical-facet.html + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ class Statistical extends AbstractFacet { /** * Sets the field for the statistical query. * - * @param string $field The field name for the statistical query. - * @return \Elastica\Facet\Statistical + * @param string $field The field name for the statistical query. + * + * @return $this */ public function setField($field) { @@ -26,8 +26,9 @@ class Statistical extends AbstractFacet /** * Sets multiple fields for the statistical query. * - * @param array $fields Numerical array with the fields for the statistical query. - * @return \Elastica\Facet\Statistical + * @param array $fields Numerical array with the fields for the statistical query. + * + * @return $this */ public function setFields(array $fields) { @@ -35,10 +36,11 @@ class Statistical extends AbstractFacet } /** - * Sets a script to calculate statistical information + * Sets a script to calculate statistical information. + * + * @param string $script The script to do calculations on the statistical values * - * @param string $script The script to do calculations on the statistical values - * @return \Elastica\Facet\Statistical + * @return $this */ public function setScript($script) { @@ -50,6 +52,7 @@ class Statistical extends AbstractFacet * facet definition of the parent. * * @see \Elastica\Facet\AbstractFacet::toArray() + * * @return array */ public function toArray() diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php index c1dab800..6af8867b 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php @@ -1,5 +1,4 @@ <?php - namespace Elastica\Facet; use Elastica\Exception\InvalidException; @@ -8,11 +7,11 @@ use Elastica\Script; /** * Implements the terms facet. * - * @category Xodoa - * @package Elastica * @author Nicolas Ruflin <spam@ruflin.com> * @author Jasper van Wanrooy <jasper@vanwanrooy.net> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html + * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead. */ class Terms extends AbstractFacet { @@ -27,8 +26,9 @@ class Terms extends AbstractFacet /** * Sets the field for the terms. * - * @param string $field The field name for the terms. - * @return \Elastica\Facet\Terms + * @param string $field The field name for the terms. + * + * @return $this */ public function setField($field) { @@ -38,8 +38,9 @@ class Terms extends AbstractFacet /** * Sets the script for the term. * - * @param string $script The script for the term. - * @return \Elastica\Facet\Terms + * @param string $script The script for the term. + * + * @return $this */ public function setScript($script) { @@ -54,8 +55,9 @@ class Terms extends AbstractFacet /** * Sets multiple fields for the terms. * - * @param array $fields Numerical array with the fields for the terms. - * @return \Elastica\Facet\Terms + * @param array $fields Numerical array with the fields for the terms. + * + * @return $this */ public function setFields(array $fields) { @@ -66,8 +68,9 @@ class Terms extends AbstractFacet * Sets the flag to return all available terms. When they * don't have a hit, they have a count of zero. * - * @param bool $allTerms Flag to fetch all terms. - * @return \Elastica\Facet\Terms + * @param bool $allTerms Flag to fetch all terms. + * + * @return $this */ public function setAllTerms($allTerms) { @@ -78,14 +81,16 @@ class Terms extends AbstractFacet * 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. + * @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 \Elastica\Facet\Terms + * + * @return $this */ public function setOrder($type) { if (!in_array($type, $this->_orderTypes)) { - throw new InvalidException('Invalid order type: ' . $type); + throw new InvalidException('Invalid order type: '.$type); } return $this->setParam('order', $type); @@ -94,8 +99,9 @@ class Terms extends AbstractFacet /** * Set an array with terms which are omitted in the search. * - * @param array $exclude Numerical array which includes all terms which needs to be ignored. - * @return \Elastica\Facet\Terms + * @param array $exclude Numerical array which includes all terms which needs to be ignored. + * + * @return $this */ public function setExclude(array $exclude) { @@ -105,8 +111,9 @@ class Terms extends AbstractFacet /** * Sets the amount of terms to be returned. * - * @param int $size The amount of terms to be returned. - * @return \Elastica\Facet\Terms + * @param int $size The amount of terms to be returned. + * + * @return $this */ public function setSize($size) { @@ -118,6 +125,7 @@ class Terms extends AbstractFacet * facet definition of the parent. * * @see \Elastica\Facet\AbstractFacet::toArray() + * * @return array */ public function toArray() diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php b/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php index 61c6b39e..22d284c5 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php +++ b/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php @@ -1,5 +1,4 @@ <?php - namespace Elastica\Facet; use Elastica\Exception\InvalidException; @@ -7,14 +6,13 @@ use Elastica\Exception\InvalidException; /** * Implements the statistical facet on a per term basis. * - * @category Xodoa - * @package Elastica * @author Tom Michaelis <tom.michaelis@gmail.com> - * @link http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html + * + * @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. @@ -23,63 +21,69 @@ class TermsStats extends AbstractFacet */ protected $_orderTypes = array('term', 'reverse_term', 'count', 'reverse_count', 'total', 'reverse_total', 'min', 'reverse_min', 'max', 'reverse_max', 'mean', - 'reverse_mean'); + 'reverse_mean', ); /** * Sets the key field for the query. * - * @param string $keyField The key field name for the query. - * @return \Elastica\Facet\TermsStats + * @param string $keyField The key field name for the query. + * + * @return $this */ - public function setKeyField( $keyField ) + public function setKeyField($keyField) { - return $this->setParam( 'key_field', $keyField ); + return $this->setParam('key_field', $keyField); } /** - * Sets a script to calculate statistical information on a per term basis + * Sets a script to calculate statistical information on a per term basis. + * + * @param string $valueScript The script to do calculations on the statistical values * - * @param string $valueScript The script to do calculations on the statistical values - * @return \Elastica\Facet\TermsStats + * @return $this */ - public function setValueScript( $valueScript ) + public function setValueScript($valueScript) { - return $this->setParam( 'value_script', $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. + * @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 \Elastica\Facet\TermsStats + * + * @return $this */ public function setOrder($type) { if (!in_array($type, $this->_orderTypes)) { - throw new InvalidException('Invalid order type: ' . $type); + throw new InvalidException('Invalid order type: '.$type); } return $this->setParam('order', $type); } /** - * Sets a field to compute basic statistical results on + * Sets a field to compute basic statistical results on. + * + * @param string $valueField The field to compute statistical values for * - * @param string $valueField The field to compute statistical values for - * @return \Elastica\Facet\TermsStats + * @return $this */ - public function setValueField( $valueField ) + public function setValueField($valueField) { - return $this->setParam( 'value_field', $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 \Elastica\Facet\Terms + * @param int $size The amount of terms to be returned. + * + * @return $this */ public function setSize($size) { @@ -91,13 +95,13 @@ class TermsStats extends AbstractFacet * facet definition of the parent. * * @see \Elastica\Facet\AbstractFacet::toArray() + * * @return array */ public function toArray() { - $this->_setFacetParam( 'terms_stats', $this->_params ); + $this->_setFacetParam('terms_stats', $this->_params); return parent::toArray(); } - } |