Failed to create primary index

I was trying to create a primary index using query:
CREATE PRIMARY INDEX ON qa_new_data.raw.user_asset

But it resulted in error as follows:
[
{
“code”: 5000,
“msg”: “GSI CreatePrimaryIndex() - cause: Index creation for index #primary, bucket qa_new_data, scope raw, collection user_asset cannot start. Reason: Fails to create index. There are not enough indexer nodes to create index with replica count of 1. Some indexer nodes may be marked as excluded…”,
“query”: “CREATE PRIMARY INDEX ON qa_new_data.raw.user_asset
}
]

From your error message, you may need to check on the state of your indexer nodes. However, can you try:

CREATE PRIMARY INDEX ON `qa_new_data`.`raw`.`user_asset` WITH { "num_replica": 0};

?
HTH.

Thanks, this worked.
But it didn’t create any replicas. How can I resolve this with creating a replica as well?

How many index nodes do you have defined in your cluster? You can’t have replicas with just one index node. Specifically:

https://docs.couchbase.com/server/current/learn/services-and-indexes/indexes/index-replication.html#index-replication

notes " Note that whenever a given number of index-replicas is specified for creation, the number must be less than the number of cluster-nodes currently running the Index Service."

HTH.