ActiveApathy
ActiveApathy

Reputation: 1211

In freebase MQL, how do I query for properties that may not have content?

Say I'm trying to get properties from a film. I can run the following which will return an array of actors:

{"type":"/film/film","id":"/m/05ggnq",
"starring":[{"mid":null,"actor":null,"character":null}]
}

However, when I try to query for another property that may or may not exist ("story_by") I simply get back an empty 200 response.

{"type":"/film/film","id":"/m/05ggnq", "story_by":[{"mid":null}], 
"starring":[{"mid":null,"actor":null,"character":null}]
}

How am I suposed to search for both of these properties at the same time?

Upvotes: 1

Views: 165

Answers (1)

Shawn Simister
Shawn Simister

Reputation: 4603

You can do this using the optional directive like this:

{
  "type": "/film/film",
  "id":   "/m/05ggnq",
  "story_by": [{
    "mid":      null,
    "optional": true
  }],
  "starring": [{
    "mid":       null,
    "actor":     null,
    "character": null
  }]
}

Upvotes: 2

Related Questions