Check the index health
There is a wide range of subcommands available in wp vip-search health 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.
Validating a single post
To ensure that a post is in the index and retrieve its information stored in the index, use the documents get <indexable-slug> command. For example, using VIP-CLI to check if post ID 123 is in the index:
vip @example-app.develop -- wp vip-search documents get post 123
Validating counts
validate-counts
To see the counts of all 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:
vip @example-app.develop -- wp vip-search health validate-counts
Example output for the above command:
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_versionDB– number of found Indexables in databaseES– number of found Indexables in indexDiff– difference betweenDBandEScounts
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)
- 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 - Comments Indexable:
wp vip-search health validate-comments-count
Validating contents
Use the validate-contents to simultaneously check for and fix any inconsistencies (e.g. content mismatches and missing posts) between the database and the index:
vip @example-app.develop -- wp vip-search health validate-contents
Example output from the command with found inconsistencies:
...✘ 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.
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.
vip @example-app.develop -- wp vip-search health validate-contents --inspect
Example output where post 5 was not found in the index:
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:
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:
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:
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.
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.
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.
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.
vip @wpvip.production -- wp vip-search health validate-contents --mode=missing
Last updated: May 26, 2025