---
title: "Index has Changed Operation"
url: "https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/index-has-changed"
version: "6.2"
language: "php"
---

# Index has Changed Operation

> Client language: PHP. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/index-has-changed.md), [Java](https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/index-has-changed.java.md), [Python](https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/index-has-changed.python.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/index-has-changed.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - **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](#check-if-index-has-changed)
>   - [Syntax](#syntax)

## Check if index has changed

```php
// 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

```php
IndexHasChangedOperation(?IndexDefinition $definition)
```

| Parameters | Type | Description |
| - | - | - |
| **$definition** | [?IndexDefinition](https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/put-indexes.php.md#indexdefinition) | The index definition to check |

| Return Value | Description |
| - | - |
| `true` | When the index **does not exist** on the server<br />or -<br />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 |

## See also

- [What are Indexes](https://docs.ravendb.net/6.2/indexes/what-are-indexes.php.md)
- [Creating and Deploying Indexes](https://docs.ravendb.net/6.2/indexes/creating-and-deploying.md)
- [Index Administration](https://docs.ravendb.net/6.2/indexes/index-administration.md)
- [How to Get Indexes](https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/get-indexes.php.md)
- [How to Put Indexes](https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/put-indexes.php.md)
- [How to Delete Index](https://docs.ravendb.net/6.2/client-api/operations/maintenance/indexes/delete-index.php.md)
