Did you know #3 - Process Search Tasks


David te Kloese

In this Quick Tip I'll talk about Search Tasks and how you can influence the processing.

Search tasks are the minor updates for every change you do to indexed content. For instance updating the content of a page, moving it do a different folder, but also deletion of an item. Kentico keeps track of these updates when you've updated an item covered by one or more search indexes.

These tasks are stored in the CMS_SearchTask table. You can view them in the Smart Search Application. If you navigate to the Tasks tab you can see all currently awaiting tasks. The "Process tasks"-button does pretty much wat its label says!
 

Smart Search tasks GUI
 
If you need some SQL magic (or just want to show of you Developer skills) you can also view them directly in your Database.

 
Smart Search tasks DB

TIP: don't see any updates to your Search index, check this to see if tasks are "stuck", giving errors or aren't even generated at all!
 

Processing

By default these tasks are processed automatically and almost directly whenever they are placed. There are 2 Search related global Scheduled tasks:
  • Execute search tasks - scheduled to run every 4 hours
  • Optimize search index -  scheduled to run once a week
 
Smart Search Scheduled tasks


As mentioned by default your search is updated immediately. If you have lots of content being edited constantly during peek business hours, you might want to instruct Kentico to store this tasks and only process them by Scheduler (or custom code). This way you can assure normal visitors won't have the load for processing these tasks.


You can do this by adding the following key in your web.config:

<appsettings>
   <add key="CMSProcessSearchTasksByScheduler" value="true"></add>
   ...
</appsettings>


So the Scheduled task "Execute search tasks" mentioned above is needed to handle the search tasks as your index will get outdated otherwise.