Developing a bridge to use a cms with MongoDB I use a storage key, value, type to manage all values linked to the cms. These key, types values are stored in the web.config to allow an extensible schema. No class object definition is allowed in this case to preserve the dynamic schema. The result is a storage as DynamicArray. This is generating some doubs about performing and the storage of latitude longitude to retrieve in a peform way using Query.Near operators.
DynamicArray
{
item : { Key: "lat", Value: "12.897", Type:double }
item : { Key: "lng", Value: "12.345", Type:double }
item : { Key: "country", Value: "USA", Type:String }
item : { Key: "state", Value: "CA", Type:String }
item : { Key: "city", Value: "San Jose", Type:String }
item : { Key: "district", Value: "", Type:String }
}
Query.ElemMatch("DynamicArray", Query.And(Query.EQ("Key", "country"), Query.EQ("Value", "USA")));
Query.Near ??
It’s a schema key value compatible with a GeoSpatial searching? And performant? How to query using official driver a Query.Near (C# official driver) in this schema way ?
Thanks.
In order to use geo-spatial queries on MongoDB, you need to store your x,y coordinates as the first two values in an object. Examples of valid schemas are:
You cannot separate the coordinates into multiple objects as you have done in your sample above.
For more information: http://www.mongodb.org/display/DOCS/Geospatial+Indexing