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

"Group" functionality issued under 'cmd' gives different results than if issued from shell

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.4
    • Component/s: Aggregation Framework
    • Labels:
    • Environment:
      Amazon Linux 64 bit running on EC2
    • Linux

      I have a very very simple aggregation command I wrote and executed from the MongoDB shell, using the db.<collection>.group() interface. It worked flawlessly and I got the expected results. I then try to execute the same aggregation command via the 'cmd' format (in order to execute it over the Sleepy Mongoose interface via CURL) and it executed - only the aggregations all came back as '0'. Same data, same logic, etc.

      My reduce function in both cases:

      "$reduce":"function(obj,res)

      {res.count++}

      "}}

      When using the cmd interface, 'res' is initialized to 0, the resultset will have the count field for the group by category set to 0.0. I tried to use the floatApprox method, setting the initial value of count to 1.0, etc but to no avail. res.count never increments. Also, while troubleshooting this, I noticed several JSON parsing issues related to the '+' operator...it seemed as if Mongo wasn't treating res.count as a long or float.

      It works fine using the db.collection.group() interface.

            Assignee:
            cwestin Chris Westin
            Reporter:
            jo6971 Joe O
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: