# Geodistance query NEST API

**URL:** https://discuss.elastic.co/t/geodistance-query-nest-api/161094
**Category:** Elasticsearch
**Created:** [December 17, 2018, 8:43am UTC](https://discuss.elastic.co/t/geodistance-query-nest-api/161094 "2018-12-17T08:43:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![waleedkaramat](https://avatars.discourse-cdn.com/v4/letter/w/6a8cbe/32.png) [@waleedkaramat](https://discuss.elastic.co/u/waleedkaramat)
#### Post date: [December 17, 2018, 8:43am UTC](https://discuss.elastic.co/t/geodistance-query-nest-api/161094/1 "2018-12-17T08:43:43Z")

</div>

Hello,  
I want to use elastic geodistance query in my C# application. I have referred the example on Elastic NEST API documentation which didn't work for me.  
Below is my code. kindly share with me an example I'm using elasticsearch version 6+

```
   var geoResult = client.Search<Myclass>(s => s
                     .Take(100)
                     .Query(q => q
                     .GeoDistance(g => g
                    .Boost(1.1)
                    .Name("named_query")
                    .Field(p => p.geometry)
                    .DistanceType(GeoDistanceType.Arc)
                    .Location( 39.589114,24.481397)
                    .Distance("200.0m")
                    .ValidationMethod(GeoValidationMethod.IgnoreMalformed)
                )));

```

I want to calculate the distance from the provided lat long but the query returns no results.

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [December 19, 2018, 5:20pm UTC](https://discuss.elastic.co/t/geodistance-query-nest-api/161094/2 "2018-12-19T17:20:05Z")

</div>

In your example you are searching for objects located within 200m from a point in [Aegean Sea](https://www.google.com/maps/place/39%C2%B035'20.8%22N+24%C2%B028'53.0%22E/@38.9217442,24.1667508,7.58z/data=!4m5!3m4!1s0x0:0x0!8m2!3d39.589114!4d24.481397), which is probably not what you intention was. If you were trying to find some points in Medina, you should flip the coordinates in such a way that latitude goes first: `.Location(24.481397, 39.589114)`. I

f that didn't help, could you share mapping and some test data that you are using, so I could reproduce the issue locally.

---

<div class="post-metadata">

### Author: ![waleedkaramat](https://avatars.discourse-cdn.com/v4/letter/w/6a8cbe/32.png) [@waleedkaramat](https://discuss.elastic.co/u/waleedkaramat)
#### Post date: [December 23, 2018, 1:20pm UTC](https://discuss.elastic.co/t/geodistance-query-nest-api/161094/3 "2018-12-23T13:20:30Z")

</div>

Hello Igor,  
Thanks for taking the time to reply, this worked for me.  
Thanks Once again.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 20, 2019, 1:27pm UTC](https://discuss.elastic.co/t/geodistance-query-nest-api/161094/4 "2019-01-20T13:27:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
