Regenerate a corrupt index

Typically, a corrupt index regenerates itself. If the system does not start the regeneration process, you must issue a script command to delete the existing index and regenerate it.

For example, to regenerate the task text index, the following script could be used as a background script:
var indexer = new Packages.com.glide.lucene.TextIndexEvent();
   indexer.createIndex("task", "my_email@service-now.com");
Change the email address to the address that receives the notification when the index is completed. The script creates an event that the index handler processes so the script completes almost instantly. When the scheduled job picks up the event, you can check the Component Status page and see that the index is being generated. An entry also appears in the log, as shown in the following example:
 10/28/09 15:36:19 (521) worker.1 worker.1 TextIndexGenerator: Text index generation starting for: task
As each extended table completes, it is logged:
 10/28/09 15:37:13 (213) worker.1 worker.1 [0:00:01.462] TextIndex generation complete for: problem, rows indexed: 11
After all the extended tables are completed, the Component Status page entry is updated to "completed" and a final log entry is made. The log entry shows how long the process took.
  10/28/09 15:37:20 (794) worker.1 worker.1 TextIndexGenerator: Text index generation complete for: task, in: 0:01:02.669