Reputation: 1
I try to write a SPARQL query to detect duplicated RDF triples that exist in two given graphs (on the same endpoint), but don't know how to do it.
Is it feasible, and if so, how?
Upvotes: 0
Views: 52
Reputation: 2285
SELECT DISTINCT *
WHERE {
GRAPH <https://example.com/named-graph-1/> { ?s ?p ?o . }
GRAPH <https://example.com/named-graph-2/> { ?s ?p ?o . }
}
To find duplicate triples in any two named graphs, you can use variables:
SELECT DISTINCT *
WHERE {
GRAPH ?namedGraph1 { ?s ?p ?o . }
GRAPH ?namedGraph2 { ?s ?p ?o . }
FILTER( STR(?namedGraph1) < STR(?namedGraph2) )
}
Upvotes: 3