# Bucket\_script aggregation on filters aggregation not showing results

**URL:** <https://discuss.elastic.co/t/bucket-script-aggregation-on-filters-aggregation-not-showing-results/227539>\
**Category:** Elasticsearch\
**Created:** [April 10, 2020, 5:38pm UTC](https://discuss.elastic.co/t/bucket-script-aggregation-on-filters-aggregation-not-showing-results/227539 "2020-04-10T17:38:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton\_Pirker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anton_pirker/32/1223_2.png) [@Anton\_Pirker](https://discuss.elastic.co/u/Anton_Pirker)\
**Post date:** [April 10, 2020, 5:38pm UTC](https://discuss.elastic.co/t/bucket-script-aggregation-on-filters-aggregation-not-showing-results/227539/1 "2020-04-10T17:38:27Z")

</div>

Hello!

I have "event" (like clicks on websites) documents in a index. Now I want to to calculate the ratio between events with name=x and events with name=y. I use a bucket\_script aggregation for that, but the result of it is not shown in the output...

Here is my query:

```auto
    GET /_search 
    {
      "query": { ... },
      "aggs": {
        "all_my_documents": {
          "filters": {
            "filters": {
              "all": { "match_all": {} }
            }
          }, 
          "aggs": {

            "bucket-aggregation-for-clicks-per-conversation": {
              "filters": {
                "filters": {
                  "presentation-clicks": { "term" : { "name" : "presentation-anchor-click" }},
                  "conversation-starts": { "term" : { "name" : "conversation-start" }}
                }
              }
            }, 
            "how-many-clicks-per-conversation": {
              "bucket_script": {
                  "buckets_path": {
                      "my_clicks": "bucket-aggregation-for-clicks-per-conversation['presentation-clicks']>_count", 
                      "my_starts": "bucket-aggregation-for-clicks-per-conversation['conversation-starts']>_count"
                  },
                  "script": "params.my_clicks / params.my_starts"
              }
            }

          }
        }
        
      }
    }

```

The query runs and as a result I get my two buckets but the "how-many-clicks-per-conversation" script does not seem to be run at all, because the value is missing from the output:

```auto
    ...
    "aggregations" : {
      "all_my_documents" : {
        "buckets" : {
          "all" : {
            "doc_count" : 5,
            "bucket-aggregation-for-clicks-per-conversation" : {
              "buckets" : {
                "conversation-starts" : {
                  "doc_count" : 4
                },
                "presentation-clicks" : {
                  "doc_count" : 1
                }
              }
            }
          }
        }
      }
    }

```

So, why is my bucket\_script not showing up in the output? Every help is greatly appreciated!

Thanks in advance  
Anton

---

<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:** [May 8, 2020, 5:38pm UTC](https://discuss.elastic.co/t/bucket-script-aggregation-on-filters-aggregation-not-showing-results/227539/2 "2020-05-08T17:38:31Z")

</div>

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