I created a scheduled task:
[assembly: RegisterCustomClass("ScheduledTasks.SmartSearchIndexRebuild", typeof(ScheduledTasks.SmartSearchIndexRebuild))]
namespace ScheduledTasks
{
public class SmartSearchIndexRebuild : ITask
{
public string Execute(TaskInfo task)
{
var taskData = task.TaskData;
var indexes = taskData.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var index in indexes)
{
SearchIndexInfo indexToRebuild = SearchIndexInfoProvider.GetSearchIndexInfo(index);
if (indexToRebuild != null)
{
// Creates a rebuild task for the index.
SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, null, null, indexToRebuild.IndexName,
indexToRebuild.IndexID);
}
}
return "Complete";
}
}
}
Then in the task data I have a list of search indexes codename that I want to rebuild seperated by |
codename|anothercodename|andanother
The search indexes I do this for are all custom data so the only way to update them is via rebuild. Otherwise I would listen to Juraj and try to use something that is covered by the index.