Unique request with Freebase MQL read google api

It seems that I can only make unique queries (i.e. including the object identifier in the query) with the new readbase MQL read api:

The following queries by identifier 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 are only with type:

 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 him to return a list of people names

+4
source share
2 answers

You must wrap your request in [], as in the following example:

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

I also ran into a similar problem recently. The best way to make sure you get the only result set is to use the "limit: 1" parameter in your mql query. eg:

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

Source: https://habr.com/ru/post/1415025/


All Articles