<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:58:42 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-2013] Have $or queries with two $in queries to return unique results</title>
                <link>https://jira.mongodb.org/browse/SERVER-2013</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;It seems $or queries should have the option to return unique results instead of (as far as I can tell) amalgamating the results of the individual $or statements.&lt;/p&gt;

&lt;p&gt;For example if you have&lt;/p&gt;

&lt;p&gt;1: &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;color: Color value is invalid&lt;/span&gt; &lt;/div&gt;
&lt;p&gt;2: &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;color: Color value is invalid&lt;/span&gt; &lt;/div&gt;

&lt;p&gt;$or: [ {color: {$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;blue&amp;#39;,&amp;#39;red&amp;#39;&amp;#93;&lt;/span&gt;} }, {shape: {$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;circle,square&amp;#93;&lt;/span&gt;} } ]&lt;/p&gt;

&lt;p&gt;Right now it seems to returns 4 results in the cursor. Both documents are returned twice.&lt;/p&gt;</description>
                <environment></environment>
        <key id="13517">SERVER-2013</key>
            <summary>Have $or queries with two $in queries to return unique results</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="aaron">Aaron Staple</assignee>
                                    <reporter username="chrischen21">Chris</reporter>
                        <labels>
                    </labels>
                <created>Wed, 27 Oct 2010 04:41:17 +0000</created>
                <updated>Fri, 7 Apr 2023 11:49:04 +0000</updated>
                            <resolved>Wed, 27 Oct 2010 17:11:20 +0000</resolved>
                                    <version>1.5.3</version>
                    <version>1.5.4</version>
                    <version>1.5.5</version>
                    <version>1.5.6</version>
                    <version>1.5.7</version>
                    <version>1.5.8</version>
                    <version>1.6.0</version>
                    <version>1.6.1</version>
                    <version>1.6.2</version>
                    <version>1.6.3</version>
                    <version>1.6.4</version>
                    <version>1.7.0</version>
                    <version>1.7.1</version>
                                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="19707" author="aaron" created="Wed, 27 Oct 2010 17:11:20 +0000"  >&lt;p&gt;This is &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1883&quot; title=&quot;dropping previous clause or matches fails with nested field matches&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1883&quot;&gt;&lt;del&gt;SERVER-1883&lt;/del&gt;&lt;/a&gt; which has been fixed and backported.&lt;/p&gt;</comment>
                            <comment id="19690" author="chrischen21" created="Wed, 27 Oct 2010 08:33:06 +0000"  >&lt;p&gt;Hey sorry I didn&apos;t actually test out that example since I thought it was an unimplemented feature and it would exhibit same result with non-subobjects.&lt;/p&gt;

&lt;p&gt;It turns out it may be a bug then since it only occurs on subobject query and a unique index&lt;/p&gt;

&lt;p&gt;Take this modified example:&lt;/p&gt;

&lt;p&gt;db.f.save( {_id:ObjectId(&quot;4cc7e1348b3106c682ef1bce&quot;),color:&apos;blue&apos;,shape:{a:&apos;circle&apos;}} ); &lt;br/&gt;
db.f.save( {_id:ObjectId(&quot;4cc7dfc38b3106c682ef1bca&quot;),color:&apos;red&apos;,shape:&apos;square&apos;} ); &lt;/p&gt;

&lt;p&gt;db.f.ensureIndex(&lt;/p&gt;
{&quot;shape.a&quot;:1}
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;db.f.find( { $or: [ {_id: {$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;ObjectId(&amp;quot;4cc7e1348b3106c682ef1bce&amp;quot;)&amp;#93;&lt;/span&gt;} }, {&quot;shape.a&quot;: {$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;circle&amp;#39;&amp;#93;&lt;/span&gt;} } ] } );&lt;br/&gt;
Normal: only 1 result&lt;/p&gt;

&lt;p&gt;db.f.find( { $or: [ {&quot;shape.a&quot;: {$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;circle&amp;#39;&amp;#93;&lt;/span&gt;} }, {_id:{$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;ObjectId(&amp;quot;4cc7e1348b3106c682ef1bce&amp;quot;)&amp;#93;&lt;/span&gt;}} ] } );&lt;br/&gt;
Weird: same result comes up twice, only switched the order of the or queries.&lt;/p&gt;

&lt;p&gt;It doesn&apos;t just happen when the second $or query is _id, it happens whenever the second one has a unique index on it.&lt;/p&gt;

&lt;p&gt;So this does the same thing:&lt;/p&gt;

&lt;p&gt;db.f.save( {color:&apos;blue&apos;,shape:{a:&apos;circle&apos;}} ); &lt;br/&gt;
db.f.save( &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;color: Color value is invalid&lt;/span&gt; &lt;/div&gt;
&lt;p&gt; ); &lt;/p&gt;

&lt;p&gt;db.f.ensureIndex(&lt;/p&gt;
{&quot;color&quot;:1}
&lt;p&gt;,&lt;/p&gt;
{unique:1}
&lt;p&gt;);&lt;br/&gt;
db.f.ensureIndex(&lt;/p&gt;
{&quot;shape.a&quot;:1}
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;db.f.find( { $or: [ {&quot;shape.a&quot;: {$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;circle&amp;#39;&amp;#93;&lt;/span&gt;} }, {color:{$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;blue&amp;#39;&amp;#93;&lt;/span&gt;}} ] } );&lt;/p&gt;

&lt;p&gt;On the bright side it seems the fix is just to put the unique indexed query first in the $or array;&lt;/p&gt;</comment>
                            <comment id="19689" author="aaron" created="Wed, 27 Oct 2010 07:26:41 +0000"  >&lt;p&gt;I&apos;m not seeing this behavior:&lt;/p&gt;


&lt;p&gt;&amp;gt; db.f.drop()&lt;br/&gt;
true&lt;br/&gt;
&amp;gt; db.f.save( &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;color: Color value is invalid&lt;/span&gt; &lt;/div&gt;
&lt;p&gt; );&lt;br/&gt;
&amp;gt; db.f.save( &lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;color: Color value is invalid&lt;/span&gt; &lt;/div&gt;
&lt;p&gt; );                                    &lt;br/&gt;
&amp;gt; db.f.find( { $or: [ {color: {$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;blue&amp;#39;,&amp;#39;red&amp;#39;&amp;#93;&lt;/span&gt;} }, {shape: {$in:&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;circle&amp;#39;,&amp;#39;square&amp;#39;&amp;#93;&lt;/span&gt;} } ] } );&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4cc7d3e218caa33b02e6bda5&quot;), &quot;color&quot; : &quot;blue&quot;, &quot;shape&quot; : &quot;circle&quot; }
{ &quot;_id&quot; : ObjectId(&quot;4cc7d3e918caa33b02e6bda6&quot;), &quot;color&quot; : &quot;red&quot;, &quot;shape&quot; : &quot;square&quot; }
&lt;p&gt;&amp;gt; &lt;/p&gt;

&lt;p&gt;I tried a few index combinations as well and saw the same result.&lt;/p&gt;

&lt;p&gt;Do you have a test script which generates this issue?&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>Wed, 27 Oct 2010 07:26:41 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            13 years, 17 weeks 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>chrischen21</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrijfz:</customfieldvalue>

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

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

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