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

positional operator element mismatch when using both $slice and $ projections

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 4.3.2
    • 2.4.8, 2.6.4, 2.7.6
    • Querying
    • Fully Compatible
    • ALL
    • Hide

      You insert a document with two array fields:

      db.test.insert( { "importing" : [ { "foo": "a" }, { "foo": "b" } ], "jobs" : [ { "status" : "completed" } ] } )

      You try to query it, where you use $slice on one, and $ on another. The query should match the second element in importing, which does not exist in jobs:

      db.test.find( { "importing.foo": "b" }, { jobs: { '$slice': -1 }, 'importing.$': 1 })

      You get:

      error: { "$err" : "positional operator element mismatch", "code" : 16353 }

      Show
      You insert a document with two array fields: db.test.insert( { "importing" : [ { "foo": "a" }, { "foo": "b" } ], "jobs" : [ { "status" : "completed" } ] } ) You try to query it, where you use $slice on one, and $ on another. The query should match the second element in importing, which does not exist in jobs: db.test.find( { "importing.foo": "b" }, { jobs: { '$slice': -1 }, 'importing.$': 1 }) You get: error: { "$err" : "positional operator element mismatch", "code" : 16353 }
    • Query 2019-11-18, Query 2019-12-02

    Description

      It is not possible to use both $slice and $ projections, even if they are on separate fields.

      Attachments

        Activity

          People

            ian.boros@mongodb.com Ian Boros
            mitar NOVALUE Mitar
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: