title: Return distance in geo distance query in elastic search 5.x
body: <p>I need to get distance from searched coordinates in elastic search using geo distance query. I tried this</p>
  
  <pre><code>curl -XGET 'http://127.0.0.1:9200/branch-master/master/_search?pretty=1'  -d '
  {
     "script_fields" : {
        "distance" : {
           "params" : {
              "lat" : 18.00,
              "lon" : 72.00
           },
           "script" : "doc[\u0027location\u0027].distanceInKm(lat,lon)"
        }
     }
  }
  '
  </code></pre>
  
  <p>This is got from <a href="https://stackoverflow.com/questions/9295118/return-distance-in-elasticsearch-results">Return distance in elasticsearch results?</a></p>
  
  <p>But this gives me error "unknown key for a start_object in [params]". I am not able understand what this is. Above solution seems to be for quite older version of ES. I am using ES 5.1. In the manual I couldn't find relavant solution for geo distance query. Could someone please help me?</p>