We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
BPCABA
4 years agoExplorer | Level 3
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...
Greg-DB
Dropbox Community Moderator
4 years agoThe 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!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!