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

MongoDB: Too many positional (i.e. '$') elements found in path

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.0, 2.6.1
    • Component/s: Querying
    • None
    • ALL
    • Hide

      Run this query:

      db.post.update(

      { 'answers.comments.name': 'jeff' }

      ,
      { '$set': {
      'answers.$.comments.$.name': 'joe'
      }},

      { multi: true }

      )

      Show
      Run this query: db.post.update( { 'answers.comments.name': 'jeff' } , { '$set': { 'answers.$.comments.$.name': 'joe' }}, { multi: true } )

      I just upgraded to Mongo 2.6.1 and one update statement that was working before is not returning an error. The update statement is:

      db.post.update( { 'answers.comments.name': 'jeff' },
          { '$set': {
              'answers.$.comments.$.name': 'joe'
          }},
          { multi: true }
      )
      

      The error I get is:

      WriteResult({
          "nMatched" : 0,
          "nUpserted" : 0,
          "nModified" : 0,
          "writeError" : {
              "code" : 2,
              "errmsg" : "Too many positional (i.e. '$') elements found in path 'answers.$.comments.$.createUsername'"
          }
      })
      

      When I update an element just one level deep instead of two (i.e. answers.$.name instead of answers.$.comments.$.name), it works fine. If I downgrade my mongo instance below 2.6, it also works fine.

            Assignee:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Reporter:
            jeffwhelpley Jeff Whelpley
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: