What are the brackets in SPARQL and why is the linked movie database limited to 2500 entries?

The following SPARQL query retrieves only 2500 records with actors and films, which I don’t know why its limited to 2500:

PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX movie: <http://data.linkedmdb.org/resource/movie/> SELECT ?id ?filmTitle ?actorName WHERE { SERVICE <http://data.linkedmdb.org/sparql> { ?film a movie:film ; movie:filmid ?id ; dcterms:title ?filmTitle ; movie:actor [ a movie:actor ; movie:actor_name ?actorName ]. } } 

Query from the answer to the question: Query the associated movie database (LMDB) using SPARQL

What does the keyword a mean? What do the square brackets [] mean?

I realized that the keyword a replaces rdf:type , and I rewrote the part of the SPARQL query without actors. But I still can not understand the meaning of the square brackets [].

 PREFIX movie: <http://data.linkedmdb.org/resource/movie/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?film ?id ?filmTitle WHERE { #VALUES ?filmTitle { "The Matrix" } SERVICE <http://data.linkedmdb.org/sparql> { ?film rdf:type movie:film. ?film movie:filmid ?id. ?film rdfs:label ?filmTitle. } } 

Thanks for your answers, but the code skips some actors for films. For example, in the movie "A Bridge Too Far" there are 18 participants, but the result of this query has only 2

 PREFIX dcterms: <purl.org/dc/terms/>; PREFIX movie: <data.linkedmdb.org/resource/movie/>; SELECT ?id ?filmTitle ?actorName WHERE { SERVICE <data.linkedmdb.org/sparql>; { ?film a movie:film ; movie:filmid ?id ; dcterms:title ?filmTitle ; movie:actor [ a movie:actor ; movie:actor_name ?actorName ]. } } ORDER BY ASC(?filmTitle) 

My edited code still giving the same result to 2 actors instead of 18

filmlist.rq

 PREFIX movie: <http://data.linkedmdb.org/resource/movie/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?film ?id ?filmTitle ?actorName WHERE { #VALUES ?filmTitle { "The Matrix" } SERVICE <http://data.linkedmdb.org/sparql> { ?film rdf:type movie:film. ?film movie:filmid ?id. ?film rdfs:label ?filmTitle. ?film movie:actor ?actorID. ?actorID movie:actor_name ?actorName. } } ORDER BY ASC(?filmTitle) 
+1
source share
2 answers

[...] is an empty node

The square brackets are described in the SPARQL 1.1 query language . In particular, see 4.1.4 Syntax for Empty Nodes

4.1.4 Syntax for empty nodes

Empty nodes in graphic templates act as variables, and not as references to specific empty nodes in the requested data.

Empty nodes are indicated by either the label form, for example, "\_:abc" , or the abbreviated form "[]" . An empty node that is used only in one place in the query syntax can be specified using [] . The unique space node will be used to form the triple pattern. The empty node labels are written as "_:abc" for the space node with the label "abc". The same empty node label cannot be used in two different main graphic templates in the same request.

The [:p :v] construct can be used in triple patterns. It creates a node form, which is used as the subject of all contained pairs of the predicate object. The created empty node can also be used in additional triple patterns in objects and objects.

Next two forms

 [ :p "v" ] . [] :p "v" . 

highlight the unique empty node label (here "b57") and the scripture is equivalent:

 _:b57 :p "v" . 

This highlighted empty node label can be used as an object or an object of additional triple patterns. For example, as a topic:

 [ :p "v" ] :q "w" . 

which is equivalent to two triples:

 _:b57 :p "v" . _:b57 :q "w" . 

and as an object:

 :x :q [ :p "v" ] . 

which is equivalent to two triples:

 :x :q _:b57 . _:b57 :p "v" . 

a is short for rdf:type

What does a keyword mean? What are the square brackets [] for?

I realized that the keyword a is a replacement for rdf: type

There is not much more to say than that. You can use a instead of rdf:type :

4.2.4 rdf: type

The keyword "a" can be used as a predicate in a triple pattern and is an alternative to IRI http://www.w3.org/1999/02/22-rdf-syntax-ns#type . This keyword is case sensitive.

 ?xa :Class1 . [ a :appClass ] :p "v" . 

- syntactic sugar for:

 ?x rdf:type :Class1 . _:b0 rdf:type :appClass . _:b0 :p "v" . 

LinkedMDB imposes some odd limits

The LinkedMDB endpoint places some odd limits on query results. Some other questions and answers related to this in the past, including:

If you need to get some specific results that fall outside the default return range, you probably want to include order by and then limit . However, this endpoint has some weird behavior, and for specific problems you are probably best off contacting them directly; some of these oddities do not indicate a problem with your request, but this is just an endpoint problem.

+7
source

Square brackets are empty nodes in SPARQL, see http://www.w3.org/TR/sparql11-query/#QSynBlankNodes

It looks like a new variable. Therefore, instead of:

 ?film movie:actor [ a movie:actor ; movie:actor_name ?actorName ]. 

You can write:

 ?film movie:actor ?actor . ?actor a movie:actor . ?actor movie:actor_name ?actorName . 

where ?actor is a new variable that is not used anywhere else. For different b-nodes (different pairs of brackets), these would be different variables.

As for the limit, I do not know. The server is currently unavailable, so I cannot verify. These may be some of the restrictions that they have set up on their side.

In any case, in order to get all the results, you must “paginate” the results using SPARQL LIMIT and OFFSET .

+5
source

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


All Articles