GraphStore`
GraphStore`

SPARQLSelect

SPARQLSelect[pattern]

is a query operator that can be applied to an RDFStore, which returns a list of associations of variables to corresponding values in subgraphs that match pattern.

SPARQLSelect[patternvars]

returns values only for the variables vars.

Details

  • SPARQLSelect can be used in SPARQLExecute to query a SPARQL endpoint.
  • The result of executing SPARQLSelect[pattern] is a list of associations {<|"var1"val1,1,|>,} where each "vari" is the name of a SPARQLVariable appearing in pattern and each vali,j is the value appearing in the corresponding position of a matching subgraph.
  • In SPARQLSelect[pattern], pattern can be any of the following forms:
  • RDFTriple[s,p,o]triple pattern
    {RDFTriple[],RDFTriple[],}basic graph pattern
    {patt1,patt2,}group graph pattern
    patt/;exprfilter solutions by expr
    SPARQLOptional[patt]optional pattern
    patt1|patt2|...union pattern
    Except[patt]eliminate solutions which are compatible with patt
    SPARQLPropertyPath[]property path pattern
    "var"exprbind expression expr to a variable with name "var"
    SPARQLValues[vars, values]specify values for variables
    SPARQLSelect[patt]subquery
    SPARQLGraph[g,patt]match patt agains the graph with name g
    SPARQLService[url,patt]federate matching patt to the SPARQL endpoint located at url
  • In a triple pattern RDFTriple[s,p,o] a SPARQLVariable stands for any expression.
  • The following options can be given:
  • "Distinct"Falsewhether duplicate solutions are deleted
    "Limit"Infinitymaximum numer of solutions to return
    "Offset"0number of solutions to skip
    "OrderBy"Noneexpression by which solutions are ordered
    "Reduced"Falsewhether duplicate solutions can be deleted

Examples

open all close all

Basic Examples  (2)

In[1]:=
Click for copyable input

Data about fruits:

In[2]:=
Click for copyable input
In[3]:=
Click for copyable input

Find the color of fruits:

In[4]:=
Click for copyable input
Out[4]=

Find the color and the shape of fruits:

In[5]:=
Click for copyable input
Out[5]=
In[1]:=
Click for copyable input

Find formulas (P274) and the Japanese name of chemicals (Q11173) containing (P527) calcium (Q706) in Wikidata:

In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=

Scope  (9)

Neat Examples  (1)