diff --git a/lib/Query/Common/AggregationVisitor/AbstractStatsAggregationVisitor.php b/lib/Query/Common/AggregationVisitor/AbstractStatsAggregationVisitor.php index fad48e0e..1d9fab28 100644 --- a/lib/Query/Common/AggregationVisitor/AbstractStatsAggregationVisitor.php +++ b/lib/Query/Common/AggregationVisitor/AbstractStatsAggregationVisitor.php @@ -26,7 +26,7 @@ public function visit( return [ 'type' => 'query', - 'q' => '*:*', + 'q' => $field . ':[* TO *]', 'facet' => [ 'sum' => "sum($field)", 'min' => "min($field)", diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/StatsAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/StatsAggregationVisitorTest.php index 800d83e7..d0de1885 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/StatsAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/StatsAggregationVisitorTest.php @@ -57,7 +57,7 @@ public function dataProviderForVisit(): iterable self::EXAMPLE_LANGUAGE_FILTER, [ 'type' => 'query', - 'q' => '*:*', + 'q' => 'custom_field_id:[* TO *]', 'facet' => [ 'sum' => 'sum(custom_field_id)', 'min' => 'min(custom_field_id)',