Skip to content

Count unique records by field added - #50

Merged
k-samuel merged 2 commits into
3.xfrom
3.3.0
Jun 9, 2026
Merged

Count unique records by field added#50
k-samuel merged 2 commits into
3.xfrom
3.3.0

Conversation

@k-samuel

@k-samuel k-samuel commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Count unique records by field added Feature Request

IndexInterface->aggregate() method is marked as deprecated but retained for backward compatibility.
use
IndexInterface->aggregation() method instead, it returns AggregationQueryResult instead of an array

$query = (new AggregationQuery())
         ->filters($filters) 
         ->countTotal() // count unique records by field
         ->countItems() // count unique records by field value
         ->sort();

$queryResult =  $search->aggregation($query);
$oldResults = $queryResult->getValues() // return results same as deprecated IndexInterface->aggregate()
$fieldCounts = $queryResult->getFields() // return count of unique records for each field

Demo updated

@k-samuel k-samuel added the enhancement New feature or request label Jun 8, 2026
@k-samuel
k-samuel merged commit 3b4e2f1 into 3.x Jun 9, 2026
7 of 8 checks passed
@k-samuel
k-samuel deleted the 3.3.0 branch June 9, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant