You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

sbrownnw's avatar
sbrownnw
Explorer | Level 4
2 years ago

SearchV2Async returning inconsistent results

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:

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

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"

  • Greg-DB's avatar
    Greg-DB
    2 years ago

    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's avatar
    sbrownnw
    Explorer | Level 4

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

     

    • sbrownnw's avatar
      sbrownnw
      Explorer | Level 4

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

      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's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        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.