我在上创建了元素范围索引
modificationDateTime
元素。
我们的XML是这样的:
<data>
<id>456789</id>
<modificationDateTime>2018-10-15T15:16:37.047Z</modificationDateTime>
<otherElementsFollow> ... </otherElementsFollow>
</data>
我正在使用以下查询获取
15th Oct 2018
甚至是15到16的范围:
cts:search(/, (
cts:and-query((
cts:directory-query("/my-directory/", "1")
, cts:element-range-query(xs:QName("modificationDateTime"), ">=", xs:dateTime("2018-10-15T00:00:00.000+05:30"))
, cts:element-range-query(xs:QName("modificationDateTime"), "<=", xs:dateTime("2018-10-15T23:59:59.000+05:30"))
))
)
我在运行查询时得到以下错误:
[1.0-ml] XDMP-CAST: (err:FORG0001) cts:search(fn:collection(), cts:and-query((cts:directory-query("/my-directory/", "1"), cts:element-range-query(xs:QName("modificationDateTime"), ">=", xs:dateTime("2018-10-15T00:00:00+05:30"), (), 1), cts:element-range-query(xs:QName("modificationDateTime"), "<=", xs:dateTime("2018-10-15T23:59:59+05:30"), (), 1)), ())) -- Invalid cast: "" cast as xs:dateTime
经过分析,我发现有些XML
<modificationDateTime>
元素值为空,如:
<data>
<id>1234567</id>
<modificationDateTime></modificationDateTime>
<otherElementsFollow> ... </otherElementsFollow>
</data>
所以这就是导致这个问题的原因,我们不能删除这个元素,也不能有一些值,因为空是一个有效值。
关于如何在空元素上使用范围索引进行搜索的任何帮助,理想情况下都应该考虑这些记录,但是当我将空值更新为有效的日期时间值时,相同的查询会正常工作。