Unable to create index on bucket

Hi,
I’m using the latest python sdk and testing it out for a project. I’m able to create a bucket but when I want to create an index, the call fails. I’m unable to understand the error. Can somebody help to resolve this?

The code:
qstr = ‘CREATE PRIMARY INDEX id ON first USING GSI’
try:
result = cb_cluster.query(qstr).rows()
print(result)
except CouchbaseException as ce:
print(ce)

Error
<RC=0xD0[LCB_ERR_PARSING_FAILURE (208)], HTTP Request failed. Examine ‘objextra’ for full result, Results=1, C Source=(src/pycbc_http.c,212), OBJ=ViewResult<rc=0xD0[LCB_ERR_PARSING_FAILURE (208)], value={‘requestID’: ‘11bda1a7-fae1-423f-94b4-c9009e37bcbf’, ‘clientContextID’: ‘80956feef55270df’, ‘errors’: [{‘code’: 3000, ‘msg’: ‘syntax error - at first’}], ‘status’: ‘fatal’}, http_status=0, tracing_context=0, tracing_output=None>, Context={‘first_error_code’: 3000, ‘http_response_code’: 400, ‘first_error_message’: ‘syntax error - at first’, ‘statement’: ‘CREATE PRIMARY INDEX id ON first USING GSI’, ‘client_context_id’: ‘80956feef55270df’, ‘query_params’: ‘’, ‘http_response_body’: ‘’, ‘endpoint’: ‘localhost:8093’, ‘type’: ‘QueryErrorContext’}, Tracing Output={":nokey:0": null}>

I don’t understand why the ‘endpoint’: ‘localhost:8093’ when I’ve specified in the cluster connect as 8091.

Thanks,
Kashyap

first is RESERVE keyword. USE escaped identifier. https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/identifiers.html#escaped-identifiers

CREATE PRIMARY INDEX id 
ON `first` USING GSI

Hello @vsr1,
Thanks for helping me out.
I’ve a performance question now. I ran multiple iterations to see the performance and while the bucket gets created in a few milliseconds, the query for indexes is taking significant time.

Run: 1
Time to create bucket: 0.007006168365478516
Time to run query on bucket: 12.176998138427734
Total time to configure bucket: 12.184004306793213
Time to remove bucket: 10.222846984863281

Run: 2
Time to create bucket: 0.02100086212158203
Time to run query on bucket: 13.25831413269043
Total time to configure bucket: 13.279314994812012
Time to remove bucket: 10.51314902305603

Run: 3
Time to create bucket: 0.00800323486328125
Time to run query on bucket: 13.205000162124634
Total time to configure bucket: 13.213003396987915
Time to remove bucket: 9.282864332199097

Is this normal?
How can this be improved?

Thanks,
Kashyap


https://index-advisor.couchbase.com/indexadvisor/#1

This is quite detailed, need time to digest.

Thanks
Kashyap