eXist Command: query

invokes an 'ad-hoc' query supplied locally

Synopsis

query [exist options] [options] query-uri

Description

Invokes an ad-hoc query supplied locally and executed on the eXist server.


Options

The query command accepts all eXist Common Options in addition to

-start #Start at result row # (default 1)
-max #Return at most # results (default no limit)
-q querySpecifies the query to execute as an argument
-f query_fileSpecifies the name of the file containing the query
-t,-textOutputs the result as text. Equivalent to -contentType text/plain
-b,-binaryOutputs the result as binary. Equivilent to -contentType application/octet-stream
-x,-xml Outputs the result as xml. Equivalent to -contentType text/xml
-rawOutputs the results without any parsing.
-session sessionidAssociates a session with this query
-p property=value,
-prop property=value
Assigns a property with the query
-vSpecifies that external variables are supplied as argument pairs at the end of the command line - NOT IMPLEMENTED IN CURRENT VERSION of eXist Server
-m,-metaOutputs the meta data returned with the query as the first element of the result sequence as well as the results


If no -f or -q is specified then the first argument is taken to be the query.

Example

Assuming the prefix "e" is imported as the exist, invokes the query '"Hello World"'


e:query "'Hello World'"


Result
Hello World



Execute the query '1 to 5,"hello",<text>world</text>'

e:query -q '1 to 5,"hello",<text>world</text>'


Result
1
2
3
4
5
hello
<text>world</text>


The same query stored in a variable then outputting the 6th element

e:query -q '1 to 5,"hello",<text>world</text>' >{result}
echo ${result[6]}


Result
hello


The same query but include the meta data returned as the first element

e:query -m -q '1 to 5,"hello",<text>world</text>'


Result
<exist:result xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:hits="7"
			  exist:start="1"
			  exist:count="7"/>
1
2
3
4
5
hello
<text>world</text>


The same query without any processing returning exactly what the eXist server returns.

e:query -raw -q '1 to 5,"hello",<text>world</text>'


Result
<exist:result xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:hits="7" exist:start="1" exist:count="7">
	<exist:value exist:type="xs:integer">1</exist:value>
	<exist:value exist:type="xs:integer">2</exist:value>
	<exist:value exist:type="xs:integer">3</exist:value>
	<exist:value exist:type="xs:integer">4</exist:value>
	<exist:value exist:type="xs:integer">5</exist:value>
	<exist:value exist:type="xs:string">hello</exist:value>
	<text>world</text>
</exist:result>







Implementation


query is implemented using the REST protocol POST methods.
Currently the -v option is unimplmented until eXist support for external variables makes it into a release branch.


See http://exist.sourceforge.net/devguide_rest.html


eXist Extension Module
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki