Включить миниатюры

Thumbnails help users identify relevant search results. They have these characteristics:

  • Ширина 1024 пикселя.
  • URLs for Google Workspace file thumbnails are ACL-protected. Other file types are not.
  • Срок действия URL-адресов истекает через 5 минут.
  • Максимальный размер файла для генерации составляет 50 МБ.
  • 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 и XML

Cloud Search only returns thumbnails for items when you enable thumbnails for the data source and search application.

Включить отображение URL-адресов миниатюр для источника данных

To enable thumbnail URLs, create an API key and web application credentials. Use these to obtain an access token to update your data source.

  1. Create or select a project and enable the API. See Configure access to the Cloud Search API .
  2. Create an API key in the Google Cloud console and note the value.
  3. Create web application credentials. Use https://developers.google.com/oauthplayground as the redirect URI. See Create credentials .
  4. In the OAuth 2.0 Playground , open OAuth 2.0 Configuration .
  5. Select Use your own credentials and enter your client ID and secret.
  6. Enter https://www.googleapis.com/auth/cloud_search.settings in the scopes field and click Authorize APIs .
  7. Обменяйте код авторизации на токены.
  8. Call settings.datasources.get to 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' \
    --compressed
    
  9. Call settings.datasources.update with returnThumbnailUrls set to true :

    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
    

Включить отображение URL-адресов миниатюр для поискового приложения

You must also enable thumbnails in your search application.

  1. Obtain an API key and access token using the same method described in the previous section .
  2. Call settings.searchapplications.get to 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' \
    --compressed
    
  3. Call settings.searchapplications.update with returnResultThumbnailUrls set to true :

    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
    

Доступ к миниатюрам

To access a thumbnail for a Drive file, the user or application must use the same account credentials used to access the original item.