篩選匯出內容的範例 - Amazon Neptune

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

篩選匯出內容的範例

以下範例說明篩選所匯出資料的方式。

篩選屬性圖資料的匯出

使用 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 之後建立的節點和邊緣 (也就是說,具有其值大於 2021-10-10 的 created 屬性):

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

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