python sdk search doesn't return result but web interface does
Hi, I have a folder with some subfolders having a lot of files. When performing an exact search, the python SDK sometimes doesn't return results, but sometimes it returns. The behavior is not consistent. Is there a time out during the search?
Example folder structure:
folder_1 (containing about 30 subfolders)
- subfolder_1 (containing about 20 sub-sub-folders)
-- sub-subfolder_1 (containing about 2000 files)
--- file_A
--- file_B
--- file_C
Code:
for filename in list:
time.sleep(0.1) # to avoid hitting box rate limit
items = box_client.search().query(query=f'\"{filename}\"', type="file",
content_types=["name"], ancestor_folder_ids=box_root_id)
is_file_exist_in_box = False
for item in items:
is_file_exist_in_box = True
do something
break # I only need the first one if multiple file with same name are found.
if not is_file_exist_in_box:
print(f"{filename} not found!")
Problems:
The script reports file_A and file_C are found, but file_B is missing during the loop. But file_B can be found via the search box in the box web interface, and if I run a search for file_B using python SDK without the loop, it can be found.
If I run the for loop script again, file_B may be found but maybe file_C is reported missing this time.
In summary, it seems that the search API doesn't perform consistently? But no error is reported.
Thank you for advice on how to debug and fix this!
Post is closed for comments.
Comments
0 comments