如果您的数据存储区使用基本的网站搜索功能,那么您商店的索引的新鲜度与 Google 搜索中的新鲜度相同。
如果您的数据存储区中启用了高级网站索引编制,系统会以以下方式刷新数据存储区中的网页:
- 自动刷新
- 手动刷新
- 基于站点地图的刷新
本页介绍了自动刷新和手动刷新。如需了解并实现基于站点地图的刷新,请参阅根据站点地图编制索引和刷新。
准备工作
如果您在网站中使用 robots.txt
文件,请更新该文件。如需了解详情,请参阅准备网站的 robots.txt
文件。
自动刷新
Vertex AI 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
:Vertex AI 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" } }
在监控重新抓取操作的状态时,请保存
name
值,以作为operations.get
操作的输入。
监控重新抓取操作的状态
您用于抓取数据存储区中的网页的 recrawlUris
方法是一种长时间运行的操作,它会一直运行,直到抓取完您指定的网页或在 24 小时后超时(以先到者为准)。您可以通过轮询 operations.get
方法来监控此长时间运行的操作的状态,并指定 recrawlUris
方法返回的 name
值。继续轮询,直到响应表明以下任一情况:(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
:表示上次更新长时间运行的操作元数据的时间。表示元数据每五分钟更新一次,直到操作完成。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
表示重新抓取操作已完成。
如果响应表明存在待处理的 URI,并且重新抓取操作已完成,则表示重新抓取操作在抓取所有网页之前超时(24 小时后)。从重新抓取数据存储区中的网页开始。在对
recrawlUris
方法的新调用中,使用operations.get
响应中的failedUris
值作为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
。长时间运行的操作元数据的上次更新时间。元数据每 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
方法之前可以采取的操作。您可以立即重试所有暂时性错误。在实施补救措施后,可以重试所有非暂时性错误。
错误消息 | 是暂时性错误吗? | 在重试重新抓取之前采取的操作 |
---|---|---|
网页已抓取,但未在 24 小时内被 Vertex AI Search 编入索引 | 是 | 调用 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
服务器错误代码,则会将该无响应的网页从索引中移除。