Search code examples
couchdbdatabase-replicationcloudant

How to/Can we apply a "limit" when we use replication in Cloudant?


I'm replicating a database called "foo" to a database called "bar". There are 10 documents in foo. 5 of the docs have a field called "flag" set to "true". I'm using a filter for the replication which returns true if the "flag" is "true".

Now, just as I'm setting the "filter" parameter for the replication, I want to set a "limit" parameter as well so only 2 documents are replicated. I know that we can set "limit" parameters for other endpoints like "_all_docs", "_changes" and others but it doesn't seem to be working with replication. There's nothing in the cloudant documentation on replication about setting limits as well.

Can we even set a "limit" parameter to replication? If so how do I do that? Thank you very much.


Solution

  • You are correct that you can filter documents when replicating to select documents that have a certain feature (e.g only replicate documents where x >1, or only replicate documents that are not deleted).

    But you cannot limit a replication job to a number of documents; it will continue until completion, or in the case of continuous replication it will continue to replicate new/updated/deleted documents in "foo" to "bar" as the data changes.