如何使用“过滤器不存在”查询使用ARC2?

时间:2017-01-27 11:21:22

标签: sparql arc2

我有一个基于ARC2的RDF商店设置并填充了一些数据。当我运行而没有 vcard:Individual部分时,以下查询返回预期结果(foaf:PersonFILTER NOT EXISTS类型的所有URI的所有URI):

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX app: <http://example.com#>

SELECT ?person
WHERE {
  ?person rdf:type ?type .
  FILTER (?type = vcard:Individual || ?type = foaf:Person)
  FILTER NOT EXISTS {
    ?person app:id ?id
  }
}

当我尝试通过运行完整查询来排除那些具有app:id属性的东西时,它会失败并显示以下消息:

Incomplete FILTER in ARC2_SPARQLPlusParser
Incomplete or invalid Group Graph pattern. Could not handle &quot;        FILTER NOT EXISTS {   &quot; in ARC2_SPARQLPlusParser

query validator on sparql.org中测试查询时,没有问题。我错过了我的查询是否有问题,或者这是ARC2的缺点?

您能想到我可以尝试使用ARC2获得所需结果的替代查询吗?

1 个答案:

答案 0 :(得分:3)

ARC2 支持SPARQL 1.1,因此,您必须使用常见的OPTIONAL-FILTER(!BOUND())模式:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX app: <http://example.com#>

SELECT ?person
WHERE {
  ?person rdf:type ?type .
  FILTER (?type = vcard:Individual || ?type = foaf:Person)
  OPTIONAL {
    ?person app:id ?id
  }
  FILTER ( !BOUND(?id) ) 
}
相关问题