-
Notifications
You must be signed in to change notification settings - Fork 3
Querying KaBOB
There are several ways to query KaBOB once it has been built. This wiki page details a few examples. Note, before submitting queries to Blazegraph, it is worth reading the Blazegraph documentation regarding ordering of SPARQL statements.
There are some example queries on the Sample Queries wiki page.
Perhaps the easiest way to query KaBOB is to use the built-in Blazegraph UI. This is a straight forward way to test queries. It is recommended to use the LIMIT operator when experimenting with queries in the Blazegraph UI, e.g. LIMIT 100, to restrict the number of results that are returned.
To query KaBOB using the Blazegraph UI, visit the UI URL in a web browser, e.g. http://url/to/host:8889, where url/to/host/ is the URL to the machine hosting your Blazegraph instance (i.e. the machine running Docker).
Visit the Blazegraph Namespace screen, and click the Use link for the relevant namespace that you would like to query. By default the kabobhuman namespace is created during the KaBOB build process.
Then, visit the Blazegraph Query screen and input your query and click on Execute. When complete, query results will appear below the Execute button.
The Clojure Boot script in this KaBOB project has a query task included. To run, you will need to have a few dependencies installed locally.
- Java 8
- Leiningen
- Clojure Boot
Obtain a copy of this repository, using git clone or by downloading and unpacking the current release, e.g.
git clone https://github.com/UCDenver-ccp/kabob.git ./kabob.git
Install the KaBOB project by running the following from inside the base directory of the KaBOB project:
cd kabob.git
lein install
Then, the system is ready to submit queries. Queries can be submitted directly as part of the command, or can be read from a file. Query results will be printed to the console, so it may be advisable to use the LIMIT operator depending on the number of expected results.
To submit a query as part of the command, execute the following:
boot query -b -n $NAMESPACE -l http://$URL:8889 -u $USERNAME -p $PASSWORD -q $QUERY
where,
- $NAMESPACE is the repository to query, use kabobhuman by default
- $URL is the URL for the machine hosting Blazegraph (the machine running Docker)
- $USERNAME is the Blazegraph username to use (currently admin is the default. An read-only user will be added in the future)
- $PASSWORD is the Blazegraph user password (currently admin is the default. An read-only user will be added in the future)
- $QUERY is the query to execute
Alternatively, to submit a query that is read from a file, execute the following (note the use of the -f argument instead of the -q argument used above):
boot query -b -n $NAMESPACE -l http://$URL:8889 -u $USERNAME -p $PASSWORD -f $QUERY_FILE
where,
- $NAMESPACE is the repository to query, use kabobhuman by default
- $URL is the URL for the machine hosting Blazegraph (the machine running Docker)
- $USERNAME is the Blazegraph username to use (currently admin is the default. An read-only user will be added in the future)
- $PASSWORD is the Blazegraph user password (currently admin is the default. An read-only user will be added in the future)
- $QUERY_FILE is the file containing the query to execute
Blazegraph offers several APIs with which you can connect to Blazegraph directly. Please see the Blazegraph documentation for information on the REST API and the Java Client API, among others.