Skip to main content

Endpoint

POST /search/reindex
Triggers a full reindex operation that syncs all data from the PostgreSQL database to Typesense search collections. This process runs asynchronously to avoid HTTP timeouts.

Request Body

batch_size
integer
default:"1000"
Number of records to process in each batch. Larger values are faster but use more memory

Response

message
string
Confirmation message that the reindex operation has started
progress
object
Initial progress information

Example Request

curl -X POST "https://api.blnk.io/search/reindex" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"batch_size": 1000}'
{
  "batch_size": 1000
}

Example Response

{
  "message": "Reindex operation started",
  "progress": {
    "status": "in_progress",
    "total_records": 0,
    "processed_records": 0,
    "current_collection": "ledgers",
    "started_at": "2024-03-04T12:00:00Z"
  }
}

Monitoring Progress

Use the Get Reindex Progress endpoint to monitor the reindex operation:
curl -X GET "https://api.blnk.io/search/reindex" \
  -H "Authorization: Bearer YOUR_API_KEY"

When to Reindex

You should trigger a reindex in the following situations:

Initial Setup

When first deploying Blnk with Typesense search enabled.

After Data Migration

After importing large amounts of data directly into the database.

Schema Changes

After updating search collection schemas or adding new searchable fields.

Data Inconsistencies

If you notice search results don’t match database records.

Recovery

After recovering from a Typesense outage or data corruption.

Reindex Process

The reindex operation processes collections in the following order:
  1. Ledgers: Base collection, reindexed first
  2. Identities: User and entity records
  3. Balances: Account balance records
  4. Transactions: Transaction history
  5. Reconciliations: Reconciliation records

Error Responses

error
string
Error message describing what went wrong
progress
object
Current progress information (returned when a reindex is already running)

Common Errors

409 Conflict: A reindex operation is already in progress
{
  "error": "A reindex operation is already in progress",
  "progress": {
    "status": "in_progress",
    "total_records": 50000,
    "processed_records": 12500,
    "current_collection": "transactions",
    "started_at": "2024-03-04T11:45:00Z"
  }
}

Performance Considerations

Batch Size

  • Small (100-500): Lower memory usage, slower overall
  • Medium (500-1000): Balanced performance (recommended)
  • Large (1000-5000): Faster but higher memory usage

Database Impact

Reindexing reads from your database:
  • Uses read replicas if available
  • Minimal impact on write operations
  • May increase database CPU during reindex

Duration Estimates

RecordsBatch SizeEstimated Time
10,0001,0001-2 minutes
100,0001,00010-15 minutes
1,000,0001,0001-2 hours
10,000,0002,0008-12 hours

Best Practices

  1. Schedule during low traffic: Run reindex during off-peak hours
  2. Monitor progress: Check the progress endpoint regularly
  3. Use appropriate batch size: Balance speed and resource usage
  4. Don’t interrupt: Let the reindex complete naturally
  5. Have a backup: Ensure your database is backed up before major reindex operations

Incremental Updates

For normal operations, you don’t need to reindex. Blnk automatically updates the search index when:
  • New records are created
  • Existing records are updated
  • Records are deleted
Only use full reindex for the scenarios listed above.

Build docs developers (and LLMs) love