cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

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

Re: Dropbox search may not be working as expected

Re: Dropbox search may not be working as expected

BPCABA
Explorer | Level 3

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

 

3 Replies 3

Greg-DB
Dropbox 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
Explorer | Level 3

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

 

Screen Shot 2022-10-25 at 2.52.06 PM.png

 

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

 

Screen Shot 2022-10-25 at 2.52.26 PM.png

 

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

 

Screen Shot 2022-10-25 at 2.53.27 PM.png

 

Greg-DB
Dropbox 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.

Need more support?
Who's talking

Top contributors to this post

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