If you need to re-index, and do not want to drop the current index, follow the below steps in creating a new index, ensuring it is healthy, and activating it.
1) Register a new index
This will create a new index for post content (this will also work with other Indexables such as term):
$ wp vip-search index-versions add post Success: Registered and created new index version 2
The response will include the version number added (in this case, 2).
A new index version has been added and created (with mapping) on Elasticsearch. The current active version will continue to receive incremental changes as well.
This does not do any bulk indexing of content, but it will start the indexing of incremental changes to the new version.
2) Build the new index
Now, build the new index alongside the current one (depending on the size of the database, this may take some time).
In the command, specify a version:
$ wp vip-search index --indexables="post" --version="next" Indexing posts... Processed 500/37674. Last Object ID: 37550 Processed 1000/37674. Last Object ID: 37050 Processed 1500/37674. Last Object ID: 36550 ... Processed 37674/37674. Last Object ID: 1 Number of posts indexed: 37674 Total time elapsed: 492.615 Success: Done!
3) Health check
Check the status of the indexes (both the current and next):
$ wp vip-search health validate-counts 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)
There is also a query parameter that can be used to verify search results before activating the new version. To use that add
vip_search_<indexable>_version parameter to your URL.
As an example, if you would like to run a search against the
next index on posts you could navigate to an URL similar to:
4) Activate the new index
Once the new index version shows that it is in sync (“healthy”), it can be activated.
The active index is the one that serves site traffic (queries), so be sure the target index is ready for production before switching.
$ wp vip-search index-versions activate post next Are you sure you want to activate index version next for type post? [y/n] y Success: Successfully activated index version next for type post
5) Delete the old index
Once you’ve verified the new index is handling requests correctly, you can delete the old index. (You cannot delete the active index).
$ wp vip-search index-versions delete post previous ⚠️ You are about to run a destructive operation. Are you sure? [y/n] y Success: Successfully deleted index version 1 for type post