Discuss Dropbox Developer & API
I have an android app and I am having mp3 files in my dropbox and i am using search bar to type their name and get them using:
sresult = client.files().searchBuilder(path2, query2).withMode(mode).withMaxResults(max).withStart(stat).start();
Above feature is fulfilled but now i am having .txt files and i want to get text from those text files as i type a keyword in search bar. I used the above code for this feature but it gives me the exception:
class com.dropbox.core.v2.files.searcherrorexception exception in 2/files/search: {".tag":"path","path":"not_found"}
Is it possible to do this in my app?
Yes, the Dropbox API does offer the ability to search for a particular query in a particular file type under a particular path. I see you're using searchBuilder though, which is deprecated, so you should update to searchV2Builder instead. The SearchV2Builder documentation shows what methods/parameters you can use.
A 'not_found' error like you're getting indicates that there's nothing at the specified path, so make sure you're supplying a correct path value, in your code 'path2', for the connected account. I recommend reading the File Access Guide for information on interacting with the Dropbox filesystem via the API.
I tried using this code:
SearchV2Builder searchBuilder = client.files().searchV2Builder(query);
List<String> fileExtensions = Arrays.asList(extensions);
SearchOptions searchOptions = SearchOptions.newBuilder().withFileExtensions(fileExtensions).build();
SearchV2Result searchResult = searchBuilder.withOptions(searchOptions).start();
List<SearchMatchV2> searchMatches = searchResult.getMatches();
but it only searches for text file name and not for the content placed inside it. Suppose i have a word "hello" placed inside my text file named "documents" so if i starts typing "he" then the word "hello" should appear in searches from "documents" file. Is the possible as i am having different text files and that should search in all of the text files before giving me the result
It sounds like you're looking for the feature called "full-text search". That's only available to accounts with certain Dropbox plans. Please refer to the help center article for more information.
Hi there!
If you need more help you can view your support options (expected response time for a 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!