kissge / elastica-friendly-result-set

包装Elastica的ResultSet对象。

1.2.0 2016-07-28 14:47 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:45 UTC


README

Build Status Coverage Status

轻量但强大的ruflin/Elastica包装器。

安装

只需将此库添加到项目中作为依赖项

composer require kissge/elastica-friendly-result-set

用法

示例1。

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>);
}

示例2。

use Kissge\ElasticaFriendlyResultSet\Aggregations;

$aggs = new Aggregations($index->search($query)->getAggregations());
$this->render($view, ['aggs' => $aggs]);
{% for key, interval in aggs.interval %}
    <tr>
        <th>
            {{ key }}
        </th>

        <td>
            {{ interval.visitors.female }}
        </td>
        <td>
            {{ interval.visitors.male }}
        </td>
        <td>
            {{ interval.averageScore }}
        </td>
    </tr>
{% endfor %}

作者

Yuto Kisuge

许可证

此库采用MIT许可证。请参阅LICENSE以获取完整的许可证。