<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:19:08 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-9028] Using positional operator with db.collection.find() to fetch multiple embedded documents does not work as expected</title>
                <link>https://jira.mongodb.org/browse/SERVER-9028</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I am not very sure whether this is bug, or that was intention to limit functionality this way. However here is the description:&lt;/p&gt;

&lt;p&gt;PRECONDITIONS:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;There is a DB with collection.&lt;/li&gt;
	&lt;li&gt;Collection documents have structure as follows:&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;Root document:&lt;br/&gt;
{&lt;br/&gt;
    _id:ObjectId(),&lt;br/&gt;
    name: ...,&lt;br/&gt;
    description: ...,&lt;br/&gt;
    subdocuments:&lt;br/&gt;
    [&lt;br/&gt;
        &lt;/p&gt;
{
            _id:ObjectId(),
            name: &apos;test1&apos;,
            description: ...,
        }
&lt;p&gt;,&lt;br/&gt;
        &lt;/p&gt;
{
            _id:ObjectId(),
            name: &apos;test2&apos;,
            description: ...,
        }
&lt;p&gt;,&lt;br/&gt;
        ...&lt;br/&gt;
    ]&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;STEPS TO REPRODUCE:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Open MongoDB Shell, switch to db &quot;DB&quot;&lt;/li&gt;
	&lt;li&gt;Execute query:&lt;br/&gt;
        db.collection.find(
{&apos;subdocuments.test&apos;: /test/i}
&lt;p&gt; ,&lt;/p&gt;
{&apos;subdocuments.$&apos;: 1, _id:0}
&lt;p&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;EXPECTED OUTCOME:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;The returned result should be the list of all subdocuments across the entire collection. Perhaps grouped into arrays by root documents, so if there are two satisfying elements in one root document and three in another then results will be list with two arrays where one has two elements and another has three.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;ACTUAL OUTCOME:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Error message with code 16352 appears. Which is illogical, because same conditions query but findOne instead of find, works as a charm and returns the array with one element in it, which is searched embedded document.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;As it is stated in ACTUAL OUTCOME block, the expected outcome is based on behavior with similar query but for finding single document.&lt;br/&gt;
Means &quot;db.collection.findOne(&lt;/p&gt;
{&apos;subdocuments.test&apos;: /test/i}
&lt;p&gt; ,&lt;/p&gt;
{&apos;subdocuments.$&apos;: 1, _id:0}
&lt;p&gt;)&quot; works, whereas &quot;db.collection.find(&lt;/p&gt;
{&apos;subdocuments.test&apos;: /test/i}
&lt;p&gt; ,&lt;/p&gt;
{&apos;subdocuments.$&apos;: 1, _id:0}
&lt;p&gt;)&quot; doesn&apos;t.&lt;/p&gt;



&lt;p&gt;Why is this important?&lt;br/&gt;
We chose this schema because 99% of queries fetch root document together with its subdocuments, but according to new functionality we should be able to get only subdocuments satisfying to specific conditions (think of it as regex search).&lt;br/&gt;
Of course its possible to first get entire root document (just remove field part from query and it will work), but then we would need to iterate through whole subdocuments array searching for the right ones. Seems like double work here, because DB already did scan for it ones (or used indexes) and we need to do it ourselves second time. Waste of time and resources.&lt;/p&gt;</description>
                <environment>Platform: Ubuntu 12.10 x64&lt;br/&gt;
Platform2: Debian Squeeze</environment>
        <key id="69048">SERVER-9028</key>
            <summary>Using positional operator with db.collection.find() to fetch multiple embedded documents does not work as expected</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</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="3">Duplicate</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="akamensky">Alexey Kamensky</reporter>
                        <labels>
                    </labels>
                <created>Wed, 20 Mar 2013 03:51:32 +0000</created>
                <updated>Wed, 10 Dec 2014 23:06:12 +0000</updated>
                            <resolved>Sun, 7 Apr 2013 11:58:34 +0000</resolved>
                                    <version>2.2.3</version>
                                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="307903" author="scotthernandez" created="Sun, 7 Apr 2013 11:58:34 +0000"  >&lt;p&gt;This feature request (returning multiple matches, instead of just one) in here: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6612&quot; title=&quot;Support projecting multiple array values in a projection like the $elemMatch projection specifier&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-6612&quot;&gt;&lt;del&gt;SERVER-6612&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The regex positional operator issue is here: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1155&quot; title=&quot;Update with positional operator with regex selector fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1155&quot;&gt;&lt;del&gt;SERVER-1155&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="307803" author="ronalstal@gmail.com" created="Sun, 7 Apr 2013 05:54:09 +0000"  >&lt;p&gt;From: &lt;a href=&quot;http://stackoverflow.com/questions/15496071/finding-embedded-documents-in-mongoose-odm&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://stackoverflow.com/questions/15496071/finding-embedded-documents-in-mongoose-odm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Issue can be reproduced in mongo shell&lt;/p&gt;

&lt;p&gt;&amp;gt; db.xx.find().pretty()&lt;br/&gt;
{&lt;br/&gt;
	&quot;_id&quot; : ObjectId(&quot;51610020672afd480ccfb9c4&quot;),&lt;br/&gt;
	&quot;name&quot; : &quot;any&quot;,&lt;br/&gt;
	&quot;subsets&quot; : [&lt;br/&gt;
		&lt;/p&gt;
{
			&quot;number&quot; : 3,
			&quot;name&quot; : &quot;aba&quot;
		}
&lt;p&gt;,&lt;/p&gt;
		{
			&quot;number&quot; : 4,
			&quot;name&quot; : &quot;aka&quot;
		}
&lt;p&gt;	]&lt;br/&gt;
}&lt;br/&gt;
&amp;gt; // works as expected:&lt;br/&gt;
&amp;gt; db.xx.find(&lt;/p&gt;
{&quot;subsets.number&quot;: 3}
&lt;p&gt;,{_id:0, &quot;subsets.$&quot;:1})&lt;br/&gt;
{ &quot;subsets&quot; : [ &lt;/p&gt;
{ &quot;number&quot; : 3, &quot;name&quot; : &quot;aba&quot; }
&lt;p&gt; ] }&lt;br/&gt;
&amp;gt; // does not work&lt;br/&gt;
&amp;gt; db.xx.find(&lt;/p&gt;
{&quot;subsets.name&quot;: /k/}
&lt;p&gt;,{_id:0, &quot;subsets.$&quot;:1})&lt;br/&gt;
error: {&lt;br/&gt;
	&quot;$err&quot; : &quot;positional operator (subsets.$) requires corresponding field in query specifier&quot;,&lt;br/&gt;
	&quot;code&quot; : 16352&lt;br/&gt;
}&lt;br/&gt;
&amp;gt; // but this works!&lt;br/&gt;
&amp;gt; db.xx.find({&quot;subsets&quot;: {$elemMatch:&lt;/p&gt;
{name:/k/}
&lt;p&gt;}},{_id:0, &quot;subsets.$&quot;:1})&lt;br/&gt;
{ &quot;subsets&quot; : [ &lt;/p&gt;
{ &quot;number&quot; : 4, &quot;name&quot; : &quot;aka&quot; }
&lt;p&gt; ] }&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="45484">SERVER-6612</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="12025">SERVER-1155</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sun, 7 Apr 2013 05:54:09 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 45 weeks, 3 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>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 45 weeks, 3 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_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>akamensky</customfieldvalue>
            <customfieldvalue>ronalstal@gmail.com</customfieldvalue>
            <customfieldvalue>scotthernandez</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrn0yn:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>46835</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|hszz6v:</customfieldvalue>

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