cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Discuss Dropbox Developer & API

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

SearchV2Async returning inconsistent results

SearchV2Async returning inconsistent results

sbrownnw
Explorer | Level 4
Go to solution

given the following code:

namespace Dropbox
{
   internal class Program
   {
      static void Main(string[] args)
      {
         DropboxClientConfig config = new DropboxClientConfig
         {
            MaxRetriesOnError = 0
         };
         DropboxClient dropboxClient = new DropboxClient(AccessToken.ValidToken, config);

         SearchOptions searchOptions = new SearchOptions("", fileStatus: FileStatus.Active.Instance, filenameOnly: true, fileExtensions: new List<string> { "txt"});
         SearchV2Arg searchV2Arg = new SearchV2Arg("test", options: searchOptions);

         var result = dropboxClient.Files.SearchV2Async(searchV2Arg).Result;
         List<string> filePaths = new List<string>();

         foreach (SearchMatchV2 match in result.Matches)
         {
            filePaths.Add(match.Metadata.AsMetadata.Value.PathLower);
         }
      }
   }
}

if I run it, it shows the following results:

sbrownnw_0-1686613411436.png

if I change the query value to "this" at line 19 and I run it, I get:

sbrownnw_1-1686613507574.png

Note, the filePaths list is empty.  I would expect the two following file paths to be found (subset from the original 9 above):

"/this is a test.txt"

"/test 2/this is a test.txt"

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

The Dropbox search backend may apply some tokenization and rewriting to queries, e.g., to try to handle typos, exclude potentially extraneous results, include potentially relevant results, etc. That being the case, you won't always see only exact matches. For instance, for the cases you have shown here, it may remove stop words like "this", and include results for potentially correcting typos or related tokens, such as "text" for "txt".

 

I'll pass this along as requests to specifically document these behaviors for the API endpoint, as well as the ability to do strict matching searches, but I can't promise if/when these might be done.

View solution in original post

5 Replies 5

sbrownnw
Explorer | Level 4
Go to solution

note, if I remove the fileExtensions filter arg, I still get no results searching for "test":

sbrownnw_0-1686613912288.png

 

sbrownnw
Explorer | Level 4
Go to solution

and when I change the query value to "txt", I get the following:

sbrownnw_0-1686615411140.png

I would expect every file expect the last one "/new rich text format.rtf" to be returned.  Why is the .rtf file being returned with this query?

Greg-DB
Dropbox Staff
Go to solution

The Dropbox search backend may apply some tokenization and rewriting to queries, e.g., to try to handle typos, exclude potentially extraneous results, include potentially relevant results, etc. That being the case, you won't always see only exact matches. For instance, for the cases you have shown here, it may remove stop words like "this", and include results for potentially correcting typos or related tokens, such as "text" for "txt".

 

I'll pass this along as requests to specifically document these behaviors for the API endpoint, as well as the ability to do strict matching searches, but I can't promise if/when these might be done.

sbrownnw
Explorer | Level 4
Go to solution

a list of the stop words would be appreciated also.

Greg-DB
Dropbox Staff
Go to solution

Thanks for the note, I'll add that to the request as well.

Need more support?
Who's talking

Top contributors to this post

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