<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:12:44 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-6800] New Support for Positional Operator in Fields List Prevents Limited Inclusion of Fields in Selected Doc</title>
                <link>https://jira.mongodb.org/browse/SERVER-6800</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;When using the positional operator ($) in the field selection list of a find query to limit the embedded documents that are returned (new feature from &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-828&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-828&lt;/a&gt;), any other field inclusions for the embedded document are ignored (unless I&apos;m doing it wrong, although I don&apos;t think I am).&lt;/p&gt;

&lt;p&gt;I put a gist on gisthub that illustrates (&lt;a href=&quot;https://gist.github.com/3398285&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://gist.github.com/3398285&lt;/a&gt;), but a brief illustration would be:&lt;/p&gt;

&lt;p&gt;Blog post has multiple comments, you want to select the blog, along with the comment that has id 4. You also want to limit the fields of the comment that are returned to the title and body:&lt;/p&gt;

&lt;p&gt;db.BlogPosts.find(&lt;/p&gt;
{&quot;comments.id&quot;: 4}
&lt;p&gt;, &lt;/p&gt;
{&quot;title&quot;:1, &quot;body&quot;:1, &quot;comments.$&quot;:1, &quot;comments.title&quot;:1, &quot;comments.body&quot;:1}
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;The BlogPost is returned with its own title and body, and with just the one comment, but the entire comment is returned:&lt;/p&gt;

&lt;p&gt;{&lt;br/&gt;
   title: &apos;title&apos;, &apos;body&apos;: &apos;body&apos;&lt;br/&gt;
   comments: [&lt;/p&gt;
       {
           id: 4,
           title: &apos;title&apos;, &apos;body&apos;: &apos;body&apos;,
           &apos;otherFieldOne&apos;: &apos;etc&apos;, &apos;otherFieldTwo&apos;: &apos;etc&apos;
       }
&lt;p&gt;   ]&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;This isn&apos;t a big deal in a lot of situations, but if there were a number of embedded documents in the comment document, you might want to exclude them.&lt;/p&gt;</description>
                <environment></environment>
        <key id="47590">SERVER-6800</key>
            <summary>New Support for Positional Operator in Fields List Prevents Limited Inclusion of Fields in Selected Doc</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="scotthernandez">Scott Hernandez</assignee>
                                    <reporter username="isac1984">Isaac Foster</reporter>
                        <labels>
                    </labels>
                <created>Sun, 19 Aug 2012 22:59:43 +0000</created>
                <updated>Fri, 15 Feb 2013 15:06:25 +0000</updated>
                            <resolved>Mon, 20 Aug 2012 17:34:37 +0000</resolved>
                                    <version>2.2.0-rc1</version>
                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="155126" author="scotthernandez" created="Mon, 20 Aug 2012 22:48:31 +0000"  >&lt;p&gt;Yep, it is working as designed and I think exclusion is what you want to remove the fields you don&apos;t want from the embedded doc.&lt;/p&gt;</comment>
                            <comment id="155002" author="isac1984" created="Mon, 20 Aug 2012 18:17:28 +0000"  >&lt;p&gt;Sure, happy to, although I&apos;m not sure I got my issue across. &lt;/p&gt;

&lt;p&gt;The issue wasn&apos;t with mixing inclusion/exclusion clauses for retrievedFields (i.e. &lt;/p&gt;
{&quot;embedded.name&quot;: 1, &quot;embedded.body&quot;: 0}
&lt;p&gt;): it was &quot;mixing&quot; inclusion clauses in the retrievedFields object, when one of those projections uses the positional operator to return only the matched embedded document, and the other is to limit the returned fields in said document (i.e. &lt;/p&gt;
{&quot;embedded.$&quot;: 1, &quot;embedded.name&quot;: 1}
&lt;p&gt;). Just based on intuition (as far as that matters) I would expect the result set to include only the name field of the matched embedded document, but instead the whole matched embedded document is returned. I put an updated example below.&lt;/p&gt;

&lt;p&gt;Since the ability to use the positional operator to limit to the matched embedded document is a new feature in 2.2 (well, 2.1.2, but coming out in 2.2), I figured this was a bug.&lt;/p&gt;

&lt;p&gt;Not sure if that&apos;s what you thought I meant. If that behavior is expected and I&apos;m just missing something, let me know and I&apos;ll make a new feature request ticket.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

&lt;p&gt;UPDATED EXAMPLE:&lt;br/&gt;
&amp;gt; db.Col.find(&lt;/p&gt;
{conditions}
&lt;p&gt;, &lt;/p&gt;
{&quot;embedded.$&quot;:1, &quot;embedded.name&quot;:1}
&lt;p&gt;)&lt;br/&gt;
//EXPECTING&lt;br/&gt;
{&lt;br/&gt;
    _id: ObjectId(&apos;some id&apos;),&lt;br/&gt;
    embedded: [&lt;/p&gt;
        {
            name: &apos;name&apos;
        }
&lt;p&gt;    ]&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;//GETTING&lt;br/&gt;
{&lt;br/&gt;
    _id: ObjectId(&apos;some id&apos;),&lt;br/&gt;
    embedded: [&lt;/p&gt;
        {
            name: &apos;name&apos;,
            body: &apos;whatever&apos;,
            otherField: &apos;etc&apos;
        }
&lt;p&gt;    ]&lt;br/&gt;
}&lt;/p&gt;</comment>
                            <comment id="154972" author="scotthernandez" created="Mon, 20 Aug 2012 17:34:37 +0000"  >&lt;p&gt;Isaac, this sounds more like a feature request to allow mixing or inclusion/exclusion clauses for projection (retrievedFields). Can you create a new improvement request for that, if that is what you want.&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>Mon, 20 Aug 2012 17:34:37 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 26 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, 26 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>isac1984</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|hrnrh3:</customfieldvalue>

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

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

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