如果您的数据存储区使用基本网站搜索,则存储区的索引新鲜度与 Google 搜索中提供的新鲜度一致。
如果您的数据存储区中启用了高级网站索引编制,则数据存储区中的网页会以以下方式刷新:
- 自动刷新
- 手动刷新
- 基于站点地图的刷新
本页面介绍了自动刷新和手动刷新。如需了解和实现 基于站点地图的刷新,请参阅根据站点地图编入索引和刷新。
准备工作
如果您在网站中使用 robots.txt 文件,请更新该文件。如需了解
详情,请参阅如何
准备网站的 robots.txt 文件。
自动刷新
Agent Search 会按如下方式执行自动刷新:
- 创建数据存储区后,它会为包含的网页生成初始索引。
- 在初始索引编制完成后,它会尽力对任何新发现的网页进行索引,并重新抓取 现有网页。
- 它会定期刷新查询速率为 50 次查询/30 天的数据存储区。
手动刷新
如果您想在启用了
高级网站索引编制的数据存储区中刷新特定网页,您
可以调用
recrawlUris方法。您可以使用 uris 字段指定要抓取的每个网页。recrawlUris 方法是一种 长时间运行
操作,它会一直运行,直到您指定的网页被
抓取,或者在 24 小时后超时(以先到者为准)。如果 recrawlUris 方法超时,您可以再次调用该方法,并指定仍需抓取的网页。您可以轮询 operations.get 方法来 监控重新抓取操作的状态。
重新抓取限制
您可以抓取网页的频率以及一次可以抓取的网页数量都有限制:
- 每日调用次数。每个项目每天允许调用
recrawlUris方法的次数上限为 20 次。 - 每次调用抓取的网页数。通过调用
recrawlUris方法,您可以指定的uris值数量上限为 10,000 个。
重新抓取数据存储区中的网页
您可以手动抓取启用了 高级网站索引编制的数据存储区中的特定网页。
REST
如需使用命令行抓取数据存储区中的特定网页,请按以下步骤操作:
查找您的数据存储区 ID。如果您已有数据存储区 ID,请跳至下一步。
在 Google Cloud 控制台中,前往 AI Applications 页面,然后 在导航菜单中点击 数据存储区。
点击您的数据存储区的名称。
在数据存储区的数据 页面上,获取数据存储区 ID。
调用
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" } }
监控重新抓取操作的状态
您可以使用 recrawlUris 方法抓取数据存储区中的网页。该方法是一种长时间运行的操作,它会一直运行,直到您指定的网页被抓取,或者在 24 小时后超时(以先到者为准)。您可以轮询 operations.get 方法来监控此
长时间运行的操作的状态,并指定 name 值,该值由
recrawlUris 方法返回。继续轮询,直到响应表明以下任一情况:(1) 所有网页都已抓取完毕;(2) 操作在所有网页都抓取完毕之前超时。如果 recrawlUris 超时,您可以再次调用该方法,并指定未抓取的网站。
REST
如需使用命令行监控重新抓取操作的状态,请按以下步骤操作:
查找您的数据存储区 ID。如果您已有数据存储区 ID,请跳至下一步。
在 Google Cloud 控制台中,前往 AI Applications 页面,然后 在导航菜单中点击 数据存储区。
点击您的数据存储区的名称。
在数据存储区的数据 页面上,获取数据存储区 ID。
轮询
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"替换以下内容:
PROJECT_ID:您的 Google Cloud 项目的 ID。OPERATION_NAME:操作名称,可在重新抓取数据存储区中的网页时调用recrawlUris方法后返回的name字段中找到。您还可以通过列出长时间运行的操作来获取操作名称。
评估每个响应。
如果响应表明有待处理的 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:表示上次更新长时间运行的操作元数据的时间。表示元数据每 5 分钟更新一次,直到操作完成。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:表示上次更新长时间运行的操作元数据的时间。表示元数据每 5 分钟更新一次,直到操作完成。validUrisCount:表示您在调用recrawlUris方法时指定了 4,000 个有效 URI。successCount:表示已成功抓取 4,000 个 URI。done:值true表示重新抓取操作已完成。
如果响应表明有待处理的 URI 且重新抓取操作已完成,则表示重新抓取操作在所有网页都抓取完毕之前超时(24 小时后)。请从重新抓取 数据存储区中的网页重新开始。在您对
recrawlUris方法的新调用中,将operations.get响应中的failedUris值用作uris字段中的值。示例。
{ "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:上次更新长时间运行的操作元数据的时间。元数据每 5 分钟更新一次,直到操作完成。validUrisCount:表示您在调用recrawlUris方法时指定了 10,000 个有效 URI。successCount:表示已成功抓取 9,988 个 URI。pendingCount:表示有 12 个 URI 尚未抓取。done:值true表示重新抓取操作已完成。failedUris:在重新抓取操作超时之前未抓取的 URI 列表。failureInfo:有关抓取失败的 URI 的信息。即使有超过 10 个 URI 抓取失败,系统最多也会返回 10 个failureInfo数组值。errorMessage:URI 因corpusType而抓取失败的原因。如需了解详情,请参阅错误消息。
及时刷新
Google 建议您对新网页和更新后的网页执行 手动刷新 以确保您拥有最新的索引。
错误消息
在监控重新抓取操作的状态时,如果您在
轮询 operations.get 方法时重新抓取操作超时,operations.get 会针对
未抓取的网页返回错误消息。下表列出了错误消息、错误是否为暂时性错误(自行解决的临时错误),以及在重试 recrawlUris 方法之前可以采取的操作。您可以立即重试所有暂时性错误。在实施补救措施后,可以重试所有非暂时性错误。
| 错误消息 | 是否为暂时性错误? | 重试重新抓取之前的操作 |
|---|---|---|
| 网页已抓取,但 Agent Search 未在 24 小时内将其编入索引 | 是 | 在调用 recrawlUris 方法时,将 operations.get 响应中的 failedUris 值用作 uris 字段中的值。 |
抓取被网站的 robots.txt 阻止 |
否 | 在网站的 robots.txt 文件中取消阻止 URI,确保 Googlebot 用户代理获准抓取网站,
然后重试重新抓取。如需了解详情,请参阅
如何编写和提交 robots.txt 文件。
如果您无法访问 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 服务器错误代码,则系统会从索引中移除无响应的网页。