Closed namedgraph closed 9 years ago
the difference is inherent in the way the respective query is to be interpreted. in the form which involves a binding for ?this, the second clause in the union lacks that dimension. as a consequence, where '?this' is not bound, the construct operation suppresses the intended
?this <http://graphity.org/gpl#count> ?count .
pattern.
I think I get it. Works with a join instead of UNION:
CONSTRUCT { ?this ?p ?o . ?this http://graphity.org/gpl#count ?count . } { { GRAPH ?graph { ?this ?p ?o . FILTER (?this = http://localhost:8080/ref-stock/products) } . { SELECT ((COUNT(DISTINCT ?doc)) AS ?count) WHERE { GRAPH ?childGraph { ?doc http://xmlns.com/foaf/0.1/primaryTopic ?product . ?product http://purl.org/goodrelations/v1#name ?name . } . } } . } }
On Tue, Apr 28, 2015 at 10:07 AM, james anderson notifications@github.com wrote:
the difference is inherent in the way the respective query is to be interpreted. in the form which involves a binding for ?this, the second clause in the union lacks that dimension. as a consequence, where '?this' is not bound, the construct operation suppresses the intended
?this http://graphity.org/gpl#count ?count .
pattern.
— Reply to this email directly or view it on GitHub https://github.com/dydra/support/issues/23#issuecomment-96967901.
yes, but that will add the count value to each of the results from the graph clause. you need have the two clauses share a ?this binding.
in any event, for such a small solution field, the effect is innocuous and the construct will suppress the duplicates.
curl -X POST -d @construct-count-bound.rq -H "Content-Type: application/sparql-query" -H "Accept: application/n-triples" "http://graphity.dydra.com/graphity/refrigeration-stock-test/sparql"
Returns 11 triples.versus
curl -X POST -d @construct-count.rq -H "Content-Type: application/sparql-query" -H "Accept: application/n-triples" "http://graphity.dydra.com/graphity/refrigeration-stock-test/sparql?%24this=%3Chttp%3A%2F%2Flocalhost%3A8080%2Fref-stock%2Fproducts%3E"
Returns 10 triples.The following triple is missing:
<http://localhost:8080/ref-stock/products> <http://graphity.org/gpl#count> "801"^^<http://www.w3.org/2001/XMLSchema#integer> .
construct-count-bound.rq
:construct-count.rq
: