2

MQL 参考的第 3 章(特别是第 3.2.6 节)讨论了反转查询以获取不同结构中的相同数据,以简化查询或处理数据以返回类似于您自己的结构。

所以我从以下查询开始:

https://api.freebase.com/api/service/mqlread?query={"query":{"type":"/automotive/model","name":"Ford Taurus","generations":[]}}

可读版本:

{
    "type":"/automotive/model",
    "name":"Ford Taurus",
    "generations":[]
}

结果:

{
  "code": "/api/status/ok",
  "result": {
    "generations": [
      "First Generation Ford Taurus",
      "Second Generation Ford Taurus",
      "Fifth Generation Ford Taurus",
      "Sixth Generation Ford Taurus",
      "Fourth Generation Ford Taurus",
      "Third Generation Ford Taurus"
    ],
    "name": "Ford Taurus",
    "type": "/automotive/model"
  },
  "status": "200 OK",
  "transaction_id": "cache;cache04.p01.sjc1:8101;2013-04-25T22:05:58Z;0012"
}

但我想让查询以生成为中心,所以我修改它如下:

https://api.freebase.com/api/service/mqlread?query={"query":[{"type":"/automotive/generation","model":"Ford Taurus","name":null}]}

可读版本:

[{
    "type":"/automotive/generation",
    "model":"Ford Taurus",
    "name":null
}]

结果:

{
  "code": "/api/status/ok",
  "result": [
    {
      "model": "Ford Taurus",
      "name": "First Generation Ford Taurus",
      "type": "/automotive/generation"
    },
    {
      "model": "Ford Taurus",
      "name": "Third Generation Ford Taurus",
      "type": "/automotive/generation"
    }
  ],
  "status": "200 OK",
  "transaction_id": "cache;cache01.p01.sjc1:8101;2013-04-25T23:00:35Z;0010"
}

我的倒排查询只返回两代!请帮我弄清楚这是为什么。

4

1 回答 1

1

如果您查看汽车生成的 Freebase 模式页面,您会看到该model属性已被弃用并被模型属性替换。对您的查询进行更改:

[{
  "type": "/automotive/generation",
  "models": "Ford Taurus",
  "name": null
}]

为您提供预期的结果集:

[
  {
    "models": "Ford Taurus",
    "name": "First Generation Ford Taurus",
    "type": "/automotive/generation"
  },
  {
    "models": "Ford Taurus",
    "name": "Second Generation Ford Taurus",
    "type": "/automotive/generation"
  },
  {
    "models": "Ford Taurus",
    "name": "Fifth Generation Ford Taurus",
    "type": "/automotive/generation"
  },
  {
    "models": "Ford Taurus",
    "name": "Sixth Generation Ford Taurus",
    "type": "/automotive/generation"
  },
  {
    "models": "Ford Taurus",
    "name": "Fourth Generation Ford Taurus",
    "type": "/automotive/generation"
  },
  {
    "models": "Ford Taurus",
    "name": "Third Generation Ford Taurus",
    "type": "/automotive/generation"
  }
]
于 2013-04-25T23:27:53.447 回答