[SERVER-84794] $geoWithin queries have missing results when location field has extra sub-fields Created: 11/Jan/24  Updated: 02/Feb/24

Status: Open
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Will Buerger Assignee: Backlog - Query Integration
Resolution: Unresolved Votes: 0
Labels: qi-geo
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Integration
Operating System: ALL
Steps To Reproduce:

// Insert identical documents with different field orders

replset [direct: primary] test> db.test.find()
[
{
_id: ObjectId("65a04bdf95d67a5d1230b4c3"),
be:

{ ua: 209268.984375, coordinates: [ -95.90898701416783, -78.02003547216432 ], type: 'Point' }

},
{
_id: ObjectId("65a04c0895d67a5d1230b4c4"),
be:

{ coordinates: [ -95.90898701416783, -78.02003547216432 ], type: 'Point', ua: 209268.984375 }

},
{
_id: ObjectId("65a04fae95d67a5d1230b4c5"),
be:

{ coordinates: [ -95.90898701416783, -78.02003547216432 ], ua: 209268.984375, type: 'Point' }

},
{
_id: ObjectId("65a04fd395d67a5d1230b4c6"),
be:

{ type: 'Point', ua: 209268.984375, coordinates: [ -95.90898701416783, -78.02003547216432 ] }

},
{
_id: ObjectId("65a0506095d67a5d1230b4c7"),
be:

{ ua: 209268.984375, type: 'Point', coordinates: [ -95.90898701416783, -78.02003547216432 ] }

},
{
_id: ObjectId("65a050ae95d67a5d1230b4c8"),
be:

{ type: 'Point', coordinates: [ -95.90898701416783, -78.02003547216432 ], ua: 209268.984375 }

}
]
 
// $geoWithin query only matches documents that don't have the numeric field as the first field

replset [direct: primary] test> db.test.find({ $or: [{ "be": { $geoWithin:

{ $centerSphere: [[179.03531532305314, 0.7050703681776871], 2.145221550434281] }

} }] })
[
{
_id: ObjectId("65a04c0895d67a5d1230b4c4"),
be:

{ coordinates: [ -95.90898701416783, -78.02003547216432 ], type: 'Point', ua: 209268.984375 }

},
{
_id: ObjectId("65a04fae95d67a5d1230b4c5"),
be:

{ coordinates: [ -95.90898701416783, -78.02003547216432 ], ua: 209268.984375, type: 'Point' }

},
{
_id: ObjectId("65a04fd395d67a5d1230b4c6"),
be:

{ type: 'Point', ua: 209268.984375, coordinates: [ -95.90898701416783, -78.02003547216432 ] }

},
{
_id: ObjectId("65a050ae95d67a5d1230b4c8"),
be:

{ type: 'Point', coordinates: [ -95.90898701416783, -78.02003547216432 ], ua: 209268.984375 }

}
]

Participants:

 Description   

When working with GeoJSON data, we expect location fields to be one sub-object with a "type" and "coordinates" field. When there's an extra field in the field's sub-object, some $geoWithin queries miss matching documents.

See reproducing steps for more details.


Generated at Thu Feb 08 06:56:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.