Index Service

    +
    The Index Service supports the creation of primary and secondary indexes on items stored within Couchbase clusters. Indexes enable and enhance the performance of query operations.

    About the Index Service

    The Index Service is used to create indexes from predefined subsets of bucket-data. The Query Service relies on indexes provided by the Index Service.

    The N1QL query language is used to instruct the Index Service to create indexes. The Index Service can create two types of indexes:

    • Primary: Based on the unique key of every item in a specified bucket.

      A primary index is intended to be used for simple non-production queries, which have no filters or predicates. The CREATE PRIMARY INDEX statement is used to create primary indexes.

    • Secondary: Based on an attribute within a document. The value associated with the attribute can be of any type: scalar, object, or array.

      Secondary indexes, also know as Global Secondary Indexes (GSI) make up all non-primary indexes, and are the most frequently used kind of index for queries performed with the N1QL query language. The CREATE INDEX statement is used to create secondary indexes.

    Couchbase Cloud supports standard index storage for saving indexes. By default, an index is saved on the node on which it is created. Each index is created on one bucket only; but multiple indexes may be created on a single bucket.

    Using the Index Service

    Like the other Couchbase services, the Index Service can be deployed during cluster creation, or by adding it to an existing cluster. The Index Service depends on the Data Service for underlying functionality, and depends on the Query Service for creating and managing indexes via the N1QL query language. These services must also be deployed on the cluster in order to use the Index Service. (Information about how these services interact with one another can be found in the Couchbase Server documentation.)

    Indexes can be managed and monitored from the Couchbase Cloud UI. In addition, the Query Workbench can be used to do things like create, modify, and drop indexes using N1QL statements.