Manage Indexes

    +
    Primary and Global Secondary Indexes can be managed with Couchbase Web Console.

    Access the Indexes Screen

    To access the Indexes screen, left-click on the tab in the left-hand navigation bar:

    indexesTab

    An index list, showing a summary of all indexes, is displayed in table format.

    indexScreenWithIndexes

    Change the Index View

    To change the index view, open the view by drop-down list and choose a view.

    view by menu
    • index displays all the available indexes in a single list.

    • bucket groups the indexes by bucket.

    • server node groups the indexes by server.

    Filter the Indexes

    To filter the indexes, type a filter term in the filter indexes box.

    Only indexes whose definition contains the filter term are shown.

    filter indexes

    To remove the filter and display all indexes, left-click the cross icon, at the end of the filter indexes box.

    Index Summary

    The index list displays the following information about each index:

    • index name. The name of the index. There may also be one or more indicators after the index name, giving further information:

      index indicators
      • partitioned indicates that the index is partitioned.

      • replica n indicates that this is an index replica, where n is the replica ID.

      • stale indicates that the node on which the index or partition is stored is not available.

    • requests/sec. The number of requests per second.

    • resident ratio. The percentage of the data held in memory.

    • items. The number of items currently indexed.

    • data size. The size of indexable data that is maintained for the index or replica.

    • bucket. (Only displayed if viewing the indexes by index, or by server node.) The bucket for which the index or replica was created.

    • node. (Only displayed if viewing the indexes by bucket.) The server node on which the index or replica is stored, or a list of the nodes on which index partitions are stored.

    • status. The current state of the index service on the node on which this index is stored: ready, pause, or warmup.

      The color of the left margin of the index row also reflects the current state of the index. For example, the left margin of the index row is green when the index is ready, orange when the index is in warmup, and so on.

      index margins

    Index Administration

    To administer an index, left-click the index row in the indexes list, to expand the index row. The index row is a toggle — left-click the row again to collapse it.

    When the index row is expanded, the following extra information is displayed.

    index row expanded
    • Definition. The N1QL statement used to define the index.

    • Storage Mode. The storage mode used by the index service on the node on which this index is stored.

    • Nodes. (Only displayed for partitioned indexes.) The nodes on which the index partitions are stored, and the number of partitions stored on each node.

    • Last Scanned. The time and data of the last scan request received for this index. If the index service cannot determine when this index was last scanned, this statistic is not displayed. This may be useful for determining whether this index is currently unused.

      Note that this statistic is persisted to disk every 15 minutes, so it is preserved when the indexer restarts.

    In addition, when the index row is expanded, the Index Stats heading is also displayed, along with the Open in Workbench and Drop buttons.

    Show the Index Statistics

    To see statistics for the index, left-click the Index Stats heading in the expanded index row.

    The Index Stats heading is a toggle — left-click the heading again to hide the statistics.

    For details of the index statistics, refer to Index Statistics.

    Open the Index Definition

    To open the index definition:

    1. Left-click the Open in Workbench button, in the expanded index row.

      The index definition is displayed in the Query Workbench.

    2. Modify the index definition as required. (You cannot change the definition of the existing index, but you can create a new index with the modified definition.)

    indexInQueryWorkbench

    Note that the defining and editing of indexes is performed by means of N1QL. See the N1QL Language Reference for information.

    Immediately beneath the Query Editor, three buttons are displayed. These can be used to test queries, and to determine how to design corresponding indexes; so as to maximize query-performance. The buttons are as follows.

    Execute

    When left-clicked on, this executes the query that has been typed into the Query Editor. For example, type the following query into the Query Editor: SELECT icao FROM `travel-sample` WHERE name = "SeaPort Airlines";. This selects every icao key-value pair from the bucket travel-sample, where the host document also contains a name value that is SeaPort Airlines.

    The Query Editor now appears as follows:

    queryEditorWithSelectQuery

    Left-click on the Execute button.

    leftClickOnExecuteButton

    Couchbase Web Console now provides feedback on the ongoing execution of the query.

    executingQuery

    When query-execution has concluded, the results are duly displayed:

    resultsOfqueryExecution

    Explain

    When left-clicked on, this provides an explanation of how query-execution proceeded:

    leftClickOnExplainButton

    The explanation is now displayed in the Query Results panel:

    queryExplanation

    This indicates the bucket and primary index scan that have been used in the query; as well as the filter applied, and the number of terms returned.

    Advise

    When left-clicked on, this displays advice as to what index or indexes might be created, in order to improve the future performance of the query:

    leftClickOnAdviseButton

    Advice is duly displayed in the Query Results panel:

    queryAdviceDisplay

    In this instance, the advice consists of two options; which are, respectively, the creation of a covered index, and the creation of a regular index. To create a covered index, left-click on the corresponding button:

    createAndBuildIndex

    The following notification is now displayed:

    indexCreateWarning

    Left-click on Continue. When index-creation is completed, the following success-message appears on the Query screen:

    createIndexSuccessMessage

    Index-Definition Support in Community Edition

    Note that in Couchbase Server Community Edition, index-definition support is provided in a slightly different way. The area immediately below the Query Editor appears as follows:

    ceIndexAdvisorLink

    The External Query Advisor link takes the user to an external web-site, where the Query Advisor can be accessed and used.

    Drop the Index

    To drop the index from the bucket:

    1. Left-lick the Drop button in the expanded index row.

      A pop-up message appears, asking if you are sure you want to drop the index.

      drop index
    2. Left-click Drop Index to drop the index, or Cancel to cancel.

    Note that you can also drop an index by means of the N1QL DROP INDEX and DROP PRIMARY INDEX commands.

    Index Summary Statistics

    Summary statistics for the index service are displayed in the footer of the Indexes screen.

    service stats

    For details of the index summary statistics, refer to Index Service Statistics.

    Manage Indexes with the CLI

    You can manage some index service settings using the CLI. Refer to Index Storage Settings via CLI.

    Note that there is no CLI support for the administration of specific indexes. However, you can get index information from the system catalog. Refer to Querying Indexes.

    You can also edit or remove indexes using N1QL. Refer to N1QL Language Reference for more details.

    Manage Indexes with the REST API

    You can manage some index service settings using the REST API. Refer to Index Settings via REST.

    Note that there is no REST API support for the administration of specific indexes.