Question: I'm trying to fetch geo index in pymongo and asyncmongo using `$near` options. But it's always returning wrong **nearby locations**. Could anyone help me to sort out the problem.

```
self.application.db.citydetails.find({"loc":{"$near":(latitude, longitude)}}, limit=20, callback=self.loadMoreSearchResponse)

```

Answer: 
First, ensure your `citydetails.loc` data is stored as a GeoJSON point:

```
{loc: {type: "Point", coordinates: [ longitude, latitude ]}}

```

Please note that when saving geo spatial points, longitude must be placed at the 0 index in the `coordinates` array.

Then, change your code placing longitude before latitude in the query:

```
self.application.db.citydetails.find({"loc":{"$near":(longitude, latitude)}}, limit=20, callback=self.loadMoreSearchResponse)

```
I didn't realize, am kind of fool here. As soon as i get the `POST` arguments, am trying to pass it in query like

```
coordinates = self.get_argument("coordinates", "")
latitude = coordinates.split("_")[0]
longitude = coordinates.split("_")[1]
self.application.db.cityinfo.find({"loc":{"$near":(longitude, latitude)}}, limit=20, callback=self.loadMoreSearchResponse)

```

It seems, i'm passing string into the query. I just converted to `float` then its working fine

```
coordinates = self.get_argument("coordinates", "")
latitude = float(coordinates.split("_")[0])
longitude = float(coordinates.split("_")[1])
self.application.db.cityinfo.find({"loc":{"$near":(longitude, latitude)}}, limit=20, callback=self.loadMoreSearchResponse)

```

Hope, it'll help for someone else in future.