Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 219

Mongodb / atlas search: Many to Many relationship with huge collections

$
0
0

im modeling an app where user can stamps (up to 100 000 stamps).I created the following collections:

users:

{"_id": {"$oid": "xxx"    },"email": "test@gmail.com",    ...}

stamps:

{"_id": {"$oid": "ccc"    },"searchTags": ["tag1", "tag2", "tag3"],    ...}

users_stamps

{"_id": {"user": {"$oid": "xxx"        },"stamp": {"$oid": "ccc"        }    },"searchTags": ["tag1", "tag2", "tag3"],}

My goal is to allow users to search stamps in their collection by name (sql equilvalent: "SELECT * FROM stamps WHERE name LIKE "%uru%" and id IN (SELECT stamp_id FROM user_stamps WHERE user_id="xxx")".

I added "searchTags" in users_stamps documents to make fast indexed search on this field.(tried with lookup + condition + filter + limit = too slow as i need to do the lookup on first stage).

Im not sure about this approach so i have some questions:

  1. Is it ok to do so as when user search for a stamp, i query stamps or users_stamps depending on user request ?
  2. As searchTags is duplicated, is it best to create a DB trigger to update users_stamps each time a stamp is updated (rarely updated) ?
  3. Is this approach good enough for 10k users (10k * 100k stamps= 1billion records on users_stamps) ?

Thanks


Viewing all articles
Browse latest Browse all 219

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>