Scheduled rebuild of indexs

Rahim Remtulla asked on September 4, 2019 17:52

hi

is it possible to have a scheduled full rebuild of smart search index's , i know there is a built in task for optimising them , but i have a need to rebuild them , any suggestions how i could do this ?

Recent Answers


Peter Mogilnitski answered on September 4, 2019 18:04

Take a look at this answer

0 votesVote for this answer Mark as a Correct answer

vasu yerramsetti answered on September 4, 2019 18:15

You can go through Kentico documentation for creating custom smart search using Kentico API.

Hope helps you.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on September 5, 2019 08:56

What is the reason you want to rebuild the index? Keep in mind that it is a complex operation using quite a lot of resources. So it can have some negative impact on the performance. You do not need to rebuild index unless you change the structure of the index. This means e.g. if you have pages index and you add/remove or modify page type fields which are covered by the index. In this case rebuild is required to update the index structure. However, if you are just working with pages, the content of the index is updated in the existing structure and there is no need for rebuilding.

0 votesVote for this answer Mark as a Correct answer

Zach Perry answered on September 5, 2019 22:22

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.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.