In couchbase are updates implemented as copies of the original record written out to a new location, which likely requires updating of indexes as well OR are updates done in-place when only a few fields have changed on the document.
Couchbase writes are Atomic on a per document UPDATE/INSERT. When a write happens the SDK (App/Clients) always know exactly where the document is located in the cluster , via CRC32() hash, to a particular data node. Once written to a particular data node in the cluster the change is replicated to:
- another node(s) , memory to memory,
- local disk (safe keepings)
- global indexer service
- even to another cluster in another data center if on is set up.
The documents are versioned and incremented on every update and are updated in place with a successful response sent back to the application that updated the doc with the new revision and incremented sequence of the doc.
On each data node there is a copy of the index definitions so when a document is mutated it gets evaluated and if it meets the index parameters it is sent to the indexer to be re-indexed.
Example CREATE INDEX email1 on bucket(email) WHERE docType = "profile";
so if its not a profile do the indexer will never see it.