SOLR SPARQL

Solr SPARQL Endpoint in Two Minutes

How to store and query RDF data in Solr? Let’s do that in 2 minutes / 5 steps!

Step #1: What we need?

  • A shell  (in case you are on the dark side of the moon, all steps can be easily done in Eclipse or whatever IDE)
  • Java 7 or higher
  • Apache Maven (3.x)
  • git 

Step #2: Checkout SolRDF

Open a shell and type the following:
				
					> cd /tmp
> git clone https://github.com/agazzarini/SolRDF.git solrdf-download
				
			
				
					> cd solrdf-download/solrdf
> mvn clean install
> cd solrdf-integration-tests
> mvn clean package cargo:run
				
			

Step #3: Build and Run SolRDF

The very first time you run this command a lot of things will be downloaded, Solr included. At the end you should see something like this:
				
					[INFO] Jetty 7.6.15.v20140411 Embedded started on port [8080]
[INFO] Press Ctrl-C to stop the container...
				
			
Congrats! SolRDF is up and running!

Step #4: Add Some Data

Open another 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 
				
			
Wait a moment and…ok! You’ve added (about) 5000 triples!

Step #5: Query

				
					> cd solrdf-download/solrdf
> mvn clean install
> cd solrdf-integration-tests
> mvn clean package cargo:run
				
			
Open another shell and type the following:
Et voilà!

Share this post

Leave a Reply