SuiteCRM – clear / reindex search index
Came across a problem with a SuiteCRM where the search was not working correctly, returning none or unrelated results. SuiteCRM relies on an indexing service called Lucene, which handles indexing for advanced searches, as in my case, this needs to be full reindexed to work correctly.
1. Lock Files
When Lucene begins indexing it generates lock files, normally found under modules/AOD_Index/Index/Index
with the extension .lock
, it is save to delete these files if they are old (have an old time stamp), sometimes this is enough to fix the issue, as previous indexing attempts max have failed and left the lock file, stopping future indexing processes from starting. First try, removing these lock files and wait and see if the indexing processes continue / repair them selfs.
2. Full Reindexing
I would recommend you do a full backup of the modules/AOD_Index
directory before starting, as well as a backup of the database.
Also temperarly stop cronjobs from running, as we dont want the cron indexer to kick in during this clearing process.
1. Rename index folder (can be deleted after)
From your SuiteCRM root directory:
mv modules/AOD_Index/Index/Index modules/AOD_Index/Index/Index.BACKUP
We are renaming your current (old) index to Index.BACKUP, you can delete this later once you are sure everything is resolved.
2. Empty Table
Now delete all rows from the table aod_index
3. Schedules
Make sure the Optimise AOD Index and Perform Lucence Index are running as part of the schedule.
4. Wait
Make sure you have re-enabled your cronjob and wait for the indexes to rebuild. This will take a long time, but you can monitor the rebuilding process with the below command. Once it has stabilised, it should be complete.
watch du -h modules/AOD_Index/Index/Index
This code is provided as it and may require changes to work for your needs.