0

I am trying to perform a bounding box query on a mongo db collection. The collection has been there for quite a while and I recently upgraded my driver from 1.3 to 1.6 to take advantage of some new features in Mongodb 2.2. The following query doesn't work:

var query = Query<TrafficUpdate>.WithinRectangle(x => x.Loc, lowerLeft.Lon, lowerLeft.Lat, upperRight.Lon, upperRight.Lat);

The above line doesnt work anymore though. Comes back with an error about "cannot find special index 2d for ....."

Any help would be appreciated.

Thanks.

4

1 回答 1

0

Just found the answer actually. There must be a bug in the driver. Property Loc should be automapped as "loc" in the collection. This works just fine when writing to or reading from the db. But in the case of the WithinRectangle query (same for .Near query) it throws the error mentioned above.

The answer is to explicitly map the property in the configuration:

cm.MapProperty(c => c.Loc).SetElementName("loc");`

Maybe this will help some people.

于 2012-09-15T10:01:14.907 回答