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

Can create indexes on non-insertable fields (i.e. beginning with '$')

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.4
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • Minor Change
    • ALL
    • Hide
      > coll.ensureIndex({'x.$a':1})
      Show
      > coll.ensureIndex({ 'x.$a' :1})

      Can create indices, for example:

      > coll.ensureIndex({'x.$a':1})
      > coll.getIndexes()
      [
      	{
      		"v" : 1,
      		"name" : "_id_",
      		"ns" : "test.t",
      		"key" : {
      			"_id" : 1
      		}
      	},
      	{
      		"v" : 1,
      		"ns" : "test.t",
      		"key" : {
      			"x.$a" : 1
      		},
      		"name" : "x.$a_1"
      	}
      ]

      You can also create an index that contains an empty field name, i.e.: "x..a"

      As you cannot save/insert/upsert a field with that name, it seems like incorrect behavior to be able to index on it.

            Assignee:
            amalia.hawkins@10gen.com Amalia Hawkins
            Reporter:
            amalia.hawkins@10gen.com Amalia Hawkins
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: