No Offset Based Pagination in Search
See original GitHub issueDescription 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/
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/
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
- Run a search on an area with more than 100 items in the folder hierarchy as reported by the box API.
- You can only ever get the top 100 results…
Error Message, Including Stack Trace
N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (4 by maintainers)
Top GitHub Comments
Thank you @ianhorn for the answer. @vroommm We will create a ticket on our backlog to allow a user to specify the
RESULTS_LIMIT
.I ran into the same issue where I needed more than 100 results. I modified the search.js file max results to 2500 or 5000.The search takes a little longer, but I get all the results I need.
Location on a PC
C:\Program Files\@boxcli\client\src\commands\users\search.js