File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
tests/SpameriTests/ElasticQuery/Response Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ public function __construct(
1313 private int $ position ,
1414 private \Spameri \ElasticQuery \Response \Result \Aggregation \BucketCollection $ bucketCollection ,
1515 private \Spameri \ElasticQuery \Response \Result \AggregationCollection $ aggregations ,
16+ private \Spameri \ElasticQuery \Response \Result \HitCollection $ hits ,
1617 )
1718 {
1819 }
@@ -36,6 +37,12 @@ public function buckets(): \Spameri\ElasticQuery\Response\Result\Aggregation\Buc
3637 }
3738
3839
40+ public function hits (): \Spameri \ElasticQuery \Response \Result \HitCollection
41+ {
42+ return $ this ->hits ;
43+ }
44+
45+
3946 public function countBuckets (): int
4047 {
4148 $ count = 0 ;
Original file line number Diff line number Diff line change @@ -186,6 +186,7 @@ private function mapAggregation(
186186 {
187187 $ i = 0 ;
188188 $ buckets = [];
189+ $ hits = [];
189190 $ aggregations = [];
190191
191192 if (isset ($ aggregationArray ['buckets ' ])) {
@@ -200,6 +201,12 @@ private function mapAggregation(
200201 }
201202 }
202203
204+ if (isset ($ aggregationArray [$ name ]['hits ' ])) {
205+ foreach ($ aggregationArray [$ name ]['hits ' ] as $ hitPosition => $ hit ) {
206+ $ hits [] = $ this ->mapHit ($ hit , $ hitPosition );
207+ }
208+ }
209+
203210 if (
204211 ! isset ($ aggregationArray ['buckets ' ])
205212 && ! isset ($ aggregationArray [$ name ]['buckets ' ])
@@ -242,6 +249,9 @@ private function mapAggregation(
242249 new \Spameri \ElasticQuery \Response \Result \AggregationCollection (
243250 ... $ aggregations ,
244251 ),
252+ new \Spameri \ElasticQuery \Response \Result \HitCollection (
253+ ... $ hits ,
254+ ),
245255 );
246256 }
247257
Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ class Result extends \Tester\TestCase
101101 }
102102 }
103103
104+ // HITS tests
105+ \Tester \Assert::count (0 , $ aggregation ->hits ());
106+
104107 // STATS tests
105108 \Tester \Assert::same (FALSE , $ resultObject ->stats ()->timedOut ());
106109 \Tester \Assert::same (37 , $ resultObject ->stats ()->took ());
You can’t perform that action at this time.
0 commit comments