One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
CCra
6 years agoExplorer | Level 4
Documentation for searchV2(String query) how to type a query ?
I have been using older dropboxapiv2 (java) to search "Files" for 2 years. Today it started to malfunction due to a dropbox server side "malformed query" error. While I assume it is again a Dropbox development malfunction, I also would like to upgrade the dropboxapiv2 I am using to version 3.1.3 . It seems there is now a search method searchV2(String query) ,but I could not find any documentation about how to write a search query for dropbox search in api.
Can anybody help ?
with errors below is my code for, now deprecated, search method
public List<SearchMatch> findFile(String code) { try { SearchResult sr = dbxClient.files().search("/drawings/",code); List<SearchMatch> sm = sr.getMatches(); List<SearchMatch> rmlist = new ArrayList<SearchMatch>(); for (SearchMatch searchMatch : sm) { if (!fileMidir(searchMatch.getMetadata())) { rmlist.add(searchMatch); } } for (SearchMatch searchMatch : rmlist) { sm.remove(searchMatch); } return sm; } catch (DbxException e) { e.printStackTrace(); } return null; } public boolean fileMidir(Metadata metadata){ if (metadata instanceof FolderMetadata) { return false; }else { return true; } }
To use the new search method in the Java SDK, you can start by supplying your "query", which is the string you want to search for, to the searchV2Builder method to get a SearchV2Builder.
Then you can use the SearchV2Builder.withOptions method to add other optional settings, such as the path to search in, by passing it a SearchOptions object.
Then you can use SearchV2Builder.start to perform the search.
- CCraExplorer | Level 4
BTW, the error is old path name for search "/drawings/" now should be "/drawings". If anybody can help me with searchV2 -how to write a query- (for path specifying and other options), I would appreciate it very much.
- Greg-DB
Dropbox Staff
To use the new search method in the Java SDK, you can start by supplying your "query", which is the string you want to search for, to the searchV2Builder method to get a SearchV2Builder.
Then you can use the SearchV2Builder.withOptions method to add other optional settings, such as the path to search in, by passing it a SearchOptions object.
Then you can use SearchV2Builder.start to perform the search.
- CCraExplorer | Level 4
Thanks Greg. It did the trick.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,949 PostsLatest Activity: 3 hours ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!