Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
6 contributors

Users who have contributed to this file

@gcurtis @mattwiller @LouisWayne @carycheng @iamharish @cbetta
53 lines (39 sloc) 2.09 KB

Search

Different examples of search which have been implemented in the example SearchExamplesAsAppUser.java

For more information refer to the Search API documentation.

Search

A search can be performed in your Box instance with specified starting position with searchRange(long offset, long limit, BoxSearchParameters queryParams)

You can use the limit and offset parameters to page through the search results.

// Find the first 10 files matching "taxes"
long offsetValue = 0;
long limitValue = 10;
BoxSearch boxSearch = new BoxSearch(api);
BoxSearchParameters searchParams = new BoxSearchParameters();
searchParams.setQuery("taxes");
searchParams.setType("file");
PartialCollection<BoxItem.Info> searchResults = boxSearch.searchRange(offsetValue, limitValue, searchParams);

You can also sort the search results with the sort and direction flags passed into BoxSearch. This allows for the order of items returned to be maintained. The sort field can only be set to modified_at currently. For direction you can specify either DESC for descending order or ASC for ascending order to sort the results.

long offsetValue = 0;
long limitValue = 10;
BoxSearch boxSearch = new BoxSearch(api);
BoxSearchParameters searchParams = new BoxSearchParameters();
searchParams.setQuery("taxes");
searchParams.setSort("modified_at");
searchParams.setDirection("DESC");
PartialCollection<BoxItem.Info> searchResults = boxSearch.searchRange(offsetValue, limitValue, searchParams);
You can’t perform that action at this time.