Disable Index



DisableIndexOperation

Overview

On which node the index is disabled:

  • The index can be disabled either:

    • On a single node, or
    • Cluster wide - on all database-group nodes.
  • When disabling the index from the client on a single node:
    The index will be disabled on the preferred node only, and Not on all the database-group nodes.

  • When disabling an index from the Studio (from the indexes list view),
    The index will be disabled on the local node the browser is opened on, even if it is Not the preferred node.

When index is disabled:

  • No indexing will be done by a disabled index on the node where index is disabled.
    However, new data will be indexed by the index on other database-group nodes where it is not disabled.

  • You can still query the index,
    but results may be stale when querying a node on which the index was disabled.

  • Disabling an index is a persistent operation:

How to enable the index:

  • To enable the index from the client - see enable index operation.

  • To enable the index from the Studio - go to the indexes list view.

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

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

Disable index - single node

// Define the disable index operation
// Use this overload to disable on a single node
var disableIndexOp = new DisableIndexOperation("Orders/Totals");

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

// At this point, the index is disabled only on the 'preferred node'
// New data will not be indexed on this node only
// Define the disable index operation
// Use this overload to disable on a single node
var disableIndexOp = new DisableIndexOperation("Orders/Totals");

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

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

Disable index - cluster wide

// Define the disable index operation
// Pass 'true' to disable the index on all nodes in the database-group
var disableIndexOp = new DisableIndexOperation("Orders/Totals", true);

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

// At this point, the index is disabled on all nodes
// New data will not be indexed
// Define the disable index operation
// Pass 'true' to disable the index on all nodes in the database-group
var disableIndexOp = new DisableIndexOperation("Orders/Totals", true);

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

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

Syntax

// Available overloads:
public DisableIndexOperation(string indexName)
public DisableIndexOperation(string indexName, bool clusterWide)
Parameters Type Description
indexName string Name of index to disable
clusterWide bool true - Disable index on all database-group nodes
false - Disable index only on a single node (the preferred node)

Manually Disabling an Index

It may sometimes be useful to disable an index manually, through the file system.
A faulty index may, for example, load before DisableIndexOperation gets a chance to disable it, but manually disabling the index will assure that its loading is prevented.

  • To manually disable an index simply place a file named disable.marker in the index directory.
    Indexes are kept under the database directory, each index in a directory whose name is simlar to the index's.
    The disable.marker file can be empty, and can be placed in the index directory in any available method, e.g. using explorer, a terminal, or code.

  • Attempting to use a manually disabled index will generate the following exception:
    Unable to open index: '{index.IndexName}', it has been manually disabled via the file: '{disableMarkerPath}'. To re-enable, remove the disable.marker file and enable indexing.

  • To enable a manually disabled index delete disable.marker from the index directory and call EnableIndexOperation.