【问题标题】:Find the documents which have element in proper "dateTime" format查找具有正确“dateTime”格式元素的文档
【发布时间】:2018-08-16 08:43:22
【问题描述】:

我正在 marklogic-9 中尝试以下查询:

cts:element-value-match(xs:QName("cd:modificationDate"), "[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].000Z", ("type=dateTime","timezone=TZ"))

实现这一点,但这给了我以下错误:

[1.0-ml] XDMP-ARG: cts:element-value-match(xs:QName("cd:modificationDate"), "[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].000Z", ("type=dateTime", "timezone=TZ")) -- arg2 is invalid

我要做的是找出所有符合dateTime 特定模式的文档。我们在这个元素上有一个日期范围索引 - modificationDate

我们如何最好地使用 marklogic 和 xquery api 来做到这一点。

【问题讨论】:

    标签: xquery marklogic


    【解决方案1】:

    cts:element-value-match 实际上只对字符串范围索引有用,即使在那里它也只需要简单的通配符(*?),而不是一般的正则表达式或日期格式。

    如果您的范围索引是 dateTime 范围索引,那么每个值都必须符合正确的xs:dateTime 格式,因此该查询不会告诉您任何信息。

    这将为您提供在该元素中具有有效日期时间的所有 URI 的列表:

    cts:uris("", (),
        cts:element-range-query(xs:QName("modificationDate"), ">", xs:dateTime("0001-01-01T00:00:00"))
    )
    

    【讨论】:

    • 不完全是我想要的,但它解决了我面临的问题:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-11
    相关资源
    最近更新 更多