google shared drive search api

328 Views Asked by At

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

1

There are 1 best solutions below

0
On BEST ANSWER

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: