I want to fetch paginated data using SPARQL query for one type of record that has some duplicate attributes like type, image.
below query returns duplicates and hence pagination get wrong.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema:<http://schema.org/>
SELECT distinct ?uri ?label ?r ?type ?image ?ownership ?rating ?comments ?allOwners
FROM <http://sample.net/>
WHERE {
?r rdf:type <http://schema.org/Relation> .
?r schema:property ?uri.
?r schema:owner ?owner .
?r schema:ownership ?ownership .
?uri rdfs:label ?label .
?uri rdf:type ?type .
?uri schema:image ?image .
OPTIONAL {?r schema:comments ?comments .}
OPTIONAL {?r schema:rating ?rating .}
filter (?owner =<http://sample.net/resource/37654824-334f-4e57-a40c-4078cac9c579>)
} limit 20 offset 0
sample data
subject,predicate,object
Product-uri,type,Vehicle
Product-uri,type,Car
Product-uri,type,Toyota
Product-uri,image,Image-key1.png
Product-uri,image,Image-key2.png
Product-uri,image,Image-key3.png
Product-uri2,type,Vehicle
Product-uri2,type,Car
Product-uri2,type,Toyota
Product-uri2,image,Image-key21.png
Product-uri2,image,Image-key22.png
Product-uri2,image,Image-key23.png
if I query on this data to fetch list of unique products (where each product has multiple types & images) the total count will be 12 instead of 2.