cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Discuss Dropbox Developer & API

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

Search text in Text File

Search text in Text File

qazimuneeb1
Explorer | Level 3

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?

3 Replies 3

Greg-DB
Dropbox Staff

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.

qazimuneeb1
Explorer | Level 3

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  

Greg-DB
Dropbox Staff

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.

Need more support?
Who's talking

Top contributors to this post

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