我的三重商店里有一些数据,如:
Subject Predicate Object
-----------------------------------------------------------------------------------
<http://Doc1> http://purl.org/dc/terms/created 2013
<http://Doc1> http://purl.org/dc/terms/contributor John
.
.
<http://Doc2> http://purl.org/dc/terms/created 2014
<http://Doc2> http://purl.org/dc/terms/contributor David
.
.
<http://Doc3> http://purl.org/dc/terms/created 2013
<http://Doc3> http://purl.org/dc/terms/contributor John
.
.
.
我想选择主题为Doc1的每个三元组:
SELECT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object
FILTER ( ?subject = <http://Doc1> )
}
这很简单!这是我的输出:
Subject Predicate Object
-----------------------------------------------------------------------------------
<http://Doc1> http://purl.org/dc/terms/created 2013
<http://Doc1> http://purl.org/dc/terms/contributor John
..
现在,对于每个对象,我想先返回N三元组。事实上,我想选择N三元组,其中一些文档是在2013年创建的,N三元组是贡献者是John等。 我试着做类似的事情:
SELECT ?subject ?predicate ?specObject
WHERE {
<http://Doc1> ?predicate ?specObject.
?subject ?predicate ?specObject
}
但是这个查询返回对象是2013和John的每个三元组。我需要每组前五个三联。我该如何构建此查询? 谢谢!