node.js - MongoDB - removing duplicate documents (GeoJSON) -
i know best method removing duplicate documents large geojson collection (approx 80k lines) have stored in mongodb. believe duplicates causing error on front end cannot log full collection console.
i have tried use dropdups method in mongo shell explained in following url have had no success.. mongodb query remove duplicate documents collection . believe dropdups depreciated of mongodb 2.6
here sample of schema structure:
{ "type": "featurecollection", "features": [ { "geometry": { "type": "point","coordinates": [-73.994720, 40.686902] } }, { "geometry": { "type": "point","coordinates": [-73.994720, 40.686902] } }, { "geometry": { "type": "point","coordinates": [-73.989205, 40.686675] } }, { "geometry": { "type": "point","coordinates": [-73.994655, 40.687391] } }, { "geometry": { "type": "point","coordinates": [-73.985557, 40.687683] } }, { "geometry": { "type": "point","coordinates": [-73.985557, 40.687683] } }, { "geometry": { "type": "point","coordinates": [-73.984656, 40.685462] } }, ] }
here create index attempts in mongo shell, , duplicates still remain!
> db.testschema.createindex( { coordinates: 1 }, { unique: true, dropdups: true } ) { "createdcollectionautomatically" : false, "numindexesbefore" : 1, "numindexesafter" : 2, "ok" : 1 } > db.testschema.createindex( { geometry: 1 }, { unique: true, dropdups: true } ) { "createdcollectionautomatically" : false, "numindexesbefore" : 2, "numindexesafter" : 3, "ok" : 1 } > db.testschema.ensureindex({'testschema.features.geometry.coordinates': 1}, {unique: true, dropdups: true}) { "createdcollectionautomatically" : false, "numindexesbefore" : 3, "numindexesafter" : 4, "ok" : 1 }
Comments
Post a Comment