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.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.
Add or replace documents
UsePOST /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.
Example
Suppose your index contains this document:genres field is gone because it was not included in the replacement.
Add or update documents
UsePUT /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. Partial updates apply only to top-level fields: updating an object field replaces the entire object, removing any omitted subfields.
Example
Starting with the same document:overview field is preserved because the update only touched title and genres.
Delete documents
UseDELETE /indexes/{index_uid}/documents/{document_id} to remove a single document by its primary key:
- Delete by batch: send a
POST /indexes/{index_uid}/documents/delete-batchrequest with an array of document IDs - Delete by filter: send a
POST /indexes/{index_uid}/documents/deleterequest with a filter expression to remove all matching documents
Choosing the right operation
| Operation | HTTP method | Behavior | Use when |
|---|---|---|---|
| Add or replace | POST | Replaces entire document | You have complete documents and want exact control |
| Add or update | PUT | Merges fields into existing document | You only need to change specific fields |
| Delete | DELETE | Removes document entirely | You need to remove documents from the index |
Batch operations
All three operations support sending multiple documents in a single request. Send an array of documents in the request body:Update without creating new documents
By default, bothPOST 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.
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.
Retrieve multiple documents by ID
UsePOST /indexes/{index_uid}/documents/fetch to retrieve specific documents by their primary keys:
results array. Note that documents are not returned in the order you queried them, and non-existent IDs are silently ignored.
Filter the documents you fetch
You can pass afilter expression to POST /indexes/{index_uid}/documents/fetch to retrieve only documents that match a condition:
Any attribute you reference in a document
filter must first be declared in the index’s filterableAttributes setting. This rule is the same as for search filters and is specific to the documents endpoint when filtering the documents you retrieve or delete.Supported content types
By default, Meilisearch expects a JSON array in the request body and theContent-Type: application/json header. The documents endpoint also accepts NDJSON (application/x-ndjson) and CSV (text/csv) payloads when you set the matching header.
csvDelimiter query parameter (for example, ?csvDelimiter=;).
Next steps
Documents API reference
Full API reference for document operations
Indexing overview
Learn more about how indexing works in Meilisearch
Monitor tasks
Track the status of your document operations