Title: Check the index health
Author: WordPress VIP Documentation
Published: October 26, 2021
Last modified: April 23, 2026

---

 1. [Enterprise Search](https://docs.wpvip.com/enterprise-search/)
 2. Check the index health

#  Check the index health

Several subcommands and options for `wp vip-search health` are available to check
if an index is in sync with the database and to assist in debugging.

**VIP-CLI command examples**

For demonstration purposes, the `<app-name>` value `example-app` and the `<env>`
value `develop` are used in the VIP-CLI command examples below. Read more about 
[how to target environments in VIP-CLI commands](https://docs.wpvip.com/vip-cli/target-environments/).

## `validate-contents`

The `validate-contents` command simultaneously checks for and fixes any inconsistencies(
e.g. content mismatches and missing posts) between the database and the index:

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents
    ```

Example output from the command with found inconsistencies:

    ```wp-block-preformatted
    ...✘
    Warning: Inconsistencies fixed:
    type,id,issue
    post,5,missing_from_index
    post,7,missing_from_index
    post,1,mismatch
    ```

### Command options

#### `--do_not_heal`

_Values not accepted. _

Prevents the `validate-contents` command from fixing index inconsistencies.

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents --do_not_heal
    ```

#### `--inspect`

_Values not accepted. _

Provides verbose output in an array format for each inconsistency.

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents --inspect
    ```

Example output where post 5 was not found in the index:

    ```wp-block-preformatted
    Warning: Inconsistencies found!
    Warning: Formatting is being ignored!
    array(1) {
      ["existence"]=>
      array(2) {
        ["expected"]=>
        string(20) "Post 5 to be indexed"
        ["actual"]=>
        NULL
      }
    }
    ```

#### `--start_post_id`, `--last_post_id`

_Accepted values: single numerical post ID_

Limits the command to run against a subset of post IDs. 

For example, to start at 900:

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents --start_post_id=900
    ```

Use both of these options together to limit the command to run against a range of
posts.

For example, to index only post IDs from `900` to `1200`:

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents --start_post_id=900 --last_post_id=1200
    ```

#### `--batch_size`

_Accepted values: numerical amount of objects to process per batch_
_Default value:
500, Maximum value: 5000_

Determines the amount of posts to be checked and fixed per validation cycle.

For example, to increase the objects per cycle to `1000`:

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents --batch_size=1000
    ```

#### `--max_diff_size`

_Accepted values: numerical amount of inconsistencies
Default value: 1000

To customize exiting the command after a certain amount of inconsistent records 
found in index. A large number of inconsistencies indicates the need to [re-index](https://docs.wpvip.com/vip-search/index-with-vip-search/).

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents --max_diff_size=2000
    ```

#### `--format`

_Accepted values: _`table`, `json`, `csv`, `yaml`, `ids`, `count`
Default value:`
csv`

Customizes the format of the output.

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents --format=yaml
    ```

#### `--force_parallel_execution`

_Values not accepted. _

Allows an additional validation command to run parallel with a validation command
already in progress.

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-contents --force_parallel_execution
    ```

**Caution**

For sites with large databases, it could be costly in performance to run parallel
commands.

#### `--mode`

_Accepted values_: `missing`, `mismatch`_. _

Mode to target validation to a specific subset of index inconsistencies.

    ```wp-block-preformatted
    vip @wpvip.production -- wp vip-search health validate-contents --mode=missing
    ```

## `validate-counts`

To output the counts of all [Indexables](https://docs.wpvip.com/vip-search/vip-search-features/#h-indexables),
use the `validate-counts` subcommand.

For example, a site that has Indexables of posts (with two index versions, `1` and`
2` ), terms, and users:

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health validate-counts
    ```

Example output for the above command:

    ```wp-block-preformatted
    Validating post count

    ✅ no inconsistencies found when counting entity: post, type: post, index_version: 1 - (DB: 37498, ES: 37498, Diff: 0)
    ✅ no inconsistencies found when counting entity: post, type: page, index_version: 1 - (DB: 176, ES: 176, Diff: 0)
    ✅ no inconsistencies found when counting entity: post, type: post, index_version: 2 - (DB: 37498, ES: 37498, Diff: 0)
    ✅ no inconsistencies found when counting entity: post, type: page, index_version: 2 - (DB: 176, ES: 176, Diff: 0)

    Validating term count

    ✅ no inconsistencies found when counting entity: term, type: N/A, index_version: 1 - (DB: 4, ES: 4, Diff: 0)


    Validating user count

    ✅ no inconsistencies found when counting entity: user, type: N/A, index_version: 1 - (DB: 1, ES: 1, Diff: 0)
    ```

The output from the command will display for each Indexable:

 * `type` (usually only applicable for posts)
 * `index_version`
 * `DB` – number of found Indexables in database
 * `ES` – number of found Indexables in index
 * `Diff` – difference between `DB` and `ES` counts

### `stop-validate-contents`

A running `validate-counts` command can be terminated with a `stop-validate-contents`
command. For example:

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search health stop-validate-contents
    ```

## `validate-<Indexables>-count`

To only display the individual Indexable count, use the `validate-<Indexables>-count`
subcommands:

_Accepted options:_ `--version=<index version number>`, `--network-wide` (for [WordPress multisite](https://docs.wpvip.com/wordpress-multisite/))

 * Posts Indexable: `wp vip-search health validate-posts-count`
 * Terms Indexable: `wp vip-search health validate-terms-count`
 * Users Indexable: `wp vip-search health validate-users-count`

## Validate a single post

The `documents get <indexable-slug>` command validates if a specific post exists
in the index and is so—it retrieves the information that is stored in the index 
for that post.

In this example, the command is used to validate if post ID 123 is in the index:

    ```wp-block-preformatted
    vip @example-app.develop -- wp vip-search documents get post 123
    ```

Last updated: April 23, 2026