使用基于查询的灵活复制时,是否可以在警报规则中使用集合查询?如果可能的话,任何人都有如何创建这样的规则的例子?警报规则是否可以包含集合查询?
我们希望将需要拉到副本系统的文档添加到集合中,而不是像单词查询那样依赖基于内容的警报。
使用基于查询的灵活复制时,是否可以在警报规则中使用集合查询?如果可能的话,任何人都有如何创建这样的规则的例子?警报规则是否可以包含集合查询?
我们希望将需要拉到副本系统的文档添加到集合中,而不是像单词查询那样依赖基于内容的警报。
为了有一个更完整的答案,这里是我所学到的......从文档中不是很明显(至少对我来说)。在使用API创建规则与使用XQuery库之间,我迷失了方向。我发现最适合我的目的不用担心使用API。此示例旨在设置基于查询的灵活复制时专门使用alert
库。
设置提醒的CPF域:
xquery version "1.0-ml";
import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
(: Run against the content database :)
let $domain-id := 12956765056276017188 (: There are functions to help get this programmatically :)
let $alerting-uri := flexrep:domain-alerting-uri($domain-id)
let $existing := alert:config-get($alerting-uri)
return
if ($existing)
then $alerting-uri
else
(alert:config-insert(
alert:make-config(
$alerting-uri,
"qbfr",
"alerting rules for QBFR",
<alert:options/>
)
), fn:concat("Alerting configuration created- ",$alerting-uri))
创建警报配置
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
(: Run against the content database :)
let $alerting-uri :=
"http://marklogic.com/xdmp/flexrep/12956765056276017188/alerting"
return
alert:action-insert($alerting-uri, alert:make-log-action())
插入为目标用户规则的日志动作
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
let $alerting-uri := "http://marklogic.com/xdmp/flexrep/12956765056276017188/alerting"
let $rule-name := "StackFlow-Collection-Alert-Rule"
let $description := "Will alert on documents in the StackFlow collection"
let $user-id := xdmp:user("my-username")
(: The cts query in the rule can use any of the cts constructs! :)
let $rule :=
alert:make-rule(
$rule-name,
$description,
$user-id,
cts:collection-query("StackFlow"),
"log",
<alert:options />
)
return
alert:rule-insert($alerting-uri, $rule)
我在文档部分将这个主题放在一起,并会尝试发布一些更多的例子等。现在,随着这个项目一起移动。希望这可以帮助那些在路上的人。
是的,这应该很好。我没有一个方便的例子。
谢谢,我会继续为此制定规则... –