Enable Index Operation



Enable index - single node

  • With this option, the index will be enabled on the preferred node only.
    The preferred node is simply the first node in the database group topology.

  • Note: When enabling an index from the Studio,
    the index will be enabled on the local node the browser is opened on, even if it is Not the preferred node.

// Define the enable index operation
// Use this overload to enable on a single node
const enableIndexOp = new EnableIndexOperation("Orders/Totals");

// Execute the operation by passing it to maintenance.send
await documentStore.maintenance.send(enableIndexOp);

// At this point, the index is enabled on the 'preferred node'
// New data will be indexed on this node

Enable index - cluster wide

// Define the enable index operation
// Pass 'true' to enable the index on all nodes in the database-group
const enableIndexOp = new EnableIndexOperation("Orders/Totals", true);

// Execute the operation by passing it to maintenance.send
await documentStore.maintenance.send(enableIndexOp);

// At this point, the index is enabled on all nodes
// New data will be indexed

Syntax

const enableIndexOp = new EnableIndexOperation(indexName, clusterWide = false);
Parameters Type Description
indexName string Name of index to enable
clusterWide bool true - Enable index on all database-group nodes
false - Enable index only on a single node (the preferred node)