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

$in operator not behaving as expect in compound key scenarios

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Works as Designed
    • 1.4.4
    • None
    • Querying
    • None
    • ALL

    Description

      I have a compound key. Searching it directly works just fine.

      find({_id : { a:'1', b:'2' }}) -> 1 doc

      As I want to get a couple of documents in on query, varying on the second part of the key I tried

      find({_id : { a:'1', b: { $in: ['2'] }}) -> 0 docs

      while this was expected to give the very same result. After lots of tries I found that only

      find({ _id: { $in: [

      { a: '1', b: '2' }

      ] ]}) -> 1 docs

      works. Which essentially means one needs to send a lot of duplicated data in a query.

      find({ _id: { $in: [

      { a: '1', b: '1' }

      ,

      { a: '1', b: '2' }

      ,

      { a: '1', b: '3' }

      ,

      { a: '1', b: '4' }

      ] ]}) -> 4 docs

      Even worse - there is no error message or reason given why the $in operator does not work in compound keys.

      Could be related to http://jira.mongodb.org/browse/SERVER-1026

      Attachments

        Activity

          People

            eliot Eliot Horowitz (Inactive)
            tcurdt Torsten Curdt
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: