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

BPCABA's avatar
BPCABA
Explorer | Level 3
3 years ago

Re: Dropbox search may not be working as expected

Greg,

 

It appears that basic search is now working - however #tags are not working as expected. 

When I search for 2 tags it automatically searches as an or function - #tag1 or #tag2. Is there a way to only search for files containing both #tag1 and #tag2? 

 

Thank you

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The Dropbox API search functionality doesn't have a parameter to control that behavior, nor documentation or a guarantee on the specific expected behavior for that. However in my testing it does currently seem to behave as you want, that is, when specifying multiple tags in the "query", it is returning only files that contain both tags for me.

     

    Here's an example of what I'm seeing:

    curl -X POST https://api.dropboxapi.com/2/files/search_v2 \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/json' \
      --data '{"query":"#banana","options":{"path":"/files with tags"}}'
    
    # {
    #   "has_more": false,
    #   "matches": [
    #     {
    #       "match_type": {
    #         ".tag": "file_content"
    #       },
    #       "metadata": {
    #         ".tag": "metadata",
    #         "metadata": {
    #           ".tag": "file",
    #           "client_modified": "2022-10-25T14:56:59Z",
    #           "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75",
    #           "id": "id:25N5ksooX-sAAAAAAAQvrQ",
    #           "is_downloadable": true,
    #           "name": "test one tag.txt",
    #           "path_display": "/files with tags/test one tag.txt",
    #           "path_lower": "/files with tags/test one tag.txt",
    #           "rev": "5ebdd4583eb3d763fca20",
    #           "server_modified": "2022-10-25T15:07:50Z",
    #           "sharing_info": {
    #             "modified_by": "dbid:AABL4QRrY7tB9viLgPUqmjkzE6Fe5ujlnlE",
    #             "parent_shared_folder_id": "1983892000",
    #             "read_only": false
    #           },
    #           "size": 27
    #         }
    #       }
    #     },
    #     {
    #       "match_type": {
    #         ".tag": "file_content"
    #       },
    #       "metadata": {
    #         ".tag": "metadata",
    #         "metadata": {
    #           ".tag": "file",
    #           "client_modified": "2022-10-25T14:56:57Z",
    #           "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75",
    #           "id": "id:25N5ksooX-sAAAAAAAQvqw",
    #           "is_downloadable": true,
    #           "name": "test both tags.txt",
    #           "path_display": "/files with tags/test both tags.txt",
    #           "path_lower": "/files with tags/test both tags.txt",
    #           "rev": "5ebdd4583eb3f763fca20",
    #           "server_modified": "2022-10-25T15:07:50Z",
    #           "sharing_info": {
    #             "modified_by": "dbid:AABL4QRrY7tB9viLgPUqmjkzE6Fe5ujlnlE",
    #             "parent_shared_folder_id": "1983892000",
    #             "read_only": false
    #           },
    #           "size": 27
    #         }
    #       }
    #     }
    #   ]
    # }
    
    curl -X POST https://api.dropboxapi.com/2/files/search_v2 \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/json' \
      --data '{"query":"#orange","options":{"path":"/files with tags"}}'
    
    # {
    #   "has_more": false,
    #   "matches": [
    #     {
    #       "match_type": {
    #         ".tag": "file_content"
    #       },
    #       "metadata": {
    #         ".tag": "metadata",
    #         "metadata": {
    #           ".tag": "file",
    #           "client_modified": "2022-10-25T14:56:57Z",
    #           "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75",
    #           "id": "id:25N5ksooX-sAAAAAAAQvqw",
    #           "is_downloadable": true,
    #           "name": "test both tags.txt",
    #           "path_display": "/files with tags/test both tags.txt",
    #           "path_lower": "/files with tags/test both tags.txt",
    #           "rev": "5ebdd4583eb3f763fca20",
    #           "server_modified": "2022-10-25T15:07:50Z",
    #           "sharing_info": {
    #             "modified_by": "dbid:AABL4QRrY7tB9viLgPUqmjkzE6Fe5ujlnlE",
    #             "parent_shared_folder_id": "1983892000",
    #             "read_only": false
    #           },
    #           "size": 27
    #         }
    #       }
    #     },
    #     {
    #       "match_type": {
    #         ".tag": "file_content"
    #       },
    #       "metadata": {
    #         ".tag": "metadata",
    #         "metadata": {
    #           ".tag": "file",
    #           "client_modified": "2022-10-25T14:56:58Z",
    #           "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75",
    #           "id": "id:25N5ksooX-sAAAAAAAQvrA",
    #           "is_downloadable": true,
    #           "name": "test another tag.txt",
    #           "path_display": "/files with tags/test another tag.txt",
    #           "path_lower": "/files with tags/test another tag.txt",
    #           "rev": "5ebdd4583eb3e763fca20",
    #           "server_modified": "2022-10-25T15:07:50Z",
    #           "sharing_info": {
    #             "modified_by": "dbid:AABL4QRrY7tB9viLgPUqmjkzE6Fe5ujlnlE",
    #             "parent_shared_folder_id": "1983892000",
    #             "read_only": false
    #           },
    #           "size": 27
    #         }
    #       }
    #     }
    #   ]
    # }  
    
    curl -X POST https://api.dropboxapi.com/2/files/search_v2 \
      --header 'Authorization: Bearer <ACCESS_TOKEN>' \
      --header 'Content-Type: application/json' \
      --data '{"query":"#orange #banana","options":{"path":"/files with tags"}}'
    
    # {
    #   "has_more": false,
    #   "matches": [
    #     {
    #       "match_type": {
    #         ".tag": "file_content"
    #       },
    #       "metadata": {
    #         ".tag": "metadata",
    #         "metadata": {
    #           ".tag": "file",
    #           "client_modified": "2022-10-25T14:56:57Z",
    #           "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75",
    #           "id": "id:25N5ksooX-sAAAAAAAQvqw",
    #           "is_downloadable": true,
    #           "name": "test both tags.txt",
    #           "path_display": "/files with tags/test both tags.txt",
    #           "path_lower": "/files with tags/test both tags.txt",
    #           "rev": "5ebdd4583eb3f763fca20",
    #           "server_modified": "2022-10-25T15:07:50Z",
    #           "sharing_info": {
    #             "modified_by": "dbid:AABL4QRrY7tB9viLgPUqmjkzE6Fe5ujlnlE",
    #             "parent_shared_folder_id": "1983892000",
    #             "read_only": false
    #           },
    #           "size": 27
    #         }
    #       }
    #     }
    #   ]
    # }

    For context: there are three files, one with one tag, one with a different tag, and one with both tags.


    If you're seeing otherwise, can you share a sample so I can check on that with the team for you? Please show the search parameters you're using, as well as the full result you're getting back, but be sure to redact the access token itself. Feel free to open an API ticket if you'd prefer to share privately. Thanks!

    • BPCABA's avatar
      BPCABA
      Explorer | Level 3

      Example of search inside 2022 folder for all items with # - results show 0

       

       

      Example of 2 tags being used to perform search without limiting it to a specific folder. Again results = 0

       

       

      Example of a file - one of many in that 2022 folder and subfolders that contains both tags.

       

       

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        Thanks for following up. You originally replied in a thread regarding using the Dropbox API search functionality in the API section of the forum, but I see you're actually referring to using the Dropbox web site, which may work a bit differently than the public Dropbox API. For help with the Dropbox web site, please contact Dropbox support.