如何避免与附件中的索引字段同名的字段出现范围索引错误?

How can I avoid range index error for fields with the same name as the index field in attached documents?

对于我的项目,我必须从各种来源获取和整理数据。 我通过使用流程的数据中心框架来做到这一点。 我所有的不同来源都有一个名为“日期”的字段。然而,它们都有不同的形式,例如yyyy-mm-dd,yyyymmdd,dd.mm.yyyy.

我通过映射到一种通用格式 yyyy-mm-dd 来进行管理。 映射后该字段仍称为“日期”。

因为我希望能够进行范围搜索,所以我需要一个关于我的“约会”的索引。然而,这会导致在摄取数据时出错,因为摄取数据的“日期”字段尚未映射到正确的格式。

我的解决方案是不拒绝 STAGING 数据库的无效值。但是,由于旧文档附加在映射后移至 FINAL 数据库的精选新文档的信封中,因此我收到附加文档的范围索引错误。

我想拒绝 FINAL 数据库中的无效值,但我还想将原始文档作为附件保留在最终文件中。

到目前为止,我能看到的唯一解决方案是将 FINAL 数据库中的“日期”元素命名为类似 iDate 的名称,以避免冲突。

这对我来说似乎不是一个干净的解决方案。你有更好的建议吗?

我正在使用:

如果您使用路径范围索引,则可以将其限制为 top-level 实例中而不是附件中的那些 date 元素。

有关使用路径范围索引的详细信息,请参阅 https://docs.marklogic.com/guide/admin/range_index#id_40666

配置路径字段以仅针对规范化日期,排除信封中的那些原始日期元素。

https://docs.marklogic.com/guide/admin/fields#id_23934

In a path field, the included and excluded elements are constrained to the sub-tree identified by the path. For example, if the path for the field is /A/B/C, only elements in node C, such as A/B/C/D, A/B/C/D/E and /A/B/C/Z, are included or excluded from the field.

A path field may include one or more paths. Multiple paths are treated as the union of the paths. Consequently, each of them will identify a root of a field-instance in a given document.

给标准化的“日期”元素一个不同的名称似乎是一种非常干净的方法。理想情况下,所有同名元素(由命名空间限定)具有相同的定义和相同的语义。当您的来源给您的“日期”实际上不是 xs:dates 时,那么提供的“日期”节点实际上只是一个(稍微受限的)字符串。当然,它以某种 easily-translated 的方式描述日期,但它实际上不是日期字段,因此不能作为日期字段进行索引。当您标准化源数据时,您正在创建一个新的数据点,它实际上是一个日期,并且它 'should' 采用新的身份:您建议的新本地名称,或者您的“日期” “规范化数据”命名空间。

<envelope>
  <original>
    <date>09-09-2020</date>
    <!-- etc -->
  </original>
  <normalized>
    <my:date>2020-09-09</my:date>
  </normalized>
</envelope>