I am trying to restore the travel-sample bucket to another bucket using cbbackupmgr restore command and having arguments --map-data and --auto-create-buckets, restore goes fine but then while viewing bucket in cluster is see bucket with correct count of items in buckets page. While viewing the documents it gives an error :
Query: select meta().id from `travel-sample-restore`.`_default`.`_default` data order by meta().id limit 200 offset 0
Message: "Primary index def_primary not online."
Can someone please help here?
Configuration : 3 nodes cluster
Did try to restart the server but still no help.
You need to rebuild/re-reate the indexes after restore on the new collection
Hello @vsr1 ,
Can you please help me with command or any documentation, since i had to do manually for each index BUILD.
Do we have a command which list all indexes for new collection and we can run a single query?
SELECT RAW CONCAT("BUILD INDEX ON ", k , "(['", CONCAT2 ("','", inames), "']);")
FROM system:indexes AS s
LET bid = CONCAT("`",s.bucket_id, "`"),
sid = CONCAT("`", s.scope_id, "`"),
kid = CONCAT("`", s.keyspace_id, "`"),
k = NVL2(bid, CONCAT2(".", bid, sid, kid), kid)
WHERE s.namespace_id = "default"
GROUP BY k
LETTING inames = ARRAY_AGG(s.name) FILTER (WHERE s.state = 'deferred')
HAVING ARRAY_LENGTH(inames) > 0;
By executing this it gives BUILD Index statement for each collection on the cluster that has at least one “deferred” index state. Take the output and execute them.
Thanks @vsr1. I will try this.