Disable Index



Overview

Which node is the index disabled on?

  • 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 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.


What happens when the 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:

Disable index from the Client API

Disable index - single node:

// Define the disable index operation
// Use this overload to disable on a single node
$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

Disable index - cluster wide:

// Define the disable index operation
// Pass 'true' to disable the index on all nodes in the database-group
$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

Syntax:

DisableIndexOperation(?string $indexName, bool $clusterWide = false)
Parameter 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)

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.
  • 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.