totalItems with pagination and filtering

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?

2) Is it correct that "totalItems" is the total number of items of the 
/users collection, not regarding any filters?

If both answers are yes: Where does the total number of items for the 
filtered query (50 here) go? Similarly, does /users?name=Bob go anywhere?

Cheers
Maik

Received on Saturday, 14 November 2015 17:25:37 UTC