How to automate a calculation in MarkLogic 8 after a document is loaded or updated?

92 Views Asked by At

Is there any way in MarkLogic 8 to create pipe that runs when an XML document is created or updated in order to do some statistical calculation such as count number of nodes in which certain words appear and store results in a file?

2

There are 2 best solutions below

3
On

You could enable triggers by adding a triggers database to your documents database, and installing triggers. The trigger can respond to create or update in pre-, and post-commit behavior, and run arbitrary code. You could for instance get the document, do the counts you are after, and insert stats inside the document properties. You could then run aggregates to get sums over the total database afterwards..

HTH!

3
On

You can also look at the Content Processing Framework (CPF), which I believe runs on triggers. It's intended to solve exactly this kind of problem.