4.5. View recommendations¶
4.5.1. Deploying a view change in a live environment¶
It is possible to change the definition of a view, build the index, then make
those changes go live without causing downtime for your application. The trick
the contents of the design document - not its name,
_id or revision. This
means that two design documents with identical view code will share the same
on-disk view index files.
Here is a worked example, assuming your
/db/_design/ddoc needs tobe updated.
Upload the old design doc to
/db/_design/ddoc-old(or copy the document) if you want an easy way to rollback in case of problems. The
ddoc-olddocument will reference the same view indexes already built for
Upload the updated design doc to
Query a view in the new design document to trigger secondary index generation. You can track the indexing progress via the
/_active_tasksendpoint, or through the Fauxton web interface.
When the index is done being built, re-upload the updated design document to
/db/_design/ddoc(or copy the document). The
ddocdocument will now reference the same view indexes already built for
/db/_design/ddoc-oldat your discretion. Don’t forget to trigger Views cleanup to reclaim disk space after deleting
The COPY HTTP verb can be used to copy the design document with a single command:
curl -X COPY <URL of source design document> -H "Destination: <ID of destination design document>"