$merge to output results to a database residing in different host

Hi,
I have two mongo database residing on different host/mongo instances i.e., DB1 in host1 and DB2 in host2. Aggregate query with $merge on DB1 to output the results to DB2 failed with the following error.

java.lang.Exception: com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized):
'not authorized on DB2 to execute command.

Is there anyway out to make $merge to work across different mongo instances?

Mongo data lake, Is this the only option to run $merge and output the results to a database residing on different host?

Hi @Laks,

Running $merge via Atlas Data Lake is currently the only way to $merge data across clusters without resorting to custom code.

More specifically, Atlas Data Lake adds syntax to $merge into the same or different Atlas cluster, database, or collection within the same Atlas project.

Regards,
Stennie

Thanks @Stennie for confirming.