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"
}
我的倒排查询只返回两代!请帮我弄清楚这是为什么。