The goal of this article is to give complete instructions on how to rebuild your local search index in 4.x environment if you are a experiencing unresolvable issues with local search.
1. Remove data sync job from job management
Pre-requisite: Obtain the environment ID and instance ID related to the search index you wish to delete.
First retrieve all search indices by performing
Delete by performing
Elastic search should reply with a JSON confirming deletion
For Elastic Search to rebuild the search index correctly I've found a restart of the Search module is necessary/sufficient. Note: in some environments it has been observed that simply restarting the Search module is not enough and you must restart the container, if there are issues during refresh metadata (e.g. 504 errors) this may be the case.
Either restart the services or use the restart script in the bin folder of the container.
If you are still getting local search index issues after rebuilding the local search index you may have wider issues with Elastic Search. One thing to try would be stopping all data sync jobs for all instances, deleting entire Elastic Search data folder, restarting search, performing refresh metadata for all instances.