0

I am trying to query 2 specific movies and their imdb pages with linkedmdb and it throws a parse error.

I get a list of all movies when I remove the below line. How do I get links of a specific set.

FILTER (str(?title) IN ("The Magician","Royal Flash"))

Here is my code.

SELECT  ?title ?imdbID 
WHERE {
   ?film foaf:page ?imdbID .  
   ?film dc:title ?title .

   FILTER(regex(str(?imdbID), "www.imdb.com" ) )
   FILTER (str(?title) IN ("The Magician","Royal Flash"))
}
UninformedUser
  • 8,397
  • 1
  • 14
  • 23
VKB
  • 65
  • 1
  • 7
  • It does **not** support SPARQL 1.1, thus, SPARQL `UNION` has to be used. See the specs: https://www.w3.org/TR/sparql11-query/#alternatives – UninformedUser Mar 15 '17 at 03:34

2 Answers2

1

The SPARQL 1.1 spec shows the equivalence of IN

https://www.w3.org/TR/sparql11-query/#func-in

so

FILTER (str(?title) IN ("The Magician","Royal Flash"))

is the same as

FILTER (str(?title) = "The Magician" || str(?title) = "Royal Flash")

which is SPARQL 1.0

AndyS
  • 16,345
  • 17
  • 21
  • I did try that out before using IN. The problem is all these variations work when I retrieve all the movies or just one. When I try to restrict to a couple of them, they don work. The equivalence you used only gives "The Magician". I want both "The Magician" and the "Royal Flash" details. – VKB Mar 15 '17 at 11:32
  • Which has nothing to do with the filter. There is simply nothing whose title matches "Royal Flash". You can only query for data that isin the knowledge base. And LinkedMDB is quite old and there is no live dataset synchronized with IMDB. The IBDM page would be http://www.imdb.com/title/tt0073639/ and you can check via SPARQL that there is no such resource with the URL as value of `foaf:page` – UninformedUser Mar 15 '17 at 15:35
0

You could try matching through VALUES instead of getting all matches and filtering the desired values out:

SELECT ?title ?imdbID 
WHERE {
   ?film foaf:page ?imdbID . 
   VALUES ?title {"The Magician" "Royal Flash"} .
   ?film dc:title ?title
}
scotthenninger
  • 3,921
  • 1
  • 15
  • 24
  • still the same error. I am using the below endpoint http://www.linkedmdb.org/snorql/ – VKB Mar 14 '17 at 22:38
  • It does **not** support SPARQL 1.1, thus, SPARQL `UNION` has to be used. Next time it would be good that you show the URL to the SPARQL service in advance. – UninformedUser Mar 15 '17 at 03:33