似乎我只能使用新的 freebase MQL 读取 API 进行唯一查询(即在查询中包含实体 ID):
以下搜索 id 和类型:
https://www.googleapis.com/freebase/v1/mqlread?query={"name":null,"id":"/en/bob_dylan","type":"/people/person"}
并成功返回:
{
"result": {
"type": "/people/person",
"id": "/en/bob_dylan",
"name": "Bob Dylan"
}
}
以下搜索仅使用类型:
https://www.googleapis.com/freebase/v1/mqlread?query={"name":null,"type":"/people/person"}
或
https://www.googleapis.com/freebase/v1/mqlread?query={"name":[],"type":"/people/person"}
并返回以下错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "Unique query may have at most one result. Got 100"
}
],
"code": 400,
"message": "Unique query may have at most one result. Got 100"
}
}
我希望它返回一个人的名字列表
您必须将
查询包装在 [ ] 中,如以下示例所示:
https://www.googleapis.com/freebase/v1/mqlread?query=[{"name":[],"type":"/people/person"}]
我最近也遇到了类似的问题。确保获得单个结果集的最佳方法是在 mql 查询中使用"limit:1"参数。例如:
https://www.googleapis.com/freebase/v1/mqlread?query={"type":[],"name":"india","limit":1}