<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:20:32 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-9484] 2dsphere Index may not return all documents for $near and geoNear</title>
                <link>https://jira.mongodb.org/browse/SERVER-9484</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;When performing a $near or geoNear query on GeoJSON data indexed with a 2dsphere index, the query appears to miss data.  This may be an issue with the 2dsphere index, as reindexing changes the number of data elements returned for a geoNear query, but &lt;b&gt;not&lt;/b&gt; for a bounding-box $geoWithin query.  In this case, all of the data is within the polygon bounded by longitude -90 to -80, and latitude 35 to 45.  The only secondary index on the collection is &lt;/p&gt;
{&quot;geometry&quot; : &quot;2dsphere&quot;}
&lt;p&gt;.&lt;/p&gt;

&lt;p&gt;&amp;gt; db.TirCSV.count({ &quot;geometry&quot; : { &quot;$near&quot; : { &quot;$geometry&quot; : &lt;/p&gt;
{ &quot;type&quot; : &quot;Point&quot;, &quot;coordinates&quot; : [ -85.389 , 40.46]}
&lt;p&gt;}} , &quot;$or&quot; : [ &lt;/p&gt;
{ &quot;data_type&quot; : &quot;tir&quot;}
&lt;p&gt;]})&lt;br/&gt;
3017&lt;br/&gt;
&amp;gt; db.TirCSV.find({geometry : {$geoWithin : {$geometry : {type : &quot;Polygon&quot;, coordinates:  [[&lt;span class=&quot;error&quot;&gt;&amp;#91;-90,45&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;-90,35&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;-80,35&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;-80,45&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;-90,45&amp;#93;&lt;/span&gt;]]}}}}).count()&lt;br/&gt;
3063&lt;br/&gt;
&amp;gt; db.TirCSV.count(&lt;/p&gt;
{&quot;data_type&quot; : &quot;tir&quot;}
&lt;p&gt;)&lt;br/&gt;
3063&lt;br/&gt;
&amp;gt; db.TirCSV.reIndex()&lt;br/&gt;
{&lt;br/&gt;
        &quot;nIndexesWas&quot; : 2,&lt;br/&gt;
        &quot;msg&quot; : &quot;indexes dropped for collection&quot;,&lt;br/&gt;
        &quot;nIndexes&quot; : 2,&lt;br/&gt;
        &quot;indexes&quot; : [&lt;br/&gt;
                {&lt;br/&gt;
                        &quot;key&quot; : &lt;/p&gt;
{
                                &quot;_id&quot; : 1
                        }
&lt;p&gt;,&lt;br/&gt;
                        &quot;ns&quot; : &quot;sparcTest.TirCSV&quot;,&lt;br/&gt;
                        &quot;name&quot; : &quot;&lt;em&gt;id&lt;/em&gt;&quot;&lt;br/&gt;
                },&lt;br/&gt;
                {&lt;br/&gt;
                        &quot;key&quot; : &lt;/p&gt;
{
                                &quot;geometry&quot; : &quot;2dsphere&quot;
                        }
&lt;p&gt;,&lt;br/&gt;
                        &quot;ns&quot; : &quot;sparcTest.TirCSV&quot;,&lt;br/&gt;
                        &quot;name&quot; : &quot;geometry_2dsphere&quot;&lt;br/&gt;
                }&lt;br/&gt;
        ],&lt;br/&gt;
        &quot;ok&quot; : 1&lt;br/&gt;
}&lt;br/&gt;
&amp;gt; db.TirCSV.count({ &quot;geometry&quot; : { &quot;$near&quot; : { &quot;$geometry&quot; : &lt;/p&gt;
{ &quot;type&quot; : &quot;Point&quot;, &quot;coordinates&quot; : [ -85.389 , 40.46]}
&lt;p&gt;}} , &quot;$or&quot; : [ &lt;/p&gt;
{ &quot;data_type&quot; : &quot;tir&quot;}
&lt;p&gt;]})&lt;br/&gt;
3016&lt;br/&gt;
&amp;gt; db.TirCSV.find({geometry : {$geoWithin : {$geometry : {type : &quot;Polygon&quot;, coordinates:  [[&lt;span class=&quot;error&quot;&gt;&amp;#91;-90,45&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;-90,35&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;-80,35&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;-80,45&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;-90,45&amp;#93;&lt;/span&gt;]]}}}}).count()&lt;br/&gt;
3063&lt;/p&gt;</description>
                <environment>Windows 7 x64</environment>
        <key id="73266">SERVER-9484</key>
            <summary>2dsphere Index may not return all documents for $near and geoNear</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="hari.khalsa@10gen.com">hari.khalsa@10gen.com</assignee>
                                    <reporter username="jdagg">Jim Dagg</reporter>
                        <labels>
                    </labels>
                <created>Fri, 26 Apr 2013 18:10:51 +0000</created>
                <updated>Mon, 11 Jul 2016 17:40:36 +0000</updated>
                            <resolved>Thu, 2 May 2013 19:51:28 +0000</resolved>
                                    <version>2.4.3</version>
                                    <fixVersion>2.4.4</fixVersion>
                    <fixVersion>2.5.0</fixVersion>
                                    <component>Geo</component>
                    <component>Index Maintenance</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="339799" author="auto" created="Mon, 20 May 2013 14:59:08 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2013-04-29T19:22:03Z&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-9484&quot; title=&quot;2dsphere Index may not return all documents for $near and geoNear&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-9484&quot;&gt;&lt;del&gt;SERVER-9484&lt;/del&gt;&lt;/a&gt; don&apos;t ignore geometries w/&amp;gt;1 covers if one of them isn&apos;t in the search annulus&lt;/p&gt;

&lt;p&gt;Conflicts:&lt;/p&gt;

&lt;p&gt;	src/mongo/db/geo/s2nearcursor.cpp&lt;br/&gt;
Branch: v2.4&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/d1d2e9c89fe5f10ba8b56e46bd38b7634bb7afa1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/d1d2e9c89fe5f10ba8b56e46bd38b7634bb7afa1&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="326920" author="auto" created="Thu, 2 May 2013 19:43:51 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2013-04-29T19:22:03Z&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-9484&quot; title=&quot;2dsphere Index may not return all documents for $near and geoNear&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-9484&quot;&gt;&lt;del&gt;SERVER-9484&lt;/del&gt;&lt;/a&gt; don&apos;t ignore geometries w/&amp;gt;1 covers if one of them isn&apos;t in the search annulus&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/fc76b559266c4e2aee0707e6d640c08d20ff9e55&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/fc76b559266c4e2aee0707e6d640c08d20ff9e55&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="324297" author="hari.khalsa@10gen.com" created="Mon, 29 Apr 2013 19:35:35 +0000"  >&lt;p&gt;Thank you for reporting it in such a helpful way!  There will be a fix in the master branch shortly and it will be backported to the next release of 2.4.&lt;/p&gt;</comment>
                            <comment id="324296" author="jdagg" created="Mon, 29 Apr 2013 19:33:35 +0000"  >&lt;p&gt;Thanks, Hari.  I appreciate the help, and I&apos;m glad we managed to figure out what was wrong.  Looking forward to the fix!&lt;/p&gt;</comment>
                            <comment id="324259" author="hari.khalsa@10gen.com" created="Mon, 29 Apr 2013 19:00:13 +0000"  >&lt;p&gt;Hello!  You found a bug.  Congratulations and my apologies.&lt;/p&gt;

&lt;p&gt;Let me tell you a bit about how the bug happened and how I will fix it.&lt;/p&gt;

&lt;p&gt;When you add something to a 2dsphere index, MongoDB takes the geometry information and creates &quot;geokeys&quot; from it.  A point has one geokey, and a polygon (or linestring) may have several since it&apos;s larger.  The geokey, aside from being more compact than GeoJSON, also provides rough information about the location of the geometry.&lt;/p&gt;

&lt;p&gt;Near searches on a 2dsphere index work by looking at concentric rings around the start point.  You find everything with a certain R0 first, then everything between R0,R1, then everything between R1,R2, etc., where R0 &amp;lt; R1 &amp;lt; R2...&lt;/p&gt;

&lt;p&gt;When MongoDB was looking at a certain &quot;ring,&quot; it was trying to see if the geokey was inside the ring.  If the geokey it was looking at wasn&apos;t inside the ring, it decided the whole object wasn&apos;t inside the ring and ignored it.&lt;/p&gt;

&lt;p&gt;The bug is: for objects that generate several geokeys, some of the geokeys may be inside the ring we&apos;re looking at, and some may not; we can&apos;t ignore an object just based on one geokey not being inside of it.  The polygons in your example had this property.&lt;/p&gt;</comment>
                            <comment id="324038" author="hari.khalsa@10gen.com" created="Mon, 29 Apr 2013 15:00:11 +0000"  >&lt;p&gt;Thanks for the helpful details.  I&apos;ll take a look soon.&lt;/p&gt;</comment>
                            <comment id="322555" author="jdagg" created="Fri, 26 Apr 2013 19:51:41 +0000"  >&lt;p&gt;Attached script to run the queries for the $near radius and 25-point polygon approximation and display the differences.&lt;/p&gt;</comment>
                            <comment id="322491" author="jdagg" created="Fri, 26 Apr 2013 18:53:23 +0000"  >&lt;p&gt;Added a ZIP of the data missing from each of a $near search and a $geoIntersects search, given a 25-, 50-, 75-, and 100-km radius.  Blue elements are those represented in the $geoIntersects query for a 25-point polygon approximation of the radius provided to $near, but not in the result set of the $near query.  The red elements are the reverse.  (The red elements generally appear on the edge of the border, which is expected.)&lt;/p&gt;

&lt;p&gt;Also note that all of the missing elements in the $near queries are polygon objects.&lt;/p&gt;</comment>
                            <comment id="322485" author="jdagg" created="Fri, 26 Apr 2013 18:49:08 +0000"  >&lt;p&gt;Added KML files showing query results.  near.kml is the result of a $near search.  geoIntersects.kml is the result of a $geoIntersects search which approximates the radius provided to $near with a 25-point polygon.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="26385" name="QueryDiff.js" size="2143" author="jdagg" created="Fri, 26 Apr 2013 19:51:41 +0000"/>
                            <attachment id="26384" name="diffs.zip" size="15191" author="jdagg" created="Fri, 26 Apr 2013 18:53:23 +0000"/>
                            <attachment id="26382" name="geoIntersects.kml" size="1009177" author="jdagg" created="Fri, 26 Apr 2013 18:49:08 +0000"/>
                            <attachment id="26383" name="near.kml" size="997302" author="jdagg" created="Fri, 26 Apr 2013 18:49:08 +0000"/>
                            <attachment id="26372" name="out.json" size="2682284" author="jdagg" created="Fri, 26 Apr 2013 18:10:51 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9.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 2013 15:00:11 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 39 weeks, 2 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>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 39 weeks, 2 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>auto</customfieldvalue>
            <customfieldvalue>hari.khalsa@10gen.com</customfieldvalue>
            <customfieldvalue>jdagg</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrmvhb:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>50942</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;Import data file (attached) into MongoDB using mongoImport to database &quot;sparcTest&quot; and collection &quot;TirCSV&quot;.  Ensure 2dsphere index on &quot;geometry&quot; field.  &lt;br/&gt;
Perform .count() on a global find.  Note it returns 3063 elements.&lt;br/&gt;
Perform $geoNear query above and note it misses some data.  Record number of elements returned.&lt;br/&gt;
Perform $within query above and note it returns all data.&lt;br/&gt;
Reindex TirCSV collection.&lt;br/&gt;
Perform $geoNear query and record number of elements returned &amp;#8211; may be different.&lt;br/&gt;
Perform $geoWithin query and note it still returns all data.&lt;/p&gt;</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>
                                

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

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