in sparql can this
select * { ?s (_:prop1 | _:prop2) "some_val" . ... #use ?s in other patterns ?s ?o ?p . }
is possible same object part of pattern? , workarounds of in case not possible?
for example:
select * { ?s _:prop ("v1" | "v2") . ... #use ?s in other patterns ?s ?o ?p . }
there few ways this. simplest , pure sparql 1.0 method use union
e.g.
select * { { ?s _:prop "v1" } union { ?s _:prop "v2" } # use ?s in other patterns }
this simplest method if need multiple constraints on ?s
can unwieldy.
second method use in
function in filter
clause, requires sparql 1.1 implementation e.g.
select * { ?s _:prop ?value . filter(?value in ("v1", "v2")) # use ?s in other patterns }
problem here using in
can perform poorly if have many alternatives or lot of data may matched ?s _:prop ?value
third method use values
clause again requires sparql 1.1 implementation:
select * { values (?value) { ( "v1" ) ( "v2 " ) } ?s _:prop ?value . # use ?s in other patterns }
this best option since scales many alternatives better (depending on sparql implementation) , maybe nicest read , write.
Comments
Post a Comment