Q:

‘Empty’ results from MQL Query. Freebase Schema: /film/film/starring & /film/actor/film

First post here, so I hope this is enough detail.
I started using freebase-python today to get film information for a program that I’m working on. One thing that I need to grab is a list of actors that starred in a film. I’ve followed some tutorials and guides on the way to do this, and can get a list of films for a director or the director of a film, but when I try to do the same with an actor or a film’s cast, I get ‘null’ results.
I have the same problem in both Python and the Freebase MQL Query Editor, and you can see what I've tried below. Links to all of the examples below written in the editor can be found here, as Stack Overflow wouldn't let me post links underneath each example on my first post!
Working director query in Python:
import freebase
fb = freebase.mqlread
q = {'type':'/film/film', 'name':'Inception', 'directed_by':[]}
fb(q)

Working director's filmography query in Python:
import freebase
fb = freebase.mqlread
q = {'type':'/film/director', 'name': 'Christopher Nolan', 'film':[]}
fb(q)

Based on these tests, I tried to do the same with actors, but with odd results:
Not working cast list query in Python:
import freebase
fb = freebase.mqlread
q = {'type':'/film/film', 'name':'Inception', 'starring':[]}
fb(q)

Not working actor's filmography query in Python:
import freebase
fb = freebase.mqlread
q = {'type':'/film/actor', 'name':'Leonardo DiCaprio', 'film':[]}
fb(q)

Strangely, I get an accurate number of actors/films back, but no names. Does anyone have any idea what the problem might be? Thanks a lot, I'd appreciate any advice.

A:

That's because films and actors are not connected directly, but instead through a "mediator" node with no name.  This is because there are three things to be connected at once: 1) the film, 2) the actor, and 3) the role/character.
Before writing any MQL, you need to review the schema of the domain/types that you want to work with to see how the information is stored.
Note also that if you just match on names, your going to get duplicates for remakes, etc.  You should keep track of IDs to disambiguate everything.  Here's modified query:
[{
  "type": "/film/film",
  "name": "Inception",
  "mid":  null,
  "starring": [{
    "actor": null,
    "mid":   null
  }]
}]​

