Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 2.08 KB

search.md

File metadata and controls

52 lines (39 loc) · 2.08 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);