cts:element-值匹配不适用于计划任务
cts:element-value-match does not works from scheduled tasks
我在计划任务XQuery中写了这段代码-
xquery version "1.0-ml";
declare namespace grp = "http://marklogic.com/xdmp/group";
declare namespace c = 'http://iddn.icis.com/ns/core';
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare variable $task-file-path := "/var/tmp/Projects/update-malformed-ids-task.xqy";
declare variable $string-starting-with-new-line-pattern := " *";
declare variable $string-starting-with-space-pattern := " *";
declare variable $LIVE-ASSET-COLLECTION := "live-collection";
declare variable $batch-size := 100;
declare function local:is-migration-needed()
{
(
fn:exists(cts:element-value-match(xs:QName("c:id"), $string-starting-with-space-pattern, (), cts:collection-query($LIVE-ASSET-COLLECTION))) or
fn:exists(cts:element-value-match(xs:QName("c:id"), $string-starting-with-new-line-pattern, (), cts:collection-query($LIVE-ASSET-COLLECTION)))
)
};
declare function local:migrate()
{
if(local:is-migration-needed())
then (: do task here :)
else ()
}
local:migrate()
但是这段代码在计划任务中不起作用。错误日志中记录的错误显示 XDMP-ARG: cts:element-value-match(xs:QName("c:id"), " *", (), cts:collection-query("live-collection")) -- arg2 is invalid
我在 QConsole 上尝试了相同的查询。它工作正常。我也尝试在同一个文件上使用 xdmp:spawn,它也工作正常。
我也尝试触发简单的 cts:element-value-match without any pattern or wildcards. Looks like cts:element-value-match 在计划任务中不受支持。
运行 计划任务中的这段代码还需要做些什么吗?
好像是cts:element-value-match doesn't work in the scheduled tasks of MarkLogic. I did the desired task using cts:element-word-query。
现在任务文件中对我有用的更新代码看起来像 -
xquery version "1.0-ml";
declare namespace grp = "http://marklogic.com/xdmp/group";
declare namespace c = 'http://iddn.icis.com/ns/core';
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare variable $task-file-path := "/var/tmp/Projects/update-malformed-ids-task.xqy";
declare variable $string-pattern-for-new-line-and-space as xs:string* := (" *"," *");
declare variable $LIVE-ASSET-COLLECTION := "live-collection";
declare function local:is-migration-needed()
{
fn:count(cts:search(
fn:collection($LIVE-ASSET-COLLECTION),
cts:element-word-query(
xs:QName("c:id"),
$string-pattern-for-new-line-and-space,
("whitespace-sensitive", "wildcarded")
)
))>0
};
declare function local:migrate()
{
if(local:is-migration-needed())
then (: do task here :)
else ()
}
local:migrate()
我在计划任务XQuery中写了这段代码-
xquery version "1.0-ml";
declare namespace grp = "http://marklogic.com/xdmp/group";
declare namespace c = 'http://iddn.icis.com/ns/core';
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare variable $task-file-path := "/var/tmp/Projects/update-malformed-ids-task.xqy";
declare variable $string-starting-with-new-line-pattern := " *";
declare variable $string-starting-with-space-pattern := " *";
declare variable $LIVE-ASSET-COLLECTION := "live-collection";
declare variable $batch-size := 100;
declare function local:is-migration-needed()
{
(
fn:exists(cts:element-value-match(xs:QName("c:id"), $string-starting-with-space-pattern, (), cts:collection-query($LIVE-ASSET-COLLECTION))) or
fn:exists(cts:element-value-match(xs:QName("c:id"), $string-starting-with-new-line-pattern, (), cts:collection-query($LIVE-ASSET-COLLECTION)))
)
};
declare function local:migrate()
{
if(local:is-migration-needed())
then (: do task here :)
else ()
}
local:migrate()
但是这段代码在计划任务中不起作用。错误日志中记录的错误显示 XDMP-ARG: cts:element-value-match(xs:QName("c:id"), " *", (), cts:collection-query("live-collection")) -- arg2 is invalid
我在 QConsole 上尝试了相同的查询。它工作正常。我也尝试在同一个文件上使用 xdmp:spawn,它也工作正常。
我也尝试触发简单的 cts:element-value-match without any pattern or wildcards. Looks like cts:element-value-match 在计划任务中不受支持。
运行 计划任务中的这段代码还需要做些什么吗?
好像是cts:element-value-match doesn't work in the scheduled tasks of MarkLogic. I did the desired task using cts:element-word-query。
现在任务文件中对我有用的更新代码看起来像 -
xquery version "1.0-ml";
declare namespace grp = "http://marklogic.com/xdmp/group";
declare namespace c = 'http://iddn.icis.com/ns/core';
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare variable $task-file-path := "/var/tmp/Projects/update-malformed-ids-task.xqy";
declare variable $string-pattern-for-new-line-and-space as xs:string* := (" *"," *");
declare variable $LIVE-ASSET-COLLECTION := "live-collection";
declare function local:is-migration-needed()
{
fn:count(cts:search(
fn:collection($LIVE-ASSET-COLLECTION),
cts:element-word-query(
xs:QName("c:id"),
$string-pattern-for-new-line-and-space,
("whitespace-sensitive", "wildcarded")
)
))>0
};
declare function local:migrate()
{
if(local:is-migration-needed())
then (: do task here :)
else ()
}
local:migrate()