Last modified 4 years ago Last modified on 04/04/11 17:27:04

Although for production use it's often easiest to work with a SPARQL HTTP protocol server, 4store includes a command line tool which can run queries directly when the HTTP daemon isn't running.

The tool has an interactive mode...

4s-query demo

In this mode you enter arbitrary SPARQL queries, then type #EOQ on a new line when you're finished, and the results are displayed in a simple tab separated fashion

4store>SELECT * WHERE { ?s ?p ?o } LIMIT 10
#EOQ
?s                ?p                 ?o
<local:dajobe>  <http://xmlns.com/foaf/0.1/nick>        "dajobe"
<local:nick>    <http://xmlns.com/foaf/0.1/nick>        "nmg"
<local:dajobe>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>       <http://xmlns.com/foaf/0.1/Person>
<local:nick>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>       <http://xmlns.com/foaf/0.1/Person>

Alternatively the tool has a command-line mode where you specify the query to run as the final parameter to the command. NB you will need to be careful about your shell's escaping rules.

4s-query demo 'SELECT * WHERE { ?s ?p ?o } LIMIT 10'

4store's query engine has a "soft limit" which prevents poorly phrased or hard to optimise queries from "running away" and consuming enormous resources. You can change this limit with the --soft-limit parameter, setting it above 1000 will make 4store work harder to try to provide a correct answer to the query, e.g. if you seem to get too few answers to a difficult query, you could try

4s-query --soft-limit 5000 demo 'SELECT ... etc.'

Setting soft-limit to -1 (minus one) disables it.