Ravi
Ravi

Reputation: 1179

Privileges need to disable triggers database in Marklogic

I have around 500k documents in my marklogic database.. And I have CPF enabled. If I want to do a mass delete or do a mass update (don;t want the CPF triggered for this update) on the documents..

I call my Marklogic administrator, who has access to the administrator page (:8001), and ask him to change the triggers database to none, and then I do my stuff and then again I ask my administrator to change it back the original triggers database.. The reason I disable the triggers database is if I don't, it takes a long time to process my request

I was thinking there must be a better way to do this :) than calling my ML administrator for every-time I do this. Following are some of the questions I have, hopefully someone can assist me with this

  1. What is the privilege needed if I want to Programmatic (xquery) disable the triggers database and re-enable it. It will be helpful if someone can provide exact xquery calls for disabling and enabling the triggers database ?
  2. Is there a better way to do this ? than doing the way I am doing ?
  3. Is there anyway I can tell CPF not to run for a given update on the document, other than me assigning some custom flag and in my CPF I check for this flag and do nothing if the flag is enabled ?

Thanks

Upvotes: 0

Views: 90

Answers (2)

(3) Run you triggers with the domain scoped to a collection rather than URI. Then to remove a document from the triggers, you should be able to remove the collection (even in bulk). Then those documents are no longer under the domain of CPF. The logic is that when the commit is done that removes the collection, it is already out of the domain in question.

See Here: https://docs.marklogic.com/guide/cpf.pdf
Page 29
Section 5.3.2
2/3 way down the page:

Note: Because domains with a collection scope can only continue the next phase of processing if the new or modified document is part of that collection, you can use collections as a way of moving documents in and out of different sets of processing.

There's the logic I mean - move the document out of the processing scope by removing the collection - then delete.

Upvotes: 1

Dave Cassel
Dave Cassel

Reputation: 8422

As I read your question, I was thinking about #3 as the solution: modify your CPF pipelines to determine whether the document needs to be processed. Each pipeline state change has a condition module associated with it, which you can customize to watch for whatever condition you want to avoid.

The problem I see with disabling triggers is that some other part of the application may cause an update to a document, in which case CPF will miss that update.

All that said, if you want to proceed with disabling CPF, one way to do it would be to set the scope of your domains to something that won't see anything (dom:domain-scope("document", "NO-SUCH-DOC", ())). You'll need to programmatically keep track of the original scopes so that you can restore them.

Upvotes: 0

Related Questions