Non unique query with Freebase MQL read google api

不问归期 提交于 2019-12-10 17:36:22

问题


It seems I am only able to do unique queries (i.e. including an entity id in the query) with the new freebase MQL read api:

The following searches on id and type:

https://www.googleapis.com/freebase/v1/mqlread?query={"name":null,"id":"/en/bob_dylan","type":"/people/person"}

and successfully returns:

{
"result": {
"type": "/people/person", 
"id": "/en/bob_dylan", 
"name": "Bob Dylan"
}
}

The following searches with type only:

https://www.googleapis.com/freebase/v1/mqlread?query={"name":null,"type":"/people/person"}

or

https://www.googleapis.com/freebase/v1/mqlread?query={"name":[],"type":"/people/person"}

and returns the following error:

{
 "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"
 }
}

I expected it to return a list of people's names


回答1:


You have to wrap your query in [ ], as in the following example:

https://www.googleapis.com/freebase/v1/mqlread?query=[{"name":[],"type":"/people/person"}]



回答2:


I too faced a similar problem recently. The best way to make sure you get a single result set is to use "limit:1" parameter in your mql query. for example:

https://www.googleapis.com/freebase/v1/mqlread?query={"type":[],"name":"india","limit":1}


来源:https://stackoverflow.com/questions/10808534/non-unique-query-with-freebase-mql-read-google-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!