本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
筛选导出内容的示例
以下示例说明了筛选导出的数据的方法。
筛选属性图数据的导出
使用 scope 仅导出边缘的示例
{ "command": "export-pg", "params": { "endpoint": "(your Neptune endpoint DNS name)", "scope": "edges" }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }
使用 nodeLabels 和 edgeLabels 仅导出带有特定标签的节点和边缘的示例
以下示例中的 nodeLabels 参数指定只应导出带有 Person 标签或 Post 标签的节点。edgeLabels 参数指定只应导出带有 likes 标签的边缘:
{ "command": "export-pg", "params": { "endpoint": "(your Neptune endpoint DNS name)", "nodeLabels": ["Person", "Post"], "edgeLabels": ["likes"] }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }
使用 filter 仅导出指定节点、边缘和属性的示例
此示例中的 filter 对象导出带有 type、code 和 desc 属性的 country 节点,还导出带有 dist 属性的 route 边缘。
{ "command": "export-pg", "params": { "endpoint": "(your Neptune endpoint DNS name)", "filter": { "nodes": [ { "label": "country", "properties": [ "type", "code", "desc" ] } ], "edges": [ { "label": "route", "properties": [ "dist" ] } ] } }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }
使用 gremlinFilter 的示例。
此示例使用 gremlinFilter 以仅导出 2021-10-10 之后创建的节点和边缘(即其 created 属性值大于 2021-10-10):
{ "command": "export-pg", "params": { "endpoint": "(your Neptune endpoint DNS name)", "gremlinFilter" : "has(\"created\", gt(datetime(\"2021-10-10\")))" }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }
使用 gremlinNodeFilter 的示例。
此示例使用 gremlinNodeFilter 以仅导出已删除的节点(其布尔 deleted 属性的值为 true 的节点):
{ "command": "export-pg", "params": { "endpoint": "(your Neptune endpoint DNS name)", "gremlinNodeFilter" : "has(\"deleted\", true)" }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }
使用 gremlinEdgeFilter 的示例。
此示例使用 gremlinEdgeFilter 以仅导出具有 strength 数值属性且属性值为 5 的边缘:
{ "command": "export-pg", "params": { "endpoint": "(your Neptune endpoint DNS name)", "gremlinEdgeFilter" : "has(\"strength\", 5)" }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }
组合 filter、gremlinNodeFilter、nodeLabels、edgeLabels 和 scope
此示例中的 filter 对象导出:
带有其
type、code和desc属性的country节点带有其
code、icao和runways属性的airport节点带有其
dist属性的route边缘
gremlinNodeFilter 参数筛选节点,以便仅导出具有 code 属性且属性值以 A 开头的节点。
nodeLabels 和 edgeLabels 参数进一步限制了输出,因此只输出 airport 节点和 route 边缘。
最后,scope 参数消除了输出中的边缘,从而在输出中只留下指定的 airport 节点。
{ "command": "export-pg", "params": { "endpoint": "(your Neptune endpoint DNS name)", "filter": { "nodes": [ { "label": "airport", "properties": [ "code", "icao", "runways" ] }, { "label": "country", "properties": [ "type", "code", "desc" ] } ], "edges": [ { "label": "route", "properties": [ "dist" ] } ] }, "gremlinNodeFilter": "has(\"code\", startingWith(\"A\"))", "nodeLabels": [ "airport" ], "edgeLabels": [ "route" ], "scope": "nodes" }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }
筛选 RDF 数据的导出
使用 rdfExportScope 和 sparql 导出特定边缘
此示例导出谓词为 < http://kelvinlawrence 的三元组。 net/air-routes/objectProperty/route> 且其对象不是字面意思:
{ "command": "export-rdf", "params": { "endpoint": "(your Neptune endpoint DNS name)", "rdfExportScope": "query", "sparql": "CONSTRUCT { ?s <http://kelvinlawrence.net/air-routes/objectProperty/route> ?o } WHERE { ?s ?p ?o . FILTER(!isLiteral(?o)) }" }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }
namedGraph用于导出单个命名的图表
此示例导出属于命名图的三元组 < http://aws.amazon。 com/neptune/vocab/v01/DefaultNamedGraph>:
{ "command": "export-rdf", "params": { "endpoint": "(your Neptune endpoint DNS name)", "rdfExportScope": "graph", "namedGraph": "http://aws.amazon.com/neptune/vocab/v01/DefaultNamedGraph" }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }