Enable Index Operation



How to enable an index

  • From the Client API:
    Use EnableIndexOperation to enable the index from the Client API.
    The index can be enabled either:

    • On a single node, or
    • Cluster wide - on all database-group nodes.
  • From Studio:
    To enable the index from the Studio go to the indexes list view.

  • Reset index:
    Resetting a disabled index will enable the index back on the local node where the reset action was performed.

  • Modify index definition:
    Modifying the index definition will also enable back the normal operation of the index.

  • An index that was disabled via the file system can also be enabled by either option from above
    after removing the disable.marker file. Learn more in Disable index manually via the file system.

Enable index from the Client API

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
var enableIndexOp = new EnableIndexOperation("Orders/Totals");

// Execute the operation by passing it to Maintenance.Send
store.Maintenance.Send(enableIndexOp);

// At this point, the index is enabled on the 'preferred node'
// New data will be indexed on this node
// Define the enable index operation
// Use this overload to enable on a single node
var enableIndexOp = new EnableIndexOperation("Orders/Totals");

// Execute the operation by passing it to Maintenance.SendAsync
await store.Maintenance.SendAsync(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
var enableIndexOp = new EnableIndexOperation("Orders/Totals", true);

// Execute the operation by passing it to Maintenance.Send
store.Maintenance.Send(enableIndexOp);

// At this point, the index is enabled on ALL nodes
// New data will be indexed
// Define the enable index operation
// Pass 'true' to enable the index on all nodes in the database-group
var enableIndexOp = new EnableIndexOperation("Orders/Totals", true);

// Execute the operation by passing it to Maintenance.SendAsync
await store.Maintenance.SendAsync(enableIndexOp);

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

Syntax:

// Available overloads:
public EnableIndexOperation(string indexName)
public EnableIndexOperation(string indexName, bool clusterWide)
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)