Thumbnails help users identify relevant search results. They have these characteristics:
- Width of 1024 px.
- URLs for Google Workspace file thumbnails are ACL-protected. Other file types are not.
- URLs expire after 5 minutes.
- Maximum file size for generation is 50 MB.
- If generation fails, Cloud Search returns a placeholder icon. For Google Workspace items, the URL returns "404 Not Found." Your application must handle this.
Google Drive automatically creates thumbnails for supported types like Docs, Sheets, and Slides. Cloud Search also generates thumbnails for:
- Microsoft Word (DOC, DOCX)
- Microsoft Excel (XLS, XLSX)
- Microsoft PowerPoint (PPT, PPTX)
- Adobe PDF
- RTF, TXT, HTML, and XML
Cloud Search only returns thumbnails for items when you enable thumbnails for the data source and search application.
Enable thumbnail URLs for a data source
To enable thumbnail URLs, create an API key and web application credentials. Use these to obtain an access token to update your data source.
- Create or select a project and enable the API. See Configure access to the Cloud Search API.
- Create an API key in the Google Cloud console and note the value.
- Create web application credentials. Use
https://developers.google.com/oauthplaygroundas the redirect URI. See Create credentials. - In the OAuth 2.0 Playground, open OAuth 2.0 Configuration .
- Select Use your own credentials and enter your client ID and secret.
- Enter
https://www.googleapis.com/auth/cloud_search.settingsin the scopes field and click Authorize APIs. - Exchange the authorization code for tokens.
Call
settings.datasources.getto get your data source ID:curl 'https://cloudsearch.googleapis.com/v1/settings/DATASOURCE_ID?key=YOUR_API_KEY' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'Accept: application/json' \ --compressedCall
settings.datasources.updatewithreturnThumbnailUrlsset totrue:curl --request PUT \ 'https://cloudsearch.googleapis.com/v1/settings/datasources/DATASOURCE_ID?key=YOUR_API_KEY' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{"source":{"name":"datasources/DATASOURCE_ID","displayName":"DISPLAY_NAME","itemsVisibility":[{"gsuiteDomain":true}],"returnThumbnailUrls":true}}' \ --compressed
Enable thumbnail URLs for a search application
You must also enable thumbnails in your search application.
- Obtain an API key and access token using the same method described in the previous section.
Call
settings.searchapplications.getto get your application ID:curl 'https://cloudsearch.googleapis.com/v1/settings/searchapplications/APP_ID?key=YOUR_API_KEY' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'Accept: application/json' \ --compressedCall
settings.searchapplications.updatewithreturnResultThumbnailUrlsset totrue:curl --request PUT \ 'https://cloudsearch.googleapis.com/v1/settings/searchapplications/APP_ID?key=YOUR_API_KEY' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{"name":"searchapplications/APP_ID","displayName":"DISPLAY_NAME","dataSourceRestrictions":[{"source":{"name":"datasources/DATASOURCE_ID"}}],"returnResultThumbnailUrls":true}' \ --compressed
Access thumbnails
To access a thumbnail for a Drive file, the user or application must use the same account credentials used to access the original item.