<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:56:12 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-40876] Aggregation lookup array field return no results</title>
                <link>https://jira.mongodb.org/browse/SERVER-40876</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Linux yukinohito-Linux-Mint-18 4.15.0-47-generic #50~16.04.1-Ubuntu SMP Fri Mar 15 16:06:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux&lt;/p&gt;

&lt;p&gt;I need to lookup array of emails to users, where user have email set following way:&lt;/p&gt;

{ emails: [ \{ address: &apos;a@b.com&apos; }
&lt;p&gt; ] }&lt;/p&gt;

&lt;p&gt;But seems currently advanced $lookup in aggregation does not match it, always return 0 results in result field. Shouldn&apos;t it be working same way is in usual query?&lt;/p&gt;</description>
                <environment></environment>
        <key id="747163">SERVER-40876</key>
            <summary>Aggregation lookup array field return no results</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="eric.sedor@mongodb.com">Eric Sedor</assignee>
                                    <reporter username="cherviakov.ivan@gmail.com">Ivan Cherviakov</reporter>
                        <labels>
                    </labels>
                <created>Mon, 29 Apr 2019 05:06:57 +0000</created>
                <updated>Fri, 7 Apr 2023 11:47:28 +0000</updated>
                            <resolved>Tue, 30 Apr 2019 19:24:30 +0000</resolved>
                                    <version>4.0.9</version>
                                                    <component>Aggregation Framework</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="2229769" author="eric.sedor" created="Tue, 30 Apr 2019 19:24:18 +0000"  >&lt;p&gt;Understood; thank you!&lt;/p&gt;</comment>
                            <comment id="2228621" author="cherviakov.ivan@gmail.com" created="Tue, 30 Apr 2019 03:23:01 +0000"  >&lt;p&gt;Hi Eric Sedor. That is correct. I was confused first that initial aggregation not working but then I think again how $in compare values and understood the way to resolve it - add $unwind before. So this is totally resolved and there is no bug in mongodb same as there no need to any additional feature here.&lt;/p&gt;</comment>
                            <comment id="2228245" author="eric.sedor" created="Mon, 29 Apr 2019 20:18:28 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=IvanCherviakov&quot; class=&quot;user-hover&quot; rel=&quot;IvanCherviakov&quot;&gt;IvanCherviakov&lt;/a&gt;; do we understand correctly from your last comment that you are no longer reporting a potential bug or feature request? If we&apos;ve misunderstood, can you clarify?&lt;/p&gt;</comment>
                            <comment id="2227231" author="cherviakov.ivan@gmail.com" created="Mon, 29 Apr 2019 05:15:51 +0000"  >&lt;p&gt;On the second thought it shouldn&apos;t actually working like in non-aggregation case and we just need to unwind result from target collection:&#160;&lt;/p&gt;

&lt;p&gt;001-rs:PRIMARY&amp;gt; db.test.aggregate([{ $lookup: { from: &apos;users&apos;, let: &lt;/p&gt;
{ arr: &apos;$myArr&apos; }
&lt;p&gt;, pipeline: [{ $unwind: &apos;$emails&apos; }, { $match: { $expr: &lt;/p&gt;
{ $in: [&apos;$emails.address&apos;, &apos;$$arr&apos;] }
&lt;p&gt; } }], as: &apos;lookedUp&apos; } }])&lt;br/&gt;
{ &quot;_id&quot; : ObjectId(&quot;5cc682c309168dd75e9cc67f&quot;), &quot;myArr&quot; : [ &quot;a@b.com&quot; ], &quot;lookedUp&quot; : [ { &quot;_id&quot; : ObjectId(&quot;5cc6829309168dd75e9cc67e&quot;), &quot;emails&quot; : &lt;/p&gt;
{ &quot;address&quot; : &quot;a@b.com&quot; }
&lt;p&gt; } ] }&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>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 29 Apr 2019 20:18:28 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 41 weeks, 1 day 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>
                            4 years, 41 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>eric.sedor@mongodb.com</customfieldvalue>
            <customfieldvalue>cherviakov.ivan@gmail.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|huvz47:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|huldaf:</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_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;001-rs:PRIMARY&amp;gt; db.users.insert({ emails: [&lt;/p&gt;
{ address: &apos;a@b.com&apos; }
&lt;p&gt;] })&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
001-rs:PRIMARY&amp;gt; db.test.find()&lt;br/&gt;
001-rs:PRIMARY&amp;gt; db.test.insert({ myArr: &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;a@b.com&amp;#39;&amp;#93;&lt;/span&gt; })&lt;br/&gt;
WriteResult({ &quot;nInserted&quot; : 1 })&lt;br/&gt;
001-rs:PRIMARY&amp;gt; db.test.aggregate([{ $lookup: { from: &apos;users&apos;, let: &lt;/p&gt;
{ arr: &apos;$myArr&apos; }
&lt;p&gt;, pipeline: [{ $match: { $expr: &lt;/p&gt;
{ $in: [&apos;$emails.address&apos;, &apos;$$arr&apos;] }
&lt;p&gt; } }], as: &apos;lookedUp&apos; } }])&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;5cc682c309168dd75e9cc67f&quot;), &quot;myArr&quot; : [ &quot;a@b.com&quot; ], &quot;lookedUp&quot; : [ ] }</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>
                                    <customfieldvalue><![CDATA[eric.sedor@mongodb.com]]></customfieldvalue>
    

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|huvldj:</customfieldvalue>

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