2012-07-11 41 views
1

有關我需要他們的父母的組織名單。在freebase.com的查詢編輯器,我使用下面的查詢:在Freebase MQL中,如何編寫查詢以獲取組織的父級名稱?

{ 「ID」: 「/ EN/daihatsu_motor_company」, 「/機構/組織/父」:{ID:空}}

而且我得到以下結果:

{ 「代碼」: 「/ API /狀態/確定」, 「結果」:{ 「/機構/組織/父」:{ 「ID 「:」/ m/04kjl82「 }, 」id「:」/ en/daihatsu_motor_company「 }, 「狀態」: 「200 OK」, 「TRANSACTION_ID」: 「緩存; cache03.p01.sjc1:8101; 2012-07-10T22:54:06Z; 0030」 }

然而,我我期待id:toyota_motor_corporation。

從freebase.com的查詢編輯器,我可以點擊ID( 「ID」: 「/ M/04kjl82」),這是來查看與該信息,我需要一個鏈接:

http://www.freebase.com/view/m/04kjl82

我如何直接獲得母公司的名稱或者它的id(例如toyota_motor_corporation)?

謝謝,

回答

1

克勞迪奧的答案是接近的,但如果你真的想要的ID,你需要調整由於返回的默認屬性是名稱而不是ID,因此稍有查詢。這將讓你的ID:

{ 
    "id": "/en/daihatsu_motor_company", 
    "/organization/organization/parent": { 
    "parent": {"id":null} 
    } 
}​ 

將返回

"result": { 
    "/organization/organization/parent": { 
     "parent": { 
     "id": "/en/toyota_motor_corporation" 
     } 
    }, 
    "id": "/en/daihatsu_motor_company" 
    } 

說了這麼多,你應該考慮using the MID而不是ID,因爲這是建議的標識,這些天。

1

您的查詢返回父和子之間的組織關係的ID。你需要的是家長,您可以用下面的查詢得到它:

{ 
    "id": "/en/daihatsu_motor_company", 
    "/organization/organization/parent": { 
    "parent": null 
    } 
}​ 

返回

{ 
    "code":   "/api/status/ok", 
    "result": { 
    "/organization/organization/parent": { 
     "parent": "Toyota Motor Corporation" 
    }, 
    "id": "/en/daihatsu_motor_company" 
    }, 
    "status":  "200 OK", 
    "transaction_id": "cache;cache03.p01.sjc1:8101;2012-07-11T21:50:01Z;0045" 
} 
+0

謝謝Claudio!它工作完美。 – user1518419 2012-07-13 18:08:35