<p dir="auto"><strong>Elasticsearch version</strong>: 2.4.0<br>
<strong>JVM version</strong>: 1.8<br>
<strong>OS version</strong>: Elastic Cloud</p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:</p>
<p dir="auto">distanceInMiles() is not recognized when GeoPoints come from an array.  Expected behavior is that the geo distance methods would operate on individual GeoPoints regardless of where they originate.</p>
<p dir="auto">Error Message: No signature of method: org.elasticsearch.common.geo.GeoPoint.distanceInMiles() is applicable for argument types: (java.lang.Double, java.lang.Double)</p>
<p dir="auto">Seems like elasticsearch is hoping for one of these: org.elasticsearch.index.fielddata.ScriptDocValues$GeoPoints</p>
<p dir="auto">Works fine: "script": "distance = doc['home.coordinates'].distanceInMiles(lat,lon)"<br>
Works fine: "script": "doc[favorite_parks.coordinates].each { coordinate -&gt; sumOfDistances = 1 }; return 1 "<br>
Doesn't work: "script": "doc[favorite_parks.coordinates].each { coordinate -&gt; sumOfDistances = coordinate.distanceInMiles(lat,lon) }; return 1 "</p>
<p dir="auto"><strong>Steps to reproduce</strong>:<br>
<a href="https://gist.github.com/alexlitvak13/8146cc5a8ac0defd5ffcf77116d375d4">https://gist.github.com/alexlitvak13/8146cc5a8ac0defd5ffcf77116d375d4</a></p>
<p dir="auto">Related commentary at the bottom of this ticket: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="134109979" data-permission-text="Title is private" data-url="https://github.com/elastic/elasticsearch/issues/16695" data-hovercard-type="issue" data-hovercard-url="/elastic/elasticsearch/issues/16695/hovercard" href="https://github.com/elastic/elasticsearch/issues/16695">#16695</a></p>
<p dir="auto">It will be really confortable to allow call to arcDistance from GeoPoint. Indeed actually we can only call them from GeoPoints (and that will use only the first point).</p>