Searching with coordinates using NEST

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?

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

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

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

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

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 for detailed information on how to get started with the high level client.

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