Elasticsearch foselastica repository and groupBy
You need to use Aggregations
.
Example:
use Elastica\Aggregation\Terms;use Elastica\Query;// set up the aggregation$termsAgg = new Terms("dates");$termsAgg->setField("column_three");$termsAgg->setSize(10);// add the aggregation to a Query object$query = new Query();$query->addAggregation($termsAgg);$index = $elasticaClient->getIndex('someindex');$buckets = $index->search($query)->getAggregation("dates");foreach($buckets as $bucket){ $statsAggResult = $bucket["column_three"]; // do something with the result of the stats agg}
Read more here: http://elastica.io/example/aggregations/terms.html
Yes, but here's problem.
How to read this data?I search about this and i found methos search(). It return SetResults with method getAggregations().
But.. this is repository.. there is method find() returns array...
How get I aggregations in this case?