On 17/05/11 17:17, Nikolaos Abatzis wrote:
Sorry about this, cleaned up the prefixes ....


SELECT DISTINCT  ?corr ?px ?ox
WHERE
   {   { { SELECT  ?s
           WHERE
             { ?s rdf:type myproj:SomeOntType
               OPTIONAL
                 { ?s myproj:correlatedRecord ?correlated }
               FILTER ( ! bound(?correlated) )
             }
         }

This subSELECT does nothing except make row duplicates.

Only ?s is visable outside the subSELCT and ....

         { SELECT DISTINCT  ?corr
           WHERE
             { ?s pf:textMatch "1*" .
               ?s myproj:hasCorrelation ?corr
             }

.. it's different from this ?s which isn't visable outside this second subSELECT.

           ORDER BY ?corr
           OFFSET  0
           LIMIT   100
         }
         { SELECT  *
           WHERE
             { ?corr myproj:isCorrelationOf ?sx .
               ?sx ?px ?ox
             }
         }
       }
     UNION

UNION isn't done in the SQL database - other than the fact you sort (which is also done client-side to get SPARQL and XSD semantics right), you might as well ask two queries.

       { { SELECT  *
           WHERE
             { ?corr rdf:type myproj:SomeOntType .
               ?corr pf:textMatch "1*"
               OPTIONAL
                 { ?corr myproj:correlatedRecord ?correlated }
               OPTIONAL
                 { ?corr myproj:hasCorrelation ?hasCorrelation }
               FILTER ( ( ! bound(?correlated) )&&  ( ! bound(?hasCorrelation) 
) )

SPARQL 1.1 has negation in the form of

FILTER NOT EXISTS { pattern }

and can be easier to use than OPTIONAL FILTER !bound

             }
           ORDER BY ?corr
           OFFSET  0
           LIMIT   100
         }
         ?corr ?px ?ox
       }
   }
ORDER BY ?corr




Please do not hesitate to contact me if you need additional information. Thank 
you.

Regards,

Nikolaos Abatzis
New River Systems Corporation
1890 Preston White Drive, Suite 240
Reston, VA 20191

        Andy

Reply via email to