<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:09:18 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-5571] Issue when using spatial query within filter using $and</title>
                <link>https://jira.mongodb.org/browse/SERVER-5571</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I am getting errors when I try a spatial query within an &quot;$and&quot; operator.&lt;/p&gt;

&lt;p&gt;I can run the following queries successfully:&lt;/p&gt;

&lt;p&gt;db.LOGGER.find({ &quot;COORDINATES&quot; : { &quot;$within&quot; : &lt;/p&gt;
{ &quot;$polygon&quot; : [[22000, 60000], [22000, 63000], [23000, 63000], [23000, 60000]] }
&lt;p&gt; } });&lt;br/&gt;
db.LOGGER.find({ &quot;$and&quot; : [{ &quot;TIME&quot; : &lt;/p&gt;
{ &quot;$gte&quot; : NumberLong(&quot;3542546522557&quot;) }
&lt;p&gt; }, { &quot;TIME&quot; : &lt;/p&gt;
{ &quot;$lt&quot; : NumberLong(&quot;3542546575557&quot;) }
&lt;p&gt; }] });&lt;/p&gt;

&lt;p&gt;However when I add the spatial query to the &quot;$and&quot; I get the following error:&lt;/p&gt;

&lt;p&gt;db.LOGGER.find({ &quot;$and&quot; : [{ &quot;COORDINATES&quot; : { &quot;$within&quot; : &lt;/p&gt;
{ &quot;$polygon&quot; : [[22000, 60000], [22000, 63000], [23000, 63000], [23000, 60000]] }
&lt;p&gt; } },{ &quot;TIME&quot; : &lt;/p&gt;
{ &quot;$gte&quot; : NumberLong(&quot;3542546522557&quot;) }
&lt;p&gt; }, { &quot;TIME&quot; : &lt;/p&gt;
{ &quot;$lt&quot; : NumberLong(&quot;3542546575557&quot;) }
&lt;p&gt; }] });&lt;/p&gt;

&lt;p&gt;error: {&lt;br/&gt;
 &quot;$err&quot; : &quot;can&apos;t find special index: 2d for: { $and: [ { COORDINATES: { $within: &lt;/p&gt;
{ $polygon: [ [ 22000.0, 60000.0 ], [ 22000.0, 63000.0 ], [ 23000.0, 63000.0 ], [ 23000.0, 60000.0 ] ] }
&lt;p&gt; } }, { TIME: &lt;/p&gt;
{ $gte: 3542546522557 }
&lt;p&gt; }, { TIME: &lt;/p&gt;
{ $lt: 3542546575557 }
&lt;p&gt; } ] }&quot;,&lt;br/&gt;
 &quot;code&quot; : 13038&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;I have a collection with the following format:&lt;br/&gt;
{&lt;br/&gt;
 &quot;_id&quot; : ObjectId(&quot;4f7c7a07d2fdb8c2db481a24&quot;),&lt;br/&gt;
 &quot;ID_NAME&quot; : NumberLong(0),&lt;br/&gt;
 &quot;SYSTEM_REFERENCE&quot; : &quot;0&quot;,&lt;br/&gt;
 &quot;TIME&quot; : NumberLong(&quot;3542546568559&quot;),&lt;br/&gt;
 &quot;COORDINATES&quot; : &lt;/p&gt;
{
 &quot;X_COORD&quot; : NumberLong(22682),
 &quot;Y_COORD&quot; : NumberLong(62220),
 &quot;Z_COORD&quot; : NumberLong(13)
 }
&lt;p&gt;}&lt;br/&gt;
There is a 2d spatial index on &quot;COORDINATES&quot;&lt;br/&gt;
Indexes are:&lt;/p&gt;


&lt;p&gt;db.LOGGER.getIndexes()&lt;br/&gt;
[&lt;br/&gt;
 {&lt;br/&gt;
 &quot;name&quot; : &quot;&lt;em&gt;id&lt;/em&gt;&quot;,&lt;br/&gt;
 &quot;ns&quot; : &quot;TEST.LOGGER&quot;,&lt;br/&gt;
 &quot;key&quot; : &lt;/p&gt;
{
 &quot;_id&quot; : 1
 }
&lt;p&gt;,&lt;br/&gt;
 &quot;v&quot; : 0&lt;br/&gt;
 },&lt;br/&gt;
 {&lt;br/&gt;
 &quot;_id&quot; : ObjectId(&quot;4f7c7b5aa22c3db066674ba0&quot;),&lt;br/&gt;
 &quot;ns&quot; : &quot;TEST.LOGGER&quot;,&lt;br/&gt;
 &quot;key&quot; : &lt;/p&gt;
{
 &quot;COORDINATES&quot; : &quot;2d&quot;
 }
&lt;p&gt;,&lt;br/&gt;
 &quot;name&quot; : &quot;Coord&quot;,&lt;br/&gt;
 &quot;min&quot; : 0,&lt;br/&gt;
 &quot;max&quot; : 101000&lt;br/&gt;
 }&lt;br/&gt;
]&lt;/p&gt;</description>
                <environment>Windows 7 32 bit</environment>
        <key id="35970">SERVER-5571</key>
            <summary>Issue when using spatial query within filter using $and</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="siddharth.singh@10gen.com">siddharth.singh@10gen.com</assignee>
                                    <reporter username="schaffer">M Schaffer</reporter>
                        <labels>
                    </labels>
                <created>Wed, 11 Apr 2012 15:05:16 +0000</created>
                <updated>Wed, 15 Aug 2012 14:24:18 +0000</updated>
                            <resolved>Fri, 20 Apr 2012 20:19:10 +0000</resolved>
                                    <version>2.1.0</version>
                                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="109819" author="siddharth.singh@10gen.com" created="Sat, 14 Apr 2012 00:52:38 +0000"  >&lt;p&gt;Yes, a compound index on secondary keys (in your case time field) should help you with what you are trying to do. Please see this similar discussion on google groups &lt;a href=&quot;http://groups.google.com/group/mongodb-user/browse_thread/thread/4417b0f9f0b3de12&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://groups.google.com/group/mongodb-user/browse_thread/thread/4417b0f9f0b3de12&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="109815" author="schaffer" created="Sat, 14 Apr 2012 00:24:09 +0000"  >&lt;p&gt;What is wrong with the spatial index that I have already added (see above)? &lt;br/&gt;
Are you suggesting to add an index for the TIME field as well?&lt;/p&gt;</comment>
                            <comment id="109338" author="siddharth.singh@10gen.com" created="Thu, 12 Apr 2012 22:16:10 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt; $and is not needed to do what you want to do. You need to have a Geospartial index on you collection like it is explained here:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCS/Geospatial+Indexing#GeospatialIndexing-CompoundIndexes&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/Geospatial+Indexing#GeospatialIndexing-CompoundIndexes&lt;/a&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>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 12 Apr 2012 04:57:16 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 44 weeks, 5 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_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>schaffer</customfieldvalue>
            <customfieldvalue>siddharth.singh@10gen.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hro6an:</customfieldvalue>

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

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

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