Skip to content

Commit c0fbdef

Browse files
committed
TASK: Only apply the size parameter if set
1 parent 301154e commit c0fbdef

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Classes/Eel/ElasticSearchQueryBuilder.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,19 +407,22 @@ public function queryFilterMultiple(array $data, $clauseType = 'must'): ElasticS
407407
* @param string $field The field to aggregate by
408408
* @param string $type Aggregation type
409409
* @param string $parentPath
410-
* @param int $size The amount of buckets to return
410+
* @param int|null $size The amount of buckets to return or null if not applicable to the aggregation
411411
* @return ElasticSearchQueryBuilder
412412
* @throws QueryBuildingException
413413
*/
414-
public function fieldBasedAggregation(string $name, string $field, string $type = 'terms', string $parentPath = '', int $size = 10): ElasticSearchQueryBuilder
414+
public function fieldBasedAggregation(string $name, string $field, string $type = 'terms', string $parentPath = '', ?int $size = null): ElasticSearchQueryBuilder
415415
{
416416
$aggregationDefinition = [
417417
$type => [
418-
'field' => $field,
419-
'size' => $size
418+
'field' => $field
420419
]
421420
];
422421

422+
if ($size !== null) {
423+
$aggregationDefinition[$type]['size'] = $size;
424+
}
425+
423426
$this->aggregation($name, $aggregationDefinition, $parentPath);
424427

425428
return $this;

0 commit comments

Comments
 (0)