Open srosset81 opened 4 years ago
Implementation note:
A subset query should work better for pagination:
CONSTRUCT { ?s ?p ?o }
WHERE {
{ SELECT ?s WHERE { ?s a <http://dbpedia.org/ontology/MusicalArtist> } LIMIT 50 }
?s ?p ?o
}
If you put the LIMIT directly in the main query, it won't work because it stops after 50 triplets.
Reading the specs, I conclude that LDP pagination is optional, so as not to impact clients who don't understand this standard.
If you do a GET on a container like this:
GET /projects HTTP/1.1
Host: example.org
Prefer: return=representation; max-member-count=“10”
In the documentation they use
max-triple-count
by default, but it seems complicated to use.
The server must return a 303 with the URL to the first page (which can be formatted as you like):
HTTP/1.1 303 See Other
Location: <http://example.org/projects?page=1>
If we then fetch page 1, always indicating the max-member-count
(so that the server knows how many elements there should be on this first page):
GET /projects?page=1 HTTP/1.1
Host: example.org
Prefer: return=representation; max-member-count=“10”
In the response header, we indicate that this is a ldp:Page. There's also a link to the following page:
HTTP/1.1 200 OK
Link: <http://www.w3.org/ns/ldp#Resource>; rel=“type”,
<http://www.w3.org/ns/ldp#Page>; rel=“type”
Link: <http://example.org/projects?page=2>; rel=“next”
... the data
You can also optionally use rel “first”, “prev” and “last” (see https://www.w3.org/TR/ldp-paging/#ldpp-ex-paging-other-links).
All in all, it doesn't look too complicated, and has the advantage of being optional and flexible (you can choose the number of elements to return per page). The main difficulty will be to make an efficient SPARQL query.
Specs: https://www.w3.org/TR/ldp-paging/