'Convert a string pair of coordinates to geomtery data type in MongoDB

I have a column in a MongoDB collection with location stored as string pair values: geometry:"POINT (72.548355 23.042458)"

I need to create a geometry field which works with MongoDB's spatial queries. Something which is in this format:

"geometry": { "type": "Point", "coordinates": [72.548355, 23.042458] },

Please help. I need to run this for billions of entries in the collection. So an optimized solution will be extremely helpful. Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source