Kjetil,

LIMIT is for WHERE, if CONSTRUCT may create up to two triples per row
then the resulting graph is no bigger than 2*4 = 8 triples. (I'm writing
"up to two triples per row", not "two triples per row" because in common
case there may be unbound variables and/or repeating triples).

In addition, you may wish to abbreviate the query as follows:

prefix dct:<http://purl.org/dc/terms/> 
prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT { ?resource dct:title ?title ; 
                      a ?type }

FROM <http://msone.computas.no/graphs/inferred/classification> 
FROM <http://msone.computas.no/graphs>
FROM <http://msone.computas.no/graphs/instance/nfi> 
FROM <http://msone.computas.no/graphs/instance/mo> 
FROM <http://msone.computas.no/graphs/ontology/mediasone>
FROM <http://msone.computas.no/graphs/vocab/mediasone> 
FROM <http://msone.computas.no/graphs/inferred/nfi/realisation1>
FROM <http://msone.computas.no/graphs/inferred/mo/realisation1> 
FROM <http://msone.computas.no/graphs/inferred/nfi/realisation2>
FROM <http://msone.computas.no/graphs/inferred/mo/realisation2> 
FROM <http://msone.computas.no/graphs/inferred/agent-classification> 
FROM <http://msone.computas.no/graphs/ontology/mediasone/agent>

WHERE {
  {
        ?resource a ?type .
        FILTER (?type = <http://www.w3.org/2002/07/owl#Class> ) .  
        ?resource rdfs:label ?title . 
  } UNION {
        ?resource a ?type .
        FILTER (?type in (
          <http://musicbrainz.org/mm/mm-2.1#Track> ,
          <http://www.csd.abdn.ac.uk/~ggrimnes/dev/imdb/IMDB#Movie> ,
          <http://xmlns.com/foaf/0.1/Image> ,
          <http://www.computas.com/mediasone#Text> ) ) .
        ?resource dct:title ?title .
  }
  FILTER regex(?title, "turi", "i") 
}  
ORDER BY ?title LIMIT 4 OFFSET 0 


Best Regards,

Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com

On Fri, 2009-02-20 at 16:41 +0100, Kjetil Kjernsmo wrote:
> All,
> 
> I have the following query, which is a rather complex one. The weird thing 
> about it is that I have a LIMIT 4 at the end, but it still gives 6 solutions. 
> I'm a bit uncertain about how LIMIT should work, but to me this looks wrong.
> 
> 
> prefix dct:<http://purl.org/dc/terms/> 
> prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>
> 
> CONSTRUCT { ?resource dct:title ?title ; 
>                       a ?type }
> 
> FROM <http://msone.computas.no/graphs/inferred/classification> 
> FROM <http://msone.computas.no/graphs>
> FROM <http://msone.computas.no/graphs/instance/nfi> 
> FROM <http://msone.computas.no/graphs/instance/mo> 
> FROM <http://msone.computas.no/graphs/ontology/mediasone>
> FROM <http://msone.computas.no/graphs/vocab/mediasone> 
> FROM <http://msone.computas.no/graphs/inferred/nfi/realisation1>
> FROM <http://msone.computas.no/graphs/inferred/mo/realisation1> 
> FROM <http://msone.computas.no/graphs/inferred/nfi/realisation2>
> FROM <http://msone.computas.no/graphs/inferred/mo/realisation2> 
> FROM <http://msone.computas.no/graphs/inferred/agent-classification> 
> FROM <http://msone.computas.no/graphs/ontology/mediasone/agent>
> 
> WHERE {
>   {
>       ?resource a ?type .
>       FILTER (?type = <http://www.w3.org/2002/07/owl#Class> ) .  
>       ?resource rdfs:label ?title . 
>   } UNION {
>       ?resource a ?type .
>       FILTER (?type = <http://musicbrainz.org/mm/mm-2.1#Track> ) .
>       ?resource dct:title ?title .
>   } UNION {
>       ?resource a ?type .
>       FILTER (?type = 
> <http://www.csd.abdn.ac.uk/~ggrimnes/dev/imdb/IMDB#Movie> ).
>       ?resource dct:title ?title .
>   } UNION {
>       ?resource a ?type .
>       FILTER (?type = <http://xmlns.com/foaf/0.1/Image> ) .
>       ?resource dct:title ?title .
>   } UNION {
>       ?resource a ?type .
>       FILTER (?type = <http://www.computas.com/mediasone#Text> ) .
>       ?resource dct:title ?title .
>   }
>   FILTER regex(?title, "turi", "i") 
> }  
> ORDER BY ?title LIMIT 4 OFFSET 0 
> 
> The query can be run at this endpoint:
> http://msoneutv.computas.no:8890/sparql
> 
> Can anyone explain why this happens?
> 
> Kind regards 
> 
> Kjetil Kjernsmo


Reply via email to