box / box/boxcli

No Offset Based Pagination in Search

Open
#187 18 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
284
Forks
67
Avg merge
6h 45m
Merged PRs (30d)
4

Description

### Description of the Issue
There doesn't seem to be a way to use Offset based pagination with the box search command
[https://developer.box.com/guides/api-calls/pagination/offset-based/](https://developer.box.com/guides/api-calls/pagination/offset-based/)

Instead there is a hard limit on the size of the search Result defined as 100. This is smaller than the max results size in the REST API which is 200 results.
[https://developer.box.com/reference/get-search/](https://developer.box.com/reference/get-search/)

The limitation is significant because search is the only method I have found to recurse over a folder structure and get all items matching a pattern in one step for example... find me all the pdfs in my folders under a given start folder..

* it would be better if the search method applied the max and limits something like, .e.g
```
const RESULTS_LIMIT = 100;
cons MAX_RESULTS_LIMIT=200;
... and then later...
class SearchCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(SearchCommand);
let options = {}
if (flags.limit) {
options.limit= (MAX_RESULTS_LIMIT< flags.limit ? MAX_RESULTS_LIMIT: flags.limit);
} else {
options.limit= RESULTS_LIMIT;
}
if (flags.offset) {
options.offset= flags.offset;
}

```
(deep apologies if the code is pants I'm no expert!!!)

* there is no method to pass an offset to get a specific set of results.

* there is no way to get `total_count` the absolute result set size as per the docs

Maybe the best option here is to wrap all of this into the search options interface so we can have

`box search abc` would fetch the first 100 records as it does now...
`box search:total_count --limit=200` would fetch back the total number of pages if the limit is 200 per page
`box search abc* --limit=200 --offset=2 ` fetches 200 entries from the 3rd page of the collection

### Versions Used
Box CLI: @box/cli/2.4.0 win32-x64 node-v12.6.0
Operating System: Windows 10

### Steps to Reproduce
1. Run a search on an area with more than 100 items in the folder hierarchy as reported by the box API.
2. You can only ever get the top 100 results..

### Error Message, Including Stack Trace
N/A

[cli-docs]: https://github.com/box/boxcli#command-topics
[api-docs]: https://developer.box.com/docs

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.