Primary index required error

I have nearly 2 million documents.

Here is my query :

cbq> select

IFNULL(X.No_,“”) AS No_,
IFNULL(Sum(X.Balance),0) as Balance
from NAV X
Group by X.No_
;
and the error mentioned below.
I have 3 node cluster (4.1)
I have created two secondary indexes this way but not a primary index:

NAV 172.16.47.60:8091 idx_No_ Ready 100%
Definition: CREATE INDEX idx_No_ ON NAV(No_) USING GSI
and also
NAV 172.16.47.62:8091 idx_Balance Ready 100%
Definition: CREATE INDEX idx_Balance ON NAV(Balance) USING GSI

{
“requestID”: “827bd9d1-9114-490a-a68b-623f37a7d1af”,
“errors”: [
{
“code”: 4000,
“msg”: “No primary index on keyspace NAV. Use CREATE PRIMARY INDEX to create one.”
}
],
“status”: “fatal”,
“metrics”: {
“elapsedTime”: “14.645386ms”,
“executionTime”: “14.529859ms”,
“resultCount”: 0,
“resultSize”: 0,
“errorCount”: 1
}
}

Hi Siddhu, I don’t see WHERE clause in your SELECT.
N1QL requires the where-clause to pick/use right index. It uses primary index when no where-clause is provided.

hth,
-Prasad