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

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

用于数据的 Neptune 数据模型 OpenSearch

Amazon Neptune 使用统一的JSON文档结构将两者SPARQL和 Gremlin 数据存储在服务中。 OpenSearch 中的每个文档都 OpenSearch 对应一个实体,并存储该实体的所有相关信息。对于 Gremlin 来说,顶点和边被视为实体,因此相应的 OpenSearch 文档包含有关顶点、标签和属性的信息。因为SPARQL,主题可以被视为实体,因此相应的 OpenSearch 文档在一个文档中包含有关所有谓词-对象对的信息。

注意

Neptune-to-OpenSearch复制实现仅存储字符串数据。但是,您可以对其进行修改以存储其他数据类型。

统一的JSON文档结构如下所示。

{ "entity_id": "Vertex Id/Edge Id/Subject URI", "entity_type": [List of Labels/rdf:type object value], "document_type": "vertex/edge/rdf-resource" "predicates": { "Property name or predicate URI": [ { "value": "Property Value or Object Value", "graph": "(Only for Sparql) Named Graph Quad is present" "language": "(Only for Sparql) rdf:langString" }, { "value": "Property Value 2/ Object Value 2", } ] } }
  • entity_id – 表示文档的实体唯一 ID。

    • 因为SPARQL,这就是主题URI。

    • 对于 Gremlin,这是 Vertex_IDEdge_ID

  • entity_type – 表示顶点或边缘的一个或多个标签,或者表示主题的零个或多个 rdf:type 谓词值。

  • document_type – 用于指定当前文档表示顶点、边缘还是 rdf 资源。

  • predicates – 对于 Gremlin,存储顶点或边缘的属性和值。对于SPARQL,它存储谓词-对象对。

    属性名称采用的properties.name.value格式为 OpenSearch。要查询它,您必须以该形式命名它。

  • value — Gremlin 的属性值或的对象值。SPARQL

  • graph— 的命名图表SPARQL。

  • language— 中rdf:langString文字的语言标记。SPARQL

示例SPARQL OpenSearch 文档

数据

@prefix dt: <http://example.org/datatype#> . @prefix ex: <http://example.org/> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . ex:simone rdf:type ex:Person ex:g1 ex:michael rdf:type ex:Person ex:g1 ex:simone ex:likes "spaghetti" ex:g1 ex:simone ex:knows ex:michael ex:g2 # Not stored in ES ex:simone ex:likes "spaghetti" ex:g2 ex:simone ex:status "La vita è un sogno"@it ex:g2 ex:simone ex:age "40"^^xsd:int DG # Not stored in ES ex:simone ex:dummy "testData"^^dt:newDataType DG # Not stored in ES ex:simone ex:hates _:bnode # Not stored in ES _:bnode ex:means "coding" DG # Not stored in ES

Documents

{ "entity_id": "http://example.org/simone", "entity_type": ["http://example.org/Person"], "document_type": "rdf-resource" "predicates": { "http://example.org/likes": [ { "value": "spaghetti", "graph": "http://example.org/g1" }, { "value": "spaghetti", "graph": "http://example.org/g2" } ] "http://example.org/status": [ { "value": "La vita è un sogno", "language": "it" // Only present for rdf:langString } ] } }
{ "entity_id" : "http://example.org/michael", "entity_type" : ["http://example.org/Person"], "document_type": "rdf-resource" }

Gremlin 文档 OpenSearch 示例

数据

# Vertex 1 simone label Person <== Label simone likes "spaghetti" <== Property simone likes "rice" <== Property simone age 40 <== Property # Vertex 2 michael label Person <== Label # Edge 1 simone knows michael <== Edge e1 updated "2019-07-03" <== Edge Property e1 through "company" <== Edge Property e1 since 10 <== Edge Property

Documents

{ "entity_id": "simone", "entity_type": ["Person"], "document_type": "vertex", "predicates": { "likes": [ { "value": "spaghetti" }, { "value": "rice" } ] } }
{ "entity_id" : "michael", "entity_type" : ["Person"], "document_type": "vertex" }
{ "entity_id": "e1", "entity_type": ["knows"], "document_type": "edge" "predicates": { "through": [ { "value": "company" } ] } }