Query (QPF)#
Changed in version 2.0.
ESS provides a Query service that allows a Pod Owner (or other agents with Control access to the Pod) to query RDF (Resource Description Framework) data in the Pod. Specifically, ESS Query service provides a Quad Pattern Fragment (QPF) interface that the Pod Owner (or other agents with Control access to the Pod) can use to query RDF data.
Requirements#
Indexed Data#
To return data that match the query quad pattern, the RDF resource must be indexed by the Query service’s indexer.
To index Pod resources for querying, the indexer requires:
Read access to the Resource.
You can grant Read access specifically to the indexer using its WebID:
https://fragments-indexer.{ESS DOMAIN}/id
In addition, like any other agent, the indexer has Read access to those resources with Read access granted to the Public.
Change notifications on the Resource.
That is, once the indexer is given Read access to a Resource, a Resource change notification triggers the indexing of that Resource.
Important
Because the indexing occurs after the indexer consumes a change notification event, the query results lag behind the current state of the Resource. The delay amount depends on the lag in the notification queue.
Querying Agent Access#
Only Agents who have Control Read access to the root of the Pod, such as the Pod Owner, can access data from the QPF endpoint.
You can further specify which applications can query the endpoint by granting specific applications appropriate access.
UMA and Solid-OIDC Access Tokens#
For query access to the Pod, the ESS’ Query service can use either:
UMA token, or
Solid-OpenID Connect (OIDC) access token.
With the UMA authorization flow:
When you issue your query without an access token, the Query service returns a
401
along with a ticket and authorization server in the WWW-Authenticate header.From the authorization server, the client can exchange the UMA ticket for the UMA access token.
To exchange the UMA ticket for the access token, the client must include its
client_id
.
Include the access token in the header of your query request and retry.
Querying RDF Data#
RDF statements have the following form (also known as a triple):
<subject> <predicate> <object>
For a given Pod, ESS Query service
allows the Pod Owner (or other agents with Control access to the Pod)
to query the Pod’s RDF resources based on the QPF quad pattern selector;
i.e., a combination of subject
, predicate
,
object
, and graph
(where graph
indicates the resource URL).
https://fragments.{ESS DOMAIN}/qpf?storage={POD}&subject={SUBJECT}&predicate={PREDICATE}&object={OBJECT}&graph={GRAPH}
Important
ESS Query service scopes its queries to a single Pod, specified in the
storage
query parameter.ESS Query service returns results that may lag behind the current state of the Resources. For details, see Query Service Indexer and Query Response.
Query Parameters#
To query a Pod using QPF, you can specify the following query
parameters to the service as part of a GET
operation:
?storage={POD}&subject={SUBJECT}&predicate={PREDICATE}&object={OBJECT}&graph={GRAPH}
Tip
The Query service includes the
Hypermedia Control as part of every result set.
You can issue a GET
to the service with only the storage
parameter set (i.e., omit the data matching pattern parameters) to
return just the Hypermedia Control.
The Hypermedia Control provides the supported query template and mapping of the QPF quad pattern selector parameters for querying data. Hypermedia Control acts as the definitive source.
The table of parameters is provided below only to complement the returned Hypermedia Control information.
Parameter |
Description |
---|---|
|
Required. URL of the Pod to query. URL-encode the value. If the Note
|
|
The subject to match, as defined in the QPF quad pattern selector. Triples with blank node values will be normalized into statements with URIs. URL-encode the value. |
|
The predicate to match, as defined in the QPF quad pattern selector. URL-encode the value. |
|
The object to match, as defined in the QPF quad pattern selector. URL-encode the value. |
|
The graph (the URL of the Resource) to match, as defined in the QPF quad pattern selector. URL-encode the value. |
Query Response#
Important
The query results may lag behind the current state of the Resource. For more details, see Query Service Indexer.
The response includes:
Hypermedia Control that includes the definitive search pattern template.
Metadata that includes the estimated count of matching data and links for pagination.
Matching Data Results that includes up to
INRUPT_FRAGMENTS_PAGE_SIZE
number of matching records.
For example:
<https://fragments.example.com/qpf?storage=https%3A%2F%2Fstorage.example.com%2Ff0a179f8-zzzz-9999-aa17-7912971b69d6%2F>
<http://rdfs.org/ns/void#subset>
<https://fragments.example.com/qpf?storage=https%3A%2F%2Fstorage.example.com%2Ff0a179f8-zzzz-9999-aa17-7912971b69d6%2F&object=https%3A%2F%2Fwww.w3.org%2Fns%2Factivitystreams%23Article> ;
<http://www.w3.org/ns/hydra/core#search>
[ <http://www.w3.org/ns/hydra/core#mapping>
[ <http://www.w3.org/ns/hydra/core#property>
<http://www.w3.org/ns/sparql-service-description#graph> ;
<http://www.w3.org/ns/hydra/core#variable>
"graph"
] ;
<http://www.w3.org/ns/hydra/core#mapping>
[ <http://www.w3.org/ns/hydra/core#property>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ;
<http://www.w3.org/ns/hydra/core#variable>
"subject"
] ;
<http://www.w3.org/ns/hydra/core#mapping>
[ <http://www.w3.org/ns/hydra/core#property>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> ;
<http://www.w3.org/ns/hydra/core#variable>
"predicate"
] ;
<http://www.w3.org/ns/hydra/core#mapping>
[ <http://www.w3.org/ns/hydra/core#property>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ;
<http://www.w3.org/ns/hydra/core#variable>
"object"
] ;
<http://www.w3.org/ns/hydra/core#template>
"https://fragments.example.com/qpf?storage=https%3A%2F%2Fstorage.example.com%2Ff0a179f8-zzzz-9999-aa17-7912971b69d6%2F{&graph,subject,predicate,object}"
] .
<https://fragments.example.com/qpf?storage=https%3A%2F%2Fstorage.example.com%2Ff0a179f8-zzzz-9999-aa17-7912971b69d6%2F&object=https%3A%2F%2Fwww.w3.org%2Fns%2Factivitystreams%23Article>
<http://rdfs.org/ns/void#subset>
<https://fragments.example.com/qpf?storage=https%3A%2F%2Fstorage.example.com%2Ff0a179f8-zzzz-9999-aa17-7912971b69d6%2F&object=https%3A%2F%2Fwww.w3.org%2Fns%2Factivitystreams%23Article> ;
<http://rdfs.org/ns/void#triples>
"10"^^<http://www.w3.org/2001/XMLSchema#long> ;
<http://www.w3.org/ns/hydra/core#next>
<https://fragments.example.com/qpf?storage=https%3A%2F%2Fstorage.example.com%2Ff0a179f8-zzzz-9999-aa17-7912971b69d6%2F&object=https%3A%2F%2Fwww.w3.org%2Fns%2Factivitystreams%23Article&after=1051973> ;
<http://www.w3.org/ns/hydra/core#previous>
<https://fragments.example.com/qpf?storage=https%3A%2F%2Fstorage.example.com%2Ff0a179f8-zzzz-9999-aa17-7912971b69d6%2F&object=https%3A%2F%2Fwww.w3.org%2Fns%2Factivitystreams%23Article&before=1051955> ;
<http://xmlns.com/foaf/0.1/isPrimaryTopicOf>
[] .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/publicList#title3>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/publicList#title1>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/publicList#title4>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/publicList#title2>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/publicList#title0>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/indexerOnlyList#title2>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/indexerOnlyList#title0>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/indexerOnlyList#title3>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/indexerOnlyList#title1>
a <https://www.w3.org/ns/activitystreams#Article> .
<https://storage.example.com/f0a179f8-zzzz-9999-aa17-7912971b69d6/readingLists/indexerOnlyList#title4>
a <https://www.w3.org/ns/activitystreams#Article> .
For more information, see Query Service.