Date histogram aggregation

Hello there !

can you provide me an example of dateHistogram aggregation and tell me how to make subaggregation please ? :slight_smile:

Here my elastic search query :

"aggs": {
    "something_lost_in_time": {
      "date_histogram": {
        "field": "date",
        "calendar_interval": "month",
        "min_doc_count": 0,
        "extended_bounds": {
          "min": "now-2y",
          "max": "now"
        }
      },
      "aggs" : {
        "my_filter_1" : {
            "filter" : { "term": { "xxxx": "true" } }
        },
        "my_filter_1" : {
            "filter" : { "term": { "yyyy": "true" } }
        }
      }
    }
  }

Thank you @yrodiere ( i assume you will answer me :stuck_out_tongue: )

Hello,

There is no built-in API for aggregations beyond terms/range in the Search DSL yet.

You can always use native aggregations as a fallback, however: pass the aggregation definition as JSON, and get the result as JSON. See here.

1 Like

Thank you, that what i choose for now.on the other hand i tried to use the HighLevelClient as a Aggregation builder and convert the aggregation part to json but there is no simple way to do that.

Anyway, thank you