Freebase MQL Query - Getting Frequency for Award - freebase

I'm new to Freebase mql querying and would like to get the /time/recurring_event/current_frequency for all awards (/award/award).

That query looks like this in MQL:
[{
"type": "/award/award",
"name": null,
"/time/recurring_event/current_frequency": [{
"id": null,
"name": null
}]
}]
In order to get all the results, you'll need to use a cursor to page through the results set.

Related

/film/film/runtime always returns null

Whenever I try to query for the length of a film I get lists of null. The query I use is directly from the "Build query" button on their site and looks like this:
[{
"id": null,
"name": null,
"type": "/film/film",
"/film/film/runtime": []
}]
Ufortunately all the responses I get look like this:
{
"name": "4D Man",
"type": "/film/film",
"/film/film/runtime": [
null
],
"id": "/en/4d_man"
}
I can hover over the links you can see on the query page and see the runtime (in this case 85 minutes) but as you can see all I get from the query is null. This may be a Freebase bug, but any help is appreciated. Thank you.
There's not a single runtime of a film, the same film can have different runtimes (original version, director's cut, etc...) Freebase use the film_cut type to contain the different runtimes of a movie
You can use this query to get the runtimes:
[{
"id": null,
"name": null,
"/film/film/runtime": [{
"runtime": null
}]
}]
Tune this query to your needs, you may need type_of_film_cut or film_release_region.

Run query on previous result in Freebase

I would like to run a query on a preselected set of topics in freebase.
Specifically, I'd like to find out how many, out of 1000 movies do not have a Netflix ID.
What I tried:
[{
"type": "/film/film",
"mid": null,
"name": null,
"netflix_id": {
"optional": "forbidden",
"return": "count"
},
"limit": 1000,
"return": "count"
}]
This, of course, returns 1000. What I wanted was, to select 1000 movies
[{
"type": "/film/film",
"mid": null,
"name": null,
"limit": 1000,
}]
and then look for objects without netflix_id within this result.
Can anybody help me with that?
Edit:
What I am actually looking for is a kind of statistic: x out of 1000 movies do not have a netflix_id. What I need for this is to select 1000 movies, and within this set look for movies without netflix_id.
For now, I simply looked for all movies without a netflix_id and divided it by the number of all movies. I posted the question nonetheless because I'd generally like to know how to use sub-queries.
The following MQL query:
[{
"type": "/film/film",
"mid": null,
"name": null,
"netflix_id": {
"optional": "forbidden",
"return": "count"
},
"limit": 1000
}]
... returns up to 1000 films that have no netflix_id property set. In other words, what you had was mostly correct, except for that last "return": "count", which was then aggregating the result to a single count.
Edit
Based on the updated explanation/requirement, you can use the following MQL query:
[{
"type": "/film/film",
"mid": null,
"name": null,
"netflix_id": [],
"limit": 1000
}]
... to list up to 1000 films and, if they have a netflix_id, the associated IDs. You can tell whether there are any IDs present by examining the size of the returned "netflix_id" array.

Freebase MQL Query

I have a couple of questions.
I have a MQL query that gets some movie information. The trimmed query looks like this.
[{
"id": "/en/a_beautiful_mind",
"name": null,
"type": "/film/film",
"/common/topic/article": [{
"id": null,
"optional": true,
"limit": 3
}]
}]
it works just fine, I can retrieve the ID but is there a way to also get the article text without having to run a separate text query?
Second is I am trying to figure out how to get the featured song performer. I can do this and get the songs name.
[{
"id": "/en/a_beautiful_mind",
"name": null,
"type": "/film/film",
"featured_song": [{
"name": null,
"optional": true
}],
}]
But cant seem to figure out how to get the songs performer. Is it possible?
thanks for the help
Scott
One simple way to get this type of information about a film is to use the Topic API like this:
https://www.googleapis.com/freebase/v1/topic/en/a_beautiful_mind?filter=suggest&filter=/film/film
This won't get the featured song artist though. At least not without an additional API call. To do that in MQL you just nest additional queries inside the featured song like this:
[{
"id": "/en/a_beautiful_mind",
"name": null,
"type": "/film/film",
"featured_song": [{
"name": null,
"/music/recording/artist": [{}],
"/film/film_featured_song/performed_by": [{}],
"optional": true
}]
}]
Note that I've added two separate properties one for the artist who originally recorded the song and one for the artist who performed it in the film. In this case, the second property is empty implying that the original recording was used. Since I'm mixing properties from different types I need to use the fully-qualified property names.
All Freebase types are documented in the graph so you can look up types like /music/recording and /film/film_featured_song to see how they are meant to be used.

Query for all Nobel Peace Prize recipients in Freebase

I want to query all recipients of the Nobel Peace Prize and the date (year) from Freebase. I looked at the site, which shows me all winners, but if I do the query here, I do only get "null" results!
What I have so far:
[{
"id": "/m/05f3q",
"/award/award_category/winners": []
}]
If you look at the schema for the information that you're trying to query, you can see that what you are getting back is actually an Award Honor object which has a schema like this. It's got a bunch of different properties, but it doesn't have any meaningful name which is why it's coming back as null.
Try something more along the lines of the below (add additional properties as needed):
[{
"type": "/award/award_honor",
"award": {
"id": "/m/05f3q"
},
"award_winner": [{
"id": null,
"name": null
}],
"year": null
}]
[{
"id": "/en/nobel_prize_in_economics",
"/award/award_category/winners": [{
"/award/award_honor/award_winner": [],
"/award/award_honor/year": null,
"/award/award_honor/award": null,
"/award/award_honor/honored_for": []
}]
}]
I cannot do it in just one call, so I do the same for "/en/nobel_prize_in_physiology_or_medicine", "/en/nobel_prize_in_chemistry", "/en/nobel_peace_prize", "/en/nobel_prize_in_literature".

How to express current date in MQL Freebase Query?

Freebase's metaweb query language can be used to retreive future events if you pass in an ISO8601 formatted date.
[{
"id": null,
"name": null,
"start_date" : null,
"type": "/time/event",
"start_date>" : "2011-09-02"
}]​
^ run this query
Does MQL support an equivalent to SQL's NOW() or CURDATE()?
You can also use __now__ in timestamp fields as a special shortcut:
[{
"id": null,
"name": null,
"start_date" : null,
"type": "/time/event",
"start_date>" : "__now__"
}]​
You can see a live demo of this via this Freebase Query Editor snippet.
There is no equivalent to SQL's NOW() or CURDATE in MQL. Whichever programming language you're using to send the query should have an equivalent function which you can use.
You can kind of get a list of future events by sorting them in descending order of start_date like this:
[{
"id": null,
"name": null,
"type": "/time/event",
"start_date": {
"value": null,
"optional": false
},
"sort": "-start_date.value"
}]​

Resources