# Update Search Index Job

Maintains search index consistency across document libraries by re-indexing libraries that have item count mismatches.

Configuration class: UpdateSearchIndexJobCfg

Schedule base: RandomEveryDayScheduleCfg (runs once daily at a random time)

# Purpose

SharePoint search index can occasionally become out of sync with actual library contents. This job detects and fixes index inconsistencies by:

  • Comparing indexed item counts with actual library item counts
  • Triggering re-indexing for libraries with mismatches
  • Optionally sending reports of problematic libraries

# Configuration

# Disabled

  • Type: bool?
  • Default:
  • Required: No
  • Description: Disable this job without removing configuration

# AutoIndex

  • Type: bool
  • Default: false
  • Required: No
  • Description: Automatically trigger re-indexing for libraries with item count mismatches. If false, only reports discrepancies.

# SendReport

  • Type: bool
  • Default: true
  • Required: No
  • Description: Send email report of libraries needing re-indexing

# Subject

  • Type: string
  • Default: "Update search index job"
  • Required: No
  • Description: Email subject line for the report

# Take

  • Type: int
  • Default: 50
  • Required: No
  • Description: Page size — number of matters to retrieve per search query

# EndTime

  • Type: TimeSpan
  • Default: 06:00:00
  • Required: No
  • Description: Stop processing new batches after this time of day. Active batches are completed even if past this time. Example: 06:00:00 means stop starting new work at 6 AM.

# SortBy

  • Type: string
  • Default: "ID"
  • Required: No
  • Description: Field name to sort results by when querying libraries. Example: "Modified" to process recently changed items first.

# CurrentState

  • Type: UpdateSearchIndexJobState
  • Default:
  • Required: No
  • Description: System-managed — stores current job state

# Scheduling Properties

# StartTime

  • Type: TimeSpan?
  • Default:
  • Description: Earliest time of day to run. Example: "22:00:00" for 10 PM (useful for overnight processing).

# Example Configuration

{
  "Disabled": false,
  "AutoIndex": true,
  "SendReport": true,
  "Subject": "Daily Search Index Report",
  "Take": 100,
  "EndTime": "06:00:00",
  "SortBy": "Modified",
  "StartTime": "22:00:00",
  "CurrentState": {}
}

# How It Works

  1. Job runs daily at a random time between StartTime and (if configured) midnight
  2. Retrieves document libraries in batches of size Take
  3. For each library:
    • Compares indexed item count with actual library item count
    • If mismatch detected and AutoIndex is true, triggers re-indexing
  4. Stops starting new batches after EndTime to avoid daytime overhead
  5. If SendReport is enabled, sends email summary of findings
  6. Email recipients come from global email settings

# Report Contents

The email report includes:

  • List of libraries with search index mismatches
  • Number of indexed vs. actual items for each library
  • Whether auto-indexing was triggered
  • Any errors encountered during processing

# Notes

  • Page size: Increase Take for faster processing, decrease to reduce server load per batch
  • Overnight processing: Combine StartTime (22:00:00) and EndTime (06:00:00) to run heavy indexing overnight
  • AutoIndex: Leave false to audit discrepancies before automatically re-indexing; turn true to automatically heal
  • Sort order: SortBy: "Modified" prioritizes recently changed libraries (often the source of index lag)
Last Updated: 4/15/2026, 8:56:27 AM