【问题标题】:Clear data in AWS Neptune清除 AWS Neptune 中的数据
【发布时间】:2020-02-21 17:07:20
【问题描述】:

我正在尝试运行简单的 CLEAR 和 DELETE SPARQL 查询并不断返回:

    Malformed query: Encountered \" \"clear\" \"CLEAR \"\" at line
    1, column 1.\n Was expecting one of:\n \"base\" ...\n \"prefix\" 
...\n \"select\" ...\n \"construct\" ...\n \ "describe\" ...\n \"ask\" ...\n

是否不支持 CLEAR 和 DELETE 查询?或者 Neptune 是否有其他方法可以清除实例中的图表。

谢谢

【问题讨论】:

  • 如何运行命令?请注意,SPARQL 更新命令与查询不同,即您应该使用 update 而不是 query 参数 - 执行类似 curl https://your-neptune-endpoint:port/sparql -d "update=YOUR_UPDATE_COMMAND" 的操作
  • 我通过邮递员使用 Content-Type = application/sparql-query 和 Accept = application/sparql-results+json 的标头运行它。我正在使用 POST 请求发送一个简单的 CLEAR [ GRAPH ] 以删除所有三元组
  • application/sparql-update
  • 谢谢!是否还有其他标题。我正在使用简单的查询DELETE [ <uri> ] { ?s ?p ?o } WHERE { ?s ?p ?o },我仍然得到"Malformed query: Encountered \" \"delete\" \"DELETE \"\" at line 1, column 1.\nWas expecting one of:\n \"base\" ...\n \"prefix\" ...\n \"drop entailments\" ...\n \"create entailments\" ...\n \"enable entailments\" ...\n \"disable entailments\" ...\n \"load\" ...\n \"clear\" 我假设海王星将支持 DELETE,不知道为什么它没有检测到它
  • 已解决。 'CLEAR ALL' 命令有效。我猜 SPARQL UPDATE 实现只支持某些命令

标签: curl postman sparql rdf amazon-neptune


【解决方案1】:

注意事项:答案包含删除所有数据的示例, 所以在数据库中执行这些查询时要格外小心。

Neptune 确实支持 CLEAR 和 DELETE。 CLEAR 和 DELETE 是 UPDATE 操作,因此您可以通过两种方式进行操作:

1) 在请求参数中使用“update=”

curl http://endpoint:8182/sparql -d "update=DELETE DATA { <http://x> <http://y> <http://z> }” 

OR

curl http://localhost:8182/sparql -d "update=DELETE WHERE { ... }” 

You can use a similar one for CLEAR.

2) 使用 Content-Type Header (application/sparql-update) 并在请求参数中直接使用查询。

curl http://endpoint:8182/sparql -H "Content-Type: application/sparql-update" -d "DELETE DATA { <http://x> <http://y> <http://z> }” 

您似乎尝试了两者的混合,并且可能组合不正确。 Neptune 完全符合 SPARQL 1.1,因此,如果您发现某些东西无法正常工作,请告诉我们。在几乎所有情况下,请求都不会遵守 SPARQL HTTP 规范。

【讨论】:

  • 这太完美了!谢谢
  • 使用awscurl,似乎只有第二个变体对我有用:awscurl -X POST --region "${region}" --service neptune-db --access_key "${access_key}" --secret_key "${secret_key}" "https://${url}:${port}/sparql" -d 'DROP ALL' -H "Content-Type: application/sparql-update"
猜你喜欢
  • 2019-05-13
  • 2020-06-21
  • 1970-01-01
  • 1970-01-01
  • 2022-01-08
  • 1970-01-01
  • 2021-03-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多