Cannot get high id movies from LinkedMDB using SPARQL

I run the following query on the LinkedMDB SPARQL endpoint and it works. With it, I get all the information I need about the director of the movie with ID 72, which is Titanic, so I get information about James Cameron.

PREFIX mdb: <http://data.linkedmdb.org/resource/movie/> SELECT ?director?nombre_director?id_director WHERE { ?pelicula mdb:filmid ?id . ?pelicula <http://data.linkedmdb.org/resource/movie/director> ?director . ?director <http://data.linkedmdb.org/resource/movie/director_name> ?nombre_director . ?director <http://data.linkedmdb.org/resource/movie/director_directorid> ?id_director . FILTER (?id = 72). } 

With movies with a higher identifier, for example, Star Trek with ID 44396 , if I replace 72 with 44396, the query does not return Results. The record explicitly has a directory, id and name. Why does the modified request not work?

+4
source share
1 answer

SPARQL allows you to write 72 as a shorthand for the literal "72"^^xsd:integer . As you saw, you can get the movie with the identifier "72"^^xsd:integer without any problems. However, the other movie you are looking for has the identifier "44396"^^xsd:int (note that the data type is xsd:int , not xsd:integer ). I don’t know why the data type is different, but it is enough to help us get what we want:

 PREFIX mdb: <http://data.linkedmdb.org/resource/movie/> SELECT ?director?nombre_director?id_director WHERE { ?pelicula mdb:filmid "44396"^^xsd:int . ?pelicula <http://data.linkedmdb.org/resource/movie/director> ?director . ?director <http://data.linkedmdb.org/resource/movie/director_name> ?nombre_director . ?director <http://data.linkedmdb.org/resource/movie/director_directorid> ?id_director . } 

SPARQL Results (one)

 director nombre_director id_director ---------------------------------------------- db:director/9025 "JJ Abrams" 9025 

Note that instead of filtering, I simply put the actual desired value in the query template. I find this a little easier, and if the query engine is not optimized, it can be more efficient (since it does not create a large set of results and does not filter it). In fact, this may explain why a semantically equivalent query that uses a variable and a filter does not return results if there is a limit on the number of results that the query can return. (But this is pure speculation.) In any case, the following query does not work, but I think it should:

 PREFIX mdb: <http://data.linkedmdb.org/resource/movie/> SELECT ?director?nombre_director?id_director WHERE { ?pelicula mdb:filmid ?id . ?pelicula <http://data.linkedmdb.org/resource/movie/director> ?director . ?director <http://data.linkedmdb.org/resource/movie/director_name> ?nombre_director . ?director <http://data.linkedmdb.org/resource/movie/director_directorid> ?id_director . filter ( ?id = "44396"^^xsd:int ) } 

SPARQL Results (none)

+6
source

Source: https://habr.com/ru/post/1200181/


All Articles