We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Nathan P.9
10 years agoNew member | Level 1
Python files_search return empty?
Not sure what's happening but I'm working on a little python tool to look up a file by name in a given dropbox. I can do a files_list_folder fine and see the results:
dbx.files_list_folder('')
ListFolderResult(entries=[FolderMetadata(name='Team Files', id='id:mkPLvUa8vRAAAAAAAAAAAg', path_lower='/team files', path_display='/Team Files', parent_shared_folder_id=None, shared_folder_id='1287208110', sharing_info=FolderSharingInfo(read_only=False, parent_shared_folder_id=None, shared_folder_id='1287208110'), property_groups=None), FolderMetadata(name='public', id='id:mkPLvUa8vRAAAAAAAAAAIw', path_lower='/public', path_display='/public', parent_shared_folder_id=None, shared_folder_id=None, sharing_info=None, property_groups=None), FolderMetadata(name='test', id='id:mkPLvUa8vRAAAAAAAAAAJA', path_lower='/test', path_display='/test', parent_shared_folder_id=None, shared_folder_id=None, sharing_info=None, property_groups=None), FileMetadata(name='nate.png', id='id:mkPLvUa8vRAAAAAAAAAAPA', client_modified=datetime.datetime(2016, 8, 1, 18, 40, 11), server_modified=datetime.datetime(2016, 8, 16, 21, 41, 58), rev='454cb918c3', size=38806, path_lower='/nate.png', path_display='/nate.png', parent_shared_folder_id=None, media_info=None, sharing_info=None, property_groups=None, has_explicit_shared_members=None)], cursor='AAGJecrngGsg6I7pFXXhuxK2RNpTIdXSzLw-3YRrttJjeC9sFWjQ6zZ8Zqjz5bbpXe4VXAQpwbF9f8x01b5xP1c6Gj_TtaGd1yqyOodee35FlVdcTASSOXdBODxFJyV2r3EcHK4wwV6lo1vZkq7YLA68', has_more=False)
But doing a search returns empty. Am I messing up the query or doing something wrong?
dbx.files_search('', '.png')
SearchResult(matches=[], more=False, start=0)
4 Replies
- Greg-DB10 years ago
Dropbox Community Moderator
There can be some lag on search results (as opposed to the list_folder result). Are you still seeing this now that some time has gone by?
- Nathan P.910 years agoNew member | Level 1
I tried again this morning and I am finally seeing some results. Is there any metric on the standard lag for search results?
I had loaded files then waited about 30 minutes without any search results coming back but list files worked fine. This also kind of begs the question... why the difference in behavior between list and search? Aren't they roughly equivalent styles of operations?
files_search(", "Foo") seems like it should be the same as if I did
files_list_folder(") filtered with "Foo" in metadata.name
Although that may be dependent on your backend infrastructure but from an API standpoint they both look like hierarchy walkers but react/operate very differently.
- Greg-DB10 years ago
Dropbox Community Moderator
Thanks for following up on this Nathan. The lag is usually relatively short, but it can vary, and can be on the scale of minutes.
Anyway, the search and list_folder operations do operate using entirely different mechanisms. So, in general, if you can use list_folder in any particular scenario, that would be the better choice.
- Nathan P.910 years agoNew member | Level 1
Thanks Gregory; I was just a bit surprised by this delay especially comparing it to the sync operation when looking at files/folders uploaded in the Dropbox App on multiple Windows system. Both systems showed the files as synced but search was still returning empty which is what started my concern that I had hit a possible bug :)
My tool is trying to walk through a heirarchy to find a particular file by name (I wish I could do by MD5 or SHA1 as well but that doesn't seem to be supported) and I would hate to have to walk through the user's entire dropbox to find a particular file (or multiple instances of that file) as that seems extremely expensive. I will simply note that there may be a delay so users are aware.
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!