Skip to content

No Offset Based Pagination in Search #187

@vroommm

Description

@vroommm

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/

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

  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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions