1

如 GraphDB 的帮助部分(REST API 文档)中所述,我在使用 Graph Store 协议时遇到了麻烦。具体来说,我有两个问题:

  1. Graph Store 协议应该支持 PUT 请求(请参阅https://rdf4j.org/documentation/reference/rest-api/),但 GraphDB REST API 文档仅指示 GET、DELETE 和 POST 操作(列出所有操作时文档的“图形存储”部分)

  2. “直接引用图”的概念似乎不起作用,不确定我是否做错了什么。我尝试的是:

步骤1。我创建了存储库 myrepo 并在 IRI http://example.org/graph1中包含了一个命名图

第2步。我试图通过在 URL 中包含各种形式的 IRI 来访问该图表。以下均无效:

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

此外,“试试看!” 如果我尝试填充这些框(repository=myrepo,graph=graph1),则每个操作下的 REST API 文档中提供的按钮报告错误请求

任何想法如何实际使用此功能?是否有在请求 URL 中编写“直接引用的命名图”的特定方法?(也许 GraphDB 会为每个命名图生成一些可解析的标识符?它们会是什么样子?)

4

2 回答 2

0

SPARQL 1.1 Graph Store HTTP 协议经常被误解,尤其是“直接引用图”的概念。当您使用诸如 http://localhost:7200/repository/myrepo/rdf-graphs/graph1 之类的 URL 调用协议时,您实际上提供了一个由整个 URL 标识的命名图,即您的命名图将是“http://localhost :7200/repository/myrepo/rdf-graphs/graph1" 而不仅仅是 "graph1"。因此,您不能使用像“http://localhost:7200/repository/myrepo/rdf-graphs/http://example.org/graph1”这样的 URL,并期望协议将其解释为对命名图的寻址“ http://example.org/graph1"。该协议还支持“间接引用的图”,这是使用不是从用于调用协议的 URL 派生的图 URI 的唯一方法。https://www.w3.org/TR/sparql11-http-rdf-update/#direct-graph-identification以获得更详细的解释。

由于上述混淆,我建议完全避免使用 Graph Store 协议,而是使用 SPARQL 1.1 协议,它可以做 Graph Store 协议可以做的所有事情,除了直接引用图的复杂概念。不可否认,某些 Graph Store 协议端点的 REST API 文档“试用”功能已损坏。

例如,要获取命名图http://example.com/graph1中的所有语句,您可以使用 curl 执行此操作:

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

要将数据添加到命名图,只需使用 POST 发送数据,使用 PUT 替换数据并删除数据发出 DELETE 请求。

这可在 GraphDB Workbench 的“存储库”下的 REST API 文档部分中找到。请注意,在 SPARQL 1.1 协议中,URI 必须用 < > 括起来,这与 SPARQL 1.1 图形存储协议中不同。

Workbench REST API 文档中的 SPARQL 1.1 协议

于 2021-02-25T13:32:24.807 回答
0

我确认您的观察并发布了错误 GDB-5486

  1. 而不是 POST,您可以使用 DELETE 然后 PUT。
  2. 暂时使用“间接引用”。

作为记录,“间接引用图”有效,并返回各种格式,例如:

> 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"
} ]
于 2021-02-12T11:27:22.863 回答