Skip to main content

Endpoint

GET /search/reindex
Retrieves the current progress and status of the reindex operation.

Response

status
string
Current status of the reindex operation:
  • in_progress: Reindex is currently running
  • completed: Reindex finished successfully
  • failed: Reindex encountered an error
total_records
integer
Total number of records to reindex across all collections
processed_records
integer
Number of records successfully processed so far
current_collection
string
The collection currently being reindexed (e.g., “transactions”, “balances”)
collections_completed
array
Array of collection names that have been fully reindexed
started_at
string
Timestamp when the reindex operation started (ISO 8601 format)
completed_at
string
Timestamp when the reindex operation completed (ISO 8601 format). Null if still in progress
error
string
Error message if the reindex failed

Example Request

curl -X GET "https://api.blnk.io/search/reindex" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response (In Progress)

{
  "status": "in_progress",
  "total_records": 150000,
  "processed_records": 45000,
  "current_collection": "transactions",
  "collections_completed": ["ledgers", "identities", "balances"],
  "started_at": "2024-03-04T12:00:00Z",
  "completed_at": null
}

Example Response (Completed)

{
  "status": "completed",
  "total_records": 150000,
  "processed_records": 150000,
  "current_collection": "reconciliations",
  "collections_completed": [
    "ledgers",
    "identities",
    "balances",
    "transactions",
    "reconciliations"
  ],
  "started_at": "2024-03-04T12:00:00Z",
  "completed_at": "2024-03-04T12:45:30Z"
}

Example Response (Failed)

{
  "status": "failed",
  "total_records": 150000,
  "processed_records": 45000,
  "current_collection": "transactions",
  "collections_completed": ["ledgers", "identities", "balances"],
  "started_at": "2024-03-04T12:00:00Z",
  "completed_at": "2024-03-04T12:23:15Z",
  "error": "Failed to connect to Typesense server"
}

Example Response (No Reindex Started)

{
  "error": "No reindex operation has been started"
}

Polling Example

const pollReindexProgress = async () => {
  const checkProgress = async () => {
    const response = await fetch('https://api.blnk.io/search/reindex', {
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      }
    });
    
    const progress = await response.json();
    
    if (progress.status === 'in_progress') {
      const percentage = (progress.processed_records / progress.total_records * 100).toFixed(2);
      console.log(`Reindex progress: ${percentage}% (${progress.current_collection})`);
      
      // Check again in 5 seconds
      setTimeout(checkProgress, 5000);
    } else if (progress.status === 'completed') {
      console.log('Reindex completed successfully!');
    } else if (progress.status === 'failed') {
      console.error('Reindex failed:', progress.error);
    }
  };
  
  checkProgress();
};

pollReindexProgress();

Progress Calculation

Calculate the completion percentage:
const calculateProgress = (progress) => {
  if (progress.total_records === 0) return 0;
  return (progress.processed_records / progress.total_records) * 100;
};

const estimateTimeRemaining = (progress) => {
  const startTime = new Date(progress.started_at);
  const now = new Date();
  const elapsed = now - startTime; // milliseconds
  
  const processedRatio = progress.processed_records / progress.total_records;
  if (processedRatio === 0) return null;
  
  const totalEstimated = elapsed / processedRatio;
  const remaining = totalEstimated - elapsed;
  
  return Math.ceil(remaining / 1000 / 60); // minutes
};

Understanding the Response

Collections Completed

The reindex processes collections in this order:
  1. ledgers
  2. identities
  3. balances
  4. transactions
  5. reconciliations
The collections_completed array shows which collections have been fully reindexed.

Processed Records

  • Includes all records successfully written to Typesense
  • Updates incrementally as batches complete
  • May not increase linearly (some collections are larger than others)

Current Collection

Shows which collection is actively being reindexed. This helps identify:
  • Where the process is in the overall workflow
  • Which collection may be causing slowdowns
  • Progress within large collections

Error Responses

error
string
Error message when no reindex has been started

Common Errors

  • 404 Not Found: No reindex operation has been started yet

Monitoring Best Practices

  1. Poll regularly: Check every 5-10 seconds for large reindex operations
  2. Set timeouts: Implement reasonable timeout limits (e.g., 12 hours)
  3. Log progress: Track progress over time to estimate completion
  4. Alert on failures: Set up notifications for failed reindex operations
  5. Display to users: Show progress bars or status updates in admin interfaces

Next Steps

After reindex completes:
  1. Verify results: Run test searches to ensure data is properly indexed
  2. Check counts: Compare record counts between database and search index
  3. Test performance: Verify search performance meets expectations
  4. Monitor errors: Check application logs for any search-related errors

Build docs developers (and LLMs) love