Reputation: 3282
I have thousands of documents in my index and what I'm trying to do is aggregate documents with the same date and display how many there are with that date. The dates are in strings. To give you a better picture of what I want, say the field for the date is called arrivalDate and each document has a specific arrivalDate. I want the data to be displayed something like this:
20110105 : 5 records
20120501 : 2 records
20120602 : 15 records
and so forth. This is basically like a GROUP BY
SQL query except using elastic search. How do I build such a query using elastic search?
Upvotes: 0
Views: 30
Reputation: 2361
What you need is term
aggregation. It will look something like this.
{
"aggs": {
"group_bu_date": {
"terms": {
"field": "arrivalDate"
}
}
}
}
Upvotes: 3