1

I want to search file contents in Google Drive for files that contain the word 'pass' - an exact match on the whole word 'pass'.

Currently I am using the following call:

var files = DriveApp.searchFiles('fullText contains \'pass\'');

I tried with double quotes as well...

var files = DriveApp.searchFiles('fullText contains "pass"');

This was based on documentation I read here: https://developers.google.com/drive/v3/web/search-parameters

However, both versions return files containing 'pass' as well as files containing derivatives of 'pass' such as 'password' or 'passing' etc. I tried to add white space to pass ('pass ' or ' pass ') but this seems to be discarded / ignored as well and I get the same results.

What must I do to get an exact match on the whole word 'pass' only?

Richard McKechnie
  • 2,748
  • 1
  • 15
  • 13
  • Remember that `fullText` searches the _entire_ file, so if you're only checking the file name, the term must be in the file somewhere. – Brian Sep 29 '17 at 16:38
  • Thanks for the feedback Brian, I've edited the question to be more specific in that searching the entire file contents is exactly what I'm trying to do. – Richard McKechnie Sep 29 '17 at 16:48
  • Very strange. I've been poking and I'm seeing the same results. – Brian Sep 29 '17 at 17:51

2 Answers2

2

Notice where the apostrophe is placed:

 fullText contains '"Hello there"'

Just noticed this in the notes from Search Files in Drive API.

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
2

It turns out that this is what I was looking for:

var files = DriveApp.searchFiles('fullText contains \'"pass"\''); 
Richard McKechnie
  • 2,748
  • 1
  • 15
  • 13