I’m currently looking if there is anyway for a person to replicate given info on a mongodb DB?
my idea is to only send a certain type of data, let’s say, if a document has the field “height”, that only documents with a height value higher than let’s say 10, would be sent to the replica.
Is this possible? and if so, could you please explain or give a link to where this might be properly documented?
Thank you.
PS: this is for a java/jsp project, so I’m adding these tags in case there are built-in commands for this in the java driver.
Answer is “yes” and “no”.
Replica Sets will not provide this functionality. Replica Sets are just that a set of replicas or clones where each node contains the same data. So there’s no easy “out of the box” way to do what you want.
However, replication works via a special “oplog” collection. This is an actual collection in the DB that contains all of the recent changes to the data.
In theory you can “tail” this oplog and selectively apply changes. In fact people have done this. However, this is not a widely supported feature and it will definitely require several hours (or days) of effort to make work.