- From: Tomasz Pluskiewicz <tomasz@t-code.pl>
- Date: Sat, 14 Nov 2015 19:03:56 +0100
- To: public-hydra@w3.org
On 2015-11-14 18:25, Maik Riechert wrote: > Hi all, > > I was thinking about paged collections a bit and have a question > regarding "totalItems" in combination with filtering a collection. > > Imagine /users has 10000 user items. You can filter via /users?name=Bob > which would match 50 user items. Let's assume I use paged collections > with 10 items per page. Then the filtered query above would result in 5 > pages from /users?name=Bob&p=1 to /users?name=Bob&p=5. If I understood > Hydra's collection design right, then a page would roughly look like: > > GET /users?name=Bob&p=1 > { > "@id": "/users", > "@type": "Collection", > "member": [ ...10 Bob items... ], > "totalItems": 10000, > "view": { > "@id": "/users?name=Bob&p=1", > "@type": "PartialCollectionView", > "first": "/users?name=Bob&p=1", > "next": "/users?name=Bob&p=2", > "last": "/users?name=Bob&p=5" > } > } > > 1) Is it correct to have /users as @id instead of /users?name=Bob? > It is an interesting question. I would automatically assume that you are browsing a filtered collection and so my choice would be /users?name=Bob. However, come think of it, the former does makes sense too. Both are identifier of a "real", existing resource after all. Hence both choices are correct IMO. > > 2) Is it correct that "totalItems" is the total number of items of the > /users collection, not regarding any filters? > Now this would depend on what you choose in 1). If you were to use /users?name=Bob as you @id, then 50 would be the totalItems value and 10000 otherwise. In the end it means "total items of the collection identified by @id". > If both answers are yes: Where does the total number of items for the > filtered query (50 here) go? As above, I don't think it goes anywhere when you use "unfiltered" @id. > Similarly, does /users?name=Bob go anywhere? I would turn this around. Where does /users when the @id is /users?name=Bob? How about sth like that GET /users?name=Bob&p=1 { "@id": "/users?name=Bob", "partOf": "/users" "@type": "Collection", "member": [ ...10 Bob items... ], "totalItems": 50, "view": { .. the page links ... } } My idea would be to always use the parametrized @id (so that you can bookmark it) and add a link to the unfiltered collection, here "partOf" as an example.
Received on Saturday, 14 November 2015 18:04:35 UTC