问题
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