1

我正在寻找一种方法来返回传递 SPARQL 查询中的父和子,并且只返回构成路径的关系。

以下查询返回指向http://example.com/child的父对象和中间对象对,但如果任何 ?parents 有其他包含语句,那么也会返回这些语句。这可以产生非常大的结果集。

PREFIX  ex:   <http://example.com/>

SELECT ?parent ?child
WHERE {
    ?parent ex:contains+ <http://example.com/child> .
    ?parent ex:contains ?child
}

有没有办法既可以将传递查询中的终端对象绑定到特定资源,又可以返回每个关系中的对象,但不是所有其他的 ex:contains 每个父对象的关系?

例如,使用下图:

ex:root ex:contains ex:rootchild1
ex:root ex:contains ex:rootchild2
ex:rootchild1 ex:contains ex:intermed
ex:intermed ex:contains ex:child

结果将是:

ex:root ex:rootchild1
ex:rootchild1 ex:intermed
ex:intermed ex:child

我正在使用 Jena 和 Fuseki 运行此查询。谢谢!

4

0 回答 0