Here we will explore two RESTful ways of searching for content using Callimachus:

Keyword searches

Keyword searches may be performed on certain RDF properties. See Appendix A for a list of RDF properties that may be searched.

An OpenSearch description document may be discovered by resolving the top-level OPTIONS and looking for the Search URL. Find the link:header with rel="search" (See the section Browsing Content for details). Search results are returned in an Atom document augmented with OpenSearch response elements.

Perform an HTTP GET on the Search URL. Provide an Accept: header including its associated content type. For example:

Accept: application/opensearchdescription+xml

The equivalent curl command is:

curl -H "Accept: application/opensearchdescription+xml" ""

Which will result in:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="">
<Url type="application/atom+xml" template=";searchTerms={searchTerms}"/>

You may then perform a subsequent HTTP GET on the Template URL using the content type specified (in the Url tag's template and typeattributes), substituting your search terms for "{searchTerms}". Note that keyword searches require authentication. To actually perform a keyword search on, for example, the word "Callimachus":

Accept: application/atom+xml
Authorization: Digest username="john", realm="", ...

The equivalent curl command is:

curl --digest --user john -H "Accept: application/atom+xml" ""

Results will look like:

<?xml version="1.0"?>
<feed xmlns="" xmlns:calli=""
  xmlns:openSearch="" xmlns:app="">
                <link href=";type=html" rel="alternate"
                <title>callimachus icon</title>
                <content src="" type="text/xsl"/>
                <link href=";type=html" rel="alternate"
                <title>callimachus ontology</title>
                <content src="" type="text/xsl"/>

See the OpenSearch description for details on the OpenSearch description document syntax and the OpenSearch response elements.

SPARQL queries

The SPARQL Query Language may be used to query RDF content. Requesting Callimachus' SPARQL endpoint via an HTTP GET with an Accept: header of text/html or application/xhtml+xml (as a browser should) will return an HTML form suitable for human-centric queries. The SPARQL endpoint may also be directly used via REST calls as described below.

The location of the SPARQL endpoint may be discovered by resolving Callimachus' VoID description and parsing out its location.

Accept: application/rdf+xml

Note that this and other responses may respond with an HTTP 303 (See Other) response directing you to another location via the Location:header:

HTTP/1.1 303 See Other
Content-Length: 0

Resolve the URL provided there for the canonical location of the VoID description:

Accept: application/rdf+xml

The equivalent curl command is:

curl -L -H "Accept: application/rdf+xml" ""

A typical response looks like:

HTTP/1.1 200 OK
Age:  0
Etag:  W/"5811c8ee-7566acc1"
Last-Modified:  Fri, 24 Feb 2012 14:49:19 GMT
Date:  Fri, 24 Feb 2012 17:14:01 GMT
Content-Type:  application/rdf+xml
Cache-Control:  public,max-age=868
Access-Control-Allow-Origin:  *
content-version:  "5811c8ee"
Content-Encoding:  gzip
Vary:  Accept,Accept-Charset
Content-MD5:  jUThXJZm7pQvWlmF6OKTNw==
Accept-Ranges:  bytes
Content-Length:  423
Server:  Callimachus Server/Callimachus 0.15-SNAPSHOT

<?xml version="1.0" encoding="UTF-8"?>

<rdf:Description rdf:about="">
        <audit:revision rdf:resource=""/>
        <rdf:type rdf:resource=""/>
        <foaf:primaryTopic rdf:resource=""/>

<rdf:Description rdf:about="">
        <rdf:type rdf:resource=""/>
        <foaf:homepage rdf:resource=""/>
        <void:sparqlEndpoint rdf:resource=""/>
        <void:rootResource rdf:resource=""/>
        <void:openSearchDescription rdf:resource=""/>
        <void:uriSpace rdf:resource=""/>


The SPARQL endpoint URL is provided in the void:sparqlEndpoint tag.

Use the SPARQL Protocol to perform queries via REST. See the SPARQL Protocol specification for URL parameters and the SPARQL Query Language specification for details of the query language.

curl --digest --user john --data-urlencode query@test.rq -H accept:application/sparql-results+xml
curl --digest --user john --data-urlencode