I'm currently working with different SPARQL endpoints and looking to query the IMDB endpoint for movies by title. I have already come up with the following query for DBPedia.
SELECT DISTINCT film_title
WHERE {
?film_title rdf:type <http://dbpedia.org/ontology/Film> .
?film_title dbpprop:name ?label . FILTER langMatches(lang(?label), "en")
?film_title rdfs:comment ?comment . FILTER(LANGMATCHES(LANG(?comment), "en")) .
FILTER (REGEX(STR(?film_title), "The Big Lebowski", "i")) .
} LIMIT 10
Would anyone have any suggestions on how to structure the query for IMDB?
Your query doesn't work on DBpedia. It's missing ?
in select distinct film_title
, and even if you add that in, you don't get any results. I expect that you actually want something like
select distinct ?film where {
?film a dbpedia-owl:Film ;
rdfs:label ?label .
filter contains( ?label, "The Big Lebowski" )
}
limit 10
I don't know of any IMDB SPARQL endpoint, and a Google search for imdb sparql endpoint
doesn't turn one up. I'll go out on a limb and assume that you're talking about the LinkedMDB SPARQL endpoint, since it has some information about some films that are also in the IMDB. It has a SPARQL endpointt, as well as a SNORQL explorer where you can test queries.
If you also browse the LinkedMDB pages for films, you can find out what properties they use. E.g., from the page for The Magician, you can see that LinkedMDB also uses rdfs:label to indicate titles. The relevant type isn't dbpedia-owl:Film, though, but movie:film, which is <http://data.linkedmdb.org/resource/movie/film>
.
Now, the LinkedMDB endpoint doesn't use SPARQL 1.1, so you can't use the contains
function, but you can still use regex. Since we know that The Magician has an entry there (it doesn't look like The Big Lebowski does), let's look at a similar query that retrieves it:
select distinct ?film where {
?film a movie:film ;
rdfs:label ?label .
filter regex( str(?label), "The Magician", "i")
}
limit 10
Now you can ask whether there's a query that would work on both LinkedMDB and on DBpedia, and sure enough there is:
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>
prefix movie: <http://data.linkedmdb.org/resource/movie/>
select distinct ?film where {
{ ?film a movie:film } union
{ ?film a dbpedia-owl:Film }
?film rdfs:label ?label .
filter regex( str(?label), "The Magician", "i")
}
limit 10
LinkedMDB SPARQL results (1 film)
DBpedia SPARQL results (10 films)