将自定义 ID 注入到 Neptune Gremlin 或 SPARQL 查询中 - Amazon Neptune
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

将自定义 ID 注入到 Neptune Gremlin 或 SPARQL 查询中

默认情况下,Neptune 为每个查询分配一个唯一的 queryId 值。您可以使用该 ID 获取有关正在运行的查询的信息(请参阅 Gremlin 查询状态 APISPARQL 查询状态 API),也可以取消查询(请参阅 Gremlin 查询取消SPARQL 查询取消)。

Neptune 还允许您在 HTTP 标头中为 Gremlin 或 SPARQL 查询指定自己的 queryId 值,或者通过使用 queryId 查询提示为 SPARQL 查询指定该值。分配自己的 queryID 可轻松跟踪查询来获取状态或取消查询。

注意

使用 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

以下是使用 SPARQL queryId 查询提示将自定义 queryId 值注入到 SPARQL 查询中的示例:

curl https://your-neptune-endpoint:port/sparql \ -d "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"