Skip to content

Delete documents

Delete documents identified by an array of their IDs.


POST /indexes/{index_name}/documents/delete-batch

Path parameters

Name Type Description
index_name String name of the index

Body

An array of document IDs, to be deleted.

[ "article_591", "article_602" ]

Example

cURL -XPOST  http://localhost:8882/indexes/my-first-index/documents/delete-batch -H 'Content-type:application/json' -d '[
"article_591", "article_602"
]'
mq.index("my-first-index").delete_documents(ids=["article_591", "article_602"])

For Marqo Cloud, you will need to access the endpoint of your index and replace your_endpoint with this. To do this, visit Find Your Endpoint. You will also need your API Key. To obtain this key visit Find Your API Key.

cURL -XPOST  your_endpoint/indexes/my-first-index/documents/delete-batch \
-H 'x-api-key: XXXXXXXXXXXXXXX' \
-H 'Content-type:application/json' -d '[
"article_591", "article_602"
]'
mq.index("my-first-index").delete_documents(ids=["article_591", "article_602"])

Response 200 OK

{
    "details": {"deletedDocuments": 2, "receivedDocumentIds": 2},
    "duration": "PT0.048207S",
    "finishedAt": "2024-01-16T23:51:25.521119Z",
    "index_name": "my-first-index",
    "items": [
        {"_id": "article_591", "result": "deleted", "status": 200},
        {"_id": "article_602", "result": "deleted", "status": 200},
    ],
    "startedAt": "2024-01-16T23:51:25.472912Z",
    "status": "succeeded",
    "type": "documentDeletion",
}

In this example, one of the articles didn't exist in the index. Therefore, only one document was deleted.