How to transfer documents from one bucket to another

You can use UUID() or generate custom expression on the key

INSERT INTO a (KEY UUID(), VALUE t) SELECT t FROM B AS t;

https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/insert.html#insert-select

Also use Eventing Bulk copy of existing documents