Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 584 Bytes

10_aggregate.md

File metadata and controls

22 lines (19 loc) · 584 Bytes

Aggregate

Description

When aggregating you dont get directly entity just array data, for this we have \Spameri\ElasticQuery\Response\ResultSearch object to encapsulate result.

Example

In this example we want number of videos released in each year.

$elasticQuery = new \Spameri\ElasticQuery\ElasticQuery();
$elasticQuery->aggregation()->add(
	new \Spameri\ElasticQuery\Aggregation\LeafAggregationCollection(
		'video-by-year',
		NULL,
		new \Spameri\ElasticQuery\Aggregation\Term(
			'year'
		)
	)
);

$aggregateResult = $videoService->aggregate($elasticQuery);