Skip to content

Get DISTINCT Statements #4518

Answered by abrokenjester
naturzukunft asked this question in Q&A
Discussion options

You must be logged in to vote

The main thing to understand is that if you ask for statements from more than one context, then you get statements from more than one context. In RDF4J, the context is part of the identity of a statement, so the same (subject, predicate, object) in multiple contexts are not considered identical to each other.

Assuming your intent is to get a Model that doesn't have contexts (and therefore no 'duplicated' triples), then one way to fix is by using a SPARQL query instead of a simple getStatement operation, to control the exact shape of the returned data. Something like this:

CONSTRUCT { ?s ?p ?o } 
FROM <context1>
FROM <context2>
...
WHERE { ?s ?p ?o }

Another way is to convert statements on…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hmottestad
Comment options

@hmottestad
Comment options

@abrokenjester
Comment options

@hmottestad
Comment options

Answer selected by naturzukunft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants