How do I limit the number of results for a specific variable in a SPARQL query?
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.