When to compact
- After bulk deletions: Removing a large number of documents leaves gaps in the internal storage.
- After many updates: Repeatedly updating the same documents accumulates obsolete data.
- When disk usage seems high: If an index uses more disk space than expected for its document count, compaction can help.
Compact an index
Send aPOST request to /indexes/{index_uid}/compact:
Monitor the compaction task
Compaction runs asynchronously. Check its progress with the task endpoint:Disk space requirements
Compaction requires temporary disk space roughly equal to the size of the index being compacted. Ensure your machine has sufficient free space before starting. If the disk fills up during compaction, the task fails and the index remains in its pre-compaction state.Search availability during compaction
Compaction does not block search. Your index remains fully searchable while the operation runs. New indexing tasks will be queued and processed after compaction completes.Next steps
Compact API reference
Full API reference for the compact endpoint
Monitor tasks
Track the status of asynchronous operations
Indexing best practices
Optimize your indexing workflow for production