# How to create a single document with fields from multi documents

**URL:** https://discuss.elastic.co/t/how-to-create-a-single-document-with-fields-from-multi-documents/270141
**Category:** Elasticsearch
**Created:** [April 14, 2021, 7:12pm UTC](https://discuss.elastic.co/t/how-to-create-a-single-document-with-fields-from-multi-documents/270141 "2021-04-14T19:12:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anjilinga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anjilinga/32/86010_2.png) [@anjilinga](https://discuss.elastic.co/u/anjilinga)
#### Post date: [April 14, 2021, 7:12pm UTC](https://discuss.elastic.co/t/how-to-create-a-single-document-with-fields-from-multi-documents/270141/1 "2021-04-14T19:12:54Z")

</div>

Hi,  
I have 4 documents with the below fields  
{sessionid :1, callid:0001, service: 001}  
{sessionid :1, state:login, city: hyderabad}  
{sessionid :1, state:login, service:002}  
{sessionid :1, state:logout, handset: mobile}

The requirement is to create single document with the all the latest status of the fields for the sessionid.

what is the aggregation to be used in continuous transform.

I am using scripted metric, but is top hit aggrgation is supported in transform ?

Regards,  
Anji

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [April 14, 2021, 11:29pm UTC](https://discuss.elastic.co/t/how-to-create-a-single-document-with-fields-from-multi-documents/270141/2 "2021-04-14T23:29:48Z")

</div>

The docs here guide you on what aggregations are supported in the `pivot` - [Create transform API | Elasticsearch Guide [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html)

---

<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 12, 2021, 11:30pm UTC](https://discuss.elastic.co/t/how-to-create-a-single-document-with-fields-from-multi-documents/270141/3 "2021-05-12T23:30:20Z")

</div>

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