將自定義 ID 注入 Neptune 小鬼或查詢 SPARQL - Amazon Neptune

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

將自定義 ID 注入 Neptune 小鬼或查詢 SPARQL

根據預設,Neptune 會將唯一 queryId 值指派給每個查詢。您可以使用此 ID 來取得執行中查詢的相關資訊 (請參閱小鬼查詢狀態 APISPARQL查詢狀態 API),或取消它 (請參閱Gremlin 查詢取消SPARQL查詢取消)。

Neptune 也可以讓您指定自己的 Grimlin 或SPARQL查詢queryId值,無論是在HTTP標頭,或使用SPARQL查詢提示queryId查詢。指派您自己的 queryID 可讓您輕鬆追蹤查詢,以取得狀態或取消該查詢。

注意

版本 1.0.1.0.200463.0 (2019 年 10 月 15 日) 開始就可以使用這項功能。

使用標HTTP題注入自訂queryId

對於 Gremlin 和SPARQL,HTTP標頭可以用來將自己的queryId值注入到查詢中。

Gremlin 範例

curl -XPOST https://your-neptune-endpoint:port \ -d "{\"gremlin\": \ \"g.V().limit(1).count()\" , \ \"queryId\":\"4d5c4fae-aa30-41cf-9e1f-91e6b7dd6f47\" }"

SPARQL範例

curl https://your-neptune-endpoint:port/sparql \ -d "query=SELECT * WHERE { ?s ?p ?o } " \ --data-urlencode \ "queryId=4d5c4fae-aa30-41cf-9e1f-91e6b7dd6f47"

使用SPARQL查詢提示注入自訂queryId

以下是如何使用SPARQLqueryId查詢提示將自訂queryId值插入SPARQL查詢的範例:

curl https://your-neptune-endpoint:port/sparql \ -d "query=PREFIX hint: <http://aws.amazon.com/neptune/vocab/v01/QueryHints#> \ SELECT * WHERE { hint:Query hint:queryId \"4d5c4fae-aa30-41cf-9e1f-91e6b7dd6f47\" \ {?s ?p ?o}}"

使用 queryId 值檢查查詢狀態

Gremlin 範例

curl https://your-neptune-endpoint:port/gremlin/status \ -d "queryId=4d5c4fae-aa30-41cf-9e1f-91e6b7dd6f47"

SPARQL範例

curl https://your-neptune-endpoint:port/sparql/status \ -d "queryId=4d5c4fae-aa30-41cf-9e1f-91e6b7dd6f47"