使用自動和手動重新整理功能重新整理網頁

如果資料儲存庫使用基本網站搜尋,儲存庫索引的新鮮度會與 Google 搜尋中的新鮮度相同。

如果資料儲存庫已啟用進階網站索引功能,系統會透過下列方式重新整理資料儲存庫中的網頁:

  • 自動重新整理
  • 手動重新整理
  • 依據 Sitemap 重新整理

本頁面說明自動和手動重新整理。如要瞭解並實作以 Sitemap 為基礎的重新整理,請參閱「根據 Sitemap 建立索引及重新整理」。

事前準備

如果您在網站中使用 robots.txt 檔案,請更新該檔案。詳情請參閱如何準備網站的 robots.txt 檔案。

自動重新整理

Agent Search 會自動重新整理,方式如下:

  • 建立資料儲存庫後,系統會為納入的頁面產生初始索引。
  • 完成初始索引後,系統會為新發現的網頁建立索引,並盡可能重新檢索現有網頁。
  • 如果資料儲存庫的查詢頻率為 50 次/30 天,系統會定期重新整理。

手動重新整理

如要重新整理資料儲存庫中已啟用進階網站索引建立功能的特定網頁,可以呼叫 recrawlUris 方法。您可以使用 uris 欄位指定要檢索的每個網頁。recrawlUris 方法是長時間執行的作業,會持續執行到指定的網頁檢索完畢,或在 24 小時後逾時 (以先發生者為準)。如果 recrawlUris 方法逾時,您可以再次呼叫該方法,並指定仍待檢索的網頁。您可以輪詢 operations.get 方法,監控重新檢索作業的狀態。

重新檢索限制

網頁檢索頻率和一次可檢索的網頁數量有限:

  • 每日通話量。每個專案每天最多可呼叫 recrawlUris 方法 20 次。
  • 每次呼叫的網頁數。呼叫 recrawlUris 方法時,最多可指定 10,000 個 uris 值。

重新檢索資料儲存庫中的網頁

如果資料儲存庫已啟用進階網站索引建立功能,您可以手動檢索特定網頁。

REST

如要使用指令列檢索資料儲存庫中的特定網頁,請按照下列步驟操作:

  1. 找出資料儲存庫 ID。如果您已有資料儲存庫 ID,請跳到下一個步驟。

    1. 前往 Google Cloud 控制台的「AI Applications」頁面,然後點選導覽選單中的「Data Stores」(資料儲存庫)。

      前往「Data Stores」(資料儲存庫) 頁面

    2. 點按資料儲存庫的名稱。

    3. 在資料儲存庫的「Data」(資料) 頁面,取得資料儲存庫 ID。

  2. 呼叫 recrawlUris 方法,並使用 uris 欄位指定要檢索的每個網頁。每個 uri 都代表單一頁面,即使包含星號 (*) 也是如此。不支援萬用字元模式。

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -H "X-Goog-User-Project: PROJECT_ID" \
    "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/siteSearchEngine:recrawlUris" \
    -d '{
      "uris": [URIS]
    }'
    

    更改下列內容:

    • PROJECT_ID: Google Cloud 專案的 ID。
    • DATA_STORE_ID:Agent Search 資料儲存庫的 ID。
    • URIS:要檢索的網頁清單,例如 "https://example.com/page-1", "https://example.com/page-2", "https://example.com/page-3"。

    輸出結果會與下列內容相似:

    {
      "name": "projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/operations/recrawl-uris-0123456789012345678",
      "metadata": {
        "@type": "type.googleapis.com/google.cloud.discoveryengine.v1alpha.RecrawlUrisMetadata"
      }
    }
    
  3. 監控重新檢索作業狀態時,請將 name 值儲存為 operations.get 作業的輸入內容。

監控重新檢索作業的狀態

recrawlUris 方法用於檢索資料儲存庫中的網頁,屬於長時間執行的作業,會持續執行到指定網頁檢索完畢,或 24 小時後逾時為止 (以先發生者為準)。您可以輪詢 operations.get 方法,並指定 recrawlUris 方法傳回的 name 值,藉此監控這項長時間執行的作業狀態。繼續輪詢,直到回應指出:(1) 所有網頁都已檢索,或 (2) 作業在所有網頁檢索完畢前逾時。如果 recrawlUris 逾時,您可以再次呼叫,並指定未檢索的網站。

REST

如要使用指令列監控重新檢索作業的狀態,請按照下列步驟操作:

  1. 找出資料儲存庫 ID。如果您已有資料儲存庫 ID,請跳到下一個步驟。

    1. 前往 Google Cloud 控制台的「AI Applications」頁面,然後點選導覽選單中的「Data Stores」(資料儲存庫)。

      前往「Data Stores」(資料儲存庫) 頁面

    2. 點按資料儲存庫的名稱。

    3. 在資料儲存庫的「Data」(資料) 頁面,取得資料儲存庫 ID。

  2. 輪詢 operations.get 方法。

    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -H "X-Goog-User-Project: PROJECT_ID" \
    "https://discoveryengine.googleapis.com/v1alpha/OPERATION_NAME"
    

    更改下列內容:

  3. 評估每則回覆。

    • 如果回應指出有待處理的 URI,且重新檢索作業尚未完成,表示網頁仍在檢索中。繼續輪詢。

      範例

        {
          "name": "projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/operations/recrawl-uris-0123456789012345678",
          "metadata": {
            "@type": "type.googleapis.com/google.cloud.discoveryengine.v1alpha.RecrawlUrisMetadata",
            "createTime": "2023-09-05T22:07:28.690950Z",
            "updateTime": "2023-09-05T22:22:10.978843Z",
            "validUrisCount": 4000,
            "successCount": 2215,
            "pendingCount": 1785
          },
          "done": false,
          "response": {
            "@type": "type.googleapis.com/google.cloud.discoveryengine.v1alpha.RecrawlUrisResponse",
          }
        }

      回應欄位說明如下:

      • createTime:表示長時間執行的作業開始時間。
      • updateTime:表示長時間執行的作業中繼資料上次更新時間。中繼資料每五分鐘更新一次,直到作業完成為止。
      • validUrisCount:表示您在呼叫 recrawlUris 方法時指定了 4,000 個有效 URI。
      • successCount:表示已成功檢索 2,215 個 URI。
      • pendingCount:表示有 1,785 個 URI 尚未檢索。
      • done:如果值為 false,表示重新檢索作業仍在進行中。

    • 如果回應指出沒有待處理的 URI (未傳回 pendingCount 欄位),且重新檢索作業已完成,則表示網頁已檢索完畢。停止輪詢,您可以退出這項程序。

      範例

        {
          "name": "projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/operations/recrawl-uris-0123456789012345678",
          "metadata": {
            "@type": "type.googleapis.com/google.cloud.discoveryengine.v1alpha.RecrawlUrisMetadata",
            "createTime": "2023-09-05T22:07:28.690950Z",
            "updateTime": "2023-09-05T22:37:11.367998Z",
            "validUrisCount": 4000,
            "successCount": 4000
          },
          "done": true,
          "response": {
            "@type": "type.googleapis.com/google.cloud.discoveryengine.v1alpha.RecrawlUrisResponse"
          }
        }

      回應欄位說明如下:

      • createTime:表示長時間執行的作業開始時間。
      • updateTime:表示長時間執行的作業中繼資料上次更新時間。中繼資料每五分鐘更新一次,直到作業完成為止。
      • validUrisCount:表示您在呼叫 recrawlUris 方法時指定了 4,000 個有效 URI。
      • successCount:表示已成功檢索 4,000 個 URI。
      • done:如果值為 true,表示重新檢索作業已完成。
  4. 如果回應指出有待處理的 URI,且重新檢索作業已完成,則表示重新檢索作業在所有網頁檢索完畢前逾時 (24 小時後)。請從「重新檢索資料儲存庫中的網頁」步驟重新開始。在 operations.get 回應中使用 failedUris 值,做為新呼叫 recrawlUris 方法時 uris 欄位的值。

    Example.

    {
      "name": "projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/operations/recrawl-uris-8765432109876543210",
      "metadata": {
        "@type": "type.googleapis.com/google.cloud.discoveryengine.v1alpha.RecrawlUrisMetadata",
        "createTime": "2023-09-05T22:07:28.690950Z",
        "updateTime": "2023-09-06T22:09:10.613751Z",
        "validUrisCount": 10000,
        "successCount": 9988,
        "pendingCount": 12
      },
      "done": true,
      "response": {
        "@type": "type.googleapis.com/google.cloud.discoveryengine.v1alpha.RecrawlUrisResponse",
        "failedUris": [
          "https://example.com/page-9989",
          "https://example.com/page-9990",
          "https://example.com/page-9991",
          "https://example.com/page-9992",
          "https://example.com/page-9993",
          "https://example.com/page-9994",
          "https://example.com/page-9995",
          "https://example.com/page-9996",
          "https://example.com/page-9997",
          "https://example.com/page-9998",
          "https://example.com/page-9999",
          "https://example.com/page-10000"
        ],
        "failureSamples": [
          {
            "uri": "https://example.com/page-9989",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9990",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9991",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9992",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9993",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9994",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9995",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9996",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9997",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          },
          {
            "uri": "https://example.com/page-9998",
            "failureReasons": [
              {
                "corpusType": "DESKTOP",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              },
              {
                "corpusType": "MOBILE",
                "errorMessage": "Page was crawled but was not indexed by UCS within 24 hours."
              }
            ]
          }
        ]
      }
    }

    以下是回應欄位的說明:

    • createTime:長時間執行作業的開始時間。
    • updateTime。上次更新長時間執行的作業中繼資料的時間。中繼資料每五分鐘更新一次,直到作業完成為止。
    • validUrisCount:表示您在呼叫 recrawlUris 方法時,指定了 10,000 個有效的 URI。
    • successCount。表示已成功檢索 9,988 個 URI。
    • pendingCount。表示有 12 個 URI 尚未檢索。
    • done。如果值為 true,表示重新檢索作業已完成。
    • failedUris:在重新檢索作業逾時前,未檢索的 URI 清單。
    • failureInfo:無法檢索的 URI 相關資訊。即使有超過十個 URI 檢索失敗,系統最多也只會傳回十個 failureInfo 陣列值。
    • errorMessage。URI 檢索失敗的原因,依corpusType。詳情請參閱「錯誤訊息」。

及時更新

Google 建議您對新網頁和更新網頁執行手動重新整理,確保您擁有最新索引。

錯誤訊息

監控重新檢索作業狀態時,如果重新檢索作業在您輪詢 operations.get 方法時逾時,operations.get 會針對未檢索的網頁傳回錯誤訊息。下表列出錯誤訊息、錯誤是否為暫時性 (會自行解決的暫時性錯誤),以及在重試 recrawlUris 方法前可採取的動作。您可以立即重試所有暫時性錯誤。所有非暫時性錯誤都可以在實施補救措施後重試。

錯誤訊息 是否為暫時性錯誤? 重新檢索前採取的動作
網頁已檢索,但 Agent Search 未在 24 小時內建立索引 是 呼叫 recrawlUris 方法時,請使用 operations.get 回應中的 failedUris 值,做為 uris 欄位的值。
檢索作業遭到網站的 robots.txt 封鎖 否 請在網站的 robots.txt 檔案中解除封鎖 URI,確保 Google-CloudVertexBot 使用者代理程式可以檢索網站,然後重新檢索。詳情請參閱「為資料進行擷取的準備作業」中的「網站資料」一節。如果無法存取 robots.txt 檔案,請與網域擁有者聯絡。
無法連上網頁 否 請檢查呼叫 recrawlUris 方法時指定的 URI。請務必提供常值 URI,而非 URI 模式。
檢索逾時 是 呼叫 recrawlUris 方法時,請使用 operations.get 回應中的 failedUris 值,做為 uris 欄位的值。
網頁遭 Google 檢索器拒絕 是 呼叫 recrawlUris 方法時,請使用 operations.get 回應中的 failedUris 值,做為 uris 欄位的值。
Google 檢索器無法追蹤網址 否 如果有多個重新導向,請使用最後一個重新導向的 URI,然後重試
找不到網頁 (404) 否 請檢查呼叫 recrawlUris 方法時指定的 URI。請務必提供常值 URI,而非 URI 模式。

任何回應「4xx」錯誤代碼的網頁都會從索引中移除。

網頁需要驗證 否 進階網站索引功能不支援檢索需要驗證的網頁。

如何處理已刪除的頁面

刪除網頁後,Google 建議您手動重新整理已刪除的網址。

自動或手動重新整理網站資料儲存庫時,如果網頁傳回 4xx 用戶端錯誤代碼或 5xx 伺服器錯誤代碼,系統會從索引中移除無回應的網頁。

如果資料儲存庫的「Sitemap Mode」(Sitemap 模式) 設為「Exact」(完全相符),從 Sitemap 移除網址後,該網址也會從索引中刪除。

如果資料儲存庫的「Sitemap 模式」設為「探索」,從 Sitemap 移除網址並不會將網址從索引中刪除。在網站經過檢索,且網頁傳回 4xx 或 5xx 程式碼之前,網址不會從索引中刪除。