MarkLogic的 temporal:document-insert操作失败
代码:
let $root :=
<tempdoc>
<content>v1-content here</content>
</tempdoc>
return
temporal:document-insert("entity:person", "koolorder.xml", $root)
失败并出现错误
[1.0-ml] XDMP-NOMATCH: xdmp:eval("xquery version "1.0-ml"; import module namesp...", (), <options xmlns="xdmp:eval"><database>7821828681277378166</database>...</options>) -- No matches for cts:field-reference("systemStart",("type=dateTime")) in <tempdoc><content>v1-content here</content></tempdoc>
下面是我如何创建我的时态集合
xquery version "1.0-ml";
import module namespace temporal = "http://marklogic.com/xdmp/temporal"
at "/MarkLogic/temporal.xqy";
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
let $config := admin:get-configuration()
return
(
admin:database-add-field($config, xdmp:database(), admin:database-field("systemStart", fn:false() )),
admin:database-add-field($config, xdmp:database(), admin:database-field("systemEnd", fn:false() )),
admin:save-configuration($config)
)
;
xquery version "1.0-ml";
import module namespace temporal = "http://marklogic.com/xdmp/temporal"
at "/MarkLogic/temporal.xqy";
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
let $config := admin:get-configuration()
let $dbid := xdmp:database()
let $systemStart := admin:database-range-field-index("dateTime", "", "systemStart", false() )
let $systemEnd := admin:database-range-field-index("dateTime", "", "systemEnd", false() )
let $config := admin:database-add-range-field-index($config, $dbid, $systemStart)
let $config := admin:database-add-range-field-index($config, $dbid, $systemEnd)
let $_ :=admin:save-configuration($config)
return ()
;
xquery version "1.0-ml";
import module namespace temporal = "http://marklogic.com/xdmp/temporal"
at "/MarkLogic/temporal.xqy";
let $systemResult := temporal:axis-create("systemAxes",cts:field-reference("systemStart"),cts:field-reference("systemEnd"))
return()
;
xquery version "1.0-ml";
import module namespace temporal = "http://marklogic.com/xdmp/temporal" at "/MarkLogic/temporal.xqy";
let $collection := "entity:person"
let $collectionResult := temporal:collection-create("entity:person", "systemAxes")
return ($collectionResult)
;
xquery version "1.0-ml";
import module namespace temporal = "http://marklogic.com/xdmp/temporal" at "/MarkLogic/temporal.xqy";
let $root :=
<tempdoc>
<content>v1-content here</content>
</tempdoc>
return
temporal:document-insert("entity:person", "koolorder.xml", $root)
一切都正常,没有错误,我也尝试使用双时态集合,但仍然出现同样的错误。我读到系统日期的元数据是由MarkLogic创建的,我试着把它们放在选项中,但仍然出现同样的错误。 我尝试从ml-gradle创建集合和索引等,但总是出现这个错误
我使用的是ML 11.3.4版本
解决方案
问题在于字段不是元数据。
要创建它们,请使用 admin:database-metadata-field():
let $config := admin:database-add-field($config, xdmp:database(),
admin:database-metadata-field("systemStart"))
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。