<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:10:37 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-6050] Consider allowing $elemMatch applied to non arrays</title>
                <link>https://jira.mongodb.org/browse/SERVER-6050</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Currently $elemMatch can only be applied to an array.  For example { a:{ $elemMatch:{ $gte:1, $lte:10 } } } will match { a:[ 5 ] } but not { a:5 }.  This is a bit awkward in a case like { &apos;a.b&apos;:{ $elemMatch:{ $gte:1, $lte:10 } } } and a document { a:[ { b:5 }, { b:15 } ] }.  The document will not match because the b values are not arrays, even though there could be multiple values of &apos;a.b&apos;.&lt;/p&gt;</description>
                <environment></environment>
        <key id="40886">SERVER-6050</key>
            <summary>Consider allowing $elemMatch applied to non arrays</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="david.storch@mongodb.com">David Storch</assignee>
                                    <reporter username="aaron">Aaron Staple</reporter>
                        <labels>
                            <label>query_triage</label>
                    </labels>
                <created>Sat, 9 Jun 2012 17:35:42 +0000</created>
                <updated>Thu, 14 May 2020 22:17:42 +0000</updated>
                            <resolved>Thu, 16 Jun 2016 22:15:59 +0000</resolved>
                                                                    <component>Querying</component>
                                        <votes>16</votes>
                                    <watches>22</watches>
                                                                                                                <comments>
                            <comment id="1297296" author="david.storch" created="Thu, 16 Jun 2016 22:15:37 +0000"  >&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;The need for this change in behavior of the &lt;tt&gt;$elemMatch&lt;/tt&gt; operator has been eliminated by work done under &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-15086&quot; title=&quot;Allow for efficient range queries over non-array fields in multikey indices&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-15086&quot;&gt;&lt;del&gt;SERVER-15086&lt;/del&gt;&lt;/a&gt;. Therefore, I am closing this request as a duplicate. Starting in 3.4, the server will track which field paths in an index are multikey, and use this information to generate more efficient query plans. Please see the description of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-15086&quot; title=&quot;Allow for efficient range queries over non-array fields in multikey indices&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-15086&quot;&gt;&lt;del&gt;SERVER-15086&lt;/del&gt;&lt;/a&gt; for more detailed information on the new behavior offered in 3.4, including an example demonstrating the kinds of queries which will benefit.&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Dave&lt;/p&gt;</comment>
                            <comment id="948802" author="nate@lever.co" created="Wed, 24 Jun 2015 00:39:08 +0000"  >&lt;p&gt;Please do address this. Being able to efficiently query a field within an object in an array is something very valuable for our reporting implementation, and the current workarounds require storing data in a very unintuitive and awkward format.&lt;/p&gt;</comment>
                            <comment id="938082" author="oleg@evergage.com" created="Thu, 11 Jun 2015 18:38:38 +0000"  >&lt;p&gt;I agree that the first desire/usecase described is backwards breaking and not desirable, given that Eduardo replied to the original reporter with a query that works today. Many queries in Mongo are tricky to put together (e.g. it required Eduardo&apos;s experience to realize that he needs to build the kind of query that he supplied), but unfortunately that&apos;s the world of Mongo querying. In my experience, while I would it find it likely having to write queries like these, I find it a lot less likely to write code that stores either a single value as or an array of values under the same key name (and that&apos;s usually something that is easily addressed in the code doing the writing).&lt;/p&gt;</comment>
                            <comment id="937859" author="asya" created="Thu, 11 Jun 2015 16:50:29 +0000"  >&lt;p&gt;&lt;b&gt;If&lt;/b&gt; this ticket was implemented, it must be considered backwards breaking, since currently it&apos;s possible to use $elemMatch to test for a match that is &lt;b&gt;only&lt;/b&gt; satisfied by an array element, i.e. changing this behavior would change results of queries on collections which have fields that have both array and non-array values that match.&lt;/p&gt;</comment>
                            <comment id="727499" author="nefiga" created="Thu, 25 Sep 2014 21:14:07 +0000"  >&lt;p&gt;It seems that this suggestion would provide a fix for &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-15086&quot; title=&quot;Allow for efficient range queries over non-array fields in multikey indices&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-15086&quot;&gt;&lt;del&gt;SERVER-15086&lt;/del&gt;&lt;/a&gt;. Please upvote this ticket and also &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-15086&quot; title=&quot;Allow for efficient range queries over non-array fields in multikey indices&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-15086&quot;&gt;&lt;del&gt;SERVER-15086&lt;/del&gt;&lt;/a&gt; as it would provide a much needed fix for using indexes on range queries of scalar values inside of arrays.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="272816" author="jemanso" created="Fri, 22 Feb 2013 05:35:25 +0000"  >&lt;p&gt;I don&apos;t think that applying $elemMatch to non arrays would be a good idea, but, I agree with you about the issue on searching objects inside arrays. &lt;/p&gt;

&lt;p&gt;The following query works perfect for your example:&lt;/p&gt;

&lt;p&gt;INDEX - &lt;/p&gt;
{&quot;a.b&quot;:1}
&lt;p&gt;QUERY - {&quot;a&quot;:{ $elemMatch:{ &quot;b&quot;:{$gte:1, $lte:10} } } }&lt;/p&gt;

&lt;p&gt;In this case $elemMatch is related to &quot;a&quot;, what is the correct way to do that, and the condition {$gte:1, $lte:10} is related to &quot;b&quot;.&lt;/p&gt;

&lt;p&gt;In my point of view, there is no need for changing $elemMatch behavior. But there is a problem here that I&apos;ve tried to explain on &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-8610&quot; title=&quot;$elemMatch (objects in array) not using index range correctly&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-8610&quot;&gt;&lt;del&gt;SERVER-8610&lt;/del&gt;&lt;/a&gt;. If you use the above query, it will work as expected but it will not use de index &lt;/p&gt;
{&quot;a.b&quot;:1}
&lt;p&gt; as it should. What happens is that It uses the index but just the &quot;$gte&quot; part, so it starts at &quot;$gte:1&quot; and don&apos;t stops at &quot;$lte:10&quot;... it just scans the whole index, without respecting the RANGE &quot;1~10&quot;.&lt;/p&gt;

&lt;p&gt;Please, see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-8610&quot; title=&quot;$elemMatch (objects in array) not using index range correctly&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-8610&quot;&gt;&lt;del&gt;SERVER-8610&lt;/del&gt;&lt;/a&gt; and, if you agree, help me voting for this urgent fix.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="155427">SERVER-15086</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="33043">SERVER-5320</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="59632">SERVER-7959</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1338881">SERVER-47925</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="12204">SERVER-1264</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>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 22 Feb 2013 05:35:25 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        7 years, 34 weeks, 6 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>david.storch@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            7 years, 34 weeks, 6 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>aaron</customfieldvalue>
            <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>nefiga</customfieldvalue>
            <customfieldvalue>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>jemanso</customfieldvalue>
            <customfieldvalue>nate@lever.co</customfieldvalue>
            <customfieldvalue>oleg@evergage.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hro0in:</customfieldvalue>

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

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

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