pdphilip / laravel-elasticsearch

Laravel Elasticsearch: An Elasticsearch implementation of Laravel's Eloquent ORM
https://elasticsearch.pdphilip.com/
MIT License
94 stars 17 forks source link

[Implemented] Allow aggregation results with rawSearch #24

Closed kenken-vpl closed 7 months ago

kenken-vpl commented 7 months ago

Is your feature request related to a problem? Please describe.

Want to perform aggregation type: date_histogram

Describe the solution you'd like

Looks like only rawSearch() can perform a "date_histogram" aggregation. However, Bridge::processSearchRaw() filters the result using _sanitizeSearchResponse().

Describe alternatives you've considered

Manually changed Bridge::processSearchRaw() to return the aggregations instead.

Additional context

    if (! empty($process['aggregations'])) {
        $meta['timed_out'] = $process['timed_out'];
        $meta['total'] = $process['hits']['total']['value'] ?? 0;
        $meta['max_score'] = $process['hits']['max_score'] ?? 0;

        return $this->_return($process['aggregations'], $meta, $params, $this->_queryTag(__FUNCTION__));
    }
pdphilip commented 7 months ago

Hi @kenken-vpl, this would be a good new addition to the Elasticsearch-specific aggregations.

I'll add this to the roadmap along with a few others aggs. Thanks

pdphilip commented 7 months ago

Hi @kenken-vpl - the new release has rawAggregation()

Laravel 10 & 11 - v4.0.1 Laravel 9 - v3.9.1 Laravel 8 - v3.8.1

See: https://elasticsearch.pdphilip.com/es-specific#raw-aggregation-queries