PHP code example of kissge / elastica-friendly-result-set
1. Go to this page and download the library: Download kissge/elastica-friendly-result-set library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kissge / elastica-friendly-result-set example snippets
use Kissge\ElasticaFriendlyResultSet\Aggregations;
$index = $container->get('fos_elastica.index.<index name>'); // Symfony assumed, but that's not necessary
$aggs = new Aggregations($index->search($query)->getAggregations());
foreach ($aggs-><aggregation name> as $key => $bucket) {
do_something($bucket-><subaggregation name>);
do_something($bucket-><subaggregation name>-><term name>);
}
use Kissge\ElasticaFriendlyResultSet\Aggregations;
$aggs = new Aggregations($index->search($query)->getAggregations());
$this->render($view, ['aggs' => $aggs]);