验证数据映射 - Amazon Neptune
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

验证数据映射

使用以下过程将数据从 Neptune 复制到 OpenSearch:

  • 如果 OpenSearch 中已经存在相关字段的映射:

    • 如果可以使用数据验证规则将数据安全地转换为现有映射,则将该字段存储在 OpenSearch 中。

    • 否则,请删除相应的流更新记录。

  • 如果相关字段没有现有的映射,请在 Neptune 中查找与该字段的数据类型对应的 OpenSearch 数据类型。

    • 如果可以使用数据验证规则将字段数据安全地转换为 OpenSearch 数据类型,则将新的映射和字段数据存储在 OpenSearch 中。

    • 否则,请删除相应的流更新记录。

值是根据等效的 OpenSearch 类型或现有 OpenSearch 映射而不是根据 Neptune 类型进行验证的。例如,对于 "123"^^xsd:int 中的值 "123" 的验证是针对 long 类型而不是 int 类型进行的。

尽管 Neptune 尝试将所有数据复制到 OpenSearch,但在某些情况下,OpenSearch 中的数据类型与 Neptune 中的数据类型完全不同,在这种情况下,会跳过记录,而不是在 OpenSearch 中编制索引。

例如,在 Neptune 中,一个属性可以有多个不同类型的值,而在 OpenSearch 中,一个字段在索引中必须具有相同的类型。

通过启用调试日志,您可以查看在从 Neptune 导出到 OpenSearch 期间删除了哪些记录。调试日志条目的示例为:

Dropping Record : Data type not a valid Gremlin type <Record>

数据类型按如下所示进行验证:

  • text – Neptune 中的所有值都可以安全地映射到 OpenSearch 中的文本。

  • long – 当 OpenSearch 映射类型为 long 时,Neptune 数据类型的以下规则适用(在以下示例中,假设 "testLong" 具有 long 映射类型):

    • boolean – 无效,无法转换,并且会删除相应的流更新记录。

      无效的 Gremlin 示例为:

      "testLong" : true. "testLong" : false.

      无效的 SPARQL 示例为:

      ":testLong" : "true"^^xsd:boolean ":testLong" : "false"^^xsd:boolean
    • datetime – 无效,无法转换,并且会删除相应的流更新记录。

      无效的 Gremlin 示例为:

      ":testLong" : datetime('2018-11-04T00:00:00').

      无效的 SPARQL 示例为:

      ":testLong" : "2016-01-01"^^xsd:date
    • floatdoubledecimal – 如果 Neptune 中的值是一个可以容纳 64 位的整数,则它是有效的,并且以 long 形式存储在 OpenSearch 中;但如果它有小数部分,或者是 NaNINF,或者大于 9,223,372,036,854,775,807 或小于 -9,223,372,036,854,775,808,则它是无效的且相应的流更新记录被删除。

      有效的 Gremlin 示例为:

      "testLong" : 145.0. ":testLong" : 123 ":testLong" : -9223372036854775807

      有效的 SPARQL 示例为:

      ":testLong" : "145.0"^^xsd:float ":testLong" : 145.0 ":testLong" : "145.0"^^xsd:double ":testLong" : "145.0"^^xsd:decimal ":testLong" : "-9223372036854775807"

      无效的 Gremlin 示例为:

      "testLong" : 123.45 ":testLong" : 9223372036854775900

      无效的 SPARQL 示例为:

      ":testLong" : 123.45 ":testLong" : 9223372036854775900 ":testLong" : "123.45"^^xsd:float ":testLong" : "123.45"^^xsd:double ":testLong" : "123.45"^^xsd:decimal
    • string – 如果 Neptune 中的值是可以包含在 64 位整数中的整数的字符串表示形式,则该值是有效的,并在 OpenSearch 中转换为 long。任何其它字符串值对于 Elasticseearch long 映射都无效,相应的数据流更新记录将被删除。

      有效的 Gremlin 示例为:

      "testLong" : "123". ":testLong" : "145.0" ":testLong" : "-9223372036854775807"

      有效的 SPARQL 示例为:

      ":testLong" : "145.0"^^xsd:string ":testLong" : "-9223372036854775807"^^xsd:string

      无效的 Gremlin 示例为:

      "testLong" : "123.45" ":testLong" : "9223372036854775900" ":testLong" : "abc"

      无效的 SPARQL 示例为:

      ":testLong" : "123.45"^^xsd:string ":testLong" : "abc" ":testLong" : "9223372036854775900"^^xsd:string
  • double – 如果 OpenSearch 映射类型为 double,则适用以下规则(此处,假定“testDouble”字段在 OpenSearch 中具有 double 映射):

    • boolean – 无效,无法转换,并且会删除相应的流更新记录。

      无效的 Gremlin 示例为:

      "testDouble" : true. "testDouble" : false.

      无效的 SPARQL 示例为:

      ":testDouble" : "true"^^xsd:boolean ":testDouble" : "false"^^xsd:boolean
    • datetime – 无效,无法转换,并且会删除相应的流更新记录。

      无效的 Gremlin 示例为:

      ":testDouble" : datetime('2018-11-04T00:00:00').

      无效的 SPARQL 示例为:

      ":testDouble" : "2016-01-01"^^xsd:date
    • 浮点 NaNINF – 如果 SPARQL 中的值是浮点 NaNINF,则该值无效,并且会删除相应的流更新记录。

      无效的 SPARQL 示例为:

      " :testDouble" : "NaN"^^xsd:float ":testDouble" : "NaN"^^double ":testDouble" : "INF"^^double ":testDouble" : "-INF"^^double
    • 数字或数字字符串 – 如果 Neptune 中的值是任何其它数字或数字的数字字符串表示(可以安全地表示为 double),那么它是有效的,并在 OpenSearch 中转换为 double。任何其它字符串值对于 OpenSearch double 映射都无效,并将删除相应的数据流更新记录。

      有效的 Gremlin 示例为:

      "testDouble" : 123 ":testDouble" : "123" ":testDouble" : 145.67 ":testDouble" : "145.67"

      有效的 SPARQL 示例为:

      ":testDouble" : 123.45 ":testDouble" : 145.0 ":testDouble" : "123.45"^^xsd:float ":testDouble" : "123.45"^^xsd:double ":testDouble" : "123.45"^^xsd:decimal ":testDouble" : "123.45"^^xsd:string

      无效的 Gremlin 示例为:

      ":testDouble" : "abc"

      无效的 SPARQL 示例为:

      ":testDouble" : "abc"
  • date – 如果 OpenSearch 映射类型为 date,则 Neptune datedateTime 值有效,任何可以成功解析为 dateTime 格式的字符串值也是有效的。

    Gremlin 或 SPARQL 中的有效示例为:

    Date(2016-01-01) "2016-01-01" " 2003-09-25T10:49:41" "2003-09-25T10:49" "2003-09-25T10" "20030925T104941-0300" "20030925T104941" "2003-Sep-25" " Sep-25-2003" "2003.Sep.25" "2003/09/25" "2003 Sep 25" " Wed, July 10, '96" "Tuesday, April 12, 1952 AD 3:30:42pm PST" "123" "-123" "0" "-0" "123.00" "-123.00"

    无效的示例为:

    123.45 True "abc"