let uris=cts.uris( null,null,cts.jsonPropertyRangeQuery(
"dateStart"
,
'>=',
xs.date('2000-01-01'),[],0.5
)).toArray()
以上结果
[javascript] XDMP-ELEMRIDXNOTFOUND:
cts.uris(null, null, cts.jsonPropertyRangeQuery("dateStart", ">=", xs.date("2000-01-01"), [], 0.5))
-- No date element range index for dateStart
数据确实存在于某些文档中,如下所示
"times": [
{
"type": "openingHours",
"value": []
},
{
"type": "eventTimes",
"value": {
"dateStart": "2020-02-01",
"dateEnd": "2020-02-01",
"timeStart": "07:00",
"timeEnd": "20:00"
}
}
],
我尝试了完全限定的路径
/ instance / times [contains(type,'eventTimes')] / value / dateStart
答案 0 :(得分:0)
函数jsonPropertyRangeQuery in the MarkLogic documentation在文档中并不明显,但是要使其正常工作,需要在此工作之前构建元素范围索引,
但是设置相对简单。只需按照Defining Element Range Index documentation中的步骤操作即可。
有一个陷阱。由于我们使用的是Data-Hub,因此每次重新部署都会覆盖设置的索引,而索引将丢失。
发现在Data-hub / src / main / mlconfg / databases / final-database.josn中,JSON有一个json文件range-element-index:我只是为要设置的每个索引添加了详细信息,这意味着它们是自动基于./gradlew mlredeploy构建。
{
"database-name": "%%mlFinalDbName%%",
"range-element-index": [
{
"scalar-type": "date",
"namespace-uri": "",
"localname": "dateStart",
"collation": "",
"range-value-positions": true,
"invalid-values": "reject"
},
{
"scalar-type": "date",
"namespace-uri": "",
"localname": "dateEnd",
"collation": "",
"range-value-positions": true,
"invalid-values": "reject"
}
],
"schema-database": "%%mlFinalSchemasDbName%%",
"triggers-database": "%%mlFinalTriggersDbName%%",
"triple-index": true,
"collection-lexicon": true,
"uri-lexicon": true
}