我用$ hint命令坚持使用Mongo.我有收藏,我已经索引了这个集合.但问题是,我使用Aggregate框架查询集合,但我想暂时禁用索引,所以我使用这样的提示命令:
db.runCommand(
{aggregate:"MyCollectionName",
pipeline:[{$match : {...somthing...},
{$project : {...somthing...}}]
},
{$hint:{$natural:1}}
)
Run Code Online (Sandbox Code Playgroud)
请注意我{$hint:{$natural:1}}用来禁用此查询的索引,我在MongoDB命令行上运行了SUCCESSFULLY这个命令.但我不知道如何将此命令映射到Mongo Java Api(Java代码).
我使用了lib mongo-2.10.1.jar