When working with datasets containing hundreds of thousands or millions of documents, how you send data to Meilisearch matters. This guide covers batch sizing, supported formats, compression, progress monitoring, and error handling for large imports.Documentation Index
Fetch the complete documentation index at: https://www.meilisearch.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Configure settings before importing
Always configure your index settings before adding documents. If you add documents first and then change settings like ranking rules or filterable attributes, Meilisearch re-indexes the entire dataset. For large imports, this doubles the work.Choose the right payload size
A single large payload is faster than many small ones. Each HTTP request creates a task, and Meilisearch processes tasks sequentially. Fewer, larger payloads mean less overhead. The default maximum payload size is 100 MB. You can adjust this with the--http-payload-size-limit configuration option.
Guidelines:
| Dataset size | Recommended batch size | Why |
|---|---|---|
| Under 100K documents | Send all at once | Fits in a single payload |
| 100K to 1M documents | 50K to 100K per batch | Balances payload size with memory usage |
| Over 1M documents | 50K to 100K per batch | Prevents memory pressure during indexing |
Use NDJSON for streaming
For large imports, NDJSON (Newline Delimited JSON) is more efficient than JSON arrays. NDJSON lets you stream documents line by line without loading the entire payload into memory:Compress payloads
Reduce network transfer time by compressing your payloads. Meilisearch supportsgzip, deflate, and br (Brotli) encoding:
Monitor import progress
Each document addition returns ataskUid. Use it to check progress:
Handle errors in batches
If a batch fails, the task status isfailed with an error description. Common errors during large imports:
| Error | Cause | Solution |
|---|---|---|
payload_too_large | Batch exceeds payload size limit | Reduce batch size or increase --http-payload-size-limit |
invalid_document_id | A document has an invalid primary key | Fix the offending documents and resend the batch |
missing_document_id | Documents are missing the primary key field | Add the primary key field or set it using the primaryKey query parameter |
Retry strategy
For automated imports, implement a simple retry pattern:- Send a batch and record the
taskUid - Poll the task status until it reaches
succeededorfailed - If
failed, log the error, fix the data if needed, and resend - If
succeeded, move to the next batch
Trim documents before importing
Remove fields that are not searchable, filterable, sortable, or displayed. Smaller documents index faster and use less disk space. If your source data has 50 fields but users only search on 5, extract those 5 fields before sending to Meilisearch.Next steps
Indexing best practices
Additional tips for efficient indexing
Monitor tasks
Track task status and progress
Design primary keys
Choose the right primary key for your documents