2015-04-17 58 views
1

我知道Freebase即將出來,但在Google知識圖譜發佈之前,我需要一種搜索​​Freebase的方式,但是ony會返回含有圖片的結果。如何將Freebase結果限制爲擁有圖片的人

我知道我可以在結果集中檢查'/ common/topic/image'的'property'節點,但對於正確的分頁,我需要通過API調用來實現,而不是通過服務器端代碼。

有沒有辦法做到這一點?

例呼叫:https://www.googleapis.com/freebase/v1/search/?query=daughtry&output=((type)(created_by)(notable)(property))

實施例響應於與圖像:

[result] => Array 
    (
     [0] => Array 
      (
       [mid] => /m/0f2jr1 
       [id] => /en/daughtry 
       [name] => Daughtry 
       [notable] => Array 
        (
         [name] => Post-grunge Artist 
         [id] => /m/05jg58 
        ) 

       [lang] => en 
       [score] => 44.129833 
       [output] => Array 
        (
         [property] => Array 
          (
           [/common/topic/image] => Array 
            (
             [0] => Array 
              (
               [mid] => /m/03t3mnz 
               [name] => Daughtry Live in NYC 12-5-07 
              ) 

            ) 

          ) 

        ) 

      ) 
    ) 

如果沒有一個圖像,則 '屬性' 陣列僅僅是空的。

感謝

回答

0

您發佈這完全不工作(由於錯字)查詢,但你需要做的是用filter參數與has運營商。運營商未在文檔中列出的事實使得它比正常情況困難得多。 :-)

https://www.googleapis.com/freebase/v1/search/?query=daughtry&filter=(all has:/common/topic/image) 

有一個小開發者的應用程序,你可以使用這裏的API進行實驗:

http://freebase-search.freebaseapps.com/?query=daughtry&filter=(all has:/common/topic/image)&output=(property) 

還要注意notable被默認包含,所以你不必問因爲它和人沒有created_by屬性,所以你可能想要進一步限定你的搜索。

例如,如果你只是想與專輯圖片,你可以使用類似:

http://freebase-search.freebaseapps.com/?query=daughtry&filter=(all type:/music/album has:/common/topic image)&output=(created_by property) 
+0

感謝湯姆,這是我需要什麼,並且也更有幫助比我所能希望的。非常感謝 – jdrucey

+0

樂意提供幫助。隨時upvote以及接受。 :-) –