I don't quite understand why in SPARQL they haven't implemented the basic logic operators. However in most of the cases is possible to obtain the same result in a number of way.
The purpose of this question is to have a quick reference for the possible way troughs that can substitute an "or" statement.
Here's what I can think of:
1)UNION
e.g:
SELECT * WHERE
{ { ?s :propA ?o } UNION { ?s :propB ?o } }
-not often suitable because it can became very verbose because
SELECT * WHERE {
{ GRAPH ?g {?s ?p ?o. ?o ?pp ?data1}} UNION
{ GRAPH ?g {?s ?p ?o. ?o ?pp ?data2}}
}
doesn't work as
SELECT * WHERE {
GRAPH ?g {
?s ?p ?o.
{?o ?pp ?data1} UNION
{?o ?pp ?data2}
}
}
(at least not with Stardog)
2)FILTER
e.g:
SELECT * WHERE
{
?s ?p ?o.
FILTER (?p = :propA || ?p = :propB )
}
Any other ideas?
UNION
would work exactly like a logical-OR the 2 queries would have produced the same result, but of course they don't. I'm sorry that I can't explain myself properly, I'm a sparql newbie and also English is not my mother tongue, thank you for your comprehension and your time. – Solubilize((?s ?p ?o ?g) AND (?o ?pp ?data1 ?g)) OR ((?s ?p ?o ?g) AND (?o ?pp ?data2 ?g))
, the second query is(?s ?p ?o ?g) AND ((?o ?pp ?data1 ?g) OR (?o ?pp ?data2 ?g))
. – Wagtail