Change Intelligence is coming.

Couchbase createPrimaryQueryIndex

Last updated: July 13, 2026

Creates a primary N1QL query index on a Couchbase collection. A primary index covers all documents in the collection, enabling queries that do not specify a predicate.

Known limitations:

  • Each collection can have at most one primary index.

  • Primary indexes are less efficient than secondary indexes for queries with specific predicates. For filtered queries, use createQueryIndex instead.

Available attributes

Attribute

Type

Description

Required

bucketName

String

The name of the bucket containing the collection.

Yes

collectionName

String

The name of the collection to index.

Yes

scopeName

String

The name of the scope containing the collection.

Yes

indexName

String

The name of the primary index. If omitted, Couchbase names it #primary.

No

deferred

Boolean

When true, the index is created in a deferred state. Build it with BUILD INDEX before use.

No

numReplicas

Integer

Number of index replicas to create.

No

loading

loading

loading