Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive API Limit on search query parameter

I have lots of sub-folders and here is my code for searching

"trashed = false 
AND ( ".$folderIds." ) 
AND mimeType != 'application/vnd.google-apps.folder'"

where the $folderIds are the subfolders, ex:

0B_123dSaMpleFolderId1 in parents or 0B_123dSaMpleFolderId2 in parents and 300 more folders

I know that limits are already posted here: What is the limit on Google Drive API usage?

but I would like to know the limits for this.. of how long should the parameter be when sending it to google drive api

Limit on search query parameter

like image 321
FritzB Avatar asked Nov 22 '25 04:11

FritzB


1 Answers

The Google Drive API v3 allowed me to search within 598 folders:

len(gdrive.search(
    f"mimeType!='application/vnd.google-apps.folder' and 
    ({build_folder_subquery(folders[0:598])})"
))

713

but not 599:

len(gdrive.search(
    f"mimeType!='application/vnd.google-apps.folder' and 
    ({build_folder_subquery(folders[0:599])})"
))
*** googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/drive/v3/files returned "The query is too complex.">

I don't know whether the 'query is too complex' error is triggered by the number of operators in the query, by the number of characters in the query, or by some other measure. The number of characters in the queries above are 29949 and 29999.

like image 198
gatherer Avatar answered Nov 24 '25 23:11

gatherer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!