node.jsgoogle-drive-apigoogle-search-apigoogle-drive-shared-drive

google shared drive search api


i have lots of google shared drive and many content in it , currently trying to search some query and i got only limited result , but when i am trying to search those query in drive i got many results.

response through API : - res.json

my code is : -

try {
    Drive.files.list({
        q: "name contains 'jeet' ",
     // q: "fullText contains 'jeet' ", -- this is also get 2-3 result
        supportsAllDrives: true
    }, function(err, res) {
        if (err) {
            console.log(err)
        }
        if (res) {
            console.log(res)
            fs.writeFile("./res.json", JSON.stringify(res.data, null, 2), function(err, res) {})
        }
    })
} catch (error) {

}

when i actually search in google drive : - i got thousands of resualts


Solution

  • In your situation, how about adding the properties of corpora and includeItemsFromAllDrives as follows?

    Modified script:

    From:

    Drive.files.list({
        q: "name contains 'jeet' ",
     // q: "fullText contains 'jeet' ", -- this is also get 2-3 result
        supportsAllDrives: true
    }, function(err, res) {
    

    From:

    Drive.files.list({
        q: "name contains 'jeet' ",
     // q: "fullText contains 'jeet' ", -- this is also get 2-3 result
        supportsAllDrives: true,
        corpora: "allDrives", // Added
        includeItemsFromAllDrives: true, // Added
    }, function(err, res) {
    

    Reference: