question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No Offset Based Pagination in Search

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sujaygarlankacommented, Apr 13, 2020

Thank you @ianhorn for the answer. @vroommm We will create a ticket on our backlog to allow a user to specify the RESULTS_LIMIT.

2reactions
ianhorncommented, Apr 13, 2020

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

'use strict';

const BoxCommand = require('../box-command');
const { flags } = require('@oclif/command');
const _ = require('lodash');
const BoxCLIError = require('../cli-error');

const RESULTS_LIMIT = 5000;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Offset-based pagination - Apollo GraphQL Docs
This is a non-paginated read function. Using with a paginated read function. In the example above, the GraphQL server returns individual pages of...
Read more >
Is offset pagination dead? Why cursor pagination is taking over
“Cursor-based pagination is the most efficient method of paging and should ... An offset is simply the number of records the database should...
Read more >
Offset-based Pagination - Box Developer Documentation
Offset -based Pagination. APIs that use offset-based paging use the offset and limit query parameters to paginate through items in a collection.
Read more >
A Comparison Between Cursor and Offset Pagination | by Kasra
Offset -based pagination is easy to use and is preferred for static data. ... An offset is the number of records that the...
Read more >
Is there any better option to apply pagination without applying ...
See also use-the-index-luke.com/no-offset, it's called Keyset Pagination. – Charlieface. Dec 29, 2021 at 13:47.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found