Jordi
Jordi

Reputation: 23187

ElasticSearch: Agregation on a datetime field

I'm trying to get aggregated information from a datetime field:

Thanks for all.

Upvotes: 0

Views: 48

Answers (1)

Sumit
Sumit

Reputation: 2270

You can use format parameter of date-histogram aggregation and chose only month field in that. Your aggregation would look like

{
  "aggs": {
    "documents_by_month": {
      "date_histogram": {
        "field": "date",
        "interval": "1M",
        "format": "MM"
      },
      "aggs": {
        "documents": {
          //... your sub aggregation
        }
      }
    }
  }
}

Upvotes: 1

Related Questions