indexing - Duplicate key error with mongodb 2dsphere unique index -
i try inserts geo points mongodb 2dsphere unique index, raises many duplicate key error.
a simple reproduce demo:
> version() 2.4.5 > use geo > db.test.ensureindex( { loc : "2dsphere" }, unique=true ) > db.test.insert({"loc" : { "type" : "point", "coordinates" : [ 113.3736642, 23.04469194 ] }}) > db.test.insert({"loc" : { "type" : "point", "coordinates" : [ 113.3734775, 23.04609556 ] }}) e11000 duplicate key error index: geo.test.$loc_2dsphere dup key: { : "1f22000102222113" }
why these totally different points raise duplicate key error?
update:
i tried other tests, seems have accuracy.
> db.test.ensureindex( { loc : "2dsphere" }, unique=true ) > db.test.insert({"loc" : { "type" : "point", "coordinates" : [ 113.373, 23.044 ] }}) > db.test.insert({"loc" : { "type" : "point", "coordinates" : [ 113.373, 23.045 ] }}) e11000 duplicate key error index: geo.test.$loc_2dsphere dup key: { : "1f22000102222113" } > db.test.insert({"loc" : { "type" : "point", "coordinates" : [ 113.373, 23.046 ] }}) e11000 duplicate key error index: geo.test.$loc_2dsphere dup key: { : "1f22000102222113" } > db.test.insert({"loc" : { "type" : "point", "coordinates" : [ 113.373, 23.047 ] }}) e11000 duplicate key error index: geo.test.$loc_2dsphere dup key: { : "1f22000102222113" } > db.test.insert({"loc" : { "type" : "point", "coordinates" : [ 113.373, 23.048 ] }}) e11000 duplicate key error index: geo.test.$loc_2dsphere dup key: { : "1f22000102222113" } > db.test.insert({"loc" : { "type" : "point", "coordinates" : [ 113.373, 23.049 ] }})
in test 23.045 23.048 failed, 23.044 23.049 succeed.
i can indeed reproduce this. using unique index 2dsphere
not think ought supported. resolution of index not high enough see 2 points not same. our implementation of s2 index uses "cells" minimum side 500m , points 65 meters away each other.
there fascinating presentation @ https://docs.google.com/presentation/d/1hl4kapfaenaof4gv-psngkwvs_jwnvhrpzttdzxxn6q/view#slide=id.i0 explains how index works.
for however, don't think there solution problem i'll more investigation.
Comments
Post a Comment