<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:13:06 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-47034] Output of the operator $type is not correct</title>
                <link>https://jira.mongodb.org/browse/SERVER-47034</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I have the following collection with name &lt;b&gt;travelers&lt;/b&gt;&lt;/p&gt;

{ &quot;_id&quot; : 1, &quot;name&quot; : &quot;Dev&quot;, &quot;nearestAirport&quot; : &quot;JFK&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }
{ &quot;_id&quot; : 2, &quot;name&quot; : &quot;Eliot&quot;, &quot;nearestAirport&quot; : [ &quot;JFK&quot;, &quot;BOS&quot; ], &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }
{ &quot;_id&quot; : 3, &quot;name&quot; : &quot;Jeff&quot;, &quot;nearestAirport&quot; : &quot;BOS&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }
{ &quot;_id&quot; : 4, &quot;name&quot; : &quot;Vijay&quot;, &quot;nearestAirport&quot; : &quot;BLR&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }
{ &quot;_id&quot; : 5, &quot;name&quot; : &quot;Reddy&quot;, &quot;nearestAirport&quot; : &quot;HYD&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-21T06:07:29.443Z&quot;) }
{ &quot;_id&quot; : 6, &quot;name&quot; : &quot;Vivek&quot;, &quot;nearestAirport&quot; : [ &quot;PNQ&quot; ], &quot;lastUpdated&quot; : ISODate(&quot;2020-03-21T06:07:29.443Z&quot;) }
{ &quot;_id&quot; : 7, &quot;name&quot; : &quot;Guru&quot;, &quot;nearestAirport&quot; : &quot;BOM&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }

&lt;p&gt;The field type of &apos;nearestAirport&apos; for id : 2 and 6 is Array and rest are string.&lt;/p&gt;

&lt;p&gt;When I ran the query&#160; &lt;b&gt;db.travelers.find({&apos;nearestAirport&apos;:{&apos;$type&apos;: 2}})&lt;/b&gt;&#160;( &lt;b&gt;2 represents type string&lt;/b&gt;) i get the following output&#160;&lt;/p&gt;

{ &quot;_id&quot; : 1, &quot;name&quot; : &quot;Dev&quot;, &quot;nearestAirport&quot; : &quot;JFK&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }
&lt;p&gt;&lt;font color=&quot;#FF0000&quot;&gt;&lt;b&gt;{ &quot;_id&quot; : 2, &quot;name&quot; : &quot;Eliot&quot;, &quot;nearestAirport&quot; : [ &quot;JFK&quot;, &quot;BOS&quot; ], &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;
{ &quot;_id&quot; : 3, &quot;name&quot; : &quot;Jeff&quot;, &quot;nearestAirport&quot; : &quot;BOS&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }
{ &quot;_id&quot; : 4, &quot;name&quot; : &quot;Vijay&quot;, &quot;nearestAirport&quot; : &quot;BLR&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }
{ &quot;_id&quot; : 5, &quot;name&quot; : &quot;Reddy&quot;, &quot;nearestAirport&quot; : &quot;HYD&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-21T06:07:29.443Z&quot;) }
&lt;p&gt;&lt;font color=&quot;#FF0000&quot;&gt;&lt;b&gt;{ &quot;_id&quot; : 6, &quot;name&quot; : &quot;Vivek&quot;, &quot;nearestAirport&quot; : [ &quot;PNQ&quot; ], &quot;lastUpdated&quot; : ISODate(&quot;2020-03-21T06:07:29.443Z&quot;) }&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;
{ &quot;_id&quot; : 7, &quot;name&quot; : &quot;Guru&quot;, &quot;nearestAirport&quot; : &quot;BOM&quot;, &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }

&lt;p&gt;The output retrieves documents with field type &lt;b&gt;Array&lt;/b&gt; also.&lt;/p&gt;

&lt;p&gt;However when i ran the query&#160;&lt;b&gt;db.travelers.find({&apos;nearestAirport&apos;:{&apos;$type&apos;: 4}}) ,&lt;/b&gt;&#160; i get only two documents which are id : 2 and 6.&lt;/p&gt;

{ &quot;_id&quot; : 2, &quot;name&quot; : &quot;Eliot&quot;, &quot;nearestAirport&quot; : [ &quot;JFK&quot;, &quot;BOS&quot; ], &quot;lastUpdated&quot; : ISODate(&quot;2020-03-20T14:34:06.749Z&quot;) }
{ &quot;_id&quot; : 6, &quot;name&quot; : &quot;Vivek&quot;, &quot;nearestAirport&quot; : [ &quot;PNQ&quot; ], &quot;lastUpdated&quot; : ISODate(&quot;2020-03-21T06:07:29.443Z&quot;) }

&lt;p&gt;Please advice why the query&#160;db.travelers.find({&apos;nearestAirport&apos;:{&apos;$type&apos;: 2}}) is pulling all documents with the filed type Array also when the condition is to fetch field with type string?&lt;/p&gt;

&lt;p&gt;Let me know if i am missing something?&lt;/p&gt;

&lt;p&gt;Below is the version of the server.&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;https://jira.mongodb.org/secure/attachment/253029/253029_image-2020-03-21-13-09-51-404.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="1284676">SERVER-47034</key>
            <summary>Output of the operator $type is not correct</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="9">Done</resolution>
                                        <assignee username="stephen.steneker@mongodb.com">Stennie Steneker</assignee>
                                    <reporter username="vbonline79@gmail.com">Vijaya Bhaskar</reporter>
                        <labels>
                    </labels>
                <created>Sat, 21 Mar 2020 07:42:24 +0000</created>
                <updated>Sat, 21 Mar 2020 22:22:21 +0000</updated>
                            <resolved>Sat, 21 Mar 2020 22:22:16 +0000</resolved>
                                                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="2991236" author="stennie" created="Sat, 21 Mar 2020 22:21:52 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=vbonline79%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;vbonline79@gmail.com&quot;&gt;vbonline79@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;This &lt;a href=&quot;https://docs.mongodb.com/manual/reference/operator/query/type/#arrays&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;$type&lt;/tt&gt; matching outcome for arrays&lt;/a&gt; is expected and documented:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;For documents where field is an array, $type returns documents in which at least one array element matches a type passed to $type.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For questions about using MongoDB products or services, please use the &lt;a href=&quot;https://community.mongodb.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;MongoDB Community Forums&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Regards,&lt;br/&gt;
 Stennie&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="253029" name="image-2020-03-21-13-09-51-404.png" size="1807" author="vbonline79@gmail.com" created="Sat, 21 Mar 2020 07:39:53 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sat, 21 Mar 2020 22:21:52 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        3 years, 46 weeks, 4 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_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16941"><![CDATA[Not Needed]]></customfieldvalue>

                        </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>stephen.steneker@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            3 years, 46 weeks, 4 days 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>stephen.steneker@mongodb.com</customfieldvalue>
            <customfieldvalue>vbonline79@gmail.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hxaa3j:</customfieldvalue>

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

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