[SERVER-13581] 2d geohash inclusive and therefore ambiguous on maximum range Created: 14/Apr/14  Updated: 06/Dec/22  Resolved: 16/Aug/19

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

Type: Bug Priority: Minor - P4
Reporter: Greg Studer Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 0
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-13577 fix geo_borders.js Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

The 2d index has a min/max range - however the exact maximum of this range hashes back to the minimum value. This results in incorrect query results when exactly on the boundary.

Unchanged in 2.6, seems to have slipped into 2.4 since the geo_borders.js test is poor.



 Comments   
Comment by David Storch [ 16/Aug/19 ]

I created a 2d index with min=1 and max=10. Points on all four corners of the resulting square appear to be given different geo hash values:

MongoDB Enterprise > db.c.find()
{ "_id" : ObjectId("5d570b8ebb1f0afa30766039"), "loc" : [ 10, 10 ] }
{ "_id" : ObjectId("5d570c01bb1f0afa3076603b"), "loc" : [ 1, 1 ] }
{ "_id" : ObjectId("5d570c3cbb1f0afa3076603c"), "loc" : [ 1, 10 ] }
{ "_id" : ObjectId("5d570c40bb1f0afa3076603d"), "loc" : [ 10, 1 ] }
MongoDB Enterprise > db.c.find().hint({loc: "2d"}).returnKey()
{ "loc" : BinData(128,"AAAAAAAAAAA=") }
{ "loc" : BinData(128,"VVVVVVVVUAA=") }
{ "loc" : BinData(128,"qqqqqqqqoAA=") }
{ "loc" : BinData(128,"////////8AA=") }

It appears, therefore, that this is not an issue anymore. I dug around a bit in the key generation code for "2d" indexes, and found that we have special code to handle the case of points with a coordinate exactly equal to max:

https://github.com/mongodb/mongo/blob/166a5d78c1103a58dbd41d1e45aa6037ba4a3e42/src/mongo/db/geo/hash.cpp#L884-L888

Without further information to suggest there is a problem here, I am closing this ticket as "Gone Away".

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