<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:59:22 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-2238] New projection operator $elemMatch</title>
                <link>https://jira.mongodb.org/browse/SERVER-2238</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Instead of a $ positional operator in projections ( as proposed here: &lt;a href=&quot;http://jira.mongodb.org/browse/SERVER-828&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/SERVER-828&lt;/a&gt;  ), I think that we could use a $elemMatch operator in projections, which will be used similiar to $slice.&lt;br/&gt;
An example in pseudo-js:&lt;br/&gt;
doc = {&apos;a&apos; : [ &lt;/p&gt;
{&apos;b&apos;:1}
&lt;p&gt;, &lt;/p&gt;
{&apos;b&apos;:2}
&lt;p&gt;, &lt;/p&gt;
{&apos;b&apos;:3}
&lt;p&gt; ],&apos;c&apos; :4}&lt;/p&gt;

&lt;p&gt;project( {&apos;a&apos; : [ &lt;/p&gt;
{&apos;b&apos;:1}
&lt;p&gt;, &lt;/p&gt;
{&apos;b&apos;:2}
&lt;p&gt;, &lt;/p&gt;
{&apos;b&apos;:3}
&lt;p&gt; ] }, {&apos;a&apos;:{$elemMatch:&lt;/p&gt;
{&apos;b&apos;:2}
&lt;p&gt;}} )&lt;br/&gt;
will be evaluated to:&lt;br/&gt;
{&apos;a&apos; : [&lt;/p&gt;
{&apos;b&apos;:2}
&lt;p&gt; ],&apos;c&apos; :4}&lt;/p&gt;

&lt;p&gt;project( {&apos;a&apos; : [ &lt;/p&gt;
{&apos;b&apos;:1}
&lt;p&gt;, &lt;/p&gt;
{&apos;b&apos;:2}
&lt;p&gt;, &lt;/p&gt;
{&apos;b&apos;:3}
&lt;p&gt; ] }, {&apos;a&apos;:{$elemMatch:{&apos;b&apos;:{&apos;$gte&apos;:2}}}} )&lt;br/&gt;
will be evaluated to:&lt;br/&gt;
{&apos;a&apos; : [&lt;/p&gt;
{&apos;b&apos;:2}
&lt;p&gt;, &lt;/p&gt;
{&apos;b&apos;:3}
&lt;p&gt;  ],&apos;c&apos; :4}&lt;/p&gt;


&lt;p&gt;The advantage over the $-operator is that, the projection is completly independent from the matching. So you could match on something completly different and return only the entries you want. Furthermore this should be easier to implement.&lt;/p&gt;

&lt;p&gt;The only problem I see is that, you will in many cases repeat yourself, because you want to extract the fields you are querying for.&lt;/p&gt;</description>
                <environment></environment>
        <key id="13988">SERVER-2238</key>
            <summary>New projection operator $elemMatch</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="benjamin.becker">Ben Becker</assignee>
                                    <reporter username="baju">Hannes</reporter>
                        <labels>
                    </labels>
                <created>Thu, 16 Dec 2010 21:39:04 +0000</created>
                <updated>Tue, 5 Mar 2013 18:07:44 +0000</updated>
                            <resolved>Fri, 15 Jun 2012 14:47:35 +0000</resolved>
                                                    <fixVersion>2.1.2</fixVersion>
                                    <component>Querying</component>
                                        <votes>19</votes>
                                    <watches>18</watches>
                                                                                                                <comments>
                            <comment id="159885" author="auto" created="Mon, 3 Sep 2012 13:56:36 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-09-02T23:51:06-07:00&apos;, u&apos;email&apos;: u&apos;stennie@10gen.com&apos;, u&apos;name&apos;: u&apos;Stephen Steneker&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-338&quot; title=&quot;Formalize process for reviewers in meta.procedures file&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-338&quot;&gt;&lt;del&gt;DOCS-338&lt;/del&gt;&lt;/a&gt;: Clarification that elemMatch projection only returns first match found (per &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2238&quot; title=&quot;New projection operator $elemMatch&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2238&quot;&gt;&lt;del&gt;SERVER-2238&lt;/del&gt;&lt;/a&gt;)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/234b3a99cc8a0222c27c5d040265588ea5d8e344&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/234b3a99cc8a0222c27c5d040265588ea5d8e344&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="148685" author="auto" created="Mon, 30 Jul 2012 15:06:46 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-07-27T20:11:08-07:00&apos;, u&apos;email&apos;: u&apos;jeff.yemin@10gen.com&apos;, u&apos;name&apos;: u&apos;Jeff Yemin&apos;}
&lt;p&gt;Message: More tests for &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-828&quot; title=&quot;Support for selecting array elements in return specifier (projection)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-828&quot;&gt;&lt;del&gt;SERVER-828&lt;/del&gt;&lt;/a&gt; and &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2238&quot; title=&quot;New projection operator $elemMatch&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2238&quot;&gt;&lt;del&gt;SERVER-2238&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/83ec59844bdd629b2b32a9791a4e7a0e93516c02&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/83ec59844bdd629b2b32a9791a4e7a0e93516c02&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="147825" author="benjamin.becker" created="Thu, 26 Jul 2012 21:06:31 +0000"  >&lt;p&gt;Just wanted to update some of the implementation details of this feature:&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;The $elemMatch projection specifier will only match one element&lt;/li&gt;
	&lt;li&gt;The projection should match the same element as the &apos;$&apos; positional operator (see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-828&quot; title=&quot;Support for selecting array elements in return specifier (projection)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-828&quot;&gt;&lt;del&gt;SERVER-828&lt;/del&gt;&lt;/a&gt;).&lt;/li&gt;
	&lt;li&gt;$elemMatch does not provide a way to sort the projected array (this could be very expensive).&lt;/li&gt;
	&lt;li&gt;&lt;tt&gt;sort()&lt;/tt&gt; still applies to the documents in the result set and does not impact the array element returned.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;This ticket outlines a nice feature to have, which is to match multiple elements in an array.  This was not implemented in the first pass due to interface and performance implications.  It&apos;s unlikely the behavior of $elemMatch will change (to ensure we don&apos;t break compatibility), but I have filed &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; to address that case in a future version.&lt;/p&gt;</comment>
                            <comment id="133298" author="benjamin.becker" created="Fri, 15 Jun 2012 14:47:35 +0000"  >&lt;p&gt;This was implemented along with &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-828&quot; title=&quot;Support for selecting array elements in return specifier (projection)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-828&quot;&gt;&lt;del&gt;SERVER-828&lt;/del&gt;&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/commit/fb66c84bc7bc1ece63a65766bfea2f797f3b7121&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/fb66c84bc7bc1ece63a65766bfea2f797f3b7121&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="103909" author="azat" created="Tue, 27 Mar 2012 10:05:44 +0000"  >&lt;p&gt;How with this feature will work sort()&lt;/p&gt;

&lt;p&gt;For example, if I add index on &quot;doc.a.b&quot; (see head of issue)&lt;br/&gt;
Is mongodb can sort(&lt;/p&gt;
{&quot;doc.a.b&quot;: -1}
&lt;p&gt;) documents using my index and is it will be sort using only that fields that I set using $elemMatch?&lt;/p&gt;</comment>
                            <comment id="22208" author="baju" created="Mon, 10 Jan 2011 11:48:44 +0000"  >&lt;p&gt;Hi Bradford.&lt;/p&gt;

&lt;p&gt;Nice idea. I thought about this feature for Arrays. But it might be surely helpful, if it was implemented for Hashes, too. Let&apos;s see what the Mongo-Developer think about it!&lt;/p&gt;</comment>
                            <comment id="22108" author="fingermark" created="Wed, 5 Jan 2011 18:36:01 +0000"  >&lt;p&gt;I really can&apos;t wait for this feature.  Mine is a little different, where I don&apos;t know the element to match on, because it&apos;s a randomly generated ID.  Would this case be handled?  I want all matched documents, but only include notes where hide == true.&lt;/p&gt;

&lt;p&gt;// given&lt;br/&gt;
{&lt;br/&gt;
        &quot;_id&quot; : &quot;store1&quot;,&lt;br/&gt;
        &quot;name&quot;: &quot;Store 1&quot;,&lt;br/&gt;
        &quot;notes&quot; : {&lt;br/&gt;
                &quot;4d221860edc6ae20218cc50a&quot; : &lt;/p&gt;
{
                        &quot;text&quot; : &quot;aaa&quot;,
                        &quot;hide&quot; : false
                }
&lt;p&gt;,&lt;br/&gt;
                &quot;4d221860edc6ae20218cc50b&quot; : &lt;/p&gt;
{
                        &quot;text&quot; : &quot;bbb&quot;,
                        &quot;hide&quot; : true
                }
&lt;p&gt;,&lt;br/&gt;
                &quot;4d221860edc6ae20218cc50c&quot; : &lt;/p&gt;
{
                        &quot;text&quot; : &quot;ccc&quot;,
                        &quot;hide&quot; : true
                }
&lt;p&gt;        }&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;// yield&lt;br/&gt;
{&lt;br/&gt;
        &quot;_id&quot; : &quot;store1&quot;,&lt;br/&gt;
        &quot;name&quot;: &quot;Store 1&quot;,&lt;br/&gt;
        &quot;notes&quot; : {&lt;br/&gt;
                &quot;4d221860edc6ae20218cc50b&quot; : &lt;/p&gt;
{
                        &quot;text&quot; : &quot;bbb&quot;,
                        &quot;hide&quot; : true
                }
&lt;p&gt;,&lt;br/&gt;
                &quot;4d221860edc6ae20218cc50c&quot; : &lt;/p&gt;
{
                        &quot;text&quot; : &quot;ccc&quot;,
                        &quot;hide&quot; : true
                }
&lt;p&gt;        }&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;// additionally, it&apos;d be nice to sort on notes.text desc:&lt;br/&gt;
{&lt;br/&gt;
        &quot;_id&quot; : &quot;store1&quot;,&lt;br/&gt;
        &quot;name&quot;: &quot;Store 1&quot;,&lt;br/&gt;
        &quot;notes&quot; : {&lt;br/&gt;
                &quot;4d221860edc6ae20218cc50c&quot; : &lt;/p&gt;
{
                        &quot;text&quot; : &quot;ccc&quot;,
                        &quot;hide&quot; : true
                }
&lt;p&gt;,&lt;br/&gt;
                &quot;4d221860edc6ae20218cc50b&quot; : &lt;/p&gt;
{
                        &quot;text&quot; : &quot;bbb&quot;,
                        &quot;hide&quot; : true
                }
&lt;p&gt;        }&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;I agree that this feature would make embedded documents more practical.&lt;/p&gt;</comment>
                            <comment id="21807" author="oallouch" created="Sun, 26 Dec 2010 11:48:57 +0000"  >&lt;p&gt;Sounds great, and if it can use indexes, it&apos;s gonna change the way we design our databases, as we won&apos;t be afraid to store a huge amount of embedded documents.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="45485">SERVER-6613</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="45484">SERVER-6612</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="65573">CSHARP-683</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="11615">SERVER-828</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="47495">DOCS-422</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>8.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sun, 26 Dec 2010 11:48:57 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 24 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, 24 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_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>azat</customfieldvalue>
            <customfieldvalue>benjamin.becker</customfieldvalue>
            <customfieldvalue>fingermark</customfieldvalue>
            <customfieldvalue>baju</customfieldvalue>
            <customfieldvalue>oallouch</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpa0f:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9016</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_10166" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Tests Written</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10154"><![CDATA[Complete]]></customfieldvalue>

                        </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|hrpmmv:</customfieldvalue>

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