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

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" : [ {"Bilekahalli", "Bengaluru", "Karnataka"},{"Electronic City","Bengaluru", "Karnataka"} ]

}

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

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.

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.

As I said, other than Response Filtering, there's no way of changing the response format that I know of.