4

I'm using Marklogic 8.0.6 and I'm wondering if we can delete in bulk method. For example, I want to delete 150 000 documents that I can identify with a list of URI or with common properties (fields COUNTRY=US and COLOR=BLUE).

Is there a way to use a ML native function (in node.js) to perform these DELETE in bulk mode (for both cases : list of URIs and common properties) ? For latencies reasons, it's obvious that 150 000 API calls are not performant.

Thanks, Romain.

romain-nio
  • 1,183
  • 9
  • 25

2 Answers2

3

There are a couple options.

  • if there is a collection or directory that you can delete, you can do that
  • if you know the URIs of the documents to delete, you can pass a list of them to the delete command; if there are too many for one transaction, you can do a multi-statement transaction to get them all.
  • you can also create a service extension, send over the query parameters, and then your extension can run a query and delete the results

Updating with additional detail for deleting multiple documents. documents.remove takes either a string or an array of strings for the uris parameter:

db.documents.remove(
  ['/doc1.json', '/doc2.json']
)
Dave Cassel
  • 8,352
  • 20
  • 38
  • "if you know the URIs of the documents to delete, you can pass a list of them to the delete command; " => how you can send a list ? – romain-nio Nov 29 '16 at 19:41
0

You can use the read/write attributes of forests, or direct-forest-placement options to document-insert to arrange for documents to 'migrate' to a new forest (or out of a forest), then simply detach the forest.

DALDEI
  • 3,722
  • 13
  • 9