# My bucket-script-based Transform is not showing the aggregation fields in the destination index

**URL:** <https://discuss.elastic.co/t/my-bucket-script-based-transform-is-not-showing-the-aggregation-fields-in-the-destination-index/284992>\
**Category:** Elasticsearch\
**Tags:** painless, transforms\
**Created:** [September 23, 2021, 10:49am UTC](https://discuss.elastic.co/t/my-bucket-script-based-transform-is-not-showing-the-aggregation-fields-in-the-destination-index/284992 "2021-09-23T10:49:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsouth](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@nsouth](https://discuss.elastic.co/u/nsouth)\
**Post date:** [September 23, 2021, 10:49am UTC](https://discuss.elastic.co/t/my-bucket-script-based-transform-is-not-showing-the-aggregation-fields-in-the-destination-index/284992/1 "2021-09-23T10:49:44Z")

</div>

Hi,

I'm trying to make my first transform and I'm not getting the results I expect. My source has multiple events correlated by a `command_unique_id` and I want to find the duration of these events by getting the timestamp difference between the last event and the first. This feels very similar to the [Getting duration by using bucket script](https://www.elastic.co/guide/en/elasticsearch/reference/current/transform-painless-examples.html#painless-bucket-script) example, but my output index is not showing any of my aggregate fields. Hopefully, I'm missing something obvious 🙂

My pivot configuration object:

```auto
{
  "group_by": {
    "command_unique_id": {
      "terms": {
        "field": "command_unique_id"
      }
    }
  },
  "aggregations": {
    "start-time": {
      "min": {
        "field": "timestamp"
      }
    },
    "end-time": {
      "max": {
        "field": "timestamp"
      }
    },
    "time_duration": {
      "bucket_script": {
        "buckets_path": {
          "start": "start-time",
          "end": "end-time"
        },
        "script": "params.end - params.start"
      }
    }
  }
}

```

One of the documents in my destination index:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/5/d5fd625b475c845532db1c3597454b520e26116a.png)

---

<div class="post-metadata">

**Author:** ![sophie\_chang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sophie_chang/32/18008_2.png) [@sophie\_chang](https://discuss.elastic.co/u/sophie_chang)\
**Post date:** [September 23, 2021, 11:05am UTC](https://discuss.elastic.co/t/my-bucket-script-based-transform-is-not-showing-the-aggregation-fields-in-the-destination-index/284992/2 "2021-09-23T11:05:57Z")

</div>

When developing the transform, it is helpful to use the transform `_preview` API. By using this, you can more easily see how adjustments to the scripts will affect results, without actually needing to create the transform and destination index. [Preview transform API | Elasticsearch Guide [7.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html)

From looking at the documented example, it expects `start-time.value` and `end-time.value` in the `bucket_script`. Have you tried this?

---

<div class="post-metadata">

**Author:** ![nsouth](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@nsouth](https://discuss.elastic.co/u/nsouth)\
**Post date:** [September 24, 2021, 10:33am UTC](https://discuss.elastic.co/t/my-bucket-script-based-transform-is-not-showing-the-aggregation-fields-in-the-destination-index/284992/3 "2021-09-24T10:33:12Z")

</div>

Thank you! The lack of the `.value` on the end was part of my issue. The other issue is that I was using the Kibana UI and for some reason it complained of a syntax error when including the "@" when specifying the `@timestamp` field. However, when I switched to using the dev console, it required the "@" and worked well with it.

---

<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:** [October 22, 2021, 10:33am UTC](https://discuss.elastic.co/t/my-bucket-script-based-transform-is-not-showing-the-aggregation-fields-in-the-destination-index/284992/4 "2021-10-22T10:33:55Z")

</div>

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