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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.4.8, 2.6.4, 2.7.6
    • 4.3.2
    • 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

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: