Search code examples
sparqlrdfallegrographnamed-graphs

SPARQL: Querying the Default Graph


With the RDF query language SPARQL, I'm trying to find a way to do a boolean query (or any other query) for anything not in a Named Graph.

ASK { GRAPH null { ?s ?p ?o } }

Can't find really any documentation on searching specifically within an empty Named Graph. Also tried replacing null with <>, empty, and (nothing).


Solution

  • This query will look for triples in the default graph, then remove ones that are also in a named graph:

    SELECT ?s ?p ?o {
       ?s ?p ?o 
       FILTER NOT EXISTS { GRAPH ?g { ?s ?p ?o } }
    }