如何将 Freebase 结果限制为拥有图像的用户



我知道Freebase即将被淘汰,但在Google Knowledge Graph发布之前,我需要一种方法来搜索Freebase,但ony返回的结果是有图像的。

我知道我可以在结果集中检查"/common/topic/image"的"属性"节点,但为了正确分页,我需要通过 API 调用来实现这一点,而不是通过服务器端代码。

有没有办法实现这一目标?

示例调用:https://www.googleapis.com/freebase/v1/search/?query=daughtry&output=((类型)(created_by)(值得注意)(属性))

带有图像的示例响应:

[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
                                            )
                                    )
                            )
                    )
            )
    )

如果没有图像,"属性"数组就是空的。

谢谢

您发布了一个根本不起作用的查询(由于拼写错误),但您需要做的是将 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)

最新更新