I have 3 "places" having each a type and a location:
PUT places/1
{
"type" : "A",
"location": {
"lat": 1.378446,
"lon": 103.763427
}
}
PUT places/2
{
"type" : "B",
"location": {
"lat": 1.478446,
"lon": 104.763427
}
}
PUT places/3
{
"type" : "A",
"location": {
"lat": 1.278446,
"lon": 102.763427
}
}
I'd like to retrieve only one (the closest from a given location) place per "type", so in my example result answer should be composed by exactly 2 elements (one for "type: A" and one for "type: B").
I'd also prefer to avoid "aggregations" as I will need the _source of each places.
Any help would be great.