<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:56 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>[CSHARP-472] MapReduce fails with options SetQuery, SetSortOrder</title>
                <link>https://jira.mongodb.org/browse/CSHARP-472</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;The attached Program.cs fails with the message:&lt;/p&gt;

&lt;p&gt;    Message=Command &apos;mapreduce&apos; failed: db assertion failure (response: { &quot;assertion&quot; : &quot;could not create cursor over test.test for query : { B: &lt;/p&gt;
{ $exists: true }
&lt;p&gt; } sort : &lt;/p&gt;
{ B: 1 }
&lt;p&gt;&quot;, &quot;assertionCode&quot; : 15876, &quot;errmsg&quot; : &quot;db assertion failure&quot;, &quot;ok&quot; : 0.0 })&lt;/p&gt;

&lt;p&gt;The code is based on the official test TestMapReduceInlineWithQuery. Perhaps&lt;br/&gt;
the problem can be seen just there if the line&lt;/p&gt;

&lt;p&gt;    var result = _collection.MapReduce(query, map, reduce);&lt;/p&gt;

&lt;p&gt;is replaced with&lt;/p&gt;

&lt;p&gt;    var options = new MapReduceOptionsBuilder();&lt;br/&gt;
    options.SetQuery(query);&lt;br/&gt;
    options.SetOutput(MapReduceOutput.Inline);&lt;br/&gt;
    options.SetSortOrder((new SortByBuilder()).Ascending(&quot;B&quot;));&lt;br/&gt;
    var result = _collection.MapReduce(map, reduce, options);&lt;/p&gt;

&lt;p&gt;If I remove the line with SetSortOrder then the code works fine.&lt;/p&gt;

&lt;p&gt;Sorry if I just do something wrong and this is a false alarm. I asked the&lt;br/&gt;
question at the forum but did not get the answer.&lt;/p&gt;</description>
                <environment></environment>
        <key id="39190">CSHARP-472</key>
            <summary>MapReduce fails with options SetQuery, SetSortOrder</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="9">Done</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="nightroman">Roman Kuzmin</reporter>
                        <labels>
                    </labels>
                <created>Sun, 20 May 2012 18:12:53 +0000</created>
                <updated>Thu, 20 Mar 2014 16:39:31 +0000</updated>
                            <resolved>Tue, 22 May 2012 15:48:54 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="130578" author="rstam" created="Mon, 11 Jun 2012 21:35:37 +0000"  >&lt;p&gt;In what way does it not work?&lt;/p&gt;

&lt;p&gt;The best thing you could do is create a sample of what you mean using the mongo shell and file a server ticket.&lt;/p&gt;</comment>
                            <comment id="130231" author="imshenitsky" created="Mon, 11 Jun 2012 12:30:36 +0000"  >&lt;p&gt;It removes the error but sorting still doesn&apos;t work.&lt;/p&gt;</comment>
                            <comment id="121928" author="nightroman" created="Tue, 22 May 2012 16:17:29 +0000"  >&lt;p&gt;Yes, it works for me.&lt;/p&gt;

&lt;p&gt;It is still an issue, MR or its documentation. But it has nothing to do with C# driver, of course.&lt;/p&gt;

&lt;p&gt;Thank you for taking a look at this.&lt;/p&gt;</comment>
                            <comment id="121916" author="rstam" created="Tue, 22 May 2012 15:46:07 +0000"  >&lt;p&gt;Looks like the server requires the existence of an appropriate index that it can use for the sort when using sort with map/reduce.&lt;/p&gt;

&lt;p&gt;Try defining this index:&lt;/p&gt;

&lt;p&gt;&amp;gt; db.test.createIndex(&lt;/p&gt;
{B:1}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;and then it should work.&lt;/p&gt;</comment>
                            <comment id="121395" author="nightroman" created="Mon, 21 May 2012 11:55:36 +0000"  >&lt;p&gt;I&apos;ve tried this in the shell (after running my app, so that the test.test collection exists).&lt;/p&gt;

&lt;p&gt;It fails with the same error message. It does not fail if I remove the line with &apos;sort&apos;.&lt;/p&gt;

&lt;p&gt;JS code:&lt;/p&gt;

&lt;p&gt;map = function() {&lt;br/&gt;
	for (var key in this) {&lt;br/&gt;
		emit(key, &lt;/p&gt;
{count : 1}
&lt;p&gt;)&lt;br/&gt;
	}&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;reduce = function(key, emits) {&lt;br/&gt;
	total = 0&lt;br/&gt;
	for (var i in emits) &lt;/p&gt;
{
		total += emits[i].count
	}
&lt;p&gt;	return &lt;/p&gt;
{count : total}
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;db.runCommand(&lt;br/&gt;
 { mapreduce : &apos;test&apos;,&lt;br/&gt;
   map : map,&lt;br/&gt;
   reduce : reduce,&lt;br/&gt;
   out : &lt;/p&gt;
{ inline : 1 }
&lt;p&gt;,&lt;br/&gt;
   query : { $exists : &lt;/p&gt;
{B : true}
&lt;p&gt; },&lt;br/&gt;
   sort : &lt;/p&gt;
{ B : 1 }
&lt;p&gt; }&lt;br/&gt;
);&lt;/p&gt;</comment>
                            <comment id="121346" author="rstam" created="Mon, 21 May 2012 02:58:37 +0000"  >&lt;p&gt;Sorry, I missed your point that the existing unit tests could be modified to give the same error. Will try that in the morning (and/or use your attached program). Thanks.&lt;/p&gt;</comment>
                            <comment id="121341" author="nightroman" created="Mon, 21 May 2012 02:25:50 +0000"  >&lt;p&gt;Robert, I will try this in the shell as soon as I can (I&apos;m very lame in the shell, btw).&lt;/p&gt;

&lt;p&gt;As for the request for more information, the attached program has it all, it creates all that it needs. Also, you can use the existing test TestMapReduceInlineWithQuery and replace one line as I suggested.&lt;/p&gt;</comment>
                            <comment id="121338" author="rstam" created="Mon, 21 May 2012 02:11:55 +0000"  >&lt;p&gt;Two requests:&lt;/p&gt;

&lt;p&gt;1. Can you try the same map/reduce in the mongo shell to see if the C# driver has anything to do with this&lt;br/&gt;
2. And if so, can you provide more information to reproduce (sample documents, indexes defined, map/reduce functions...)&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;</comment>
                            <comment id="121335" author="rstam" created="Mon, 21 May 2012 02:07:53 +0000"  >&lt;p&gt;I assume the corresponding question on Google Groups is:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://groups.google.com/forum/?fromgroups#!topic/mongodb-user/SwULp7Y6oSY&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://groups.google.com/forum/?fromgroups#!topic/mongodb-user/SwULp7Y6oSY&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="14049">SERVER-2269</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="16736" name="Program.cs" size="1416" author="nightroman" created="Sun, 20 May 2012 18:12:53 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrh7jj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14021</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>