How to refer doc_count in MovingFunctions.ewma aggregation bucket path?

Hi,

Is there a way to directly refer the doc_count of date histogram(over time_millis field) bucket(s) in MovingFunctions.ewma bucket path, instead of creating a separate value_count aggregation (for the same field time_millis)?

Sample Query:

{
  "explain": false,
  "size": 0,
  "aggregations": {
    "time_millis_histogram": {
      "date_histogram": {
        "field": "time_millis",
        "offset": 0,
        "interval": "1m",
        "keyed": false,
        "min_doc_count": 1,
        "order": {
          "_key": "asc"
        }
      },
      "aggregations": {
        "time_value_count": {
          "value_count": {
            "field": "time_millis"
          }
        },
        "ewma": {
          "moving_fn": {
            "**buckets_path**": "time_value_count",
            "window": 10,
            "script": "MovingFunctions.ewma(values, 0.3)"
          }
        }
      }
    }
  }
}

Sample Response:

Resolved! Found that the doc_count can be directly referred in the MovingFunctions.ewma bucket path of a date histogram as _count.

Sample Query:

{
  "explain": false,
  "size": 0,
  "aggregations": {
    "time_millis_histogram": {
      "date_histogram": {
        "field": "time_millis",
        "offset": 0,
        "interval": "1m",
        "keyed": false,
        "min_doc_count": 1,
        "order": {
          "_key": "asc"
        }
      },
      "aggregations": {
        "ewma": {
          "moving_fn": {
            "buckets_path": "_count",
            "window": 10,
            "script": "MovingFunctions.ewma(values, 0.3)"
          }
        }
      }
    }
  }
}

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