5

I want to retrieve name of all movies and their genre. It's ok if information about genre is empty, but if genre is known I want to retrieve it.

"/film/film/genre": [{"id":null,"optional":"optional"}]

But I'm not interested in gay pornography, so I want to exclude all movies with genre "/en/gay_pornography".

"/film/film/genre": [{"id|=":["/en/gay_pornography"],"optional":"forbidden"}]

The problem is, how to combine it in one query? I.e. how to get all movies, even those with no genre and exclude pr0n?

Edit: it's required to exclude multiple genres, e.g. also /en/pornographic_movie

Tunaki
  • 132,869
  • 46
  • 340
  • 423
user574959
  • 85
  • 5

2 Answers2

4

You're basically there: you just need two "genre" clauses. MQL lets you do this by allowing arbitrary prefixes on any clause:

[{
  "id":   null,
  "type": "/film/film",
  "genre": [{
    "id":       null,
    "optional": true
  }],
  "forbid:genre": {
    "id|=": [
      "/en/gay_pornography",
      "/en/pornographic_movie"
    ],
    "optional": "forbidden"
  }
}]​

http://tinyurl.com/4449ufg

Philip Kendall
  • 4,304
  • 1
  • 23
  • 42
  • Thanks! Now I realized that my previous attempt with 2 clauses didn't work since it wasn't valid JSON. With prefixes it works ok :) – user574959 Apr 12 '11 at 16:08
0

Use the "but not" operator:

 "genre": [{
    "id":       null,
    "id!=":     "/en/gay_pornography",
    "optional": true
  }]

Full example: http://tinyurl.com/3tjdb4j

Edit: This doesn't answer the question. It just prevents that particular id from being listed as a genre of the film but doesn't forbid the film. @phillip-kendal's answer is correct.

Community
  • 1
  • 1
Will Moffat
  • 1,009
  • 1
  • 9
  • 11
  • doesn't work:' "id": "/en/every_poolboys_dream", "type": "/film/film", "genre": [{ "id": null, "id!=": "/en/gay_pornography", "optional": true }]' – user574959 Apr 09 '11 at 13:50