가 어떻게 MongoDB를위한 10gen의 C#을 드라이버를 사용하여 Geospatial Haystack Index를 만들려면 어떻게해야합니까MongoDB를 지리 건초 더미 인덱싱
JS 예 :
db.foo.ensureIndex({ pos : "geoHaystack", type : 1 }, { bucketSize : 1 })
C# 예 작동하지 않습니다 :
BsonDocument keys = new BsonDocument();
keys.Add("pos", "geoHaystack");
keys.Add("type", "1");
IMongoIndexKeys indexKeys = new IndexKeysDocument(keys);
IndexOptionsDocument indexOptions = new IndexOptionsDocument("bucketSize", new BsonInt32(1));
collection.CreateIndex(indexKeys, indexOptions);
이를 제공 오류 :
나는이 같은 '유형'키를 제거하면 63,210MongoDB.Driver.MongoSafeModeException : Safemode detected an error 'can only have 1 index plugin/bad index key pattern'. (Response was { "err" : "can only have 1 index plugin/bad index key pattern", "code" : 13007, "n" : 0, "connectionId" : 6, "ok" : 1.0 }).
그래서 :
IMongoIndexKeys keys = new IndexKeysDocument {
{ "Position", "geoHaystack" },
{ "type", 1 }
};
IMongoIndexOptions options = new IndexOptionsDocument {
{ "bucketSize", 1 }
};
collection.EnsureIndex(keys, options);
문제 I : 내가 작업을 얻었다
MongoDB.Driver.MongoSafeModeException : Safemode detected an error 'no other fields specified'. (Response was { "err" : "no other fields specified", "code" : 13317, "n" : 0, "connectionId" : 7, "ok" : 1.0 }).
감사합니다. RameshVel :) – Robert