# Need some help on getting list of all locations associated with a keyword

**URL:** <https://discuss.elastic.co/t/need-some-help-on-getting-list-of-all-locations-associated-with-a-keyword/60518>\
**Category:** Elasticsearch\
**Created:** [September 14, 2016, 2:58pm UTC](https://discuss.elastic.co/t/need-some-help-on-getting-list-of-all-locations-associated-with-a-keyword/60518 "2016-09-14T14:58:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RamSailendraVarma](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@RamSailendraVarma](https://discuss.elastic.co/u/RamSailendraVarma)\
**Post date:** [September 14, 2016, 2:58pm UTC](https://discuss.elastic.co/t/need-some-help-on-getting-list-of-all-locations-associated-with-a-keyword/60518/1 "2016-09-14T14:58:37Z")

</div>

Hi Guys,

I have a scenario, when queried for a keyword i have to return all the locations associated with that keyword in a single document.

Lets say,

#document 1  
{

```
"bizzid": "1",
"bizzname": "Crazy Bakers",
"bizzLocation": [{
	"locationType": "locality",
	"name": "Bilekahalli"
}, {
	"locationType": "City",
	"name": "Bengaluru"
}, {
	"locationType": "State",
	"name": "Karnataka"
}],
"bizzCategory": [{
	"name": "Party planners",
	"categoryId": "10002"
}, {
	"name": "Weddings",
	"categoryId": "10023"
}]

```

}

#document 2  
{

```
"bizzid": "2",
"bizzname": "AmsterData",
"bizzLocation": [{
	"locationType": "locality",
	"name": "Electronic City"
}, {
	"locationType": "City",
	"name": "Bengaluru"
}, {
	"locationType": "State",
	"name": "Karnataka"
}],
"bizzCategory": [{
	"name": "Party planners",
	"categoryId": "10002"
}, {
	"name": "Weddings",
	"categoryId": "10023"
}]

```

}

So when i query for "Party planners" the result should give me all the bizzlocation but in a single document, some thing like

{  
"[bizzLocation.name](http://bizzLocation.name)" : [{"Bilekahalli", "Bengaluru", "Karnataka"},{"Electronic City","Bengaluru", "Karnataka"}]

}

I dont know if its possible. Any help is much appreciated.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [September 14, 2016, 3:48pm UTC](https://discuss.elastic.co/t/need-some-help-on-getting-list-of-all-locations-associated-with-a-keyword/60518/2 "2016-09-14T15:48:26Z")

</div>

Hi,

it looks like you want to transform your search results from a list of documents (matching your criteria, i.e. here the category of the business) to a single document. These kind of transformations need to happen in your own application logic. On the command line a good json processor like jq might do the trick, but in general I'd say this needs to happen on your side of things, not in elasticsearch.

---

<div class="post-metadata">

**Author:** ![ramz](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@ramz](https://discuss.elastic.co/u/ramz)\
**Post date:** [September 15, 2016, 11:02am UTC](https://discuss.elastic.co/t/need-some-help-on-getting-list-of-all-locations-associated-with-a-keyword/60518/3 "2016-09-15T11:02:49Z")

</div>

Hi Christoph,  
thanq for the reply. As you said its always good to have these logic at application level. Do we have any possibility to achieve such kind of transformations at elastic-search level?  
If so, how can we do it?

thanks,  
Ram.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [September 15, 2016, 12:08pm UTC](https://discuss.elastic.co/t/need-some-help-on-getting-list-of-all-locations-associated-with-a-keyword/60518/4 "2016-09-15T12:08:10Z")

</div>

As I said, other than [Response Filtering](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#_response_filtering), there's no way of changing the response format that I know of.

---

<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:** [July 5, 2017, 10:20pm UTC](https://discuss.elastic.co/t/need-some-help-on-getting-list-of-all-locations-associated-with-a-keyword/60518/5 "2017-07-05T22:20:01Z")

</div>


