2
Chapter 3 of the MQL reference(特別是第3.2.6節)討論顛倒查詢以獲得不同結構中的相同數據,以簡化查詢或按摩數據以返回與您自己類似的結構。反轉MQL查詢
於是我開始用下面的查詢:
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"
}
我倒查詢只返回兩代人!請幫我弄清楚這是爲什麼。
哇!我偶然發現它(我正在研究* models *模式,所以我不知道* model *)。謝謝! – 2013-04-25 23:38:38