I want to classify cities with the products they have.
I have two documents: Product and city. The product has its ID and a reference to a city document:
Product(id) City
P1 ------------ Atlanta
P2 ------------ New York
P3 ------------ Michigan
P4 ------------ Atlanta
....
I want as result of the query
[Atlant => 23, New York => 35, Michigan => 23, etc..]
But I not being able to get the result.
My actual code is
public function countBestUsers()
{
return $this->createQueryBuilder()
->select('id', 'city')
->distinct('city')
->getQuery()
->execute()
;
}