Create Primary Index syntax?

I’m trying to create a primary index on the meta().id for a given bucket using this statement and getting this:
couchbase Index

I’m running couchbase enterprise on a single node.
I’m patterning this command on the example in the couchbase documentation Indexing Metadata Information | Couchbase Docs

I don’t understand what I’m missing, I’ve tried several variations using back tics, specifying in the statement the bucket.scope.collection in the statement. What have I misunderstood in following the example?

A primary index doesn’t take field specification. You would issue:

CREATE PRIMARY INDEX ON programId;

(Ref: CREATE PRIMARY INDEX | Couchbase Docs )

HTH.

can I not create a “named” primary index? that was what I was trying to do?

You can:

CREATE PRIMARY INDEX myName ON myBucket;

HTH.

this is what I got to work:

CREATE PRIMARY INDEX programId ON incentivePrograms

it’s not clear to me that the index was built on the document’s ID. for now I’ll assume so.

A primary index only indexes the document keys, so yes, it is on the ID.

Ref: Indexing and Query Performance | Couchbase Docs

Hope this clears things up for you.

2 Likes