# Aggregation Path

**URL:** <https://discuss.elastic.co/t/aggregation-path/341172>\
**Category:** Elasticsearch\
**Created:** [August 20, 2023, 6:05am UTC](https://discuss.elastic.co/t/aggregation-path/341172 "2023-08-20T06:05:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noman13bd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/noman13bd/32/124761_2.png) [@noman13bd](https://discuss.elastic.co/u/noman13bd)\
**Post date:** [August 20, 2023, 6:05am UTC](https://discuss.elastic.co/t/aggregation-path/341172/1 "2023-08-20T06:05:05Z")

</div>

I want to use global number of total docs in bucket script. But getting the error `No aggregation found for path [global_total_docs>total_docs]`  
can you please help me to identify the right aggregation path?

```auto
GET bl_log_data/_search
{
  "size": 0,
  "aggs": {
    "global_total_docs": {
      "global": {},
      "aggs": {
        "total_docs": {
          "value_count": {
            "field": "_index"
          }
        }
      }
    },
    "group_by_keyword": {
      "terms": {
        "field": "response_code.keyword"
      },
      "aggs": {
        "percentage": {
          "bucket_script": {
            "buckets_path": {
              "doc_count": "_count",
              "total_docs": "global_total_docs>total_docs"
            },
            "script": "params.doc_count / params.total_docs * 100"
          }
        }
      }
    }
  }
}

```

---

<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:** [September 17, 2023, 6:05am UTC](https://discuss.elastic.co/t/aggregation-path/341172/2 "2023-09-17T06:05:56Z")

</div>

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