Disable Index
-
You can disable a specific index by either of the following:
- From the Client API - using
DisableIndexOperation
- From the Studio - see indexes list view
- Via the file system
- From the Client API - using
-
To learn how to enable a disabled index see article Enable index operation.
-
In this page:
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 API 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 disabling the index manually,
The index will be disabled on the preferred node only, and Not on all the database-group nodes.
-
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:
- The index will remain disabled even after restarting the server or after disabling/enabling the database.
- To only pause the index and resume after a restart see: pause index operation.
Disable index from the Client API
// 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
// 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
// Available overloads:
public DisableIndexOperation(string indexName)
public DisableIndexOperation(string indexName, bool clusterWide)
Parameter | Type | Description |
---|---|---|
indexName | string | Name of index to disable |
clusterWide | bool | true - Disable index on all database-group nodesfalse - Disable index only on a single node (the preferred node) |
Disable index manually via the file system
-
It may sometimes be useful to disable an index manually, through the file system.
For example, a faulty index may load before DisableIndexOperation gets a chance to disable it.
Manually disabling the index will ensure that the index is not loaded. -
To manually disable an index:
- 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 similar to the index's. - The
disable.marker
file can be empty,
and can be created by any available method, e.g. using the File Explorer, a terminal, or code.
- Place a file named
-
Attempting to use a manually disabled index will generate the following exception:
Unable to open 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:
- First, remove the
disable.marker
file from the index directory. - Then, enable the index by any of the options described in: How to enable an index.
- First, remove the