<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:10:07 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-5874] &quot;Group&quot; functionality issued under &apos;cmd&apos; gives different results than if issued from shell</title>
                <link>https://jira.mongodb.org/browse/SERVER-5874</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I have a very very simple aggregation command I wrote and executed from the MongoDB shell, using the db.&amp;lt;collection&amp;gt;.group() interface. It worked flawlessly and I got the expected results. I then try to execute the same aggregation command via the &apos;cmd&apos; format (in order to execute it over the Sleepy Mongoose interface via CURL) and it executed - only the aggregations all came back as &apos;0&apos;. Same data, same logic, etc.&lt;/p&gt;

&lt;p&gt;My reduce function in both cases:&lt;/p&gt;

&lt;p&gt;&quot;$reduce&quot;:&quot;function(obj,res) &lt;/p&gt;
{res.count++}
&lt;p&gt;&quot;}}&lt;/p&gt;

&lt;p&gt;When using the cmd interface, &apos;res&apos; 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 &apos;+&apos; operator...it seemed as if Mongo wasn&apos;t treating res.count as a long or float.&lt;/p&gt;

&lt;p&gt;It works fine using the db.collection.group() interface.&lt;/p&gt;</description>
                <environment>Amazon Linux 64 bit running on EC2</environment>
        <key id="39111">SERVER-5874</key>
            <summary>&quot;Group&quot; functionality issued under &apos;cmd&apos; gives different results than if issued from shell</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="2">Won&apos;t Fix</resolution>
                                        <assignee username="cwestin">Chris Westin</assignee>
                                    <reporter username="jo6971">Joe O</reporter>
                        <labels>
                            <label>commands</label>
                    </labels>
                <created>Fri, 18 May 2012 15:42:27 +0000</created>
                <updated>Wed, 15 Aug 2012 14:24:16 +0000</updated>
                            <resolved>Mon, 21 May 2012 17:00:43 +0000</resolved>
                                    <version>2.0.4</version>
                                                    <component>Aggregation Framework</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="121554" author="cwestin" created="Mon, 21 May 2012 16:59:55 +0000"  >&lt;p&gt;I&apos;ve tried several variations in the shell, and they appear to work fine.  So I think this is a problem with Sleepy.Mongoose, not the server.&lt;/p&gt;

&lt;p&gt;I an attempt to verify this, I tried installing and using Sleepy.Mongoose from &lt;a href=&quot;https://github.com/kchodorow/sleepy.mongoose/tree/master/sleepymongoose&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/kchodorow/sleepy.mongoose/tree/master/sleepymongoose&lt;/a&gt; .  However, when I try to use it, I get errors from pymongo.son that it can&apos;t import SON.  Our Python driver folks tell me this means that this package depends on a really old version of Pymongo.&lt;/p&gt;

&lt;p&gt;Then I also found out that we (10gen) don&apos;t officially support Sleepy.Mongoose.  I would suggest pursuing this through the issue tracker associated with that project.&lt;/p&gt;</comment>
                            <comment id="121047" author="jo6971" created="Fri, 18 May 2012 18:13:12 +0000"  >&lt;p&gt;Absolutely.&lt;/p&gt;

&lt;p&gt;This is the command that works from the shell:&lt;/p&gt;

&lt;p&gt;db.taxonomy_list.group({key:&lt;/p&gt;
{&quot;taxonomy&quot;:true}
&lt;p&gt;,cond:{&quot;coordinates&quot; : {&quot;$within&quot; : &lt;/p&gt;
{&quot;$box&quot; : [[-124.701058,24.434467], [-67.408986,49]]}
&lt;p&gt;}},initial:&lt;/p&gt;
{count:0}
&lt;p&gt;,reduce:function(doc,out){out.count++}});&lt;/p&gt;

&lt;p&gt;This produces the following (expected) output:&lt;/p&gt;

&lt;p&gt;[&lt;br/&gt;
	&lt;/p&gt;
{
		&quot;taxonomy&quot; : &quot;Influenza&quot;,
		&quot;count&quot; : 34
	}
&lt;p&gt;,&lt;br/&gt;
	&lt;/p&gt;
{
		&quot;taxonomy&quot; : &quot;Common Cold&quot;,
		&quot;count&quot; : 1280
	}
&lt;p&gt;,&lt;br/&gt;
	&lt;/p&gt;
{
		&quot;taxonomy&quot; : &quot;mosquito borne disease&quot;,
		&quot;count&quot; : 206
	}
&lt;p&gt;,&lt;br/&gt;
	&lt;/p&gt;
{
		&quot;taxonomy&quot; : &quot;Tuberculosis&quot;,
		&quot;count&quot; : 45
	}
&lt;p&gt;,&lt;br/&gt;
	&lt;/p&gt;
{
		&quot;taxonomy&quot; : &quot;Pertussis&quot;,
		&quot;count&quot; : 314
	}
&lt;p&gt;,&lt;/p&gt;

&lt;p&gt;etc...this works great!&lt;/p&gt;

&lt;p&gt;But when I try:&lt;/p&gt;

&lt;p&gt;curl --data &apos;cmd={&quot;group&quot; : {&quot;ns&quot;: &quot;taxonomy_list&quot;,&quot;key&quot;:&lt;/p&gt;
{&quot;taxonomy&quot;:1}
&lt;p&gt;,&quot;cond&quot;:{&quot;coordinates&quot; : {&quot;$within&quot; : &lt;/p&gt;
{&quot;$box&quot; : [[-124.701058,24.434467], [-67.408986,49]]}
&lt;p&gt;}},&quot;initial&quot;:&lt;/p&gt;
{&quot;count&quot;:0}
&lt;p&gt;,&quot;$reduce&quot;:&quot;function(doc,out)&lt;/p&gt;
{out.count++}
&lt;p&gt;&quot;}}&apos; &lt;a href=&quot;http://localhost:27080/hhs/_cmd&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://localhost:27080/hhs/_cmd&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;I get:&lt;/p&gt;

&lt;p&gt;{&quot;count&quot;: 2384.0, &quot;keys&quot;: 19, &quot;retval&quot;: [&lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Influenza&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Common Cold&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;mosquito borne disease&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Tuberculosis&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Pertussis&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Gastroenteritis&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Sexually Transmitted Disease&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Yellow Fever&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Rabies&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Tetanus&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;anthrax&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Meningitis&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Varicella&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Mumps&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Typhoid&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Pneumonia&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Malaria&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;tick borne disease&quot;}
&lt;p&gt;, &lt;/p&gt;
{&quot;count&quot;: 0.0, &quot;taxonomy&quot;: &quot;Polio&quot;}
&lt;p&gt;], &quot;ok&quot;: 1.0}&lt;/p&gt;

&lt;p&gt;NOTES: &lt;/p&gt;

&lt;p&gt;1. Yes, it is a spatial query, but I get the same results when I change it to a simple filter, like &lt;/p&gt;
{taxonomy:&quot;Yellow Fever&quot;}
&lt;p&gt;2. I&apos;ve got a ssh tunnel set up between my local machine and Mongo on EC2. Never had any issues here.&lt;br/&gt;
3. I&apos;ve messed around with this for a few hours, nothing seems to cause it to aggregate, the counts in the output are always the floating point representations of whatever long is in the init.&lt;br/&gt;
4. If I try to monkey with &apos;out.count&apos; field in the reduce function by adding methods, either the methods are not recognized, or the JSON doesn&apos;t parse, because you are using invalid operators with strings (I think).&lt;/p&gt;

&lt;p&gt;Lemme know if you need more, I could open the port on EC2 and let you in if it will help. This is all public data, nothing critical here. Lemme know, and thanks for the help!&lt;/p&gt;


</comment>
                            <comment id="121040" author="cwestin" created="Fri, 18 May 2012 17:46:28 +0000"  >&lt;p&gt;Could we please get the whole group command, along with a couple of sample data documents (suitably anonymized or obfuscated if necessary) ?&lt;/p&gt;

&lt;p&gt;Since you say the db.collection.group() (mongo shell) interface gives the correct result, there&apos;s likely something wrong with the mongoose access path, not the grouping code itself.  So could you also please show us how you are invoking that, so that we can reproduce this and trace into it?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 18 May 2012 17:46:28 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 39 weeks, 2 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 39 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10020"><![CDATA[Linux]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>cwestin</customfieldvalue>
            <customfieldvalue>jo6971</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hro2nb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hriqyf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>23020</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrjd4n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>