Aggregate min geo distance from a collection of location properties

Is there a way to promote a min geo distance to the root?

I have a location property of type object that contains a geo_point and
there is often multiple locations per root object.

            "location":{
                "type":"nested",
                "properties":{
                    "facility":{
                        "type":"nested",
                        "properties":{
                            "name":{"type":"string", 

index:"not_analyzed"},
"address":{
"properties":{
"city":{"type":"string",
index:"not_analyzed"},
"state":{"type":"string",
index:"not_analyzed"},
"zip":{"type":"string",
index:"not_analyzed"},
"country":{"type":"string",
index:"not_analyzed"}
}
},
"geo":{
"type":"geo_point",
"include_in_root":true
}
}
}
}
},

I have tried a variety of things within the script fields tag.
Initially, i was not using the nested type and was expecting an array of
doc.location.facility.geo to exist but that was never the case. It was
always a single org.elasticsearch.index.mapper.geo.GeoPointDocFieldData
object. I then switched to nested in hopes of being able to access the
array of locations that i could then traverse to locate the min geo
distance.

I see that there is more sophisticated aggregate support coming in 1.0, but
in the current release is there any way other than a script field to do
this?

initially attempted with mapping of type 'object'. I was expecting that i
would get an array of geopointdocfields.... i dont get an array however

"script_fields":{
    "distance":{
        "params":{
            "lat":42.3788774,
            "lon":-72.032366
        },
        "script": "c=doc['location.facility.geo'].empty ? null : 

doc['location.facility.geo']; nearest_distance=java.lang.Double.MAX_VALUE;
if(c!=null){for(cur : c) {dist=cur.distance(lat, lon); if(dist <
nearest_distance){ nearest_distance = dist}}}}; nearest_distance"
}
},

tried this approach with nested type on both location and facility (as
shown in the above mapping). I also was experimenting with include_in_root
for geo.
"script_fields":{
"distance":{
"params":{
"lat":42.3788774,
"lon":-72.032366
},
"script": " c=doc[\u0027location\u0027].empty ? null:
doc[\u0027location\u0027]; nearest_distance=java.lang.Double.MAX_VALUE;
if(c!=null){for(cur : c)
{if(cur["facility"]["geo"]!=null){dist=cur["facility"]["geo"].distance(lat,
lon); if(dist < nearest_distance){ nearest_distance = dist}}}};
nearest_distance"
}
},

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.