I'm trying to get a simple log/email alert to fire in Marklogic and am following the examples in the documentation. However I cannot seem to execute an action.
My steps:
[1] create config and insert.
[2] create action and insert.
[3] create rule and insert.
我的警报操作很简单xdmp:log("some message", "alert")
。我创建了一个log.xqy
并将其加载到 Modules dB 中。当我调用alert:invoke-matching-actions("config uri", fn:doc("/mydocs/doc.xml"), )
. 我希望警报操作写入我的日志,但它没有,我似乎无法有意义地调试它。
(:_________**set up config**___________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
let $config := alert:make-config(
"test-config-uri",
"test-config-name",
"Alerting config for test",
`<alert:options/>`
)
return alert:config-insert($config);
(:_______**set up action**___________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
let $action := alert:make-action(
"test-action-xdmp:log",
"log to ErrorLog.txt",
xdmp:modules-database(),
xdmp:modules-root(),
"/modules/alert/log.xqy",
`<alert:options>`content modified`</alert:options>`
)
return alert:action-insert("test-config-uri", $action);
(:_____**create rule**____________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
let $rule := alert:make-rule(
"test-rule-name",
"test-rule-name-desc",
0,
cts:word-query("Radiohead"),
"test-action-xdmp:log",
`<alert:options/>`
)
return alert:rule-insert("test-config-uri", $rule);
(:_______**run rule against content**____________________:)
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
alert:invoke-matching-actions("test-config-uri",
<doc>Radiohead</doc>, <options/>);
(:_______**log.xqy**_______________________________:)
xquery version "1.0-ml";
let $msg := "Content was modified. New update alert. "
let $level := "alert"
return xdmp:log($msg, $level);