Search code examples
indexingcouchbasealter

Altering a Couchbase's index to use a num_replica


We have a Couchbase index that was created like that:

CREATE INDEX productName_index1 ON bucket_name(productName, ProductID)
   WHERE type="product"

We found out that we need to add a replica to our index as described here

CREATE INDEX productName_index1 ON bucket_name(productName, ProductID)
   WHERE type="product" USING GSI
   WITH {"num_replica": 2};

But we prefer to Alter the index and not to Drop & Create it.

So according to this example this can be done in commands like that:

ALTER INDEX `travel-sample`.def_faa
WITH {"action":"move","nodes": ["192.168.10.11:8091"]}

But what should be the action and how to specify the num_replica?


Solution

  • Right now, the only supported "action" for Alter Index is "move", which allows you to change the placement of the index(and/or its replicas). It cannot be used to change the number of replicas.

    Changing the number of replicas(using Alter Index) is going to be supported in the next release of Couchbase.

    The only option right now is to drop and recreate. You could create the index with replica first and once it is ready, drop the old index to avoid any downtime. It will be transparent to queries running on the cluster.