diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:47 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:47 -0400 |
commit | 7e85254903c7c0cb49e381f16b18441ea7b058cc (patch) | |
tree | b22328fcf4c8408fc25a7acb73d1cb1089cd82ac /vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php | |
parent | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (diff) | |
parent | 1a365e77dfb8825136626202b1df462731b42060 (diff) |
Merge commit '1a365e'
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php')
-rw-r--r-- | vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php | 50 |
1 files changed, 50 insertions, 0 deletions
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 @@ +<?php + +namespace Elastica\Aggregation; + +/** + * Reversed Nested Aggregation + * + * @package Elastica\Aggregation + * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html + */ +class ReverseNested extends AbstractAggregation +{ + /** + * @param string $name The name of this aggregation + * @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document. + */ + public function __construct($name, $path = null) + { + parent::__construct($name); + + if ($path !== null) { + $this->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; + } +} |