Scroll to navigation

4S-QUERY(1J) 1J (4store) 4S-QUERY(1J)


Run SPARQL queries on a 4store storage backend


4s-query kb-name [-f format] [-O optimisation-level] [-I insert-mode] [-r] [-s soft-limit] [-b base-URI] [-e] [-P] [query]
Set the format to output results it, options are "sparql", "text", "json", and "testcase"
Set the optimisation level of the query engine, in the range 0-3.
Treat CONSTRUCT statements as INSERT statements. This feature is highly experimental and largely untested.
Enable query complexity restriction mode
Override default soft limit on search breadth
Enable SPARQL default graph support
Set base URI for queries
Return an explanation of the query planner's decisions
Enable programatic IO mode


If [query] is omitted then 4s-query goes into interactive mode, suitable for trying queries from the command line.

-P enables programmatic interactive mode, suitable for interfacing with processes via stdin and stdout. Queries are sent as UTF-8 bytes, terminated with "#EOQ" on a line of it's own, results are returned, ending with "#EOR". Interacting with 4store in this way is more efficient than using the SPARQL protocol, but non-standard.


4s-import(1), 4s-httpd(1), 4s-backend(1), 4s-delete-model(1)


4s-query implements the SPARQL Query Language specification (aka. SPARQL/Query 1.0) and the SPARQL Result Format specification (aka. SPARQL/Results 1.0).

Default graph support is no normally enabled, the --default-graph turns it on, as does specifying FROM <default:> in the query. Data loaded with

$ 4s-import kb --add -m default: uri/filename

will be added to the default graph.


$ 4s-query -f sparql demo 'SELECT * WHERE { ?s ?p ?s } LIMIT 10'

Return 10 random triples from the knowledgebase "demo" in the SPARQL XML result format.

$ 4s-query -P demo < query.rq

Run the query in query.rq and output the result to stdout

2009-07-08 4store