As with all the v1 ReST APIs paging can also be controlled, it’s just done via the body rather than a query parameter. The results can also be sorted. The example body below shows how to execute a search to find all files ordered by the cm:name property, only show 25 results rather than the default of 100 and skip the first 10 results:
{ "query": { "query": "+TYPE:\"cm:content\"", "language": "afts" }, "paging": { "maxItems": "25", "skipCount": "10" }, "sort": [{"type":"FIELD", "field":"cm:name", "ascending":"false"}] }
This also shows how you can search for a specific content type with the TYPE keyword.
Here is how the call looks like, assuming that we have stored the query JSON data in a file called paging-sort-query.json:
$ curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' --header 'Authorization: Basic VElDS0VUXzIxYzAzOWMxNjFjYzljMDNmNmNlMzAwYzAyMDY5YTQ2OTQwZmYzZmM=' --data-binary '@paging-sort-query.json' 'http://localhost:8080/alfresco/api/-default-/public/search/versions/1/search' | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 13836 0 13622 100 214 31387 493 --:--:-- --:--:-- --:--:-- 31880 { "list": { "pagination": { "count": 25, "hasMoreItems": true, "skipCount": 10, "maxItems": 25 }, "entries": [ { "entry": { "name": "WebSiteReview.mp4", ... } }, { "entry": { "name": "turbine.JPG", ... } }, { "entry": { "name": "translatable.ftl", ... } }, { "entry": { "name": "text-file.txt", ... } }, { "name": "test return value.js.sample", ... } }, { "entry": { "name": "test-file.txt", ... } }, { "name": "system-overview.html", ... } }, { "entry": { "name": "start-pooled-review-workflow.js", ... } }, { "entry": { "name": "some-stuff.txt", ... } }, { "entry": { "name": "somefile.txt", ... } }, ... ] } }
The result have been truncated a bit here for clarity.