2017-01-04 36 views

回答

1

根據我最近的搜索/我的簡短經驗,大多數情況下,Google的知識圖譜API會返回空的結果,即使簡單的Google搜索具有完全相同的查詢也會給我我想要的結果。這就是我所說的「空的結果」的意思是(當我搜索了2014年豐田凱美瑞SE輪胎尺寸),例如:

[16] pry(main)> response = HTTParty.get("https://kgsearch.googleapis.com/v1/entities:search?query=2014 Toyota Camry SE tire size&key=#{API_KEY}") 
=> {"@context"=> 
{"@vocab"=>"http://schema.org/", 
"goog"=>"http://schema.googleapis.com/", 
"EntitySearchResult"=>"goog:EntitySearchResult", 
"detailedDescription"=>"goog:detailedDescription", 
"kg"=>"http://g.co/kg"}, 
"@type"=>"ItemList", 
"itemListElement"=>[]} 

其他時候,它返回不正確的結果(不是我要找的)。在下面的例子中,我正在尋找關於2014年的豐田凱美瑞信息,而是所有的結果看起來好像我正在尋找相關公司

[4] pry(main)> response = HTTParty.get("https://kgsearch.googleapis.com/v1/entities:search?query=2014 toyota camry&key=#{API_KEY}") 
=> {"@context"=> 
    {"@vocab"=>"http://schema.org/", 
    "goog"=>"http://schema.googleapis.com/", 
    "EntitySearchResult"=>"goog:EntitySearchResult", 
    "detailedDescription"=>"goog:detailedDescription", 
    "resultScore"=>"goog:resultScore", 
    "kg"=>"http://g.co/kg"}, 
"@type"=>"ItemList", 
"itemListElement"=> 
    [{"@type"=>"EntitySearchResult", 
    "result"=> 
    {"@id"=>"kg:/m/02qtntf", 
     "name"=>"Toyota Kirloskar Motor", 
     "@type"=>["Corporation", "Thing", "Organization"], 
     "description"=>"Automotive industry company", 
     "detailedDescription"=> 
     {"articleBody"=> 
     "Toyota Kirloskar Motor Pvt Ltd is a subsidiary of Toyota Motor Corporation of Japan, for the manufacture and sales of Toyota cars in India. It is currently the 4th largest car maker in India after Maruti Suzuki, Hyundai, and Mahindra.\n", 
     "url"=>"https://en.wikipedia.org/wiki/Toyota_Kirloskar_Motor", 
     "license"=>"https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"}, 
     "url"=>"http://www.toyotabharat.com"} 
... 

我還沒有得到結果,我的信息尋找 - 即使我指定類型(即&types=Car)。

我不知道爲什麼是這種情況,但它是。

+0

謝謝,@BryanDimas。 – Phoenix

相關問題