Couchbase createQueryIndex
Last updated: July 13, 2026
Creates a secondary (named) N1QL query index on a Couchbase collection. Secondary indexes target specific fields and improve query performance for filtered queries.
Known limitations:
Index names must be unique within a bucket.
When
deferredistrue, the index is created in a pending state and must be built with aBUILD INDEXstatement before it is available for query optimization.
Available attributes
You must specify all top-level attributes marked as required. If you specify an optional attribute, you must also specify any nested attributes that it requires.
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 index to create. Must be unique within the bucket. | Yes |
| Element | One or more fields to include in the index. See nested tags below. | Yes |
| Boolean | When | Yes |
| Integer | Number of index replicas to create (0 or more). | Yes |
Nested tags — fields
Attribute | Type | Description | Required |
|---|---|---|---|
| String | A document field to include in the index. Specify one | Yes (at least one) |