4

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

waigani
  • 3,570
  • 5
  • 46
  • 71

2 Answers2

6

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

https://www.googleapis.com/freebase/v1/mqlread?query=[{"name":[],"type":"/people/person"}]
Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
  • 1
    That will work, but the "name":[] can be simplified to "name":null since there will only be a single unique English name. If you want names for all languages instead of just the default /lang/en, you can use "name":[{}] – Tom Morris Jun 03 '12 at 13:44
1

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}