In addition to a configurable update interval, you can also
update all indexes automatically in the background. You
configure automated update through two parameters, the update
time interval in seconds and the number of document changes that
occur before the views engine updates an index. These two
parameters are updateInterval and
updateMinChanges:
updateInterval: the time interval in
milliseconds between automatic re-indexing, default is 5000
milliseconds.
updateMinChanges: the number of document
changes that occur before re-indexing occurs, default is
5000 changes.
The auto-update process only operates on full-set development and production indexes. Auto-update does not operate on partial set development indexes.
Irrespective of the automated update process, documents can
only be indexed by the system once the document has been
persisted to disk. If the document has not been persisted to
disk, the automated update process will not force the
unwritten data to be written to disk. You can use the
observe operation to monitor when documents
have been persisted to disk and/or updated in the index.
The updates are applied as follows:
Active Indexes (Production Views)
For all active indexes (production views), indexes are
automatically updated according to the update interval
(updateInterval) and the number of document
changes (updateMinChanges).
If updateMinChanges is set to 0 (zero),
then automatic updates are disabled for main indexes.
Replica Indexes
If replica indexes have been configured for a bucket, the
index is automatically updated according to the document
changes (replicaUpdateMinChanges; default
5000) settings.
If replicaUpdateMinChanges is set to 0
(zero), then automatic updates are disabled for replica
indexes.
The trigger level can be configured both globally and for individual design documents for all indexes using the REST API.
To obtain the current view update daemon settings, access a node
within the cluster on the administration port using the URL
http://nodename:8091/settings/viewUpdateDaemon:
GET http://Administrator:Password@nodename:8091/settings/viewUpdateDaemonThe request returns the JSON of the current update settings:
{ "updateInterval":5000, "updateMinChanges":5000, "replicaUpdateMinChanges":5000 }
To update the settings, use POST with a data
payload that includes the updated values. For example, to update
the time interval to 10 seconds, and document changes to 7000
each:
POST http://nodename:8091/settings/viewUpdateDaemon updateInterval=10000&updateMinChanges=7000
If successful, the return value is the JSON of the updated configuration.
To configure the update values explicitly on individual design
documents, you must specify the parameters within the
options section of the design document. For
example:
{ "_id": "_design/myddoc", "views": { "view1": { "map": "function(doc, meta) { if (doc.value) { emit(doc.value, meta.id);} }" } }, "options": { "updateMinChanges": 1000, "replicaUpdateMinChanges": 20000 } }
You can set this information when creating and updating design documents through the design document REST API. For more information, see Section 9.7, “Design Document REST API”.
To perform this operation using the curl tool:
shell> curl -X POST -v -d 'updateInterval=7000&updateMinChanges=7000' \ 'http://Administrator:Password@192.168.0.72:8091/settings/viewUpdateDaemon'
Partial-set development views are not automatically rebuilt, and during a rebalance operation, development views are not updated, even when when consistent views are enabled, as this relies on the automated update mechanism. Updating development views in this way would waste system resources.