Hi! I post yet another big query... :-) This is tested on http://msoneutv.computas.no:8890/sparql which runs 5.0.10 with a few UTF-8-related patches.
First, consider this query: CONSTRUCT { ?class rdfs:label ?title ; a <http://www.w3.org/2002/07/owl#Class> . } FROM <http://msone.computas.no/graphs> FROM NAMED <http://msone.computas.no/graphs/inferred/nfi/agent-classification> FROM NAMED <http://msone.computas.no/graphs/ontology/mediasone> FROM NAMED <http://msone.computas.no/graphs/inferred/mo/agent-classification> FROM <http://msone.computas.no/graphs/inferred/nfi/agent-classification> FROM <http://msone.computas.no/graphs/inferred/classification> FROM <http://msone.computas.no/graphs/inferred/mo/agent-classification> WHERE { { ?class rdfs:subClassOf <http://www.computas.com/mediasone-ontologi#Aktoer> . } UNION { ?class rdfs:subClassOf [ rdfs:subClassOf <http://www.computas.com/mediasone-ontologi#Aktoer> ] . } UNION { ?class rdfs:subClassOf [rdfs:subClassOf [ rdfs:subClassOf <http://www.computas.com/mediasone-ontologi#Aktoer> ] ]. } UNION { ?class rdfs:subClassOf [rdfs:subClassOf [rdfs:subClassOf [ rdfs:subClassOf <http://www.computas.com/mediasone-ontologi#Aktoer> ] ]]. } ?graph2 a <http://msone.computas.no/graphs#OntoGraph> . GRAPH ?graph2 { ?class rdfs:label ?title . FILTER regex(?title, "STR", "i") } } ORDER BY ?title Now, the problematic thing is the ordering. I get 29 "rows" from this query, and the first few literals are ns1:Xb0303efc74e6dd9d817fc8473331aa57 rdfs:label "Breistrand, Wilfred [Skuespiller]"^^xsd:string . ns1:X8a8a324148476df976ace21e84d47e rdfs:label "Breistrand, Wilfred"^^xsd:string . ns1:Xc77b5f77ef5d5821a9023be72fa94c rdfs:label "Hagstr\u00F6m, Lars"^^xsd:string . ns1:X4331152fb1d59aa53468a45a74edd3a rdfs:label "Bjerkestrand, Kjetil [Komponist]"^^xsd:string . So, it appears that the ordering of the labels here are wrong, or is there a reasonable explanation for this based on how to graph is constructed? More weirdness happens if we add a LIMIT and an OFFSET. I've been through some of that before, and at that time, it turned out that I was just confused. Perhaps it is still just me being confused, but here goes: If I adjust the last line to ORDER BY ?title LIMIT 18 OFFSET 0 I get 18 rows, which is what I expect, and if use OFFSET 18 I get another 12 rows. But now I should have exhausted the solutions, since there were only 29 rows in the original unlimited result. But I still get more results if I do ORDER BY ?title LIMIT 18 OFFSET 36 ...strange, huh? The guy who has been running these queries claim it is rather unpredictable how many solutions you get, and that it appears buggy. I could also be the data, but I'm not sure. The two anecdotes here, that the ordering appears wrong and that it gives more solutions even though the the OFFSET exceeds the total number of solutions, may indicate something is wrong. The explain output for the last query (with OFFSET 36) is: REPORT VARCHAR _______________________________________________________________________________ { Fork { Precode: 0: $26 "callret" := Call min_bnode_iri_id () 5: $27 "-ns#type" := Call __i2idn (<constant (http://www.w3.org/1999/02/22-rdf-syntax-ns#type)>) 10: $28 "phs#OntoGraph" := Call __i2idn (<constant (http://msone.computas.no/graphs#OntoGraph)>) 15: $29 "callret" := Call DB.DBA.RDF_MAKE_IID_OF_QNAME (<constant (http://msone.computas.no/graphs)>) 22: $30 "callret" := Call DB.DBA.RDF_MAKE_IID_OF_QNAME (<constant (http://msone.computas.no/graphs/inferred/nfi/agent-classification)>) 29: $31 "callret" := Call DB.DBA.RDF_MAKE_IID_OF_QNAME (<constant (http://msone.computas.no/graphs/inferred/classification)>) 36: $32 "callret" := Call DB.DBA.RDF_MAKE_IID_OF_QNAME (<constant (http://msone.computas.no/graphs/inferred/mo/agent-classification)>) 43: $33 "ema#label" := Call __i2idn (<constant (http://www.w3.org/2000/01/rdf-schema#label)>) 48: $34 "callret" := Call DB.DBA.RDF_MAKE_IID_OF_QNAME (<constant (http://msone.computas.no/graphs/ontology/mediasone)>) 55: $35 "ema#subClassOf" := Call __i2idn (<constant (http://www.w3.org/2000/01/rdf-schema#subClassOf)>) 60: $36 "ogi#Aktoer" := Call __i2idn (<constant (http://www.computas.com/mediasone-ontologi#Aktoer)>) 65: $37 "callret" := Call DB.DBA.RDF_MAKE_IID_OF_QNAME (<constant (http://www.w3.org/2000/01/rdf-schema#label)>) 72: $38 "callret" := Call vector (<constant (1)>, <constant (0)>, <constant (3)>, $37 "callret", <constant (1)>, <constant (1)>) 77: $39 "callret" := Call DB.DBA.RDF_MAKE_IID_OF_QNAME (<constant (http://www.w3.org/1999/02/22-rdf-syntax-ns#type)>) 84: $40 "callret" := Call DB.DBA.RDF_MAKE_IID_OF_QNAME (<constant (http://www.w3.org/2002/07/owl#Class)>) 91: $41 "callret" := Call vector (<constant (1)>, <constant (0)>, <constant (3)>, $39 "callret", <constant (3)>, $40 "callret") 96: $42 "callret" := Call vector ($38 "callret", $41 "callret") 101: $43 "callret" := Call vector () 106: BReturn 0 Subquery { Subquery { Union { Subquery { Union { Subquery { Union { in iterates $60 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.46 rows Key RDF_QUAD_OGPS ASC ($63 "s-1-6-t12.S") <col=523 O = $28 "phs#OntoGraph"> , <col=520 G = $60 "in_iter"> , <col=522 P = $27 "-ns#type"> , <col=521 S < $26 "callret"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$65 "<DB.DBA.RDF_QUAD s-1-6-t12>" spec 5> in iterates $68 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($71 "s-1-7-t2-c5.S") <col=523 O = $36 "ogi#Aktoer"> , <col=520 G = $68 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$73 "<DB.DBA.RDF_QUAD s-1-7-t2-c5>" spec 5> from DB.DBA.RDF_QUAD by RDF_QUAD 0.6 rows Key RDF_QUAD ASC ($77 "s-1-42-t13.O", $76 "s-1-42-t13.S", $75 "s-1-42-t13.G") inlined <col=520 G = $63 "s-1-6-t12.S"> , <col=521 S = $71 "s-1-7-t2-c5.S"> , <col=522 P = $33 "ema#label"> Current of: <$79 "<DB.DBA.RDF_QUAD s-1-42-t13>" spec 5> After test: 0: $80 "callret" := Call one_of_these ($75 "s-1-42-t13.G", $30 "callret", $34 "callret", $32 "callret") 5: if (<constant (0)> 2(<) $80 "callret") then 9 else 24 unkn 24 9: $81 "callret" := Call __ro2sq ($77 "s-1-42-t13.O") 14: $82 "callret" := Call rdf_regex_impl ($81 "callret", <constant (STR)>, <constant (i)>) 19: if (<constant (0)> 1(=) $82 "callret") then 24 else 23 unkn 24 23: BReturn 1 24: BReturn 0 After code: 0: $55 "title" := := artm $77 "s-1-42-t13.O" 4: $56 "class" := := artm $76 "s-1-42-t13.S" 8: BReturn 0 Subquery Select($55 "title", $56 "class", <$79 "<DB.DBA.RDF_QUAD s-1-42-t13>" spec 5>, <$73 "<DB.DBA.RDF_QUAD s-1-7-t2-c5>" spec 5>, <$65 "<DB.DBA.RDF_QUAD s-1-6-t12>" spec 5>) } { in iterates $91 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.46 rows Key RDF_QUAD_OGPS ASC ($94 "s-1-6-t12.S") <col=523 O = $28 "phs#OntoGraph"> , <col=520 G = $91 "in_iter"> , <col=522 P = $27 "-ns#type"> , <col=521 S < $26 "callret"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$96 "<DB.DBA.RDF_QUAD s-1-6-t12>" spec 5> in iterates $99 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($102 "s-1-11-t3-c11.S") <col=523 O = $36 "ogi#Aktoer"> , <col=520 G = $99 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$104 "<DB.DBA.RDF_QUAD s-1-11-t3-c11>" spec 5> in iterates $107 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($110 "s-1-11-t4-c11.S") <col=523 O = $102 "s-1-11-t3-c11.S"> , <col=520 G = $107 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$112 "<DB.DBA.RDF_QUAD s-1-11-t4-c11>" spec 5> from DB.DBA.RDF_QUAD by RDF_QUAD 0.6 rows Key RDF_QUAD ASC ($116 "s-1-42-t13.O", $115 "s-1-42-t13.S", $114 "s-1-42-t13.G") inlined <col=520 G = $94 "s-1-6-t12.S"> , <col=521 S = $110 "s-1-11-t4-c11.S"> , <col=522 P = $33 "ema#label"> Current of: <$118 "<DB.DBA.RDF_QUAD s-1-42-t13>" spec 5> After test: 0: $119 "callret" := Call one_of_these ($114 "s-1-42-t13.G", $30 "callret", $34 "callret", $32 "callret") 5: if (<constant (0)> 2(<) $119 "callret") then 9 else 24 unkn 24 9: $120 "callret" := Call __ro2sq ($116 "s-1-42-t13.O") 14: $121 "callret" := Call rdf_regex_impl ($120 "callret", <constant (STR)>, <constant (i)>) 19: if (<constant (0)> 1(=) $121 "callret") then 24 else 23 unkn 24 23: BReturn 1 24: BReturn 0 After code: 0: $55 "title" := := artm $116 "s-1-42-t13.O" 4: $56 "class" := := artm $115 "s-1-42-t13.S" 8: BReturn 0 Subquery Select($55 "title", $56 "class", <$79 "<DB.DBA.RDF_QUAD s-1-42-t13>" spec 5>, <$73 "<DB.DBA.RDF_QUAD s-1-7-t2-c5>" spec 5>, <$65 "<DB.DBA.RDF_QUAD s-1-6-t12>" spec 5>) } } After code: 0: $51 "title" := := artm $55 "title" 4: $52 "class" := := artm $56 "class" 8: BReturn 0 Subquery Select($51 "title", $52 "class") } { in iterates $137 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.46 rows Key RDF_QUAD_OGPS ASC ($140 "s-1-6-t12.S") <col=523 O = $28 "phs#OntoGraph"> , <col=520 G = $137 "in_iter"> , <col=522 P = $27 "-ns#type"> , <col=521 S < $26 "callret"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$142 "<DB.DBA.RDF_QUAD s-1-6-t12>" spec 5> in iterates $145 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($148 "s-1-18-t5-c17.S") <col=523 O = $36 "ogi#Aktoer"> , <col=520 G = $145 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$150 "<DB.DBA.RDF_QUAD s-1-18-t5-c17>" spec 5> in iterates $153 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($156 "s-1-18-t6-c17.S") <col=523 O = $148 "s-1-18-t5-c17.S"> , <col=520 G = $153 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$158 "<DB.DBA.RDF_QUAD s-1-18-t6-c17>" spec 5> in iterates $161 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($164 "s-1-18-t7-c17.S") <col=523 O = $156 "s-1-18-t6-c17.S"> , <col=520 G = $161 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$166 "<DB.DBA.RDF_QUAD s-1-18-t7-c17>" spec 5> from DB.DBA.RDF_QUAD by RDF_QUAD 0.6 rows Key RDF_QUAD ASC ($170 "s-1-42-t13.O", $169 "s-1-42-t13.S", $168 "s-1-42-t13.G") inlined <col=520 G = $140 "s-1-6-t12.S"> , <col=521 S = $164 "s-1-18-t7-c17.S"> , <col=522 P = $33 "ema#label"> Current of: <$172 "<DB.DBA.RDF_QUAD s-1-42-t13>" spec 5> After test: 0: $173 "callret" := Call one_of_these ($168 "s-1-42-t13.G", $30 "callret", $34 "callret", $32 "callret") 5: if (<constant (0)> 2(<) $173 "callret") then 9 else 24 unkn 24 9: $174 "callret" := Call __ro2sq ($170 "s-1-42-t13.O") 14: $175 "callret" := Call rdf_regex_impl ($174 "callret", <constant (STR)>, <constant (i)>) 19: if (<constant (0)> 1(=) $175 "callret") then 24 else 23 unkn 24 23: BReturn 1 24: BReturn 0 After code: 0: $51 "title" := := artm $170 "s-1-42-t13.O" 4: $52 "class" := := artm $169 "s-1-42-t13.S" 8: BReturn 0 Subquery Select($51 "title", $52 "class") } } After code: 0: $47 "title" := := artm $51 "title" 4: $48 "class" := := artm $52 "class" 8: BReturn 0 Subquery Select($47 "title", $48 "class") } { in iterates $191 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.46 rows Key RDF_QUAD_OGPS ASC ($194 "s-1-6-t12.S") <col=523 O = $28 "phs#OntoGraph"> , <col=520 G = $191 "in_iter"> , <col=522 P = $27 "-ns#type"> , <col=521 S < $26 "callret"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$196 "<DB.DBA.RDF_QUAD s-1-6-t12>" spec 5> in iterates $199 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($202 "s-1-28-t8.S") <col=523 O = $36 "ogi#Aktoer"> , <col=520 G = $199 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$204 "<DB.DBA.RDF_QUAD s-1-28-t8>" spec 5> in iterates $207 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($210 "s-1-28-t9.S") <col=523 O = $202 "s-1-28-t8.S"> , <col=520 G = $207 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$212 "<DB.DBA.RDF_QUAD s-1-28-t9>" spec 5> in iterates $215 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($218 "s-1-28-t10.S") <col=523 O = $210 "s-1-28-t9.S"> , <col=520 G = $215 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$220 "<DB.DBA.RDF_QUAD s-1-28-t10>" spec 5> in iterates $223 "in_iter" over ($29 "callret", $30 "callret", $31 "callret", $32 "callret") from DB.DBA.RDF_QUAD by RDF_QUAD_OGPS 0.87 rows Key RDF_QUAD_OGPS ASC ($226 "s-1-28-t11.S") <col=523 O = $218 "s-1-28-t10.S"> , <col=520 G = $223 "in_iter"> , <col=522 P = $35 "ema#subClassOf"> row specs: <col=523 O LIKE <constant (T�)>> Current of: <$228 "<DB.DBA.RDF_QUAD s-1-28-t11>" spec 5> from DB.DBA.RDF_QUAD by RDF_QUAD 0.6 rows Key RDF_QUAD ASC ($232 "s-1-42-t13.O", $231 "s-1-42-t13.S", $230 "s-1-42-t13.G") inlined <col=520 G = $194 "s-1-6-t12.S"> , <col=521 S = $226 "s-1-28-t11.S"> , <col=522 P = $33 "ema#label"> Current of: <$234 "<DB.DBA.RDF_QUAD s-1-42-t13>" spec 5> After test: 0: $235 "callret" := Call one_of_these ($230 "s-1-42-t13.G", $30 "callret", $34 "callret", $32 "callret") 5: if (<constant (0)> 2(<) $235 "callret") then 9 else 24 unkn 24 9: $236 "callret" := Call __ro2sq ($232 "s-1-42-t13.O") 14: $237 "callret" := Call rdf_regex_impl ($236 "callret", <constant (STR)>, <constant (i)>) 19: if (<constant (0)> 1(=) $237 "callret") then 24 else 23 unkn 24 23: BReturn 1 24: BReturn 0 After code: 0: $47 "title" := := artm $232 "s-1-42-t13.O" 4: $48 "class" := := artm $231 "s-1-42-t13.S" 8: BReturn 0 Subquery Select($47 "title", $48 "class") } } skip node After code: 0: $245 "callret" := Call __ro2lo ($47 "title") 5: $246 "callret" := Call vector ($48 "class", $245 "callret") 10: $45 "ctor-1" := := artm $246 "callret" 14: BReturn 0 Subquery Select(TOP <constant (18)>) ($45 "ctor-1") } After code: 0: if ($258 "user_aggr_notfirst" 1(=) <constant (1)>) then 15 else 4 unkn 4 4: $258 "user_aggr_notfirst" := := artm <constant (1)> 8: $260 "user_aggr_ret" := Call DB.DBA.SPARQL_CONSTRUCT_INIT ($259 "user_aggr_env") 15: $260 "user_aggr_ret" := Call DB.DBA.SPARQL_CONSTRUCT_ACC ($259 "user_aggr_env", $42 "callret", $45 "ctor-1", $43 "callret", <constant (1)>) 22: BReturn 0 } After code: 0: $261 "callret" := Call DB.DBA.SPARQL_CONSTRUCT_FIN ($259 "user_aggr_env") 7: $262 "callret-0" := Call DB.DBA.RDF_FORMAT_TRIPLE_DICT_AS_TTL ($261 "callret") 14: BReturn 0 Select (TOP <constant (1)>) ($262 "callret-0") } 282 Rows. -- 367 msec. Kind regards Kjetil Kjernsmo -- Senior Knowledge Engineer Mobile: +47 986 48 234 Email: kjetil.kjern...@computas.com Web: http://www.computas.com/ | SHARE YOUR KNOWLEDGE | Computas AS PO Box 482, N-1327 Lysaker | Phone:+47 6783 1000 | Fax:+47 6783 1001