Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-36253

partialFilterExpression in partial indexes considers order of fields relevant

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • None
    • Query
    • ALL

      test@127.0.0.1:27017(4.0.0) > db.partial.ensureIndex({i: 1}, {partialFilterExpression: {dt: {$gte:ISODate("2016-07-12T23:58:24.278Z"),$lt: ISODate("2016-07-12T23:58:33.773Z")}}});
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 4,
      	"numIndexesAfter" : 5,
      	"ok" : 1
      }
      test@127.0.0.1:27017(4.0.0) > db.partial.ensureIndex({i: 1}, {partialFilterExpression: {dt: {$gte:ISODate("2016-07-12T23:58:24.278Z"),$lt: ISODate("2016-07-12T23:58:33.773Z")}},name:"i_1_partial2"})
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 5,
      	"numIndexesAfter" : 5,
      	"note" : "all indexes already exist",
      	"ok" : 1
      }
      test@127.0.0.1:27017(4.0.0) > db.partial.ensureIndex({i: 1}, {partialFilterExpression: {dt: {$lt: ISODate("2016-07-12T23:58:33.773Z"), $gte:ISODate("2016-07-12T23:58:24.278Z")}},name:"i_1_partial3"})
      {
      	"ok" : 0,
      	"errmsg" : "Index: { v: 2, key: { i: 1.0 }, name: \"i_1_partial3\", ns: \"test.partial\", partialFilterExpression: { dt: { $lt: new Date(1468367913773), $gte: new Date(1468367904278) } } } already exists with different options: { v: 2, key: { i: 1.0 }, name: \"i_1\", ns: \"test.partial\", partialFilterExpression: { dt: { $gte: new Date(1468367904278), $lt: new Date(1468367913773) } } }",
      	"code" : 85,
      	"codeName" : "IndexOptionsConflict"
      }
      

      But changing order in logical $and expression is not actually conflicting...

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: