Run query on previous result in Freebase - 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.

Related

MQL Query Help Required: Getting aliases of episodes from a season MID

I am trying to capture 351 and their aliases of season - "/m/07mx74h", but when I am using my query it gives only not-null values, while I also need those records which are null. PFA query and let me know how can I get all results for 351 records.
Thanks in advance!
MQL Query:
[{
"id": "/m/07mx74h",
"/tv/tv_series_season/episodes": [{
"limit": 1000,
"mid": null,
"name": null,
"/common/topic/alias": [{
"value": null
}]
}]
}]
I'm not sure I completely understand your question, but if the goal is to also include episodes which don't have an alias, you can use this:
[{
"id": "/m/07mx74h",
"/tv/tv_series_season/episodes": [{
"limit": 1000,
"mid": null,
"name": null,
"/common/topic/alias": []
}]
}]
The inner text value is the default returned, so you don't need the inner curly braces.

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.

Freebase MQL Query - Getting Frequency for Award

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.

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".

List properties of several types in MQL query

Good day!
I want to obtain information about several disasters. So, I ask this query:
[{
"type": "/event/disaster",
"*": null,
"limit": 10
}]
Ok, but I also need /time/event properties such as start_date. I'm trying this:
[{
"type": "/event/disaster",
"type": "/time/event",
"*": null,
"limit": 10
}]
and again got only /event/disaster properties because type : time/event inherently translated to "ns0:type". I've tried also this:
[{
"type": ["/event/disaster", /time/event"],
"*": null,
"limit": 10
}]
but got error. How I should formulate the query?
The MQL property wildcard (*) can only be applied to one type so you'll need to individually list the properties that you want to see like this:
[{
"type": "/event/disaster",
"/time/event/start_date": null,
"*": null,
"limit": 10
}]
Another way to do this would be to use the Search API to specify which property values to return (by type or domain) like this:
?filter=(all type:/event/disaster)
&output=(all:/event/disaster all:/time/event)

Resources