Index has Changed Operation
-
When deploying an index:
- If the new index definition is different than 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 on the server,
it will not be overwritten and re-indexing will not occur upon deploying the index.
- If the new index definition is different than the current index definition on the server,
-
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.
- Use
-
In this page:
Check if index has changed
// Some index definition
const indexDefinition = new IndexDefinition();
indexDefinition.name = "UsersByName";
indexDefinition.maps = new Set([ `from user in docs.Users select new { user.Name }` ]);
// Define the has-changed operation, pass the index definition
const indexHasChangedOp = new IndexHasChangedOperation(indexDefinition);
// Execute the operation by passing it to maintenance.send
const indexHasChanged = await documentStore.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
const indexHasChangedOp = new IndexHasChangedOperation(definition);
Parameters | Type | Description |
---|---|---|
definition | IndexDefinition | The index definition to check |
Return Value | |
---|---|
true |
When the index does not exist on the server or - When the index definition is different than the one deployed on the server |
false |
When the index definition is the same as the one deployed on the server |