When new events are added to the database, it seems the location index is not updated, meaning if the events all are deleted and then regenerated, the new events will not have been indexed on.
This also means that when new events are added to the database, their coordinate field is not being indexed on.
This is why the lat/long endpoint sometimes does not work as intended (returns an empty array for example).
Solution (Option 1): Turn on Auto-Indexing
See if there is a way to turn on auto-indexing for the indexes in our Atlas database.
Solution (Option 2): Programatically Update Index in Server Code
So far we have been manually updating the position index every once in a while. At the end of aggregation (or on failure) update the position : 2dsphere index programmatically.
Problem:
When new events are added to the database, it seems the location index is not updated, meaning if the events all are deleted and then regenerated, the new events will not have been indexed on.
This also means that when new events are added to the database, their coordinate field is not being indexed on.
This is why the lat/long endpoint sometimes does not work as intended (returns an empty array for example).
Solution (Option 1): Turn on Auto-Indexing
See if there is a way to turn on auto-indexing for the indexes in our Atlas database.
Solution (Option 2): Programatically Update Index in Server Code
So far we have been manually updating the position index every once in a while. At the end of aggregation (or on failure) update the
position : 2dsphere
index programmatically.https://docs.mongodb.com/manual/tutorial/geospatial-tutorial/#prerequisites
https://docs.mongodb.com/manual/core/2dsphere/