I am trying to use FILTER to retrieve pages that don't have a specific property.
I am getting all the links from the dbo:wikiPageWikiLink
property of that page. I want to keep only the links that don't have the dbp:carbs
property. Below is my query that from what I have read from previous questions it returns anything that isn't dbp:carbs
.
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
SELECT ?link
WHERE {
?link dbo:wikiPageWikiLink <http://dbpedia.org/resource/Category:Grape_varieties_of_Greece> .
?link ?p ?o
FILTER(?p != dbp:carbs) .
}
With FILTER NOT EXISTS
, you get all entities that don’t have the specified triple pattern(s):
SELECT ?link
WHERE {
?link dbo:wikiPageWikiLink <http://dbpedia.org/resource/Category:Grape_varieties_of_Greece> .
FILTER NOT EXISTS { ?link dbp:carbs [] . }
}