This is a tough problem. I guess you have two options:
-
use parent/child like you describe
-
add an
interacted_withfield to all your documents and update your documents to append to this list whenever there are interactions -
will be slow and makes sharding complicated while 2. will become problematic if you start having millions of entries for the
interacted_withfield.
Maybe it's best to make conscious trade-offs. For instance you could go with option 2 and make the interacted_with field a rolling buffer: whenever it reaches its maximum size (eg. 10000) then instead of just appending to it, you would also remove the first value, which is the 10000th user that the current user interacted with last. It is less correct but help keep the problem bounded and might be good enough for your users.