我正在尝试使用.Net MongoDB.Driver 2.10.0使用以下代码创建索引:
var indexKeysDefinition = Builders<Execution>.IndexKeys.Combine(
Builders<Execution>.IndexKeys.Ascending(a => a.ClientId),
Builders<Execution>.IndexKeys.Ascending(a => a.ProjectId),
Builders<Execution>.IndexKeys.Ascending(a => a.Deleted)
);
collection.Indexes.CreateOne(new CreateIndexModel<Execution>(indexKeysDefinition));
这将创建以下命令:
{ "createIndexes" : "xxx-execution", "indexes" : [{ "key" : { "ClientId" : 1, "ProjectId" : 1, "Deleted" : 1 }, "name" : "ClientId_1_ProjectId_1_Deleted_1" }] }
并导致以下错误:
Command createIndexes failed: Message: {"Errors":["Fields in 'spatialIndexes' are only allowed with newer API versions. Update your API version from '2018-06-18' to '2018-09-17' leverage this new feature."]}
字段的类型为字符串和布尔值。我找不到关于此错误的任何内容。该文档确实有一些空间字段,但是我没有在索引/查询中使用它们。