EventHopper / EHServerSide

Server-Side functionality including REST API, hosting scripts & client-server modules
0 stars 0 forks source link

Update Location Index on Aggregation Call #158

Open kylermintah opened 4 years ago

kylermintah commented 4 years ago

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.

image https://docs.mongodb.com/manual/tutorial/geospatial-tutorial/#prerequisites

https://docs.mongodb.com/manual/core/2dsphere/