批量 Feed 中的 v1 版本控制

在批量 Feed 中,实体版本通过 Feed 信封中的 dateModified 字段:

{
  "@context": "http://schema.googleapis.com",
  "dateModified": "2018-12-28T06:30:00:123-07:00",
  "@type": "DataFeed",
  "dataFeedElement": [
    /* All the items that are part of this feed go here */
  ]
}

字段 dataFeedElement 中列出的所有实体将具有相同的时间戳, 如信封中所列。

例如,您的以下 Feed 可能包含两个实体:

{
  "@context": "http://schema.googleapis.com",
  "@type": "DataFeed",
  "dateModified": "2018-12-28T06:30:00:123-07:00",
  "dataFeedElement": [
    {
      "@type": "Restaurant",
      "@id": "http://www.provider.com/somerestaurant",
      ...
    },
    {
      "@type": "Menu",
      "@id": "http://www.provider.com/somerestaurant/menu/1"
      ...
    }
  ]
}

菜单和餐馆实体在接收和处理后将变为 分别为“2018-12-28T06:30:00:123-07:00”。

通过增量更新进行版本控制

使用产品目录更新发送实体时,版本会通过 update_time 字段(如果是 add/update 调用)或 delete_time 字段(如果是删除调用)。由于这些字段是可选的, 默认时间戳设置为 Google 接到来电的时间。

示例 1:明确设置 update_time

假设在 2018-12-28T06:30:10:123-07:00 收到以下增量调用 一家全新的餐厅以下是针对该实体的 HTTP POST 请求 ID 为“http://www.provider.com/some 餐馆”,假设数据 Feed 使用 v1 广告资源架构:

POST v2/apps/provider-project/entities/http%3A%2F%2Fwww.provider.com%2Fnewrestaurant:push
Host: actions.googleapis.com
Content-Type: application/ld+json

如下所示,JSON 载荷正文包含 update_time 字段。具有 ID“http://www.provider.com/some 餐馆”会导致该实体被 版本标注为 6:30:00,而不是接收时间(十秒钟后, 6:30:10):

{
// This envelope is to be used for incremental.
  "entity": {
    // Note: "data" is not serialized as a string in our example for readability.
    "data": "[entity in JSON format serialized as a string]",
    "vertical": "FOODORDERING"
  },
  "update_time":"2018-12-28T06:30:00:123-07:00"
}

示例 2:隐式设置 update_time

假设在 2018-12-28T06:30:10:123-07:00 收到以下增量调用 一家全新的餐厅以下是针对该实体的 HTTP POST 请求 ID 为“http://www.provider.com/some 餐馆”,假设 Feed 使用 v1 广告资源架构:

POST v2/apps/provider-project/entities/http%3A%2F%2Fwww.provider.com%2Fnewrestaurant:push
Host: actions.googleapis.com
Content-Type: application/ld+json

如下所示,JSON 载荷正文包含字段 update_time。通过 ID 为“http://www.provider.com/some 餐馆”的实体因此会导致 此实体的版本为 6:30:10:

{
// This envelope is to be used for incremental.
  "entity": {
    //Note: "data" is not serialized as a string in our example for readability.
    "data": "[entity in JSON format serialized as a string]",
    "vertical": "FOODORDERING"
  }
}

批量和增量之间的版本控制

发送给 Google 的实体只有在 版本。请注意,批量发送的实体通常需要几天的时间 而通过增量 API 发送的实体将得到处理 。

最佳做法

  • 以增量和批量方式设置 update_timedateModified 字段, 。
  • 如果批量 Feed(文件)列出了多个顶级实体(例如, 将您的餐馆与服务和菜单配对),然后将时间戳更新为 实体数据会更新。
  • 对于增量调用,我们强烈建议您明确将 update_time 字段。
  • 在进行增量调用后,相应的 Feed 时间戳 (dateModified) 也会在 Google 再次提取之前更新。

示例

Google 在 2018 年 12 月 28 日上午 11 点获取以下文件, 餐馆:

{
  "@context": "http://schema.googleapis.com",
  "@type": "DataFeed",
  "dateModified": "2018-12-28T06:30:00-07:00",
  "dataFeedElement": [
    {
      "@type": "Restaurant",
      "@id": "http://www.provider.com/newrestaurant",
      ...
    },
    {
      "@type": "Menu",
      "@id": "http://www.provider.com/newrestaurant/menu/1"
      ...
    }
    {
      "@type": "Service",
      "@id": "http://www.provider.com/newrestaurant/service/1"
      ...
    }
  ]
}

这些实体会得到成功处理,并以 "2018-12-28T06:30:00-07:00".由于批量 Feed 的处理需要一定的时间, 通常在 2 天后投放

不过,在下午 1 点,合作伙伴的系统收到该餐厅电话的更新 调用,从而产生后续的增量调用,而 Google 会收到 在 13:05(5 秒后):

POST v2/apps/provider-project/entities/http%3A%2F%2Fwww.provider.com%2Fnewrestaurant:push
Host: actions.googleapis.com
Content-Type: application/ld+json
{
// This envelope is to be used for incremental.
  "entity": {
    //Note: "data" is not serialized as a string in our example for readability.
    "data": "[entity in JSON format serialized as a string]",
    "vertical": "FOODORDERING"
  },
  "update_time":"2018-12-28T13:00:00-07:00"
}

update_time 是明确提供的,并且其时间大于 之前的版本(当天早上 6:30),所以餐厅实体现在是 版本号为“2018-12-28T13:00:00-07:00”。不过,菜单和服务实体 版本仍为“2018-12-28T06:30:00-07:00”。

由于发生了增量调用,因此批量 Feed 会使用新的 相应的时间戳。此外,相应的更改会应用于 相关实体(餐馆实体的电话号码已更新)。

{
  "@context": "http://schema.googleapis.com",
  "@type": "DataFeed",
  "dateModified": "2018-12-28T13:00:00-07:00",
  "dataFeedElement": [
    {
      "@type": "Restaurant",
      "@id": "http://www.provider.com/newrestaurant",
      ...
    },
    {
      "@type": "Menu",
      "@id": "http://www.provider.com/newrestaurant/menu/1"
      ...
    }
    {
      "@type": "Service",
      "@id": "http://www.provider.com/newrestaurant/service/1"
      ...
    }
  ]
}

在第二天(2018 年 12 月 29 日)晚上 11 点,系统再次提取 Feed。餐馆 仍具有相同的版本(12 月 28 日下午 1 点),因此该实体会被丢弃 系统会保留当前版本不过,“Menu”和“Service”实体 已更新为新版本。

站点地图时间戳

站点地图中的 last-modified 响应标头不会影响 实体版本。它会影响 Google 抓取 Feed 的时间。

最佳做法

  • 只有在所有文件都已是最新并准备就绪时,才能更新响应标头 。
  • 以增量方式明确使用 update_timedelete_time
  • update_timedelete_timedateModified 设置为数据发生变化的时间 。