9c24fd75451ee60d1dc83817d840cca2c5626ec5
[idzebra-moved-to-github.git] / doc / server.xml
1 <chapter id="server">
2  <!-- $Id: server.xml,v 1.9 2006-01-19 09:27:00 marc Exp $ -->
3  <title>The Z39.50 Server</title>
4  
5  <sect1 id="zebrasrv">
6   <title>Running the Z39.50 Server (zebrasrv)</title>
7
8   <!--
9    FIXME - We need to be consistent here, zebraidx had the options at the
10            end, and lots of explaining text before them. Same for zebrasvr! -H
11    FIXME - At least we need a small intro, what is zebrasvr, and how it
12            can be run (inetd, nt service, stand-alone program, daemon...) -H
13   -->
14
15   <!-- re-write by MC, using the newly created input files for the 
16    zebrasrv manpage -->
17
18
19  <sect2><title>DESCRIPTION</title>
20     <para>Zebra is a high-performance, general-purpose structured text indexing
21    and retrieval engine. It reads structured records in a variety of input
22    formats (eg. email, XML, MARC) and allows access to them through exact
23    boolean search expressions and relevance-ranked free-text queries. 
24    </para>
25    <para>
26     <command>zebrasrv</command> is the Z39.50 and  <ulink url="http://www.loc.gov/standards/sru/srw/">SRW</ulink>/U frontend
27     server for the <command>Zebra</command> indexer.
28    </para> 
29    <para> 
30     On Unix you can run the <command>zebrasrv</command>
31     server from the command line - and put it
32     in the background. It may also operate under the inet daemon.
33     On WIN32 you can run the server as a console application or
34     as a WIN32 Service.
35    </para>
36   </sect2>
37
38  <sect2>
39    <title>SYNOPSIS</title>
40     &zebrasrv-synopsis;
41  </sect2>
42
43  <sect2>
44    <title>OPTIONS</title>
45     
46    <para>
47     The options for <command>zebrasrv</command> are the same
48     as those for YAZ' <command>yaz-ztest</command>.
49     Option <literal>-c</literal> specifies a Zebra configuration
50     file - if omitted <filename>zebra.cfg</filename> is read.
51    </para>
52    
53   &zebrasrv-options;
54   </sect2>
55   <sect2><title>VIRTUAL HOSTS</title>
56     <para>
57      <command>zebrasrv</command> uses the YAZ server frontend and does
58      support multiple virtual servers behind multiple listening sockets.
59     </para>
60     &zebrasrv-virtual;
61   </sect2>
62   <sect2><title>FILES</title>
63    <para>
64     <filename>zebra.cfg</filename>
65    </para>
66   </sect2>
67   <sect2><title>SEE ALSO</title>
68    <para>
69     <citerefentry>
70      <refentrytitle>zebraidx</refentrytitle>
71      <manvolnum>1</manvolnum>
72     </citerefentry>,
73     <citerefentry>
74      <refentrytitle>yaz-ztest</refentrytitle>
75      <manvolnum>8</manvolnum>
76     </citerefentry>
77    </para>
78    <para>
79     Section "The Z39.50 Server" in the Zebra manual.
80     <filename>http://www.indexdata.dk/zebra/doc/server.tkl</filename>
81    </para>
82    <para>
83     Section "Virtual Hosts" in the YAZ manual.
84     <filename>http://www.indexdata.dk/yaz/doc/server.vhosts.tkl</filename>
85    </para>
86    <para>
87     Section "Specification of <ulink url="http://www.loc.gov/standards/sru/cql/">CQL</ulink> to RPN mappings" in the YAZ manual.
88     <filename>http://www.indexdata.dk/yaz/doc/tools.tkl#tools.cql.map</filename>
89    </para>
90    <para>
91     The Zebra software is Copyright <command>Index Data</command> 
92     <filename>http://www.indexdata.dk</filename>
93     and distributed under the
94     GPLv2 license.
95    </para> 
96   </sect2>
97
98   <!--
99   <para>
100    <emphasis remap="bf">Syntax</emphasis>
101
102    <screen>
103     zebrasrv [options] [listener-address ...]
104    </screen>
105
106   </para>
107
108   <para>
109    <emphasis remap="bf">Options</emphasis>
110    <variablelist>
111
112     <varlistentry>
113      <term>-a <replaceable>APDU file</replaceable></term>
114      <listitem>
115       <para>
116        Specify a file for dumping PDUs (for diagnostic purposes).
117        The special name "-" sends output to <literal>stderr</literal>.
118       </para>
119      </listitem>
120     </varlistentry>
121     <varlistentry>
122      <term>-c <replaceable>config-file</replaceable></term>
123      <listitem>
124       <para>
125        Read configuration information from
126        <replaceable>config-file</replaceable>.
127        The default configuration is <literal>./zebra.cfg</literal>.
128       </para>
129      </listitem>
130     </varlistentry>
131     <varlistentry>
132      <term>-S</term>
133      <listitem>
134       <para>
135        Don't fork on connection requests. This can be useful for
136        symbolic-level debugging. The server can only accept a single
137        connection in this mode.
138       </para>
139      </listitem>
140     </varlistentry>
141     <varlistentry>
142      <term>-z</term>
143      <listitem>
144       <para>
145        Use the Z39.50 protocol. Currently the only protocol supported.
146        The option is retained for historical reasons, and for future
147        extensions.
148       </para>
149      </listitem>
150     </varlistentry>
151     <varlistentry>
152      <term>-l <replaceable>logfile</replaceable></term>
153      <listitem>
154       <para>
155        Specify an output file for the diagnostic messages.
156        The default is to write this information to <literal>stderr</literal>.
157       </para>
158      </listitem>
159     </varlistentry>
160     <varlistentry>
161      <term>-v <replaceable>log-level</replaceable></term>
162      <listitem>
163       <para>
164        The log level. Use a comma-separated list of members of the set
165        {fatal,debug,warn,log,all,none}.
166       </para>
167      </listitem>
168     </varlistentry>
169     <varlistentry>
170      <term>-u <replaceable>username</replaceable></term>
171      <listitem>
172       <para>
173        Set user ID. Sets the real UID of the server process to that of the
174        given <replaceable>username</replaceable>.
175        It's useful if you aren't comfortable with having the
176        server run as root, but you need to start it as such to bind a
177        privileged port.
178       </para>
179      </listitem>
180     </varlistentry>
181     <varlistentry>
182      <term>-w <replaceable>working-directory</replaceable></term>
183      <listitem>
184       <para>
185        Change working directory.
186       </para>
187      </listitem>
188     </varlistentry>
189     <varlistentry>
190      <term>-i</term>
191      <listitem>
192       <para>
193        Run under the Internet superserver, <literal>inetd</literal>.
194        Make sure you use the logfile option <literal>-l</literal> in
195        conjunction with this mode and specify the <literal>-l</literal>
196        option before any other options.
197       </para>
198      </listitem>
199     </varlistentry>
200     <varlistentry>
201      <term>-t <replaceable>timeout</replaceable></term>
202      <listitem>
203       <para>
204        Set the idle session timeout (default 60 minutes).
205       </para>
206      </listitem>
207     </varlistentry>
208     <varlistentry>
209      <term>-k <replaceable>kilobytes</replaceable></term>
210      <listitem>
211       <para>
212        Set the (approximate) maximum size of
213        present response messages. Default is 1024 KB (1 MB).
214       </para>
215      </listitem>
216     </varlistentry>
217    </variablelist>
218   </para>
219   -->
220  </sect1>
221
222
223  <sect1 id="protocol-support">
224   <title>Z39.50 Protocol Support and Behavior</title>
225
226   <sect2>
227    <title>Initialization</title>
228
229    <para>
230     During initialization, the server will negotiate to version 3 of the
231     Z39.50 protocol, and the option bits for Search, Present, Scan,
232     NamedResultSets, and concurrentOperations will be set, if requested by
233     the client. The maximum PDU size is negotiated down to a maximum of
234     1 MB by default.
235    </para>
236
237   </sect2>
238
239   <sect2 id="search">
240    <title>Search</title>
241
242    <!--
243     FIXME - Need to explain the string tag stuff before people get bogged 
244             down with all these attribute numbers. Perhaps in its own
245             chapter? -H
246    -->
247
248    <para>
249     The supported query type are 1 and 101. All operators are currently
250     supported with the restriction that only proximity units of type "word"
251     are supported for the proximity operator.
252     Queries can be arbitrarily complex.
253     Named result sets are supported, and result sets can be used as operands
254     without limitations.
255     Searches may span multiple databases.
256    </para>
257
258    <para>
259     The server has full support for piggy-backed retrieval (see
260     also the following section).
261    </para>
262
263    <para>
264     <emphasis>Use</emphasis> attributes are interpreted according to the
265     attribute sets which have been loaded in the
266     <literal>zebra.cfg</literal> file, and are matched against specific
267     fields as specified in the <literal>.abs</literal> file which
268     describes the profile of the records which have been loaded.
269     If no Use attribute is provided, a default of Bib-1 Any is assumed.
270    </para>
271
272    <para>
273     If a <emphasis>Structure</emphasis> attribute of
274     <emphasis>Phrase</emphasis> is used in conjunction with a
275     <emphasis>Completeness</emphasis> attribute of
276     <emphasis>Complete (Sub)field</emphasis>, the term is matched
277     against the contents of the phrase (long word) register, if one
278     exists for the given <emphasis>Use</emphasis> attribute.
279     A phrase register is created for those fields in the
280     <literal>.abs</literal> file that contains a
281     <literal>p</literal>-specifier.
282     <!-- ### whatever the hell _that_ is -->
283    </para>
284
285    <para>
286     If <emphasis>Structure</emphasis>=<emphasis>Phrase</emphasis> is
287     used in conjunction with <emphasis>Incomplete Field</emphasis> - the
288     default value for <emphasis>Completeness</emphasis>, the
289     search is directed against the normal word registers, but if the term
290     contains multiple words, the term will only match if all of the words
291     are found immediately adjacent, and in the given order.
292     The word search is performed on those fields that are indexed as
293     type <literal>w</literal> in the <literal>.abs</literal> file.
294    </para>
295
296    <para>
297     If the <emphasis>Structure</emphasis> attribute is
298     <emphasis>Word List</emphasis>,
299     <emphasis>Free-form Text</emphasis>, or
300     <emphasis>Document Text</emphasis>, the term is treated as a
301     natural-language, relevance-ranked query.
302     This search type uses the word register, i.e. those fields
303     that are indexed as type <literal>w</literal> in the
304     <literal>.abs</literal> file.
305    </para>
306
307    <para>
308     If the <emphasis>Structure</emphasis> attribute is
309     <emphasis>Numeric String</emphasis> the term is treated as an integer.
310     The search is performed on those fields that are indexed
311     as type <literal>n</literal> in the <literal>.abs</literal> file.
312    </para>
313
314    <para>
315     If the <emphasis>Structure</emphasis> attribute is
316     <emphasis>URx</emphasis> the term is treated as a URX (URL) entity.
317     The search is performed on those fields that are indexed as type
318     <literal>u</literal> in the <literal>.abs</literal> file.
319    </para>
320
321    <para>
322     If the <emphasis>Structure</emphasis> attribute is
323     <emphasis>Local Number</emphasis> the term is treated as
324     native Zebra Record Identifier.
325    </para>
326
327    <para>
328     If the <emphasis>Relation</emphasis> attribute is
329     <emphasis>Equals</emphasis> (default), the term is matched
330     in a normal fashion (modulo truncation and processing of
331     individual words, if required).
332     If <emphasis>Relation</emphasis> is <emphasis>Less Than</emphasis>,
333     <emphasis>Less Than or Equal</emphasis>,
334     <emphasis>Greater than</emphasis>, or <emphasis>Greater than or
335      Equal</emphasis>, the term is assumed to be numerical, and a
336     standard regular expression is constructed to match the given
337     expression.
338     If <emphasis>Relation</emphasis> is <emphasis>Relevance</emphasis>,
339     the standard natural-language query processor is invoked.
340    </para>
341
342    <para>
343     For the <emphasis>Truncation</emphasis> attribute,
344     <emphasis>No Truncation</emphasis> is the default.
345     <emphasis>Left Truncation</emphasis> is not supported.
346     <emphasis>Process # in search term</emphasis> is supported, as is
347     <emphasis>Regxp-1</emphasis>.
348     <emphasis>Regxp-2</emphasis> enables the fault-tolerant (fuzzy)
349     search. As a default, a single error (deletion, insertion, 
350     replacement) is accepted when terms are matched against the register
351     contents.
352    </para>
353
354    <sect3>
355     <title>Regular expressions</title>
356     
357     <para>
358      Each term in a query is interpreted as a regular expression if
359      the truncation value is either <emphasis>Regxp-1</emphasis> (102)
360      or <emphasis>Regxp-2</emphasis> (103).
361      Both query types follow the same syntax with the operands:
362      <variablelist>
363
364       <varlistentry>
365        <term>x</term>
366        <listitem>
367         <para>
368          Matches the character <emphasis>x</emphasis>.
369         </para>
370        </listitem>
371       </varlistentry>
372       <varlistentry>
373        <term>.</term>
374        <listitem>
375         <para>
376          Matches any character.
377         </para>
378        </listitem>
379       </varlistentry>
380       <varlistentry>
381        <term><literal>[</literal>..<literal>]</literal></term>
382        <listitem>
383         <para>
384          Matches the set of characters specified;
385          such as <literal>[abc]</literal> or <literal>[a-c]</literal>.
386         </para>
387        </listitem>
388       </varlistentry>
389      </variablelist>
390      and the operators:
391      <variablelist>
392       
393       <varlistentry>
394        <term>x*</term>
395        <listitem>
396         <para>
397          Matches <emphasis>x</emphasis> zero or more times. Priority: high.
398         </para>
399        </listitem>
400       </varlistentry>
401       <varlistentry>
402        <term>x+</term>
403        <listitem>
404         <para>
405          Matches <emphasis>x</emphasis> one or more times. Priority: high.
406         </para>
407        </listitem>
408       </varlistentry>
409       <varlistentry>
410        <term>x?</term>
411        <listitem>
412         <para>
413          Matches <emphasis>x</emphasis> zero or once. Priority: high.
414         </para>
415        </listitem>
416       </varlistentry>
417       <varlistentry>
418        <term>xy</term>
419        <listitem>
420         <para>
421          Matches <emphasis>x</emphasis>, then <emphasis>y</emphasis>.
422          Priority: medium.
423         </para>
424        </listitem>
425       </varlistentry>
426       <varlistentry>
427        <term>x|y</term>
428        <listitem>
429         <para>
430          Matches either <emphasis>x</emphasis> or <emphasis>y</emphasis>.
431          Priority: low.
432         </para>
433        </listitem>
434       </varlistentry>
435      </variablelist>
436      The order of evaluation may be changed by using parentheses.
437     </para>
438
439     <para>
440      If the first character of the <emphasis>Regxp-2</emphasis> query
441      is a plus character (<literal>+</literal>) it marks the
442      beginning of a section with non-standard specifiers.
443      The next plus character marks the end of the section.
444      Currently Zebra only supports one specifier, the error tolerance,
445      which consists one digit. 
446     </para>
447
448     <para>
449      Since the plus operator is normally a suffix operator the addition to
450      the query syntax doesn't violate the syntax for standard regular
451      expressions.
452     </para>
453
454    </sect3>
455
456    <sect3>
457     <title>Query examples</title>
458
459     <para>
460      Phrase search for <emphasis>information retrieval</emphasis> in
461      the title-register:
462      <screen>
463       @attr 1=4 "information retrieval"
464      </screen>
465     </para>
466
467     <para>
468      Ranked search for the same thing:
469      <screen>
470       @attr 1=4 @attr 2=102 "Information retrieval"
471      </screen>
472     </para>
473
474     <para>
475      Phrase search with a regular expression:
476      <screen>
477       @attr 1=4 @attr 5=102 "informat.* retrieval"
478      </screen>
479     </para>
480
481     <para>
482      Ranked search with a regular expression:
483      <screen>
484       @attr 1=4 @attr 5=102 @attr 2=102 "informat.* retrieval"
485      </screen>
486     </para>
487
488     <para>
489      In the GILS schema (<literal>gils.abs</literal>), the
490      west-bounding-coordinate is indexed as type <literal>n</literal>,
491      and is therefore searched by specifying
492      <emphasis>structure</emphasis>=<emphasis>Numeric String</emphasis>.
493      To match all those records with west-bounding-coordinate greater
494      than -114 we use the following query:
495      <screen>
496       @attr 4=109 @attr 2=5 @attr gils 1=2038 -114
497      </screen> 
498     </para>
499    </sect3>
500   </sect2>
501
502   <sect2>
503    <title>Present</title>
504    <para>
505     The present facility is supported in a standard fashion. The requested
506     record syntax is matched against the ones supported by the profile of
507     each record retrieved. If no record syntax is given, SUTRS is the
508     default. The requested element set name, again, is matched against any
509     provided by the relevant record profiles.
510    </para>
511   </sect2>
512   <sect2>
513    <title>Scan</title>
514    <para>
515     The attribute combinations provided with the termListAndStartPoint are
516     processed in the same way as operands in a query (see above).
517     Currently, only the term and the globalOccurrences are returned with
518     the termInfo structure.
519    </para>
520   </sect2>
521   <sect2>
522    <title>Sort</title>
523
524    <para>
525     Z39.50 specifies three different types of sort criteria.
526     Of these Zebra supports the attribute specification type in which
527     case the use attribute specifies the "Sort register".
528     Sort registers are created for those fields that are of type "sort" in
529     the default.idx file. 
530     The corresponding character mapping file in default.idx specifies the
531     ordinal of each character used in the actual sort.
532    </para>
533
534    <para>
535     Z39.50 allows the client to specify sorting on one or more input
536     result sets and one output result set.
537     Zebra supports sorting on one result set only which may or may not
538     be the same as the output result set.
539    </para>
540   </sect2>
541   <sect2>
542    <title>Close</title>
543    <para>
544     If a Close PDU is received, the server will respond with a Close PDU
545     with reason=FINISHED, no matter which protocol version was negotiated
546     during initialization. If the protocol version is 3 or more, the
547     server will generate a Close PDU under certain circumstances,
548     including a session timeout (60 minutes by default), and certain kinds of
549     protocol errors. Once a Close PDU has been sent, the protocol
550     association is considered broken, and the transport connection will be
551     closed immediately upon receipt of further data, or following a short
552     timeout.
553    </para>
554   </sect2>
555  </sect1>
556 </chapter>
557  <!-- Keep this comment at the end of the file
558  Local variables:
559  mode: sgml
560  sgml-omittag:t
561  sgml-shorttag:t
562  sgml-minimize-attributes:nil
563  sgml-always-quote-attributes:t
564  sgml-indent-step:1
565  sgml-indent-data:t
566  sgml-parent-document: "zebra.xml"
567  sgml-local-catalogs: nil
568  sgml-namecase-general:t
569  End:
570  -->