JDBC Driver for Couchbase

Build 20.0.7654

ManageIndices

Creates/Drops an index in a target bucket in Couchbase.

Building Indices

An anonymous primary index can be created with these parameters:

EXECUTE ManageIndices
  @BucketName = 'Players'
  @Action = 'CREATE'
  @IsPrimary = 'true'
  @IndexType = 'VIEW'

This is the same as executing this N1QL:

CREATE PRIMARY INDEX ON `Players` USING VIEW

A named primary index can be created by specifying an @Name, in addition to the parameters listed above:

EXECUTE ManageIndices
  @BucketName = 'Players'
  @Action = 'CREATE'
  @IsPrimary = 'true'
  @Name = 'Players_primary'
  @IndexType = 'VIEW'

A secondary index can be created by setting @IsPrimary to false and providing at least one expression.

EXECUTE ManageIndices
  @BucketName = 'Players',
  @Action = 'CREATE',
  @IsPrimary = 'false',
  @Name = 'Players_playtime_score',
  @Expression#1 = 'score',
  @Expression#2 = 'playtime',

This is the same as running the following N1QL:

CREATE INDEX `Players_playtime_score` ON `Players`(score, playtime) USING GSI;

Multiple nodes and filters can also be provied to generate more complex indices:

EXECUTE ManageIndices
  @BucketName = 'Players',
  @Name = 'TopPlayers',
  @Expression#1 = 'score',
  @Expression#2 = 'playtime',
  @Filter#1 = 'TopScore > 1000',
  @Filter#2 = 'PlayTime > 600',
  @Nodes#1 = '127.0.0.1:8091',
  @Nodes#2 = '192.168.0.100:8091'

This is the same as running the following N1QL:

CREATE INDEX `TopPlayers` ON `Players`(score, playtime) WHERE topscore > 1000 AND playtime > 600 USING GSI WITH { "nodes": ["127.0.0.1:8091", "192.168.0.100:8091"]};

Input

Name Type Required Description
BucketName String True The target bucket to create or the the index in.
Action String True Specifies which action to perform on the index, can be Create or Drop.
Expression# String False Specifies which expressions or functions will the index be based off of. At least one is required if IsPrimary is set to false and the action is Create.
Name String False The name of the index to create or drop, required if IsPrimary is set to false.
IsPrimary String False Specifies wether the index should be a primary index.

The default value is true.

Filter# String False A list of filters to apply on the index.
IndexType String False The type of index to create, can be GSI or View, only used if the action is Create.

The default value is GSI.

ViewName String False Deprecated, included for compatibility only. Does nothing.
Nodes# String False A list of nodes to contain the index, must contain the port, only used if the action is Create.
NumReplica String False How many replicas to create among the index nodes in the cluster.

Result Set Columns

Name Type Description
Success String Whether or not the index was successfully created.

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7654