如何通过C#驱动程序创建2dsphere索引
我正试图做这样的事如何通过C#驱动程序创建2dsphere索引,c#,mongodb,indexing,2dsphere,C#,Mongodb,Indexing,2dsphere,我正试图做这样的事 db.points.ensureIndex( { <location field> : "2dsphere" } ) db.points.ensureIndex({:“2dsphere”}) 通过C#driver。但是API看起来只是以“key”作为参数,无法指定类型 你知道如何通过驱动程序来实现吗 谢谢关键是整个对象 {“位置”:“2dsphere”} 我有错误的理解 如果有人遇到与我相同的问题,请在此处发布。关键是整个对象 {“位置”:“2dspher
db.points.ensureIndex( { <location field> : "2dsphere" } )
db.points.ensureIndex({:“2dsphere”})
通过C#driver。但是API看起来只是以“key”作为参数,无法指定类型
你知道如何通过驱动程序来实现吗
谢谢关键是整个对象 {“位置”:“2dsphere”} 我有错误的理解
如果有人遇到与我相同的问题,请在此处发布。关键是整个对象 {“位置”:“2dsphere”} 我有错误的理解
如果有人遇到与我相同的问题,请在此处发布假设您有一个名为“位置”的字段,其中包含“类型”和“坐标”,即,它看起来如下所示:
{ _id : ...,
...,
'location' : {
'type' : 'Point',
'coordinates' : [ longValue, latValue]
}
}
为了在“location”字段上创建2dsphere索引,我们按照以下方式进行操作:
Collection.CreateIndex(IndexKeys.GeoSpatialSpherical("location"));
假设您有一个名为“位置”的字段,其中包含“类型”和“坐标”,即,它看起来如下所示:
{ _id : ...,
...,
'location' : {
'type' : 'Point',
'coordinates' : [ longValue, latValue]
}
}
为了在“location”字段上创建2dsphere索引,我们按照以下方式进行操作:
Collection.CreateIndex(IndexKeys.GeoSpatialSpherical("location"));