# Elasticsearch 5.5.2 Matrix Stats Aggregation on Date histogram

**URL:** <https://discuss.elastic.co/t/elasticsearch-5-5-2-matrix-stats-aggregation-on-date-histogram/112299>\
**Category:** Elasticsearch\
**Created:** [December 18, 2017, 8:11pm UTC](https://discuss.elastic.co/t/elasticsearch-5-5-2-matrix-stats-aggregation-on-date-histogram/112299 "2017-12-18T20:11:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamisalex](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tamisalex](https://discuss.elastic.co/u/tamisalex)\
**Post date:** [December 18, 2017, 8:11pm UTC](https://discuss.elastic.co/t/elasticsearch-5-5-2-matrix-stats-aggregation-on-date-histogram/112299/1 "2017-12-18T20:11:42Z")

</div>

I am trying to use Matrix Stats aggregation to get the skew and kurtosis of a date histogram. Its the possible?

My knowledge of nesting aggs together is very basic. I've tried to do this query but it does not work. Is there a way I can format the date histogram agg to pass it to the matrix stats histogram or a better/easier way to do what I'm trying?

```auto
curl -XPOST 'localhost:9200/wos/_search?size=0&pretty' -H 'Content-Type: application/json' -d'
> {
> "query": {
> "bool": {
> "must": 
> { "match": { "_all": "Supercapacitor" } }
> ,
> "filter": 
> { "range" : {
> "date" : {
> "gte" : "now-15y",
> "lt" : "now"
> }
> }
> }
> }
> },
> "aggs": {
> "matrixstats": {
> "matrix_stats": {
> "aggs" : {
> fields: [
> "aggs" : {
> "papers_over_time" : {
> "date_histogram" : {
> "field" : "date",
> "interval" : "year"
> }
> }
> }
> ]
> }
> }
> }
> }
>     
> }
> '
{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "Unexpected token START_OBJECT [aggs] in [matrixstats].",
        "line" : 21,
        "col" : 26
      }
    ],
    "type" : "parsing_exception",
    "reason" : "Unexpected token START_OBJECT [aggs] in [matrixstats].",
    "line" : 21,
    "col" : 26
  },
  "status" : 400
}

```

Thanks in advance,

Alex

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 15, 2018, 8:11pm UTC](https://discuss.elastic.co/t/elasticsearch-5-5-2-matrix-stats-aggregation-on-date-histogram/112299/2 "2018-01-15T20:11:57Z")

</div>

Closed on January 15, 2018, 8:11pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
