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

Creating Index with invalid properties

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.6.4
    • Component/s: Index Maintenance
    • None
    • ALL
    • Hide
      db.test.save({name : 'mongodb', date: new Date()})
      WriteResult({ "nInserted" : 1 })
      > db.test.save({name : 'mongodb2'})
      WriteResult({ "nInserted" : 1 })
      > db.test.find()
      { "_id" : ObjectId("55f8762792a0ee661e65b90b"), "name" : "mongodb", "date" : ISODate("2015-09-15T19:48:55.803Z") }
      { "_id" : ObjectId("55f8763192a0ee661e65b90c"), "name" : "mongodb2" }
      > db.test.ensureIndex({date :1}, {sparsse : true})
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.test.getIndexes()
      [
      	{
      		"v" : 1,
      		"key" : {
      			"_id" : 1
      		},
      		"name" : "_id_",
      		"ns" : "easytaxi_driver_restore.test"
      	},
      	{
      		"v" : 1,
      		"key" : {
      			"date" : 1
      		},
      		"name" : "date_1",
      		"ns" : "easytaxi_driver_restore.test",
      		"sparsse" : true
      	}
      ]
      
      Show
      db.test.save({name : 'mongodb' , date: new Date()}) WriteResult({ "nInserted" : 1 }) > db.test.save({name : 'mongodb2' }) WriteResult({ "nInserted" : 1 }) > db.test.find() { "_id" : ObjectId( "55f8762792a0ee661e65b90b" ), "name" : "mongodb" , "date" : ISODate( "2015-09-15T19:48:55.803Z" ) } { "_id" : ObjectId( "55f8763192a0ee661e65b90c" ), "name" : "mongodb2" } > db.test.ensureIndex({date :1}, {sparsse : true }) { "createdCollectionAutomatically" : false , "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.test.getIndexes() [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_" , "ns" : "easytaxi_driver_restore.test" }, { "v" : 1, "key" : { "date" : 1 }, "name" : "date_1" , "ns" : "easytaxi_driver_restore.test" , "sparsse" : true } ]

      When I created a index with a non existing property name by mistake I saw the "inexistent" property at getIndexes() property of my collection.

      Is this behaviour expected?

            Assignee:
            Unassigned Unassigned
            Reporter:
            adamobr Adamo Tonete
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: