# Convert a field datatype to object or nested in logstash

**URL:** <https://discuss.elastic.co/t/convert-a-field-datatype-to-object-or-nested-in-logstash/51419>\
**Category:** Logstash\
**Created:** [May 31, 2016, 11:11am UTC](https://discuss.elastic.co/t/convert-a-field-datatype-to-object-or-nested-in-logstash/51419 "2016-05-31T11:11:49Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![star](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@star](https://discuss.elastic.co/u/star)\
**Post date:** [June 2, 2016, 9:19am UTC](https://discuss.elastic.co/t/convert-a-field-datatype-to-object-or-nested-in-logstash/51419/6 "2016-06-02T09:19:31Z")

</div>

It is just like collect\_set query in hive. I want to group by on one field and want to get array of unique values from other field.  
Below is the JSON I got from elasticsearch after performing group by on 2 fields, city and hotels. Instead of that I want to group by on city and get distinct hotel names as array.

{ "key" : "Mumbai",  
"doc\_count" : 31348,  
"hotels in mumbai" : {  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 250,  
"buckets" : [ {  
"key" : "The Lalit",  
"doc\_count" : 20927  
}, {  
"key" : "Three Star",  
"doc\_count" : 5421  
}, {  
"key" : "Holiday Inn",  
"doc\_count" : 2295  
}]  
}  
}

---

_[View the full topic](https://discuss.elastic.co/t/convert-a-field-datatype-to-object-or-nested-in-logstash/51419)._
