SPARQL 中的 NOT IN 运算符

NOT IN operator in SPARQL

知道为什么 NOT IN 运算符在此查询中不起作用

SELECT  ?p0 ?o0 
WHERE { 
<http://dbpedia.org/resource/Berlin>  ?p0 ?o0 . 
FILTER (?p0 NOT IN("rdfs:label", "dbo:abstract", "dbo:wikiPageWikiLink", "dbp:image", "dbp:wikiPageUsesTemplate", "rdfs:comment", "rdfs:label", "rdfs:seeAlso", "owl:sameAs", "dbo:wikiPageExternalLink", "dbo:wikiPageID", "dbo:wikiPageLength", "dbo:wikiPageRevisionID", "dbp:image")). 
}

原因是您在 NOT IN 运算符中使用了 string literals instead of prefixed IRIs。只需删除所有 " 即可正常工作:

SELECT  ?p0 ?o0 
WHERE { 
  <http://dbpedia.org/resource/Berlin>  ?p0 ?o0 . 
  FILTER (?p0 NOT IN(rdfs:label, dbo:abstract, dbo:wikiPageWikiLink, dbp:image, dbp:wikiPageUsesTemplate, rdfs:comment, rdfs:label, rdfs:seeAlso, owl:sameAs, dbo:wikiPageExternalLink, dbo:wikiPageID, dbo:wikiPageLength, dbo:wikiPageRevisionID, dbp:image)).
}

Try out