Skip to content

Commit fa6f392

Browse files
committed
Bucket position is not available for all aggs
1 parent b62ee4d commit fa6f392

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/Response/Result/Aggregation/Bucket.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class Bucket
1515
*/
1616
private $docCount;
1717
/**
18-
* @var int
18+
* @var int|null
1919
*/
2020
private $position;
2121

2222

2323
public function __construct(
2424
$key
2525
, int $docCount
26-
, int $position
26+
, ?int $position = NULL
2727
)
2828
{
2929
$this->key = $key;
@@ -44,7 +44,7 @@ public function docCount() : int
4444
}
4545

4646

47-
public function position() : int
47+
public function position() : ?int
4848
{
4949
return $this->position;
5050
}

‎src/Response/ResultMapper.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ private function mapAggregation(
210210

211211

212212
private function mapBucket(
213-
int $bucketPosition
213+
$bucketPosition
214214
, array $bucketArray
215215
) : \Spameri\ElasticQuery\Response\Result\Aggregation\Bucket
216216
{
217217
return new \Spameri\ElasticQuery\Response\Result\Aggregation\Bucket(
218-
$bucketArray['key'],
218+
$bucketArray['key'] ?? $bucketPosition,
219219
$bucketArray['doc_count'],
220-
$bucketPosition
220+
\is_int($bucketPosition) ? $bucketPosition : NULL
221221
);
222222
}
223223

0 commit comments

Comments
 (0)