Skip to content

User Guide

Andrea Gazzarini edited this page Mar 16, 2015 · 22 revisions

Get me up and running

The following page will guide you through the SolRDF quick installation. I assume you already have Java (7), Maven (3.x) and git on your system.

  1. Checkout the project Open a new shell and type the following:
# cd /tmp
# git clone https://github.com/agazzarini/SolRDF.git solrdf-download
  1. Build and run SolrRDF
# cd solrdf-download/solrdf
# mvn clean package cargo:run

The very first time you run this command a lot of things will be downloaded, Solr included. At the end you should see sheomething like this:

[INFO] Jetty 7.6.15.v20140411 Embedded started on port [8080]
[INFO] Press Ctrl-C to stop the container...

SolRDF is up and running!

Add data

Now let's add some data. Open a new shell and type the following

# curl -v http://localhost:8080/solr/store/update/bulk?commit=true \ 
  -H "Content-Type: application/n-triples" \
  --data-binary @/tmp/solrdf-download/solrdf/src/test/resources/sample-data/bsbm-generated-dataset.nt

Ok, you just added (about) 5000 triples.

SPARQL 1.1. endpoint

SolRDF is a fully compliant SPARQL 1.1. endpoint. In order to issue a query just run a query like this:

# curl "http://127.0.0.1:8080/solr/store/sparql" \
  --data-urlencode "q=SELECT * WHERE { ?s ?p ?o } LIMIT 10" \
  -H "Accept: application/sparql-results+json"
  
Or  
  
# curl "http://127.0.0.1:8080/solr/store/sparql" \
  --data-urlencode "**q=SELECT * WHERE { ?s ?p ?o } LIMIT 10**" \
  -H "Accept: application/sparql-results+xml"

Hybrid mode

If the request contains a valid SPARQL query and at least one of the parameters listed below, SolRDF switches in a so-called "Hybrid" mode. That enables a set of interesting features like results pagination (without using the LIMIT keyword) and faceting (on the overall results of the SPARQL query).

Parameter Description Reference
rows The maximum number of results that will be returned in response. In case of negative or invalid value it defaults to 10. Solr Wiki (rows)
start The start offset in the complete result set. In case of negative or invalid value it defaults to 0. Solr Wiki (start)
facet A boolean value that enables or disables (default) faceting Solr Wiki (facet)
facet.field The name of the field which should be treated as a facet. In case of multiple fields, the parameter can be repeated in the request Solr Wiki (facet.field)

For more information about Solr query and facet parameters see here [1] and here [2]. Remember that only parameters listed in the table above are "supported". Hopefully I will gradually all the other parameters.

When SolRDF runs in Hybrid mode, it will produce a response like this:

<?xml version="1.0" encoding="UTF-8"?>
<response>
	<lst name="responseHeader">
		<int name="status">0</int>
		<int name="QTime">25</int>
		<int name="rows">2</int>
		<int name="start">100</int>
		<str name="query">SELECT *
		   WHERE
		   { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o}
		</str>
	</lst>
	<result name="response" numFound="18176" start="100" maxScore="1.0">
		<sparql xmlns="http://www.w3.org/2005/sparql-results#">
			<head>
				<variable name="s" />
				<variable name="o" />
			</head>
			<results>
				<result>
					<binding name="s">
						<bnode>b0</bnode>
					</binding>
					<binding name="o">
						<uri>http://purl.org/dc/terms/W3CDTF</uri>
					</binding>
				</result>
				<result>
					<binding name="s">
						<uri>http://www.gutenberg.org/feeds/catalog.rdf#etext20867</uri>
					</binding>
					<binding name="o">
						<uri>http://www.gutenberg.org/rdfterms/etext</uri>
					</binding>
				</result>
			</results>
		</sparql>
	</result>
	<lst name="facet_counts">
		<lst name="facet_queries" />
		<lst name="facet_fields">
		    <lst name="p">
			<int name="<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>">18176</int>
		    </lst>
		</lst>
		<lst name="facet_dates" />
		<lst name="facet_ranges" />
	</lst>
</response>

[1] http://wiki.apache.org/solr/CommonQueryParameters
[2] https://wiki.apache.org/solr/SimpleFacetParameters