Creating Indexes

    Full Text Searches are supported by specially purposed indexes, which can be created either from the Couchbase Web Console, or by means of the REST API.

    Every Full Text Search is performed on a user-created Full Text Index, which contains the targets on which searches are to be performed: these targets are values derived from the textual and other contents of documents within a specified bucket or collections within a scope.

    Index-creation is highly configurable, and you can select various attributes to search the specific information. For example, documents can be user-grouped into different types (for example, airline documents versus hotel documents), different scopes (for example, inventory), and collections (for example, airport or hotel).

    Based on the document-IDs, or the values of a designated document field, you can perform the following:

    • Assign index mapping to each document type

    • Assign analyzers to each index mapping

    • Apply the index mapping to a specific subset of document fields

    • Included or exclude the index mapping from the index

    Additionally, searches can be performed across multiple buckets/scopes, by means of index aliases or across multiple collections in a scope by selecting the respective non-default scope/collection(s) option.

    Scopes and Collections

    The Couchbase Enterprise Server 7.0 provides collections and scopes. Only a subset of the planned functionality is included in order to support early access and experimentation.


    A scope is a mechanism for the grouping of multiple collections. Up to 100 scopes can be created per bucket. Collection-names must be unique within their scope.

    Collections might be assigned to different scopes according to content-type, or to deployment-phase (i.e., test versus production). Applications can be assigned per-scope access rights, allowing each application to access only those collections it requires.


    A collection is a data container, defined on Couchbase Server, within a bucket whose type is either Couchbase or Ephemeral. Up to 1000 collections can be created per bucket.

    Bucket-items can optionally be assigned to different collections according to content type. For example, within a bucket that contains travel information, documents that relate specifically to airports might be assigned to an airports collection, while documents that relate to hotels might be assigned to a hotels collection, and so on.

    Naming for Scopes and Collections

    User-defined scopes and collections must be assigned user-defined names. Such names:

    • Must be between 1 and 30 characters in length.

    • Can only contain the characters A-Z, a-z, 0-9, and the symbols _, -, and %.

    • Cannot start with _ or %.

    Default Scope and Collection

    In the Developer Preview, every created bucket is automatically given a default scope, and within it, a default collection. Each is named _default. All documents created within the bucket without reference to specific scopes or collections are saved in the default collection within the default scope. The default scope and collection cannot be dropped.

    Bucket Set-Up

    Scopes and collections exist within buckets. Therefore, to test scopes and collections, at least one bucket must be created.

    In case of a multi-bucket index, absence of a collection does not return an error.

    The following options are available for creating bucket:

    The examples provided in this section use a bucket named testBucket, which is created in turn with the REST API and CLI. Note that the CLI examples demonstrate how to use the cbstats command to return information on collections, including the number of documents each contains. To provide documents to be counted, the cbc create CLI facility is used.


    The following limitations apply to scopes and collections, as made available in Developer Preview mode, in Couchbase Server Enterprise Edition 6.5:

    • Scopes and collections are supported by the Data Service only. This means that key-value data-access can be experimented with.

    • Scopes and collections are not supported by the Index, Query, Search, Eventing, and Analytics Services. This means that data-access by means of these services should not be attempted, using any bucket within which a scope or collection has been explicitly created. Note that these services will provide support for scopes and collections in future.

    • Scopes and collections are not supported by Role-Based Access Control: therefore, access to individual scopes and collections cannot be permitted or denied on the basis of assigned roles. Note that Role-Based Access Control will provide support for scopes and collections in future.

    View Indexes for N1QL

    In Couchbase Server 6.5 and later, view indexes are not supported in N1QL. New view indexes cannot be created, and existing view indexes are not accessible.