Skip to main content
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.

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.
Wait for this task to complete before sending documents.

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: The ideal batch size depends on your document size. If each document is small (under 1 KB), you can send more per batch. If documents are large (10+ KB each with long text fields), use smaller batches.

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:
An NDJSON file has one JSON object per line:
Meilisearch also supports CSV for tabular data:

Compress payloads

Reduce network transfer time by compressing your payloads. Meilisearch supports gzip, deflate, and br (Brotli) encoding:
Compression is especially effective for text-heavy documents. A typical JSON payload compresses to 10-20% of its original size.

Monitor import progress

Each document addition returns a taskUid. Use it to check progress:
The task response includes timing information:
For batch imports, filter tasks by index to see all pending work:

Handle errors in batches

If a batch fails, the task status is failed with an error description. Common errors during large imports: When a batch fails, only that batch is affected. Other batches continue processing normally.

Retry strategy

For automated imports, implement a simple retry pattern:
  1. Send a batch and record the taskUid
  2. Poll the task status until it reaches succeeded or failed
  3. If failed, log the error, fix the data if needed, and resend
  4. If succeeded, move to the next batch
Do not resend a batch before its task has completed. Sending duplicate documents is safe (Meilisearch deduplicates by primary key), but it creates unnecessary work in the task queue.

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