We are using Solr 5.4 and Sitecore 8.2 we plan to do daily/Weekly Rebuild of Indexes for Web Environment through Sitecore Job or Tasks. Can some body suggest me what is best way to do this

Note : We are already using PublishOnSync strategy


  • 5
    If you have already update index on publish, why do you need to rebuild the index?
    – Marek Musielak
    Oct 11, 2017 at 15:51
  • We still need to have full rebuild of Indexes for Web this is a Design we have closed. Oct 11, 2017 at 16:07
  • Your best option is do implement an agent which will trigger the rebuild index. Oct 11, 2017 at 18:47

1 Answer 1


I did something similar to this not long ago to rebuild the sitemaps of 800+ sites. I used the Sitecore scheduled tasks.

Create a task

namespace Sitecore.Sitemaps.Tasks
    class GenerateSitemaps
        public void Execute(
          Sitecore.Data.Items.Item[] items,
          Sitecore.Tasks.CommandItem command,
          Sitecore.Tasks.ScheduleItem schedule)
            // This is where you all your indexing code
            var sitemapService = new SitemapService();


Create a command

Go to the path /sitecore/system/Tasks/Commands/ and create a new command item. In type enter the class you created above. i.e. Sitecore.Sitemaps.Tasks.GenerateSitemaps, Sitecore.Sitemaps. In method enter Execute

Create a schedule

Go to the item /sitecore/system/Tasks/Schedules/ and create a new schedule. For the command, select the command item you created above. The schedule field is a little hard to understand, but it makes sense in the end. The text below I borrowed from this page.

The Schedule field can be a bit tricky. You’ll notice in my example above that I have several piped values. They are defined as follows:

  1. The start date in yyyyMMdd format.

  2. The end date in yyyyMMdd format.

  3. The days of the week that the task should be run. Each day is assigned a value: 1 = Sunday, 2 = Monday, 4 = Tuesday, 8 = Wednesday, 16 = Thursday, 32 = Friday, and 64 = Saturday. For example to run a task Monday through Friday you’d enter 62 (2 + 4 + 8 + 16 + 32). I have my task set up to run every day (1 + 2 + 4 + 8 + 16 + 32 + 64 = 127).

  4. The minimum interval the task is to be run in HH:mm:ss format. The example above is set to run once every 24 hours.

Thats it. Now on a schedule basis your indexing code will run.

If you need the code to rebuild an index, its pretty straight forward.

IndexCustodian.FullRebuild(ContentSearchManager.GetIndex("[INDEX NAME]"), true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.