[SERVER-9453] $within $centerSphere no longer works in versions >2.2.3 Created: 24/Apr/13  Updated: 10/Dec/14  Resolved: 26/Jan/14

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.2.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Derek Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS X 10.8


Operating System: ALL
Steps To Reproduce:

Run a query with $near: { $centerSphere: components on 2.2.4.

Participants:

 Description   

Given this query:

{ $query: { $and: [ { $and: [ { user_id: null } ], bin: { $ne: true } } ], value.loc.__loc__: { $within: { $centerSphere: { point: [ 10.2, 20 ], max: 0 } } } }

This worked fine up until version 2.2.3, which included a change that allows geo queries without a geospacial index. I'm unsure if this is related.

When we switched to 2.2.3, we started seeing errors on these kinds of queries:

Wed Apr 24 17:14:28 [conn7] assertion 16483 Couldn't pull any geometry out of $within query: { point: [ 10.2, 20 ], max: 0 } ns:cloudmine_platform_development.app_data query:{ $query: { $and: [ { $and: [ { user_id: null } ], bin: { $ne: true } } ], value.loc.__loc__: { $within: { $centerSphere: { point: [ 10.2, 20 ], max: 0 } } } }, $orderby: { _id: 1 } }

I went through the Mongo source to find where this error is thrown. It seems that centerSphere is no longer allowed for $within queries (see matcher.cpp L366-409). However, the only reason it's not allowed is because it isn't enumerated in the string of if-elses: if I simply remove the assertion in the 'else' case, the queries work as they used to.



 Comments   
Comment by Daniel Pasette (Inactive) [ 26/Jan/14 ]

I tried your example in both 2.4.9 and latest master and it works fine in both versions.

db.c.drop();
db.c.insert({value: {loc : { __loc__ : [10.2, 20]}}})
assert.eq(1, db.c.findOne({ $query: { 
    $and: [ 
        { $and: [ { user_id: null } ] },
        { bin: { $ne: true } } 
    ],  
    'value.loc.__loc__': { $within: { $centerSphere: { point: [ 10.2, 20 ], max: 0 } } } } } ) );

Comment by Thomas Rueckstiess [ 25/Apr/13 ]

Hi Derek,

Thanks for reporting this issue. We're trying to reproduce it on our side and will get back to you when we know more.

Regards,
Thomas

Generated at Thu Feb 08 03:20:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.