简体   繁体   English

通过 REST 使用 SPARQL 查询在 Marklogic 中插入三元组

[英]INSERTing triples in Marklogic with a SPARQL query via REST

I have a Marklogic SPARQL endpoint available at url http://data.mydomain.com:8910/v1/graphs/sparql我有一个 Marklogic SPARQL 端点,地址为 url http://data.mydomain.com:8910/v1/graphs/sparql

I entered this URL in my browser expecting a triple to be inserted in the database:我在浏览器中输入了这个 URL,希望在数据库中插入一个三元组:

http://data.mydomain.com:8910/v1/graphs/sparql?query=INSERT%20DATA%20{%20GRAPH%20%3Chttp://data.foobar.corp/people%3E%20{%20%3Chttp://data.foobar.corp/x%3E%20%3Chttp://www.foobar.com/#ID%3E%20%22x%22%20.%20%20}%20}

Fyi, the query parameter, once decoded, looks like this: Fyi,查询参数,一旦解码,看起来像这样:

INSERT DATA { GRAPH <http://data.foobar.corp/people> { <http://data.foobar.corp/x> <http://www.foobar.com/#ID> "x" .  } }

My endpoint returns this error message when I send the GET request above:当我发送上面的 GET 请求时,我的端点返回此错误消息:

<error-response xmlns="http://marklogic.com/xdmp/error">
<status-code>400</status-code>
<status>Bad Request</status>
<message-code>XDMP-UNEXPECTED</message-code>
<message>XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected INSERT DATA</message>
</error-response>

This query works fine in Virtuoso (another popular SPARQL endpoint).此查询在 Virtuoso(另一个流行的 SPARQL 端点)中运行良好。

Is it a normal behaviour?这是正常行为吗? Should I check my server configuration?我应该检查我的服务器配置吗?

The syntax is legal: http://www.sparql.org/update-validator.html is an online checker (runs Apache Jena).语法是合法的: http://www.sparql.org/update-validator.html是一个在线检查器(运行 Apache Jena)。

?query=

That is for queries - an update is not a query.那是针对查询的——更新不是查询。 SPARQL differentiates the two types of operation in the protocol. SPARQL 在协议中区分了两种类型的操作。

Use ?update= (and check that it is the update endpoint).使用?update= (并检查它是否是更新端点)。

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

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