main menu

sol-query component

Query RDF documents and SPARQL endpoints using triple patterns, inline SPARQL strings, or stored SPARQL queries. Display results as a table, an auto-complete field, a rolodex, or other built-in or custom views. Federated queries (multiple endpoints) and replaceable query parameters are both supported. Queries are executed by Comunica and support Solid authenticated fetch when available and needed.

AttributeDescription
endpoint One or moe URI(s) of RDF documents or SPARQL endpoints. (required)
sparql A SPARQL string, or URI of a stored query.
pattern A triple pattern.
replaceable parameters See below for using replaceable parameters.
view The name of a built-in view or URI of a custom view.

Attributes

endpoint attribute

The endpoint attribute is one or more URIs which may point to either RDF documents or SPARQL endpoints.

Fetch all data in a single RDF document
<sol-query endpoint="https://example.org/data.ttl"></sol-query>
Fetch data on a single subject in an RDF document
<sol-query endpoint="https://example.org/data.ttl#MySubject"></sol-query>
Fetch results of query on multiple endpoints or documents
<sol-query
    endpoint="https://example.org/endpoint1, https://example.org/endpoint2"
    sparql="https://example.org/myQueryLibrary.ttl#MyQuery"
></sol-query>

sparql attribute

The sparql attribute is either a literal SPARQL string, or the URI of a stored SPARQL query.

Query using an inline SPARQL string.
<sol-query
    endpoint="https://example.org/myEndpoint"
    sparql="SELECT ?s ?p ?o WHERE {?s ?p ?o.}"
></sol-query>
Query using a stored SPARQL string.
<sol-query
    endpoint="https://example.org/myEndpoint"
    sparql="https://example.org/myQueryLibrary.ttl#MyQuery"
></sol-query>

Note

When processing stored queries, the component expects the query string to be stored using the rdfs:comment predicate. Consumers may want to use this SHACL Shape for Query Libraries.

pattern attribute

The pattern attribute is a string triple pattern.
Query using a triple pattern containing a known prefix.
<sol-query
    endpoint="https://example.org/myRDFdocument"
    pattern="?person schema:name ?name"
></sol-query>
Query using a triple pattern containing an unknown prefix.
<sol-query
    endpoint="https://example.org/myRDFdocument"
    pattern="?person <https://example.org/name> ?name"
></sol-query>

replaceable parameters

Replaceable prameters can be specified using attributes starting with "var-". For example, here is an HTML component specifying a parameter called "limit" to be used with the stored query shown below it.
<sol-query
    endpoint="..."
    sparql="../data/myQueryLibrary.ttl#MyReplaceAbleQuery"
    var-limit="2"
></sol-query>
<#MyReplaceAbleQuery>
   a sparql:query ;
   rdfs:comment """
     PREFIX schema: <http://schema.org/>
     SELECT ?name ?age ?location WHERE {
       ?person a schema:Person;
               schema:name ?name;
               schema:age ?age;
               schema:location ?location.
     } LIMIT {{limit}}
   """ .

view attribute

The view attribute is the name of a built-in view or the URI of a custom view. Regardless of how the model is gathered (triple pattern, SPARQL, etc.) the results are presented in a view. Here are examples of the same SPARQL query presented in a variety of interactive and non-interactive views