File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,6 +233,10 @@ public function search(Search $search): SearchResult
233233 }
234234 }
235235
236+ if (isset ($ response ->aggregations ) && is_object ($ response ->aggregations )) {
237+ $ result ->setAggregations ($ response ->aggregations );
238+ }
239+
236240 foreach ($ response ->hits ->hits as $ resultDocument ) {
237241 /** @var ModelInterface $model */
238242 $ model = new $ modelClassName ();
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class SearchResult extends ModelCollection
1616 protected ?int $ searchTime = null ;
1717 protected ?int $ totalCount = null ;
1818 protected ?CountRelation $ totalCountRelation = null ;
19+ protected ?object $ aggregations = null ;
1920
2021 /**
2122 * @return int|null
@@ -70,4 +71,25 @@ public function setTotalCountRelation(?CountRelation $totalCountRelation): stati
7071 $ this ->totalCountRelation = $ totalCountRelation ;
7172 return $ this ;
7273 }
74+
75+ /**
76+ * Aggregations returned by OpenSearch, if any.
77+ * The structure of this object depends on the aggregations defined in the search query.
78+ *
79+ * @return object|null
80+ */
81+ public function getAggregations (): ?object
82+ {
83+ return $ this ->aggregations ;
84+ }
85+
86+ /**
87+ * @param object|null $aggregations
88+ * @return $this
89+ */
90+ public function setAggregations (?object $ aggregations ): static
91+ {
92+ $ this ->aggregations = $ aggregations ;
93+ return $ this ;
94+ }
7395}
You can’t perform that action at this time.
0 commit comments