Forum Discussion

johndoe5's avatar
johndoe5
Explorer | Level 3
5 years ago
Solved

search_v2: has_more=true even though there're no more results

I have a directory a, with one sub directory, which contains another subdirectory. Each directory contains an image file with a ".jpg" extension (so three images in total).

When I create a search query for ".jpg" inside the folder a with max_results=3, I get a response with exactly three results. But has_more equals true. When I use the returned cursor in a request to /files/search/continue_v2, an empty result is returned with has_more=false.

I would expect the API to return has_more=false on the very first request, since there are no more results.

When I change the max_results parameter of the initial search request to 4, the response contains all (three) results and has_more=false.

Is this behaviour intended?

  • Hi johndoe5,

    Since Dropbox API is asynchronous, if not explicitly pointed out something else for particular call, you can't rely on any particular result. Any possible result, described in documentation, is... possible! So you must not assume anything, but strictly follow the API description. At the point, you have described, possibly there wasn't enough time to ongoing procedure gets to the end and it assumes there are other entries (even though there are not). That's it.

    Hope this clarifies matter.

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Hi johndoe5,

    Since Dropbox API is asynchronous, if not explicitly pointed out something else for particular call, you can't rely on any particular result. Any possible result, described in documentation, is... possible! So you must not assume anything, but strictly follow the API description. At the point, you have described, possibly there wasn't enough time to ongoing procedure gets to the end and it assumes there are other entries (even though there are not). That's it.

    Hope this clarifies matter.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    johndoe5 Здравко is correct, the page size of a result from /2/files/search_v2 and /2/files/search/continue_v2 is not guaranteed, and may be empty in some cases like this, due to how the Dropbox search functionality works. Your app should be written to call back if 'has_more' is true, but be able to handle empty 'matches' lists.