title: Wrong distance returned by ElasticSearch distanceInKm
body: <p>I've implemented a script field that returns distance like here <a href="https://stackoverflow.com/questions/9295118/return-distance-in-elasticsearch-results">Return distance in elasticsearch results?</a></p>
  
  <p>Ruby:</p>
  
  <pre><code>{
    script_fields: {
      distance: {
        script: "doc['#{source_field}'].distanceInKm(#{lat}, #{lng})"
      }
    }
  }
  </code></pre>
  
  <p>However the distance returned isn't correct. If the point is close, the distance is more correct but as it gets further away it gets more and more incorrect.</p>
  
  <p>Can't seem to figure out what I'm doing wrong.</p>