SPARQL UNION - Result set incomplete

Posted by jplevac on Stack Overflow See other posts from Stack Overflow or by jplevac
Published on 2010-05-04T21:16:37Z Indexed on 2010/05/04 21:18 UTC
Read the original article Hit count: 288

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about sparql

Related posts about rdf