openanzo setup (on Mac OSX)

Installing, setting up and running openanzo

Having unzipped the download at /Applications/openanzo-3.1.0

installation directory viewI first needed to make sure that the script 'start.sh' points to the right Java version (needs to be an SDK) and the correct anzo home directory.

ANZO_HOME=/Applications/openanzo-3.1.0/
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/
After having done this you can run the start.sh script.

start.shMake sure you wait long enough until you see "All Currently Registered Services started."

One can check the status of the server at http://localhost:8080/status

openanzo statusSetting up and running anzo's command line interface

I made following changes to the 'anzo' script file.

JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/
ANZO_CLI_HOME=/Applications/openanzo-3.1.0/

Then opening a new shell and running 'anzo' gives you access to the anzo command line interface.

anzo's CLI

From there on, you are in business.

You find extensive info on the anzo CLI at http://www.openanzo.org/projects/openanzo/wiki/CommandLineInterface.

Example use of the CLI

I have my RDF sample file named 'books27.rdf' and I want to upload this to the repository. I can use the import command for that.

anzo import /Users/paul/books27.rdf

But this returns a error message.

ErrorCode[1024:131125] [CLIENT_ERROR] Error executing command:[graph option must be set for format RDFXML since this format does not support named graphs]

Leading us to the most essential lesson related to openanzo: it is a quad store and every graph you load needs to receive a unique identifier. So if we add a unique graph identifier to our import command using the -g parameter, our import succeeds.

anzo import -g http://www.example.com/graph1 /Users/paul/books27.rdf

From now on we can query our quads.

anzo query "SELECT ?title FROM <http://www.example.com/graph1> WHERE {?book a book:Novel. ?book dc:title ?title. }"

?title
-----------------------------
"The Sea Wolf"
"Call of the Wild"
"Treasure Island"
"Oliver Twist"
"Great Expectations"
"David Copperfield"
"Around the World in 80 Days"

Question 1: prefix mapping?

An attentive reader will bring up following question. How does the system know what the prefixes 'book' and 'dc' refer to, since this mapping hasn't been done in the query itself.

openanzo is using a mapping file for this.
On Mac OSX and other Unix flavours it is using the file 'settings.trig' on path ~/.anzo/settings.trig

In my case this file contains following mappings:

### standard prefixes
@prefix foaf      : <http://xmlns.com/foaf/0.1/> .
@prefix rdfs : <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dc : <http://purl.org/dc/elements/1.1/> .
@prefix xsd : <http://www.w3.org/2001/XMLSchema#> .
@prefix ex : <http://example.com/> .
@prefix book : <http://www.siderean.com/ia/ns/bookdemo/>.
@prefix dcterms : <http://purl.org/dc/terms/>.

This facility makes writing queries much easier.

Question 2: graph id?

I used in my query "FROM <http://www.example.com/graph1>". What if I do not remember the unique identifier of the graph I want to query?

You can add the '-a' parameter, which performs the query then to a merge of all named graphs in the repository.

anzo query -a "SELECT ?title WHERE {?book a book:Novel. ?book dc:title ?title. }"
?title
-----------------------------
"Treasure Island"
"Around the World in 80 Days"
"David Copperfield"
"Oliver Twist"
"Great Expectations"
"Call of the Wild"
"The Sea Wolf"

This all went pretty easy.

What I like and dislike about openanzo to follow soon.



Comments