Fix and remove OSI reference.
[yaz-moved-to-github.git] / doc / client.xml
1 <!-- $Id: client.xml,v 1.7 2001-11-27 22:12:24 adam Exp $ -->
2  <chapter id="client"><title>The YAZ client</title>
3   <sect1 id="client.introduction"><title>Introduction</title>
4    <para>
5     yaz-client is a line-mode Z39.50 client. It supports a fair amount
6     of the functionality of the Z39.50-1995 standard, but some things you
7     need to enable or disable by re-compilation.
8     Its primary purpose is to exercise the
9     package, and verify that the protocol works OK.
10     For the same reason some commands offers more functionality than others.
11     Commands that exercises common Z39.50 services such as search and present
12     have more features than less common supported services, such as Extended
13     Services (ItemOrder, ItemUpdate,..).
14    </para>
15   </sect1>
16   <sect1 id="client.invoking"><title>Invoking the YAZ client</title>
17    <para>
18     It can be started by typing
19    </para>
20    <screen>
21      yaz-client [<replaceable>options</replaceable>] [<replaceable>zurl</replaceable>]
22    </screen>
23    <simpara>
24     in a UNIX shell / WIN32 console. The <replaceable>zurl</replaceable>,
25     specifies a Z39.50 host and, if specified, the client first tries to
26     establish connection with the Z39.50 target on the host.
27     Options are, as usual, are prefixed by <literal>-</literal> followed
28     by a particular letter.
29     </simpara>
30    <simpara>
31     The following options are supported:
32    </simpara>
33    <variablelist>
34     <varlistentry><term>
35       <literal>-m</literal> <replaceable>fname</replaceable>
36      </term><listitem>
37       <simpara>ISO2709 records are appended to file
38        <replaceable>fname</replaceable>. All records as returned by a target(s)
39        in Search Responses and Present Responses are appended verbatim to 
40        the file.
41       </simpara></listitem>
42     </varlistentry>
43     <varlistentry><term>
44       <literal>-a</literal> <replaceable>fname</replaceable>
45      </term><listitem>
46       <simpara>Pretty-print log of APDUs sent and received is appended
47        to the file <replaceable>fname</replaceable>.
48        If <replaceable>fname</replaceable> is <literal>-</literal> (minus)
49        the APDU log is written to <literal>stderr</literal>.
50       </simpara></listitem>
51     </varlistentry>
52     <varlistentry><term>
53       <literal>-c</literal> <replaceable>fname</replaceable>
54      </term><listitem>
55       <simpara>Sets the filename for CCL fields to
56        <replaceable>fname</replaceable>. If this option is not given the
57        YAZ client reads CCL fields from file <literal>default.bib</literal>.
58       </simpara></listitem>
59     </varlistentry>
60     <varlistentry><term>
61       <literal>-v</literal> <replaceable>level</replaceable>
62      </term><listitem>
63       <simpara>Sets the LOG level to <replaceable>level</replaceable>.
64        Level is a sequence of tokens separated by comma. Each token
65        is a integer or a named LOG item - one of 
66        <literal>fatal</literal>,
67        <literal>debug</literal>,
68        <literal>warn</literal>,
69        <literal>log</literal>,
70        <literal>all</literal>,
71        <literal>none</literal>.
72       </simpara></listitem>
73     </varlistentry>
74    </variablelist>
75    <para>
76     In order to connect to Index Data's test Z39.50 server on
77     <literal>bagel.indexdata.dk</literal>, port 210 and with the
78     database name marc, one would have to type
79    </para>
80    <screen>
81     yaz-client bagel.indexdata.dk:210/marc
82    </screen>
83    <para>
84     In order to enable APDU log and connect to localhost, port 210 (default)
85     and database Default (default) you'd write:
86    </para>
87    <screen>
88     yaz-client -a - localhost
89    </screen>
90   </sect1>
91   <sect1 id="client.commands"><title>Commands</title>
92    <para>
93     When the YAZ client has read options and connected to a target, if given,
94     it will display <literal>Z &gt;</literal> and away your command.
95     Commands are executed by hitting the return key.
96     You can always issue the command <literal>?</literal> to see the list
97     of available commands.
98     </para>
99    <para>
100     The commands are (the letters in parenthesis are short
101     names for the commands):
102    </para>
103    <variablelist>
104     <varlistentry><term>
105       <literal>open </literal><replaceable>zurl</replaceable>
106      </term>
107      <term><literal>o</literal></term>
108      <listitem>
109       <para>Opens a connection to a server. The syntax for
110        <replaceable>zurl</replaceable> is the same as described
111        above for connecting from the command line.
112       </para>
113       <para>
114        Syntax:
115       </para>
116       <para>
117        [<literal>(tcp|ssl)':'</literal>]<replaceable>host</replaceable>[:<replaceable>port</replaceable>][/<replaceable>base&gt</replaceable>]
118       </para>
119      </listitem>
120     </varlistentry>
121     <varlistentry><term>
122       <literal>quit</literal>
123      </term>
124      <term><literal>q</literal></term>
125      <listitem>
126       <para>Ends YAZ client</para>
127      </listitem>
128     </varlistentry>
129     <varlistentry><term>
130       <literal>f </literal><replaceable>query</replaceable></term>
131      <listitem>
132       <para>Sends a Search Request using the <replaceable>query</replaceable>
133        given.
134       </para>
135      </listitem>
136     </varlistentry>
137     <varlistentry><term>
138       <literal>delete</literal> <replaceable>setname</replaceable></term>
139      <listitem>
140       <para>Deletes result set with name <replaceable>setname</replaceable>
141        on the server.</para>
142      </listitem>
143     </varlistentry>
144     <varlistentry><term>
145       <literal>base </literal><replaceable>base1</replaceable>
146       <replaceable>base2</replaceable> ...
147       </term>
148      <listitem>
149       <para>Sets the name(s) of the database(s) to search. One or more
150        databases may be specified separated by blanks. This commands overrides
151        the database given in <replaceable>zurl</replaceable>.
152        </para>
153      </listitem>
154     </varlistentry>
155     <varlistentry><term>
156       <literal>show </literal> [<replaceable>start</replaceable>[+<replaceable>number</replaceable>]]
157       </term>
158      <term><literal>s</literal></term>
159      <listitem>
160       <para>Fetches records by sending a Present Request from the start
161        position given by
162        <replaceable>start</replaceable>
163        a number of records given by <replaceable>number</replaceable>. If
164        <replaceable>start</replaceable> is not given, then the client
165        will fetch from position of the last retrieved record plus 1. If
166        <replaceable>number</replaceable> is not given, then one record will
167        be fetched at a time.
168       </para>
169       </listitem>
170     </varlistentry>
171     <varlistentry><term>
172       <literal>scan</literal> <replaceable>term</replaceable>
173      </term>
174      <listitem>
175       <simpara>Scans
176        database index for a term. The syntax resembles the syntax
177        for <literal>find</literal>.
178        If you want to scan for the word <literal>water</literal> you could
179        write
180        </simpara>
181       <screen>
182        scan water
183       </screen>
184       <simpara>
185        but if you want to scan only in, say the title field, you would write
186        </simpara>
187       <screen>
188        scan @attr 1=4 water
189       </screen>
190      </listitem>
191     </varlistentry>
192     <varlistentry id="sortspec"><term>
193       <literal>sort</literal> <replaceable>sortspecs</replaceable>
194      </term>
195      <listitem>
196       <para>Sorts a result set. The sort command takes a
197        sequence of sort specifications. A sort
198        specification holds a field (sort criteria) and is followed by flags.
199        If the sort criteria includes <literal>=</literal> it is assumed
200        that the sort SortKey is of type sortAttributes using Bib-1.
201        The integer before <literal>=</literal> is
202        the attribute type and the integer following <literal>=</literal>
203        is the attribute value.
204        If no <literal>=</literal> is in the SortKey it is treated as a
205        sortfield-type of type InternationalString.
206        Flags observed are: <literal>s</literal>
207        for case sensitive, <literal>i</literal> for case insensitive,
208        <literal>&lt;</literal> for sort ascending and <literal>&gt;</literal>
209        for sort descending.
210       </para>
211      </listitem>
212     </varlistentry>
213     <varlistentry><term>
214       <literal>sort+</literal>
215      </term>
216      <listitem>
217       <para>Same as <literal>sort</literal> but stores the sorted
218        result set in a new result set.
219       </para>
220      </listitem>
221     </varlistentry>
222     <varlistentry><term>
223       <literal>authentication</literal> <replaceable>openauth</replaceable>
224       </term>
225      <listitem>
226       <para>Sets up a authentication string if a server requires
227        authentication (v2 OpenStyle). The authentication string is first
228        sent to the server when the <literal>open</literal> command is
229        issued and the Z39.50 Initialize Request is sent, so this command
230        must be used before <literal>open</literal> in order to be effective.
231        A common convention for the <replaceable>authopen</replaceable> string
232        is that the username - and password is separated by a slash, e.g.
233        <literal>myusername/mysecret</literal>.
234       </para>
235      </listitem>
236     </varlistentry>
237     <varlistentry><term>
238       <literal>lslb</literal> <replaceable>n</replaceable>
239      </term>
240      <listitem>
241       <para>Sets the limit for when no records should be returned
242        together with the search result.
243        See the
244        <ulink
245         url="http://lcweb.loc.gov/z3950/agency/markup/04.html#3.2.2.1.6">
246         Z39.50 standard
247        </ulink>
248        for more details.
249       </para>
250      </listitem>
251     </varlistentry>
252
253     <varlistentry><term>
254       <literal>ssub</literal> <replaceable>n</replaceable>
255      </term>
256      <listitem>
257       <para>Sets the limit for when all records should be returned with
258        the search result.
259        See the
260        <ulink
261         url="http://lcweb.loc.gov/z3950/agency/markup/04.html#3.2.2.1.6">
262         Z39.50 standard
263        </ulink> for more details.
264       </para>
265      </listitem>
266     </varlistentry>
267     
268     <varlistentry><term>
269       <literal>mspn</literal> <replaceable>n</replaceable>
270      </term>
271      <listitem>
272       <para>Sets the number of records should be returned if the
273        number of records in the result set is between the values of
274        <literal>lslb</literal> and <literal>ssub</literal>.
275        See the
276        <ulink
277         url="http://lcweb.loc.gov/z3950/agency/markup/04.html#3.2.2.1.6">
278         Z39.50 standard
279        </ulink>
280        for more details.
281       </para>
282      </listitem>
283     </varlistentry>
284     <varlistentry><term>
285       <literal>status</literal>
286      </term>
287      <listitem>
288       <para>Displays the values of <literal>lslb</literal>,
289        <literal>ssub</literal> and <literal>mspn</literal>.
290       </para>
291      </listitem>
292     </varlistentry>
293     <varlistentry><term>
294       <literal>setname</literal>
295      </term>
296      <listitem>
297       <para>Switches named result sets on and off. Default is on.
298       </para>
299      </listitem>
300     </varlistentry>
301     <varlistentry><term>
302       <literal>cancel</literal>
303      </term>
304      <listitem>
305       <para>Sends a Trigger Resource Control Request to the target.
306       </para>
307      </listitem>
308     </varlistentry>
309     <varlistentry><term>
310       <literal>format</literal> <replaceable>oid</replaceable>
311      </term>
312      <listitem>
313       <para>Sets the preferred transfer syntax for retrieved records.
314        yaz-client supports all the record syntaxes that currently
315        are registered. See
316        <ulink
317         url="http://lcweb.loc.gov/z3950/agency/defns/oids.html#5">
318         Z39.50 Standard
319        </ulink>
320        for more details. Commonly used records syntaxes include usmarc,
321        sutrs, grs1 and xml.
322       </para>
323      </listitem>
324     </varlistentry>
325     <varlistentry><term>
326       <literal>elements</literal> <replaceable>e</replaceable>
327      </term>
328      <listitem>
329       <para>Sets the element set name for the records. Many targets support
330        element sets are B (for brief) and F (for full).
331       </para>
332      </listitem>
333     </varlistentry>
334     <varlistentry><term>
335       <literal>close</literal>
336      </term>
337      <listitem>
338       <para>Sends a Z39.50 Close APDU and closes connection with the peer
339       </para>
340      </listitem>
341     </varlistentry>
342     <varlistentry><term>
343       <literal>querytype</literal> <replaceable>type</replaceable>
344      </term>
345      <listitem>
346       <para>Sets the query type as used by command <literal>find</literal>.
347        The following is supported: <literal>prefix</literal> for 
348        <link linkend="PQF">Prefix Query Notation</link> (Type-1 Query);
349        <literal>ccl</literal> for CCL search (Type-2
350        Query) or <literal>ccl2rpn</literal> for
351        <link linkend="CCL">CCL</link> to RPN conversion (Type-1 Query).
352       </para>
353      </listitem>
354     </varlistentry>
355     <varlistentry><term>
356       <literal>attributeset</literal> <replaceable>set</replaceable>
357      </term>
358      <listitem>
359       <para>
360        Sets attribute set OID for prefix queries (RPN, Type-1).
361       </para>
362      </listitem>
363     </varlistentry>
364     <varlistentry><term>
365       <literal>refid</literal> <replaceable>id</replaceable>
366       </term>
367      <listitem>
368       <para>Sets reference ID for Z39.50 Request(s).
369       </para>
370      </listitem>
371     </varlistentry>
372     <varlistentry><term>
373      <literal>itemorder</literal>
374       <replaceable>type</replaceable> <replaceable>no</replaceable>
375      </term>
376      <listitem>
377       <para>Sends an Item Order Request using the ILL External. 
378        <replaceable>type</replaceable> is either 1 or 2 which corresponds to
379        ILL-Profile 1 and 2 respectively. The <replaceable>no</replaceable>
380        is the Result Set position of the record to be ordered.
381       </para>
382      </listitem>
383     </varlistentry>
384     <varlistentry><term>
385       <literal>update</literal>
386      </term>
387      <listitem>
388       <para>Sends Item Update Request. This command sends a "minimal"
389        PDU to the target supplying the last received record from the target.
390        If no record has been received from the target this command is ignored
391        and nothing is sent to the target.
392       </para>
393      </listitem>
394     </varlistentry>
395    </variablelist>
396   </sect1>
397   <sect1 id="client.searching"><title>Searching</title>
398    <para>
399     The simplest example of a Prefix Query would be something like
400     <screen>
401      f knuth
402     </screen>
403     or
404     <screen>
405      f "donald knuth"
406     </screen>
407     In those queries no attributes was specified.
408     This leaves it up to the server what fields to search but
409     most servers will search in all fields. Some servers does not
410     support this feature though, and require that some attributes
411     are defined. To add one attribute you could do:
412     <screen>
413      f @attr 1=4 computer
414     </screen>
415     where we search in the title field, since the use(1) is title(4).
416     If we want to search in the author field <emphasis>and</emphasis>
417     in the title field, and in the title field using right truncation
418     it could look something like this:
419     <screen>
420      f @and @attr 1=1003 knuth @attr 1=4 @attr 5=1 computer
421     </screen>
422     Finally using a mix of Bib-1 and GILS attributes could look
423     something like this:
424     <screen>
425      f @attrset Bib-1 @and @attr GILS 1=2008 Washington @attr 1=21 weather
426     </screen>
427     For the full specification of the Prefix Query see the section
428      <link linkend="PQF">Prefix Query Format</link>.
429    </para>
430   </sect1>
431  </chapter>
432  
433  <!-- Keep this comment at the end of the file
434  Local variables:
435  mode: sgml
436  sgml-omittag:t
437  sgml-shorttag:t
438  sgml-minimize-attributes:nil
439  sgml-always-quote-attributes:t
440  sgml-indent-step:1
441  sgml-indent-data:t
442  sgml-parent-document: "yaz.xml"
443  sgml-local-catalogs: nil
444  sgml-namecase-general:t
445  End:
446  -->