cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Documentation for searchV2(String query) how to type a query ?

Documentation for searchV2(String query) how to type a query ?

CCra
Explorer | Level 4
Go to solution

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;
	}
}

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

3 Replies 3

CCra
Explorer | Level 4
Go to solution

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
Go to solution

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.

CCra
Explorer | Level 4
Go to solution

Thanks Greg. It did the trick.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    CCra Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?