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
createQueryIndexinstead.
Available attributes
Attribute | Type | Description | Required |
|---|---|---|---|
| String | The name of the bucket containing the collection. | Yes |
| String | The name of the collection to index. | Yes |
| String | The name of the scope containing the collection. | Yes |
| String | The name of the primary index. If omitted, Couchbase names it | No |
| Boolean | When | No |
| Integer | Number of index replicas to create. | No |