You will have to iterate through all your documents that don't have a location
field and add it (presumably deleting the lat/long fields unless this will break your application).
db.mycollection.find( { location : { $exists : false } } ).forEach(
function (doc) {
// Add (lon, lat) pairs .. order is important
doc.location = { lon: doc.lon, lat: doc.lat };
// Remove old properties
delete doc.lon;
delete doc.lat;
// Save the updated document
db.mycollection.save(doc);
}
)
Note that the order for MongoDB geospatial indexing should be consistent in your document as (longitude, latitude).