简体   繁体   English

GraphDB 中的 Graph Store 协议支持

[英]Graph Store protocol support in GraphDB

I'm having troubles with using the Graph Store protocol, as documented in GraphDB's help section (the REST API docs).如 GraphDB 的帮助部分(REST API 文档)中所述,我在使用 Graph Store 协议时遇到了麻烦。 Specifically, I have two issues:具体来说,我有两个问题:

  1. The Graph Store protocol is supposed to support PUT requests (see https://rdf4j.org/documentation/reference/rest-api/ ), but the GraphDB REST API documentation only indicates GET, DELETE and POST operations (when listing all operations under "graph-store" section of the docs) The Graph Store protocol is supposed to support PUT requests (see https://rdf4j.org/documentation/reference/rest-api/ ), but the GraphDB REST API documentation only indicates GET, DELETE and POST operations (when listing all operations under文档的“图形存储”部分)

  2. The notion of "directly referenced graph" does not seem to be working, not sure if I'm doing something wrong. “直接引用图”的概念似乎不起作用,不确定我是否做错了什么。 What I tried is:我尝试的是:

Step1.步骤1。 I created repository myrepo and included a named graph with the IRI http://example.org/graph1我创建了存储库 myrepo 并包含一个带有 IRI http://example.org/graph1的命名图

Step2.第2步。 I tried to access the graph by including various forms of its IRI in the URL.我试图通过在 URL 中包含其 IRI 的各种 forms 来访问该图。 None of the following works:以下均无效:

http://localhost:7200/repository/myrepo/rdf-graphs/graph1
http://localhost:7200/repository/myrepo/rdf-graphs/http://example.org/graph1
http://localhost:7200/repository/myrepo/rdf-graphs/http%3A%2F%2Fexample.org%2Fgraph1

Also, the "Try it out," button provided in the REST API docs under each operation reports Bad Request if I try to fill those boxes (repository=myrepo, graph=graph1)此外,如果我尝试填写这些框,则每个操作下的 REST API 文档中提供的“试用”按钮会报告错误请求(repository=myrepo,graph=graph1)

Any ideas how this feature can actually be used?任何想法如何实际使用此功能? Is there a specific way of writing the "directly referenced named graph" in the request URL?在请求 URL 中是否有编写“直接引用命名图”的特定方法? (perhaps GraphDB generates some resolvable identifiers for each named graph? how would they look like?) (也许 GraphDB 会为每个命名图生成一些可解析的标识符?它们会是什么样子?)

I confirm your observations and posted a bug GDB-5486我确认您的观察并发布了错误 GDB-5486

  1. instead of POST you could use DELETE then PUT.而不是 POST,您可以使用 DELETE 然后 PUT。
  2. For the time being, use "indirectly referenced".暂时使用“间接引用”。

For the record, "indirectly referenced graph" works, and returns various formats, eg:作为记录,“间接引用图”有效,并返回各种格式,例如:

> curl -HAccept:text/turtle 'http://localhost:7200/repository/myrepo/rdf-graphs/service?graph=http%3A%2F%2Fexample.org%2Fgraph1'

<http://example.org/s> <http://example.org/p> <http://example.org/o> .

> curl -HAccept:application/trig 'http://localhost:7200/repository/myrepo/rdf-graphs/service?graph=http%3A%2F%2Fexample.org%2Fgraph1'

<http://example.org/graph1> {
  <http://example.org/s> <http://example.org/p> <http://example.org/o> .
}

> curl -HAccept:text/nquads 'http://localhost:7200/repository/myrepo/rdf-graphs/service?graph=http%3A%2F%2Fexample.org%2Fgraph1'

<http://example.org/s> <http://example.org/p> <http://example.org/o> <http://example.org/graph1> .

> curl -HAccept:application/ld+json 'http://localhost:7200/repository/myrepo/rdf-graphs/service?graph=http%3A%2F%2Fexample.org%2Fgraph1'
[ {
  "@graph" : [ {
    "@id" : "http://example.org/s",
    "http://example.org/p" : [ {
      "@id" : "http://example.org/o"
    } ]
  } ],
  "@id" : "http://example.org/graph1"
} ]

The SPARQL 1.1 Graph Store HTTP protocol is often misunderstood, particularly the notion of "directly referenced graph". SPARQL 1.1 Graph Store HTTP 协议经常被误解,尤其是“直接引用图”的概念。 When you call the protocol with a URL like http://localhost:7200/repository/myrepo/rdf-graphs/graph1 you literally provide a named graph identified by the whole URL, ie your named graph would be "http://localhost:7200/repository/myrepo/rdf-graphs/graph1" and not just "graph1". When you call the protocol with a URL like http://localhost:7200/repository/myrepo/rdf-graphs/graph1 you literally provide a named graph identified by the whole URL, ie your named graph would be "http://localhost :7200/repository/myrepo/rdf-graphs/graph1" 而不仅仅是 "graph1"。 Consequently you can't use a URL like "http://localhost:7200/repository/myrepo/rdf-graphs/http://example.org/graph1" and expect that the protocol will interpret this as addressing the named graph "http://example.org/graph1".因此,您不能使用像“http://localhost:7200/repository/myrepo/rdf-graphs/http://example.org/graph1”这样的 URL 并期望协议将其解释为寻址命名图“ http://example.org/graph1"。 The protocol also supports "indirectly referenced graphs", which is the only way to use a graph URI that isn't derived from the URL used to call the protocol.该协议还支持“间接引用的图”,这是使用不是从用于调用该协议的 URL 派生的图 URI 的唯一方法。 Please see https://www.w3.org/TR/sparql11-http-rdf-update/#direct-graph-identification for a more detailed explanation.有关更详细的说明,请参阅https://www.w3.org/TR/sparql11-http-rdf-update/#direct-graph-identification

Because of the above confusion I recommend to avoid using the Graph Store protocol entirely and instead use the SPARQL 1.1 Protocol, which can do everything the Graph Store protocol can except for the convoluted notion of directly referenced graphs.由于上述混淆,我建议完全避免使用 Graph Store 协议,而是使用 SPARQL 1.1 协议,它可以做 Graph Store 协议可以做的所有事情,除了直接引用图的复杂概念。 Admittedly the REST API doc "Try it out" feature is broken for some of the Graph Store protocol endpoints.诚然,对于某些 Graph Store 协议端点,REST API 文档“试用”功能已损坏。

Eg to fetch all statements in the named graph http://example.com/graph1 you could do this with curl:例如,要获取命名图http://example.com/graph1中的所有语句,您可以使用 curl 执行此操作:

curl -H 'Accept: text/turtle' 'http://localhost:7200/repositories/myrepo/statements?context=%3Chttp%3A%2F%2Fexample.org%2Fgraph1%3E' curl -H '接受:文本/乌龟' 'http://localhost:7200/repositories/myrepo/statements?context=%3Chttp%3A%2F%2Fexample.org%2Fgraph1%3E'

To add data to a named graph simply send the data using POST, to replace the data use PUT and to delete the data issue a DELETE request.要将数据添加到命名图,只需使用 POST 发送数据,使用 PUT 替换数据并删除数据发出 DELETE 请求。

This is available in the REST API doc section of the GraphDB Workbench, under "repositories".这在 GraphDB Workbench 的“存储库”下的 REST API 文档部分中可用。 Note that in the SPARQL 1.1 Protocol URIs must be encircled in < >, unlike in the SPARQL 1.1 Graph Store protocol.请注意,在 SPARQL 1.1 协议中,URI 必须用 < > 括起来,这与 SPARQL 1.1 图形存储协议中不同。

Workbench REST API 文档中的 SPARQL 1.1 协议

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM