SPARQL UNION - Result set incomplete
- by jplevac
I have two queries:
query 1:
SELECT DISTINCT ?o COUNT(?o)  
WHERE 
{ ?s1 ?somep1 <predicate_one-uri>. ?s1 ?p ?o}
query 2:
SELECT DISTINCT ?o COUNT(?o)  
WHERE 
{?s2 ?somep2 <predicate_two-uri>.?s2 ?p ?o.}
Each query gives me a different result set (as expected).  I need to make a union of these two sets, from what I understand the query below should give me the set I want:
SELECT DISTINCT ?o COUNT(?o)  
WHERE 
{
 { ?s1 ?somep1 <predicate_one-uri>.?s1 ?p1 ?o}
  UNION 
 {?s2 ?somep2 <predicate_two-uri>.?s2 ?p2 ?o.}
}
The problem is that some results from query 1 are not in the union set and vice-versa for query 2.  The union is not working properly as it does not incorporate all results of query 1 and query 2. Please advise on the proper structure of the sparql query for achieving the desired result set.
Thanks in advance!
JP Levac