Prepare your documents
Meilisearch accepts documents in three formats: JSON, NDJSON, and CSV. Each document must contain a field that serves as a unique primary key. Here is a small sample dataset of movies in JSON format:id is the primary key. Meilisearch automatically infers the primary key if a field is named id. If your primary key has a different name, you must specify it when adding documents.
Send documents to an index
Use thePOST /indexes/{index_uid}/documents endpoint to add documents. If the index does not exist yet, Meilisearch creates it automatically.
For a large dataset stored in a file:
Check the task status
All indexing operations in Meilisearch are asynchronous. Use thetaskUid from the response to check whether your documents have been indexed:
succeeded:
failed, the response includes an error object explaining what went wrong.
Verify documents are searchable
Once the task succeeds, your documents are ready to search. Test with a simple query:Accepted document formats
| Format | Content-Type header | Notes |
|---|---|---|
| JSON | application/json | Array of objects. Most common format. |
| NDJSON | application/x-ndjson | One JSON object per line. Useful for streaming large datasets. |
| CSV | text/csv | First row must be column headers. All values are strings by default. |
Next steps
Monitor tasks
Track and manage asynchronous indexing operations
Add and update documents
Learn the difference between replacing and partially updating documents
Indexing overview
Understand how indexing works in Meilisearch
Best practices
Optimize your indexing performance