<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:44:29 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-36927] Projection operator to return all and only array elements which matched filter in queries.</title>
                <link>https://jira.mongodb.org/browse/SERVER-36927</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;There are a dozen issues spanning years that ask for this feature and all are incorrectly closed saying that $elemMatch or $ projection operators do this. That is wrong. Examples:&lt;br/&gt;
 &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;&lt;br/&gt;
 &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6612&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-6612&lt;/a&gt;&lt;br/&gt;
 &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-7224&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-7224&lt;/a&gt;&lt;br/&gt;
 &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2238&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-2238&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Many use cases require ALL the matching elements from an array field, not just the first.&lt;/p&gt;

&lt;p&gt;I have a collection with documents that look like this:&lt;/p&gt;

&lt;p&gt;{{{}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160;entityId: 1,&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;events: [&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 2, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 3, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 4, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 5, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 6, otherData: {&lt;/tt&gt;}}&lt;br/&gt;
&lt;tt&gt;]&lt;/tt&gt;&lt;br/&gt;
{{ &lt;tt&gt;},&lt;/tt&gt;{}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160;entityId: 7,&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;events: [&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 8, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 9, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 10, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 11, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 12, otherData: {&lt;/tt&gt;}}&lt;br/&gt;
&lt;tt&gt;&#160;]&lt;/tt&gt;&lt;br/&gt;
{{ &lt;tt&gt;}&lt;/tt&gt;}}&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;and I&apos;d like to do a query like:&lt;/p&gt;

&lt;p&gt;{{&lt;tt&gt;collection.find({entityId: {$in: &lt;span class=&quot;error&quot;&gt;&amp;#91;1, 7&amp;#93;&lt;/span&gt;}, &apos;events.eventId&apos;: {$in: &lt;span class=&quot;error&quot;&gt;&amp;#91;3, 4, 5, 9&amp;#93;&lt;/span&gt;&lt;/tt&gt;, {entityId: 1, &apos;events.$$&apos;: 1})}}&lt;/p&gt;

&lt;p&gt;which I would expect to return:&lt;/p&gt;

&lt;p&gt;{{{}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160;entityId: 1,&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;events: [&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 3, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 4, otherData: {&lt;/tt&gt;,}}&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 5, otherData: {&lt;/tt&gt;}}&lt;br/&gt;
{{ &lt;tt&gt;&#160; ]&lt;/tt&gt;}}&lt;br/&gt;
&lt;tt&gt;},{&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;entityId: 7,&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;events: [&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160; &#160;{eventId: 9, otherData: {&lt;/tt&gt;}}&lt;br/&gt;
{{&lt;tt&gt;&#160;]&lt;/tt&gt;}}&lt;br/&gt;
&lt;tt&gt;}&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;This can be done with an aggregation, but that is not an acceptable work around for many use cases.&lt;/p&gt;

&lt;p&gt;Is there ever going to be such a feature for &quot;find&quot;s?&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="597382">SERVER-36927</key>
            <summary>Projection operator to return all and only array elements which matched filter in queries.</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</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="nick.brewer">Nick Brewer</assignee>
                                    <reporter username="jlangewayle">Joe Langeway at Live Earth</reporter>
                        <labels>
                    </labels>
                <created>Wed, 29 Aug 2018 19:46:44 +0000</created>
                <updated>Sun, 4 Nov 2018 17:16:21 +0000</updated>
                            <resolved>Mon, 1 Oct 2018 20:19:49 +0000</resolved>
                                                                                        <votes>2</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="2019732" author="nick.brewer" created="Mon, 1 Oct 2018 20:19:31 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jlangewayle&quot; class=&quot;user-hover&quot; rel=&quot;jlangewayle&quot;&gt;jlangewayle&lt;/a&gt; Since there&apos;s been no activity on this ticket in some time, I&apos;m going to close it. Let us know if you have any questions. &lt;/p&gt;

&lt;p&gt;-Nick&lt;/p&gt;</comment>
                            <comment id="1989487" author="nick.brewer" created="Thu, 30 Aug 2018 01:45:14 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jlangewayle&quot; class=&quot;user-hover&quot; rel=&quot;jlangewayle&quot;&gt;jlangewayle&lt;/a&gt; As you&apos;ve noted, aggregation is the way to accomplish this - there&apos;s currently not any plans to implement similar functionality in find. &lt;/p&gt;

&lt;p&gt;What use case you&apos;re hitting where aggregation isn&apos;t possible?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
-Nick&lt;/p&gt;</comment>
                            <comment id="1989248" author="jlangewayle" created="Wed, 29 Aug 2018 19:50:04 +0000"  >&lt;p&gt;I apologize, the wysiwyg editor mucked up the bits that were supposed to be preformatted. I expect most readers will still get the point.&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>Thu, 30 Aug 2018 01:45:14 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 19 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>backlog-server-pm</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            5 years, 19 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>jlangewayle</customfieldvalue>
            <customfieldvalue>nick.brewer</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu6ruf:</customfieldvalue>

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

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

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