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

$in operator not behaving as expect in compound key scenarios

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.4.4
    • Component/s: Querying
    • Labels:
      None
    • ALL

      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

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

              Created:
              Updated:
              Resolved: