Add new documents, replace existing ones, or partially update specific fields using the documents API.
Meilisearch provides three document operations: add or replace, add or update, and delete. This guide explains the difference between each operation and when to use them.
Use POST /indexes/{index_uid}/documents to add new documents or replace existing ones. If a document with the same primary key already exists, Meilisearch replaces the entire document with the new version.
Copy
curl \ -X POST 'MEILISEARCH_URL/indexes/movies/documents' \ -H 'Content-Type: application/json' \ --data-binary '[ { "id": 287947, "title": "Shazam", "poster": "https://image.tmdb.org/t/p/w1280/xnopI5Xtky18MPhK40cZAGAOVeV.jpg", "overview": "A boy is given the ability to become an adult superhero in times of need with a single magic word.", "release_date": "2019-03-23" } ]'
This operation is best when you have complete document objects and want to ensure the stored version matches exactly what you send.
When replacing a document, any fields present in the old version but missing from the new version are removed. Always include all fields you want to keep.
Use PUT /indexes/{index_uid}/documents to add new documents or partially update existing ones. If a document with the same primary key already exists, Meilisearch merges the new fields into the existing document. Fields not included in the update remain unchanged.
Batch operations are processed as a single task. Meilisearch handles large batches efficiently, so prefer sending documents in bulk rather than one at a time.
By default, both POST and PUT document operations create new documents if no document with the given primary key exists. To change this behavior, add the skipCreation=true query parameter to your request. When enabled, Meilisearch silently ignores any documents whose primary key does not match an existing document in the index.
Copy
curl \ -X POST 'MEILISEARCH_URL/indexes/movies/documents?skipCreation=true' \ -H 'Content-Type: application/json' \ --data-binary '[ { "id": 1, "title": "Updated Title" }, { "id": 99999, "title": "This document does not exist" } ]'
In this example, only document 1 is updated. Document 99999 is ignored because it does not already exist in the index.This is useful when you want to safely update fields for existing documents without accidentally creating incomplete records.
Meilisearch returns the matching documents in the results array. Note that documents are not returned in the order you queried them, and non-existent IDs are silently ignored.