# Searching with coordinates using NEST

**URL:** <https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669>\
**Category:** Elasticsearch\
**Created:** [December 7, 2017, 12:30pm UTC](https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669 "2017-12-07T12:30:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liron1379](https://avatars.discourse-cdn.com/v4/letter/l/dec6dc/32.png) [@Liron1379](https://discuss.elastic.co/u/Liron1379)\
**Post date:** [December 7, 2017, 12:30pm UTC](https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669/1 "2017-12-07T12:30:25Z")

</div>

How should the C# code look like when I'm searching with coordinates?  
I've tried to do it like a regular search but nothing seems to happen.

The regular search code is:

```
            var searchResponse = lowlevelClient.Search<string>(new
        {
            from = 0,
            size = 10,
            query = new
            {
                match = new
                {
                    fName = "name"
                }
            }
        });

        //THIS IS THE CODE I'VE TRIED TO SEARCH WITH:    
    
        var searchResponse = lowlevelClient.Search<string>(new
        {
            from = 0,
            size = 10,
            query = new
            {
                geo_bounding_box = new
                {
                    location = new
                    {
                        top_left = new
                        {
                            lat = 45,
                            lon = -55.80
                        },
                        top_right = new
                        {
                            lat = 21,
                            lon = -21.10
                        }
                    }
                }
            }
        });

```

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [December 10, 2017, 9:39pm UTC](https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669/2 "2017-12-10T21:39:49Z")

</div>

> [@Liron1379](#):
>
> ```auto
> top_left = new
> {
> lat = 45,
> lon = -55.80
> },
> top_right = new
> {
> lat = 21,
> lon = -21.10
> }
> 
> ```

In order to form a bounding box, you need to supply diagonally opposite coordinates for the box, usually `top_left` and `bottom_right`.

---

<div class="post-metadata">

**Author:** ![Liron1379](https://avatars.discourse-cdn.com/v4/letter/l/dec6dc/32.png) [@Liron1379](https://discuss.elastic.co/u/Liron1379)\
**Post date:** [December 11, 2017, 7:25am UTC](https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669/3 "2017-12-11T07:25:00Z")

</div>

Yeah I know that. But what is the syntax within NEST

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [December 11, 2017, 7:37am UTC](https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669/4 "2017-12-11T07:37:35Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/geo-bounding-box-query-usage.html](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/geo-bounding-box-query-usage.html)

---

<div class="post-metadata">

**Author:** ![Liron1379](https://avatars.discourse-cdn.com/v4/letter/l/dec6dc/32.png) [@Liron1379](https://discuss.elastic.co/u/Liron1379)\
**Post date:** [December 11, 2017, 7:49am UTC](https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669/5 "2017-12-11T07:49:38Z")

</div>

But what should I type instead of the "Project" class? And what does it contains

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [December 12, 2017, 12:32am UTC](https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669/6 "2017-12-12T00:32:00Z")

</div>

`Project` is the POCO type that represents/maps to the shape of the JSON within `_source` for a particular type within an index.

Take a look at the [NEST getting started guide](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/nest-getting-started.html) for detailed information on how to get started with the high level client.

---

<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 9, 2018, 12:32am UTC](https://discuss.elastic.co/t/searching-with-coordinates-using-nest/110669/7 "2018-01-09T00:32:12Z")

</div>

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