From ecc421826cd5eaa4b784569177cdfe1f65571924 Mon Sep 17 00:00:00 2001 From: Tomasz Grobelny Date: Tue, 4 Sep 2018 13:03:08 +0200 Subject: [PATCH] Add support for aggregations in search result --- lib/Model/SearchResult.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Model/SearchResult.php b/lib/Model/SearchResult.php index 580d5dfa..45f70c0d 100644 --- a/lib/Model/SearchResult.php +++ b/lib/Model/SearchResult.php @@ -219,6 +219,20 @@ public function setRequest($request) { $this->request = $request; } + private $aggregations = []; + + public function addAggregation($category, $value, $count) { + if (!array_key_exists($category, $this->aggregations)) { + $this->aggregations[$category] = []; + } + if (!array_key_exists($value, $this->aggregations[$category])) { + $this->aggregations[$category][$value] = $count; + } + } + + public function getAggregation($category) { + return $this->aggregations[$category]; + } /** * @return array|IndexDocument[]|integer>