Quickstart with the CLI

After deploying AnzoGraph DB, you can get a quick start to loading data and running SPARQL queries by using the AnzoGraph DB command line interface (CLI). This brief tutorial introduces you to the CLI and gets you started with loading data and running SPARQL queries.

  1. Introduction to the CLI
  2. Load and Query a Sample Data Set

Introduction to the CLI

The command line client, azgi, uses SSL protocol to interact with the database. The client exists in the <install_path>/bin directory. In a container deployment, the installation path is /opt/anzograph. On RHEL/CentOS deployments, the installation path is customizable. The default path is /opt/cambridgesemantics/anzograph. In a cluster, use azgi on the leader node only.

Running the following command displays the options that azgi supports:

./<install_path>/bin/azgi -help 

To get started, the following list describes the most frequently used azgi options:

  • azgi -c "command": Runs the command enclosed within the quotation marks. For example, the following command runs a SELECT query that returns the ?s ?p ?o triple patterns for a graph named graph:
    ./<install_path>/bin/azgi -c "select * from <graph> where {?s ?p ?o}"
  • azgi -f file.rq: Runs the query or queries saved in a file. For example, if a file called query.rq existed in the /tmp directory, the following command would run the query or queries saved in query.rq:
    ./<install_path>/bin/azgi -f /tmp/query.rq

The following examples guide you through using the azgi -c option to load RDF data. For more information about the command line interface, see Using the AnzoGraph DB CLI.

Load and Query a Sample Data Set

The instructions below guide you through using the CLI to load the sample Tickit data set from the tickit.ttl.gz directory on the file system. This simple data set captures sales activity for a fictional Tickit website where people buy and sell tickets for sporting events, shows, and concerts.

  1. Run the following command to load the Tickit Turtle files:
    azgi -c "load <dir:/<install_path>/etc/tickit.ttl.gz> into graph <http://anzograph.com/tickit>"

    Where <install_path> is the path to the anzograph installation directory. For example:

    azgi -c "load <dir:/opt/cambridgesemantics/anzograph/etc/tickit.ttl.gz> into graph <http://anzograph.com/tickit>"

    AnzoGraph DB loads the data from the files into memory, and the prompt returns when the load completes.

  2. Run the following command to count the number of triples in the tickit graph:
    azgi -c "select (count(*) as ?number) from <http://anzograph.com/tickit> where {?s ?p ?o}"
    number
    ---------
    5509095
    1 rows

If you want to continue to work with the Tickit data and run more complex queries or view explanations of the query syntax, see Working with SPARQL and the Tickit Data. For more detailed information about loading RDF data and to review load file requirements and recommendations, see Loading RDF Data from Files.