title: How to get distance from elasticsearch.net / NEST for a geo_point field
body: <p>I would like to get in my search request the distance for a geo_point..</p>
  
  <p>I already write this request that gives me closest point to my searching param.</p>
  
  <pre><code>ConnectionSettings elasticSettings = new ConnectionSettings(new Uri("http://localhost:9200"));
          ElasticClient client = new ElasticClient(elasticSettings);
  
          var searchResults = client.Search&lt;dynamic&gt;(s =&gt; s.Index("index1,index2,index3").From(0).Size(10).Query(
             q =&gt; q.Bool(
             b =&gt; b.Must(
                      f =&gt; f.GeoDistance(
                       g =&gt; g.Distance(20, DistanceUnit.Kilometers).DistanceType(GeoDistanceType.Arc).Field("geo").Location(lat, lon))))));
  </code></pre>
  
  <p>I tried a lot of code found on the web but I can not adapt it for my code..
  I just want that elasticsearch return me the distance foreach point.</p>
  
  <p>My field in elasticsearch is like that (simple string): </p>
  
  <pre><code>    geo 74.875,-179.875 
  </code></pre>
  
  <p>and in another index test, is like that (structured) : the search doesn't works like this</p>
  
  <pre><code>geo {
  "lat": 74.875,
  "lon": -178.625
  }
  </code></pre>
  
  <p>Is the first or second mapping can have an impact on the query ?</p>
  
  <p>Here is my mapping for the index : </p>
  
  <pre><code>{
  "index1": {
  "aliases": {},
  "mappings": {
    "properties": {
      "Date": { "type": "date" },
      "Value": { "type": "text" },
      "geo": { "type": "geo_point" }
    }
  },
  "settings": {
    "index": {
      "refresh_interval": "1s",
      "number_of_shards": "4",
      "provided_name": "index1",
      "creation_date": "1569420798736",
      "number_of_replicas": "0",
      "uuid": "jqc1RRhxSC2e5yJJX2lyzw",
      "version": { "created": "7030199" }
    }
  }
  </code></pre>
  
  <p>}
  }</p>
  
  <p>I integrate a scripfield in my query like that :</p>
  
  <pre><code>  var searchResults = client.Search&lt;dynamic&gt;(s =&gt; s.Index("index").From(0).Size(100).ScriptFields(sf =&gt; sf.ScriptField("distance", d =&gt; d.Source("if(doc['geo'].size(){doc['geo'].arcDistance("+ lat+","+ lon + ")}"))).Query(
         q =&gt; q.Bool(
         b =&gt; b.Must(
                  f =&gt; f.GeoDistance(
                   g =&gt; g.Distance(20, DistanceUnit.Kilometers).DistanceType(GeoDistanceType.Arc).Field("geo").Location(lat, lon))))));
  </code></pre>
  
  <p>With this request, I have a "200 successfull" responses and it seems that I it returns me the distance but not the other field, and the 100 documents are null.</p>
  
  <pre><code>    Valid NEST response built from a successful (200) low level call on 
  POST: /index1/_search?typed_keys=true
  # Audit trail of this API call:
   - [1] HealthyResponse: Node: http://localhost:9200/ Took: 
  00:00:01.0670113
  # Request:
  {"from":0,"query":{"bool":{"must":[{"geo_distance": 
  {"distance":"200km","distance_type":"arc","geo": 
  {"lat":57.123,"lon":-20.876}}}]}},"script_fields":{"distance":{"script": 
  {"source":"doc['geo'].arcDistance(57.123,-20.876)"}}},"size":100}
  # Response:
  {
    "took": 3,
    "timed_out": false,
    "_shards": {
      "total": 4,
      "successful": 4,
      "skipped": 0,
      "failed": 0
    },
    "hits": {
      "total": {
       "value": 1203,
        "relation": "eq"
      },
      "max_score": 1.0,
       "hits": [
        {
          "_index": "index1",
          "_type": "_doc",
          "_id": "121197",
          "_score": 1.0,
          "fields": { "distance": [ 198251.11868760435 ] }
         },
        {
           "_index": "index1",
           "_type": "_doc",
          "_id": "121198",
          "_score": 1.0,
          "fields": { "distance": [ 197018.831847128 ] }
        },
         ...98 more
      ]
    }
  }
  </code></pre>
  
  <p>Thank you.</p>