adamfairholm / Elasticquent

Map Larvel Eloquent models to Elasticsearch types
MIT License
201 stars 38 forks source link

ElasticquentResultCollection.php always expects aggregations #8

Closed jcdarwin closed 9 years ago

jcdarwin commented 9 years ago

Great work -- I've started using Elasticquent over the last day, and it works very nicely.

However, one issue I have is that ElasticquentResultCollection.php always expects aggregations to be returned from a search (line 26).

Most of the queries I'm doing at the moment don't need aggregations, and in order to prevent it throwing an error, I've had to change:

    $this->aggregations = $results['aggregations'];

to:

    $this->aggregations = isset($results['aggregations']) ? $results['aggregations'] : array();
adamfairholm commented 9 years ago

Thanks @jcdarwin! Feel free to send a pull request today but I'll add it in later tonight.