How to Automatically Compact the Solr Crawl Database

  • Updated

Windows task scheduler can be used to automatically restart Solr Process Manager, which automatically compacts the crawl database in version 9.1 and above. Solr for 9.0 versions requires commands to compact the crawl database. Those commands can also be run on a schedule.

IMPORTANT: When process manager is stopped, all querying and crawling functionality is unavailable, so it should be scheduled to run at a low traffic time.
The steps are the same for Solr 1.0 (used with 9.0 CMS versions) except instead of creating a .bat file, you need to reference files in this maintenance KB and comment out the javascript:alert lines from those files. 

1. In the Control Panel's Administrative Tools, open Task Scheduler. 

2. In the actions pane on the right side, choose Create Task.

3. In the security options, choose an administrator on the box and run with highest privileges. 

task scheduler general

4. Click the Triggers tab and create a new trigger.

5. Set the schedule to your desired time and frequency.


6. Create a .bat file in Notepad with the following text.

NET STOP "EktronSolrProcessManager2.0"
NET START [Service]
net start "EktronSolrProcessManager2.0"

This is just an example - modify it to suit your needs. The file has a timeout command in case Process Manager takes more than a few minutes to restart. Save the file in the place of your choosing.

7. Click the Actions tab and create a new action.


8. Browse to the location of the .bat file and hit OK.

9. Click OK, which creates the task.

10. Run the task, confirm that all 3 java processes end, then verify that they restarted.