Saturday, October 05, 2013

Integrating Google Drive Google Docs into Spotlight search: "Webpages", Kinds and Smart Folders

Mac Spotlight was behaving oddly with my Google Drive. It's not the obvious issue with indexing Google Docs files in Google Drive; was more subtle but it was fixable.

To begin with there's no problem with searching PDFs and other relatively standard files that are stored in Google Drive. They are fully indexed and searchable by title and contents. [4]

The problem is with Google documents, like those with the extension of .gsheet. Of course Spotlight can't index the contents; for most of mine there's nothing there to index anyway.[2]. What's odd is that Spotlight search on the file name didn't work from the spotlight title bar [1], but it did work from the folder search UI.

It turns out that I'd configured Spotlight preferences to exclude web pages from search results, and for Spotlight a Google Doc is a web page reference [2]. So the Google Docs were excluded from results. They showed up in the folder search because evidently Spotlight disregards file type preference there.

Next I had to address Mountain Lion's Folder Bar 'All My Files' list. Even after I revised Spotlight preferences that list didn't include my Google Folder docs.

I right clicked on 'All My Files' to see the Search Criteria -- mine showed Documents and "Kind is Other - com.microsoft.com" (Silverlight files it seems). 

So all I needed to do was add the "Kinds" for the different Google Docs. I'm embarrassed to admin I tried file extensions and Google and Terminal.app and Get Info trying to figure out what "Kind" Spotlight assigned to these files (as distinct from Type, which was "Webpages"). The answer, of course, is simply to look at the Finder's detail list (duh). The kinds in my Google Drive were:

  • "Google document" (extension .gdoc)
  • "Google spreadsheet" (extension .gsheet)
  • "Google drawing" (extension .gdraw)
I didn't have any presentations, but you can guess that one. [3]
 
Once I added those (with quotes) to the 'All My Files' criteria [7] in the Finder Sidebar they showed up in the All My Documents list. Problem is, even in Mountain Lion you can't save your edits to "All My Documents" [6]. Indeed, any editing of a saved search is weirdly obscure (no edit in context menu).
 
There was still one problem.  'All My Files' -- at best I could remove the original and save a new one with a less appealing icon. The trick, of course, is to change the icon (see comments, also [5]).
 
Alas, I couldn't put my Saved Search back into the Finder Menu! I could drag folders there, but not a File. I had to use an obscure trick - Select the file then type Cmd-T. I think this is a Mountain Lion bug, possibly for non-admin users.
 
At last all seemed well; except the Finder Sidebar persistently showed the old gear icon, even though Get Info showed the current icon. A Finder Restart didn't fix this, so I'm a bit stuck for the moment. I suspect it's a Mountain Lion bug [8].
 
(BTW, if you're a new Mac user and you do this, you probably want to set New Window Default to Home Directory or something similar. Unfortunately you can't make a smart folder a default.)
 
See also:

[1] BTW, if you use the titlebar spotlight search and mouse over a result, you get a preview. You don't see filename or path though. If you hold the command key down, you will first see filename below the preview, then, after a second or two, it will alternate with path name.

[2] Here's what a gsheet content looks like in textwrangler (GUIDs truncated for security reasons)

{"url": "https://docs.google.com/spreadsheet/ccc?key=0AtgMeRwpi&usp=docslist_api", "resource_id": "spreadsheet:0AtgMec"}

[3] I'm guessing Google Drive installation tells OS X what Spotlight Kinds to associate with these file extensions.

[4] BTW, you can use Google Drive to convert Microsoft file types to Google formats.

[5] OS X Mountain Lion: Change the icon of a file or folder. Don't try to copy the preview icon, copy the wee icon at top of get info.

[6] It is a "Canned Search" Kind, not a "Saved Search" -- and it's a System File.

[7] Get Info shows the native search language version. Here's what I got when I added kinds without quotes:

(true) && ((((kMDItemContentTypeTree = public.content) || (kMDItemKind = "com.microsoft.*"cdw) || ((kMDItemKind = "Google*"cdw) && (kMDItemKind = "Spreadsheet*"cdw)) || ((kMDItemKind = "Google*"cdw) && (kMDItemKind = "document*"cdw)) || ((kMDItemKind = "Google*"cdw) && (kMDItemKind = "drawing*"cdw)))))

Here's the better results with quotes:

(true) && ((((kMDItemContentTypeTree = public.content) || (kMDItemKind = "com.microsoft.*"cdw) || (kMDItemKind = "Google Spreadsheet"cdw) || (kMDItemKind = "Google document"cdw) || (kMDItemKind = "Google drawing"cdw))))

[8] I'm not sure if this is new with Mountain Lion, but it looks like display of custom icons in the Finder Sidebar is a known issue.

No comments:

Post a Comment