简体   繁体   中英

MINUS or NOT EXIST in SPARQL

I have a query and want NOT to show some information

SELECT ?Recipe
 WHERE {
   ?Ingredient <http://linkedrecipes.org/schema/ingredientOf> ?Recipe .
   MINUS {
       <http://linkedrecipes.org/schema#Milk> <http://linkedrecipes.org/schema/ingredientOf> ?Recipe .
     }
}

I want to choose all Recipes where Milk is not an Ingredient

After running this query I just have an error

My data is:

<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rcp="http://linkedrecipes.org/schema/">


<rdf:Description rdf:about="http://linkedrecipes.org/schema#Milk">
  <rcp:ingredientOf rdf:resource="http://linkedrecipes.org/schema#SaladUniqueID"/>
  <rcp:ingredientOf rdf:resource="http://linkedrecipes.org/schema#CoffeeUniqueID"/>
</rdf:Description>


<rdf:Description rdf:about="http://linkedrecipes.org/schema#Salt">
  <rcp:ingredientOf rdf:resource="http://linkedrecipes.org/schema#SoupUniqueID"/> 
</rdf:Description>

</rdf:RDF>

In the result I want to have "SoupUniqueID".

使用NOT FILTER会更容易。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM