Currently the sync gateway is setup with the following configuration.
"allow_conflicts": false,
"revs_limit": 20,
While fetching the raw document from sync gateway admin API, we can see the old revisions in _sync property.
But while fetching the old revision of the document using open_revs option, it’s always returning the latest revision.
Is it because old revisions are not maintained ?
If you want the body of an old revision, just use ?rev=REVID. (The open_revs query is used to add a list of revision IDs to the response, but the body of the response is still the current revision.)
Jens has responded to your question. But I am curious as to why you need access to the old revision bodies. You have set allow_conflicts as false which means that the system takes care of conflicts for you. Fetching the non-current revision bodies is typically only needed for resolving conflicts.
We wanted to take a look at the previous revisions for investigating a data issue. Can you please tell us how long Couchbase keeps old revisions before deleting them? Is there a configuration that controls this?
Sync Gateway will periodically compact away the JSON bodies of non-leaf revisions and that’s based on the TTL/expiration of the document. IIRC, that defaulted to 5 min. You can learn more about this in this blog. I have to double check if this is configurable.
You can set the expiration of current version via the _exp field when you PUT document via the Sync Gateway REST API or via the expiry() function.
You can find out the expiration time of a document using the show_exp parameter on the GET API.