Index has Changed Operation


  • When deploying an index:

    • If the new index definition is different from the current index definition on the server,
      the current index will be overwritten and data will be re-indexed according to the new index definition.
    • If the new index definition is the same as the one currently deployed on the server,
      it will not be overwritten and re-indexing will not occur upon deploying the index.
  • Prior to deploying an index:,

    • Use IndexHasChangedOperation to check if the new index definition differs from the one
      on the server to avoid any unwanted changes to the existing indexed data.
  • In this page:


Check if index has changed

// Some index definition
$indexDefinition = new IndexDefinition();
$indexDefinition->setName("UsersByName");
$indexDefinition->setMaps(["from user in docs.Users select new { user.Name }"]);

// Define the has-changed operation, pass the index definition
$indexHasChangedOp = new IndexHasChangedOperation($indexDefinition);

// Execute the operation by passing it to Maintenance.Send
$store->maintenance()->send($indexHasChangedOp);

// Return values:
// false: The definition of the index passed is the SAME as the one deployed on the server
// true:  The definition of the index passed is DIFFERENT than the one deployed on the server
//        Or - index does not exist

Syntax

IndexHasChangedOperation(?IndexDefinition $definition)
Parameters Type Description
$definition ?IndexDefinition The index definition to check
Return Value Description
true When the index does not exist on the server
or -
When the index definition is different from the one deployed on the server
false When the index definition is the same as the one deployed on the server