# Dev tools painless lab vs Watcher transform Context (Map Stream)

**URL:** <https://discuss.elastic.co/t/dev-tools-painless-lab-vs-watcher-transform-context-map-stream/318256>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [November 6, 2022, 11:05am UTC](https://discuss.elastic.co/t/dev-tools-painless-lab-vs-watcher-transform-context-map-stream/318256 "2022-11-06T11:05:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelk](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kelk](https://discuss.elastic.co/u/kelk)\
**Post date:** [November 6, 2022, 11:05am UTC](https://discuss.elastic.co/t/dev-tools-painless-lab-vs-watcher-transform-context-map-stream/318256/1 "2022-11-06T11:05:35Z")

</div>

hi  
I could use below logic successfully in Watcher transforms

```auto
def documents = ctx.payload.hits.hits.stream()
    .map(hit -> [
      "sum_other_doc_count": hit._source.event_dataset.sum_other_doc_count
    ])
    .collect(Collectors.toList());
return ["_doc" : documents]; 

```

But I want to simulate simialr in the `DEV tools -> Painless Lab`. So I've taken the same sample data input for Watcher and copied into "parameters" within the Painless Lab. Now changed the logic as below, but is NOT working. Seems like map() etc is not working in `painless lab` ?

```auto
def doc = params.aggregations.stream()
          .map(hit -> [
              "sum_other_doc_count": "hit.event_dataset.sum_other_doc_count"
              ]);

return doc;

```

I wanted to simulate the same logic in Watcher within Painless Lab without changing the logic. Any help would be appreciated.

#### Data Attached below

```auto
{event_dataset={doc_count_error_upper_bound=0, sum_other_doc_count=783, buckets=[{doc_count=1553, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=1553, key=1451606400000}]}, key=Low Tide Media}, {doc_count=1370, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=1370, key=1451606400000}]}, key=Elitelligence}, {doc_count=1218, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=1218, key=1451606400000}]}, key=Oceanavigations}, {doc_count=1055, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=1055, key=1451606400000}]}, key=Tigress Enterprises}, {doc_count=947, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=947, key=1451606400000}]}, key=Pyramidustries}, {doc_count=525, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=525, key=1451606400000}]}, key=Angeldale}, {doc_count=458, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=458, key=1451606400000}]}, key=Gnomehouse}, {doc_count=415, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=415, key=1451606400000}]}, key=Spherecords}, {doc_count=345, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=345, key=1451606400000}]}, key=Microlutions}, {doc_count=263, time_aggs={buckets=[{key_as_string=2016-01-01T00:00:00.000Z, doc_count=263, key=1451606400000}]}, key=Spritechnologies}]}}

```

---

<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:** [December 4, 2022, 11:05am UTC](https://discuss.elastic.co/t/dev-tools-painless-lab-vs-watcher-transform-context-map-stream/318256/2 "2022-12-04T11:05:56Z")

</div>

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