【问题标题】:cts:element-value-match does not works from scheduled taskscts:element-value-match 不适用于计划任务
【发布时间】:2016-06-16 08:36:15
【问题描述】:

我已经在计划任务 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计划任务中似乎不支持cts:element-value-match

是否需要执行其他操作才能从计划任务运行此代码?

【问题讨论】:

    标签: xquery marklogic marklogic-8


    【解决方案1】:

    似乎cts:element-value-match 在 MarkLogic 的计划任务中不起作用。我改为使用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()
    

    【讨论】:

      猜你喜欢
      • 2014-04-05
      • 1970-01-01
      • 2011-06-20
      • 2020-10-30
      • 2023-03-19
      • 2010-12-04
      • 1970-01-01
      • 2016-07-13
      • 2015-10-11
      相关资源
      最近更新 更多