Alternatives to the OPTIONAL fallback SPARQL pattern? -
i need retrieve single image each resource in target set, testing multiple non-exclusive predicates priority order.
i'm currently using standard optional fallback pattern along lines of
select ?r ?i { ?r dbo:automobile . optional { ?r <http://dbpedia.org/ontology/thumbnail> ?i } optional { ?r <http://xmlns.com/foaf/0.1/depiction> ?i } optional { ?r <http://xmlns.com/foaf/0.1/logo> ?i } optional { ?r <http://schema.org/image> ?i } }
but approach turning out troublesome on backends: aware of simple/efficient alternative?
what's problem optionals? repeated use of ?i
?
a different approach each alternative , pick first 1 set.
select ?r ?i { ?r dbo:automobile . optional { ?r <http://dbpedia.org/ontology/thumbnail> ?i1 } optional { ?r <http://xmlns.com/foaf/0.1/depiction> ?i2 } optional { ?r <http://xmlns.com/foaf/0.1/logo> ?i3 } optional { ?r <http://schema.org/image> ?i4 } bind(coalesce(?i1,?i2,?i3,?i4) ?i) }
Comments
Post a Comment