1

I am just getting up and running with Blazegraph in embedded mode. I load a few sample triples and am able to retrieve them with a "select all" query:

SELECT * WHERE { ?s ?p ?o }

This query returns all my sample triples:

[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>]

Next I try a simple query for a particular subject:

SELECT * WHERE { <http://github.com/jschmidt10#person_Thomas> ?p ?o }

This query yields no results. It seems that none of my queries for a URI are working. I am able to get results when I query for a literal (e.g. ?s ?p "Test").

The API I am using to create my query is BigdataSailRepositoryConnection.prepareQuery().

Code snippet (Scala) that executes and generates the query:

val props = BasicRepositoryProvider.getProperties("./graph.jnl")
val sail = new BigdataSail(props)
val repo = new BigdataSailRepository(sail)

repo.initialize()

val query = "SELECT ?p ?o WHERE { <http://github.com/jschmidt10#person_Thomas> ?p ?o }"
val cxn = repo.getConnection
cxn.begin()
var res = cxn.
    prepareTupleQuery(QueryLanguage.SPARQL, query).
    evaluate()

while (res.hasNext) println(res.next)
cxn.close()
repo.shutDown()
4

1 回答 1

3

你检查过你填充数据库的方式吗?您可能有奇怪编码的字符,或者看起来您的对象中可能有多余的括号。

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

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

当你应该这样做(没有尖括号):

val subject = valueFactory.createURI("http://some.url/some/entity")
于 2017-01-18T01:53:54.417 回答