Search API Tracker Management - Rebuild & Reset Drupal Index

Rebuild, reset, and manage indexing trackers

Tracker Management

The Search API tracker keeps track of which items need indexing. Sometimes you need to rebuild or reset it.

Queue All Items for Reindexing (Recommended)

Use the Opensolr reindex command to queue all items for reindexing on a server. This marks all tracked items as "needs indexing" without rebuilding the tracker or deleting data from Solr:

# Queue all items on a specific server
drush osri --server=my_solr_server

# Queue a specific index only
drush osri --index=my_solr_index

Search continues working during reindexing since existing Solr data is preserved.

Rebuild Trackers (When Tracker Is Out of Sync)

Use the rebuild command only when the tracker itself is broken (incorrect counts, missing items). This re-scans all content and rebuilds the tracker from scratch:

# Rebuild all indexes on a specific server
drush osrb --server=my_solr_server

# Rebuild a specific index only
drush osrb --index=my_solr_index

Mark All Items for Re-indexing (Search API Native)

The native Search API command for a single index. drush osri is preferred as it handles all indexes on a server at once:

# Mark all items for reindexing (single index)
drush search-api:reset-tracker my_solr_index

# Or use the alias
drush sapi-rt my_solr_index

Clear Index and Rebuild

This deletes all items from Solr and marks everything for re-indexing:

# Clear the Solr index completely
drush search-api:clear my_solr_index

# Or use the alias
drush sapi-c my_solr_index

Check Index Status

# Show status of all indexes
drush oss

# Or use Search API status
drush search-api:status
⚠️ Large Sites
Rebuilding trackers on sites with millions of items can take time and cause database load. Consider running during off-peak hours.

Which Command to Use

Use Reindex (drush osri) When:

  • You want to re-index everything on a server
  • Search should continue working during re-indexing
  • Routine reindexing after deployments or config changes
  • You need to reindex all indexes on a server in one command

Use Rebuild (drush osrb) When:

  • Tracker shows incorrect counts
  • Items are "stuck" and not getting indexed
  • After major content migrations
  • After restoring from backup

Use Clear When:

  • You want a completely fresh start
  • Solr index is corrupted or has stale data
  • Changing schema significantly

Tracker Internals

The tracker uses the search_api_item database table to track:

  • item_id - Entity type and ID (e.g., "entity:node/123:en")
  • index_id - Which index this item belongs to
  • status - 0 = needs indexing, 1 = indexed
# Check tracker table directly (for debugging)
mysql -e "SELECT index_id, status, COUNT(*) FROM search_api_item GROUP BY index_id, status;"