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:

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

        A Secondary Index is frequently referred to as a Global Secondary Index, or GSI. This is the kind of index used most frequently in Couchbase Server, for queries performed with the N1Ql query-language. The CREATE INDEX statement is used to create secondary indexes.

      • Primary: Based on on the unique key of every item in a specified bucket or collection (Couchbase Server 7.0+). Every primary index is maintained asynchronously.

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

      Couchbase Capella 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 keyspace (bucket or collection) only; but multiple indexes may be created on a single keyspace (bucket or collection).

      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.)

      If a cluster has the Index and Query Services deployed, indexes can be managed and monitored from the Couchbase Capella UI. In addition, the Query Workbench can be used to do things like create, modify, and drop indexes using N1QL statements.