///////////////////FOR JSON ////////////////////////////
{
"query": {
"match_all": {}
},
"aggs": {
"lv": {
"terms": {
"field": "lv"
}
}
},
"size": 0
}
{
"query": {
"match_all": {}
},
"size": 0,
"aggs": {
"group_by_cl": {
"terms": {
"field": "_index"
}
}
}
}
//////////////////////////FOR PHP////////////////////
$query = new \Elastica\Query(new \Elastica\Query\MatchAll());
// More complex aggregation, we get categories for each month
$dateAggregation = new \Elastica\Aggregation\DateHistogram('dateHistogram','publishedAt','month');
$dateAggregation->setFormat("dd-MM-YYYY");
$categoryAggregation = new \Elastica\Aggregation\Terms('category');
$categoryAggregation->setField("category");
$dateAggregation->addAggregation($categoryAggregation);
$query->addAggregation($dateAggregation);
// we don't need any results, only the statistics
$query->setSize(0);