本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
在 Amazon Neptune 中使用 SPARQL 1.1 图形存储 HTTP 协议 (GSP)
在SPARQL 1.1 图形存储 HTTP 协议
图形存储协议 (GSP) 提供了一种方便的方法来操作整个图形,而无需编写复杂的 SPARQL 查询。
截至发布: 1.0.5.0 (2021-07-27),Neptune 完全支持这个协议。
图形存储协议 (GSP) 的终端节点为:
https://
your-neptune-cluster
:port
/sparql/gsp/
要使用 GSP 访问默认图表,请使用:
https://
your-neptune-cluster
:port
/sparql/gsp/?default
要使用 GSP 访问命名图表,请使用:
https://
your-neptune-cluster
:port
/sparql/gsp/?graph=named-graph-URI
Neptune 普惠制实施的特殊细节
Neptune 完全实现W3C 推荐
其中之一就是PUT
要么POST
请求在请求正文中指定一个或多个与请求 URL 指定的图形不同的命名图形。只有在请求正文 RDF 格式支持命名图表时才会发生这种情况,例如,使用Content-Type: application/n-quads
要么Content-Type:
application/trig
.
在这种情况下,Neptune 会添加或更新正文中存在的所有命名图形以及 URL 中指定的命名图形。
例如,假设从空数据库开始,您发送一个PUT
请求将投票变成三张图表。一个,命名urn:votes
,包含所有选举年份的所有选票。另外两个名字urn:votes:2005
和urn:votes:2019
,包含特定选举年份的选票。请求及其有效负载如下所示:
PUT "http://
your-Neptune-cluster
:port
/sparql/gsp/?graph=urn:votes" Host: example.com Content-Type: application/n-quads PAYLOAD: <urn:JohnDoe> <urn:votedFor> <urn:Labour> <urn:votes:2005> <urn:JohnDoe> <urn:votedFor> <urn:Conservative> <urn:votes:2019> <urn:JaneSmith> <urn:votedFor> <urn:LiberalDemocrats> <urn:votes:2005> <urn:JaneSmith> <urn:votedFor> <urn:Conservative> <urn:votes:2019>
执行请求后,数据库中的数据如下所示:
<urn:JohnDoe> <urn:votedFor> <urn:Labour> <urn:votes:2005> <urn:JohnDoe> <urn:votedFor> <urn:Conservative> <urn:votes:2019> <urn:JaneSmith> <urn:votedFor> <urn:LiberalDemocrats> <urn:votes:2005> <urn:JaneSmith> <urn:votedFor> <urn:Conservative> <urn:votes:2019> <urn:JohnDoe> <urn:votedFor> <urn:Labour> <urn:votes> <urn:JohnDoe> <urn:votedFor> <urn:Conservative> <urn:votes> <urn:JaneSmith> <urn:votedFor> <urn:LiberalDemocrats> <urn:votes> <urn:JaneSmith> <urn:votedFor> <urn:Conservative> <urn:votes>
另一种模糊的情况是,在请求 URL 本身中指定了多个图表,使用PUT
、POST
、GET
要么DELETE
. 例如:
POST "http://
your-Neptune-cluster
:port
/sparql/gsp/?graph=urn:votes:2005&graph=urn:votes:2019"
或者:
GET "http://
your-Neptune-cluster
:port
/sparql/gsp/?default&graph=urn:votes:2019"
在这种情况下,Neptune 返回 HTTP 400,其中显示一条消息,指出请求 URL 中只能指定一个图形。