# Bucket\_script - No aggregation found for path ERROR

**URL:** https://discuss.elastic.co/t/bucket-script-no-aggregation-found-for-path-error/235092
**Category:** Elasticsearch
**Created:** [May 31, 2020, 9:24pm UTC](https://discuss.elastic.co/t/bucket-script-no-aggregation-found-for-path-error/235092 "2020-05-31T21:24:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![vdalvi](https://avatars.discourse-cdn.com/v4/letter/v/54ee81/32.png) [@vdalvi](https://discuss.elastic.co/u/vdalvi)
#### Post date: [May 31, 2020, 9:24pm UTC](https://discuss.elastic.co/t/bucket-script-no-aggregation-found-for-path-error/235092/1 "2020-05-31T21:24:31Z")

</div>

HI,

I have the below query, however in the buckets\_path for "var2" I am getting the ""No aggregation found for path" error.

Query

```auto
GET snmp-*/_search
{
  "_source": false,
  "query": {
    "range": {
      "timestamp": {
        "gte": "now-90m/m",
        "lte": "now"
      }
    }
  },
  "size": 0,
  "aggs": {
    "all_matching_docs": {
      "filters": {
        "filters": {
          "all": {
            "match_all": {}
          }
        }
      },
      "aggs": {
        "baselineCmtsCount": {
          "cardinality": {
            "field": "cmtsId"
          }
        },
        "every45min": {
          "date_histogram": {
            "field": "timestamp",
            "fixed_interval": "45m",
            "order": {
              "_key": "asc"
            }
          },
          "aggs": {
            "cmtsPer45min": {
              "cardinality": {
                "field": "cmtsId"
              }
            }
          }
        },
        "cmtsDerivative": {
          "bucket_script": {
            "buckets_path": {
              "var1": "baselineCmtsCount.value",
              "var2": "every45min.buckets.1.cmtsPer45min.value"
              
            },
            "script": "params.var1 - params.var2"
          }
        }
      }
    }
  }
}

```

Error

```auto
      {
        "type": "illegal_argument_exception",
        "reason": "No aggregation found for path [every45min.buckets.1.cmtsPer45min.value]"
      },

```

I am trying to parse the value from "every45min.buckets.1.cmtsPer45min.value" in my var2 to perform a difference with var1 (i.e var1 - var2)

Any help on what is wrong please ? 🙂

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [June 3, 2020, 5:48pm UTC](https://discuss.elastic.co/t/bucket-script-no-aggregation-found-for-path-error/235092/3 "2020-06-03T17:48:52Z")

</div>

Looks like you withdrew the post. Did you find the solution? What was it? Please share as others may have similar problems

---

<div class="post-metadata">

### Author: ![vdalvi](https://avatars.discourse-cdn.com/v4/letter/v/54ee81/32.png) [@vdalvi](https://discuss.elastic.co/u/vdalvi)
#### Post date: [June 3, 2020, 5:51pm UTC](https://discuss.elastic.co/t/bucket-script-no-aggregation-found-for-path-error/235092/4 "2020-06-03T17:51:37Z")

</div>

Hi Nathan, I did not find a solution actually, I just withdrew the last comment. However if you have any solution please share with me, thanks kindly 🙂

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [June 3, 2020, 5:57pm UTC](https://discuss.elastic.co/t/bucket-script-no-aggregation-found-for-path-error/235092/5 "2020-06-03T17:57:34Z")

</div>

Since this is a purely elasticsearch question. I have changed the topic from kibana to elasticsearch. That is a better place for elasticsearch DSL quesitons

---

<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: [July 1, 2020, 5:57pm UTC](https://discuss.elastic.co/t/bucket-script-no-aggregation-found-for-path-error/235092/6 "2020-07-01T17:57:47Z")

</div>

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