带有数组和排序的Mongodb复杂索引

带有数组和排序的Mongodb复杂索引,mongodb,Mongodb,我的mongodb中有一个集合具有这种模式: processing { _id: ObjectId email: string country: [int] dtCreated: ISODate } 我创建了三个索引: 第一个是介于电子邮件和国家/地区之间: { "email" : 1.0, "country" : 1.0 } 第二个仅适用于创建的DTS: { "dtCreated" : 1

我的mongodb中有一个集合具有这种模式:

processing {
   _id: ObjectId
   email: string
   country: [int]
   dtCreated: ISODate
}
我创建了三个索引: 第一个是介于电子邮件和国家/地区之间:

{
   "email" : 1.0,
   "country" : 1.0
}
第二个仅适用于创建的DTS:

{
   "dtCreated" : 1.0
}
第三个涉及所有三个领域

{
   "email" : 1.0,
   "country" : 1.0,
   "dtCreated" : 1.0
}
当我执行一个按电子邮件和国家过滤并按dtCreated排序的查询时,我希望使用第二个索引,但只有当查询看起来像这样时才会出现这种情况

find({email:"myemail@email.email", country:1}).sort({dtCreated:1})
find({email:"myemail@email.email", country:{$ne:2}}).sort({dtCreated:1})
有时我不得不做一个不同的过滤器,看起来像这样

find({email:"myemail@email.email", country:1}).sort({dtCreated:1})
find({email:"myemail@email.email", country:{$ne:2}}).sort({dtCreated:1})
通过这一细微的改变,mongo使用dtCreated索引,而我期望使用的索引(包含所有三个字段的索引)被拒绝。
有没有办法让mongo使用复杂索引,即使应用了$ne过滤器?

这是否回答了您的问题?