Let's say I have a SPARQL query like this, looking for resources that have some shared property with a focal resource, and also getting some other statements about the focal resource :
CONSTRUCT {
?focal pred:icate ?shared .
?other pred:icate ?shared .
}
WHERE {
?focal pred:icate ?shared ;
more:info ?etc ;
a "foobar" .
?other pred:icate ?shared .
}
LIMIT 500
If there are more than 500 other resources, that LIMIT
might exclude that more:info
statement and object. So, is there a way to say "I only want at most 500 of ?other
", or do I have to break this query into multiple pieces?
You can use LIMIT
in subqueries, i.e. something like the following:
CONSTRUCT {
?focal pred:icate ?shared .
?other pred:icate ?shared .
}
WHERE {
?focal pred:icate ?shared ;
more:info ?etc ;
a "foobar" .
{
SELECT ?shared {
?other pred:icate ?shared .
}
LIMIT 500
}
}
http://www.w3.org/TR/2012/WD-sparql11-query-20120105/#modResultLimit
The LIMIT clause puts an upper bound on the number of solutions returned. If the number of actual solutions, after OFFSET is applied, is greater than the limit, then at most the limit number of solutions will be returned.
You can only limit the number of solutions to your query, not a specific subset of it. You can use a subquery with a LIMIT
clause though: http://www.w3.org/TR/sparql-features/#Subqueries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With