简单的SPARQL查询不会返回任何结果

时间:2017-01-15 16:14:41

标签: sparql rdf blazegraph

我刚刚在嵌入式模式下使用Blazegraph。我加载了一些样本三元组,并且能够通过“全选”查询来检索它们:

${xpdi}

此查询返回我的所有样本三元组:

SELECT * WHERE { ?s ?p ?o }

接下来,我尝试对特定主题进行简单查询:

[s=<<<http://github.com/jschmidt10#person_Thomas>, <http://github.com/jschmidt10#hasAge>, "30"^^<http://www.w3.org/2001/XMLSchema#int>>>;p=blaze:history:added;o="2017-01-15T16:11:15.909Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>]
[s=<<<http://github.com/jschmidt10#person_Tommy>, <http://github.com/jschmidt10#hasLastName>, "Test">>;p=blaze:history:added;o="2017-01-15T16:11:15.909Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>]
[s=<<<http://github.com/jschmidt10#person_Tommy>, <http://www.w3.org/2002/07/owl#sameAs>, <http://github.com/jschmidt10#person_Thomas>>>;p=blaze:history:added;o="2017-01-15T16:11:15.909Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>]
[s=<http://github.com/jschmidt10#person_Thomas>;p=<http://github.com/jschmidt10#hasAge>;o="30"^^<http://www.w3.org/2001/XMLSchema#int>]
[s=<http://github.com/jschmidt10#person_Tommy>;p=<http://github.com/jschmidt10#hasLastName>;o="Test"]
[s=<http://github.com/jschmidt10#person_Tommy>;p=<http://www.w3.org/2002/07/owl#sameAs>;o=<http://github.com/jschmidt10#person_Thomas>]

此查询不会产生任何结果。似乎我对URI的查询都没有起作用。当我查询文字时,我能够得到结果(例如SELECT * WHERE { <http://github.com/jschmidt10#person_Thomas> ?p ?o } )。

我用来创建查询的API是?s ?p "Test"

执行并生成查询的代码段(Scala):

BigdataSailRepositoryConnection.prepareQuery().

1 个答案:

答案 0 :(得分:3)

您是否检查了填充数据库的方式?您可能会对编码奇怪的字符进行编码,或者看起来您的对象中可能有多余的括号。

从print语句中,您的URI正在打印额外的斜角括号。您可能正在使用:

val subject = valueFactory.createURI("<http://some.url/some/entity>")

当你应该这样做时(没有斜角括号):

val subject = valueFactory.createURI("http://some.url/some/entity")