<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:45:43 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-37341] get value from document using expression</title>
                <link>https://jira.mongodb.org/browse/SERVER-37341</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;can we hav an aggregation operator like &quot;$arrayElemAt&quot;&#160;&lt;br/&gt;
but instead of working on array the input is a document&lt;/p&gt;

{ $elemAt: [ &amp;lt;document&amp;gt;, &amp;lt;key&amp;gt; ] }

&lt;p&gt;The &amp;lt;document&amp;gt; expression can be any valid expression as long as it resolves to a document.&lt;/p&gt;

&lt;p&gt;The &amp;lt;key&amp;gt; expression can be any valid expression as long as it resolves to a String.&lt;/p&gt;

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

&lt;p&gt;Behavio&lt;/p&gt;


&lt;p&gt;Example&#160; &#160; &#160;-&amp;gt;&#160; &#160; &#160;Results&lt;/p&gt;

{ $elemAt: [ \{k1:&quot;v1&quot;,k2:&quot;v2&quot;}
&lt;p&gt;, &quot;k1&quot; ] }&#160; &#160;-&amp;gt; &quot;v1&quot;&lt;/p&gt;

{ $elemAt: [ \{k1:&quot;v1&quot;,k2:&quot;v2&quot;}
&lt;p&gt;, &quot;k3&quot; ] }&#160; &#160;-&amp;gt; null&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="610687">SERVER-37341</key>
            <summary>get value from document using expression</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="nick.brewer">Nick Brewer</assignee>
                                    <reporter username="yassineKarim">yassine Karim [X]</reporter>
                        <labels>
                    </labels>
                <created>Thu, 27 Sep 2018 08:34:10 +0000</created>
                <updated>Thu, 4 Oct 2018 19:36:19 +0000</updated>
                            <resolved>Thu, 4 Oct 2018 19:36:19 +0000</resolved>
                                                                    <component>Aggregation Framework</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="2024205" author="nick.brewer" created="Thu, 4 Oct 2018 19:36:03 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=yassineKarim&quot; class=&quot;user-hover&quot; rel=&quot;yassineKarim&quot;&gt;yassineKarim&lt;/a&gt; I believe what you&apos;re describing is similar to the functionality described here: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-30417&quot; title=&quot;add expression to get value by keyname from object&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-30417&quot;&gt;&lt;del&gt;SERVER-30417&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can vote for that ticket, and follow along with it for updates. &lt;/p&gt;

&lt;p&gt;-Nick&lt;/p&gt;</comment>
                            <comment id="2023343" author="yassinekarim" created="Thu, 4 Oct 2018 11:00:09 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=nick.brewer&quot; class=&quot;user-hover&quot; rel=&quot;nick.brewer&quot;&gt;nick.brewer&lt;/a&gt;&#160;the second parameter of&#160;arrayElemAt is an expression which resolve to an integer&lt;/p&gt;

&lt;p&gt;currently there is no way in mongo to access a sub Document using an expression as key&#160;&lt;br/&gt;
as an example&#160;&lt;/p&gt;

&lt;p&gt;inpput :&lt;/p&gt;
{

filed1:\{k1:v1,k2:v2}
&lt;p&gt;,&lt;/p&gt;

&lt;p&gt;field2:&lt;span class=&quot;error&quot;&gt;&amp;#91;k1,k2,k3&amp;#93;&lt;/span&gt;&lt;/p&gt;

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

&lt;p&gt;in our aggregation pipeline we are intersted in unwinding on field 2 and getting the associated value on field1&lt;br/&gt;
output :&lt;/p&gt;

{

filed1:v1,

field2:k1

}
&lt;p&gt;,&lt;/p&gt;

{

filed1:v2,

field2:k2

}
&lt;p&gt;,&lt;/p&gt;

{

field2:k3

}

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

&lt;p&gt;our workaround is storing in an array field1 and using the unwind index to get the elements&lt;/p&gt;

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


&lt;p&gt;Yassine&lt;/p&gt;</comment>
                            <comment id="2019475" author="nick.brewer" created="Mon, 1 Oct 2018 17:50:47 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=yassineKarim&quot; class=&quot;user-hover&quot; rel=&quot;yassineKarim&quot;&gt;yassineKarim&lt;/a&gt; What you&apos;re describing does not appear to replicate the functionality of &lt;tt&gt;arrayElemAt&lt;/tt&gt;, which uses an integer to return a value at a specific position. By comparison, what you&apos;re suggesting appears to use two equality statements. &lt;/p&gt;

&lt;p&gt;It would be useful to see what a sample document would look like in the example you&apos;ve provided. Can you provide some more details on the specific task you&apos;re trying to accomplish?&lt;/p&gt;

&lt;p&gt;-Nick&lt;/p&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="409814">SERVER-30417</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <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>Mon, 1 Oct 2018 17:50:47 +0000</customfieldvalue>

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

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

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htze9j:</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|hu8lyf:</customfieldvalue>

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