过滤导出内容的示例 - Amazon Neptune
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

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

过滤导出内容的示例

以下示例说明了过滤导出数据的方法。

筛选属性图数据的导出

使用的示例scope只导出边

{ "command": "export-pg", "params": { "endpoint": "(your Neptune endpoint DNS name)", "scope": "edges" }, "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export" }

使用的示例nodeLabelsedgeLabels仅导出具有特定标签的节点和边

这些区域有: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本示例中的对象导出country带有他们的节点typecodedesc房地产,还有route他们的边缘dist财产。

{ "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" }

组合filtergremlinNodeFilternodeLabelsedgeLabelsscope

这些区域有:filter本示例中的对象导出:

  • country带有他们的节点typecodedesc属性

  • airport带有他们的节点codeicaorunways属性

  • route他们的边缘dist属性

这些区域有:gremlinNodeFilter参数过滤节点,以便只有具有code其值以 A 开头的属性将被导出。

这些区域有:nodeLabelsedgeLabels参数进一步限制输出,以便只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 数据的导出

使用rdfExportScopesparql以导出特定边

此示例导出了谓词为 < 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" }