More Docbook doc updates
[idzebra-moved-to-github.git] / doc / administration.xml
1 <chapter id="quick-start">
2  <title>Quick Start </title>
3  
4  <para>
5   In this section, we will test the system by indexing a small set of sample
6   GILS records that are included with the software distribution. Go to the
7   <literal>test/gils</literal> subdirectory of the distribution archive.
8   There you will find a configuration
9   file named <literal>zebra.cfg</literal> with the following contents:
10   
11   <screen>
12    # Where are the YAZ tables located.
13    profilePath: ../../../yaz/tab ../../tab
14    
15    # Files that describe the attribute sets supported.
16    attset: bib1.att
17    attset: gils.att
18   </screen>
19  </para>
20  
21  <para>
22   Now, edit the file and set <literal>profilePath</literal> to the path of the
23   YAZ profile tables (sub directory <literal>tab</literal> of the YAZ
24   distribution archive).
25  </para>
26  
27  <para>
28   The 48 test records are located in the sub directory
29   <literal>records</literal>. To index these, type:
30   
31   <screen>
32    $ ../../index/zebraidx -t grs.sgml update records
33   </screen>
34  </para>
35  
36  <para>
37   In the command above the option <literal>-t</literal> specified the record
38   type &mdash; in this case <literal>grs.sgml</literal>.
39   The word <literal>update</literal> followed
40   by a directory root updates all files below that directory node.
41  </para>
42  
43  <para>
44   If your indexing command was successful, you are now ready to
45   fire up a server. To start a server on port 2100, type:
46   
47   <screen>
48    $ ../../index/zebrasrv tcp:@:2100
49   </screen>
50   
51  </para>
52
53  <para>
54   The Zebra index that you have just created has a single database
55   named <literal>Default</literal>.
56   The database contains records structured according to
57   the GILS profile, and the server will
58   return records in either either USMARC, GRS-1, or SUTRS depending
59   on what your client asks for.
60  </para>
61  
62  <para>
63   To test the server, you can use any Z39.50 client (1992 or later).
64   For instance, you can use the demo client that comes with YAZ: Just
65   cd to the <literal>client</literal> subdirectory of the YAZ distribution
66   and type:
67  </para>
68  <para>
69   <screen>
70    $ ./yaz-client tcp:localhost:2100
71   </screen>
72  </para>
73  
74  <para>
75   When the client has connected, you can type:
76  </para>
77  
78 <para>
79   
80   <screen>
81    Z&#62; find surficial
82    Z&#62; show 1
83   </screen>
84  </para>
85  
86  <para>
87   The default retrieval syntax for the client is USMARC. To try other
88   formats for the same record, try:
89  </para>
90  <para>
91   <screen>
92    Z&#62;format sutrs
93    Z&#62;show 1
94    Z&#62;format grs-1
95    Z&#62;show 1
96    Z&#62;elements B
97    Z&#62;show 1
98   </screen>
99  </para>
100  
101  <note>
102   <para>You may notice that more fields are returned when your
103    client requests SUTRS or GRS-1 records. When retrieving GILS records,
104    this is normal - not all of the GILS data elements have mappings in
105    the USMARC record format.
106   </para>
107  </note>
108  <para>
109   If you've made it this far, there's a good chance that
110   you've got through the compilation OK.
111  </para>
112  
113 </chapter>
114
115 <chapter id="administration">
116  <title>Administrating Zebra</title>
117  
118  <para>
119   Unlike many simpler retrieval systems, Zebra supports safe, incremental
120   updates to an existing index.
121  </para>
122  
123  <para>
124   Normally, when Zebra modifies the index it reads a number of records
125   that you specify.
126   Depending on your specifications and on the contents of each record
127   one the following events take place for each record:
128   <variablelist>
129    
130    <varlistentry>
131     <term>Insert</term>
132     <listitem>
133      <para>
134       The record is indexed as if it never occurred before.
135       Either the Zebra system doesn't know how to identify the record or
136       Zebra can identify the record but didn't find it to be already indexed.
137      </para>
138     </listitem>
139    </varlistentry>
140    <varlistentry>
141     <term>Modify</term>
142     <listitem>
143      <para>
144       The record has already been indexed. In this case
145       either the contents of the record or the location (file) of the record
146       indicates that it has been indexed before.
147      </para>
148     </listitem>
149    </varlistentry>
150    <varlistentry>
151     <term>Delete</term>
152     <listitem>
153      <para>
154       The record is deleted from the index. As in the
155       update-case it must be able to identify the record.
156      </para>
157     </listitem>
158    </varlistentry>
159   </variablelist>
160  </para>
161  
162  <para>
163   Please note that in both the modify- and delete- case the Zebra
164   indexer must be able to generate a unique key that identifies the record in
165   question (more on this below).
166  </para>
167  
168  <para>
169   To administrate the Zebra retrieval system, you run the
170   <literal>zebraidx</literal> program.
171   This program supports a number of options which are preceded by a dash,
172   and a few commands (not preceded by dash).
173 </para>
174  
175  <para>
176   Both the Zebra administrative tool and the Z39.50 server share a
177   set of index files and a global configuration file. The
178   name of the configuration file defaults to <literal>zebra.cfg</literal>.
179   The configuration file includes specifications on how to index
180   various kinds of records and where the other configuration files
181   are located. <literal>zebrasrv</literal> and <literal>zebraidx</literal>
182   <emphasis>must</emphasis> be run in the directory where the
183   configuration file lives unless you indicate the location of the 
184   configuration file by option <literal>-c</literal>.
185  </para>
186  
187  <sect1 id="record-types">
188   <title>Record Types</title>
189   
190   <para>
191    Indexing is a per-record process, in which either insert/modify/delete
192    will occur. Before a record is indexed search keys are extracted from
193    whatever might be the layout the original record (sgml,html,text, etc..).
194    The Zebra system currently supports two fundamantal types of records:
195    structured and simple text.
196    To specify a particular extraction process, use either the
197    command line option <literal>-t</literal> or specify a
198    <literal>recordType</literal> setting in the configuration file.
199   </para>
200   
201  </sect1>
202  
203  <sect1 id="configuration-file">
204   <title>The Zebra Configuration File</title>
205   
206   <para>
207    The Zebra configuration file, read by <literal>zebraidx</literal> and
208    <literal>zebrasrv</literal> defaults to <literal>zebra.cfg</literal>
209    unless specified by <literal>-c</literal> option.
210   </para>
211   
212   <para>
213    You can edit the configuration file with a normal text editor.
214    parameter names and values are seperated by colons in the file. Lines
215    starting with a hash sign (<literal>&num;</literal>) are
216    treated as comments.
217   </para>
218   
219   <para>
220    If you manage different sets of records that share common
221    characteristics, you can organize the configuration settings for each
222    type into "groups".
223    When <literal>zebraidx</literal> is run and you wish to address a
224    given group you specify the group name with the <literal>-g</literal>
225    option.
226    In this case settings that have the group name as their prefix 
227    will be used by <literal>zebraidx</literal>.
228    If no <literal>-g</literal> option is specified, the settings
229    without prefix are used.
230   </para>
231   
232   <para>
233    In the configuration file, the group name is placed before the option
234    name itself, separated by a dot (.). For instance, to set the record type
235    for group <literal>public</literal> to <literal>grs.sgml</literal>
236    (the SGML-like format for structured records) you would write:
237   </para>
238   
239   <para>
240    <screen>
241     public.recordType: grs.sgml
242    </screen>   
243   </para>
244   
245   <para>
246    To set the default value of the record type to <literal>text</literal>
247    write:
248   </para>
249   
250   <para>
251    <screen>
252     recordType: text
253    </screen>
254   </para>
255   
256   <para>
257    The available configuration settings are summarized below. They will be
258    explained further in the following sections.
259   </para>
260   
261   <para>
262    <variablelist>
263     
264     <varlistentry>
265      <term>
266       <emphasis>group</emphasis>
267       .recordType&lsqb;<emphasis>.name</emphasis>&rsqb;
268      </term>
269      <listitem>
270       <para>
271        Specifies how records with the file extension
272        <emphasis>name</emphasis> should be handled by the indexer.
273        This option may also be specified as a command line option
274        (<literal>-t</literal>). Note that if you do not specify a
275        <emphasis>name</emphasis>, the setting applies to all files.
276        In general, the record type specifier consists of the elements (each
277        element separated by dot), <emphasis>fundamental-type</emphasis>,
278        <emphasis>file-read-type</emphasis> and arguments. Currently, two
279        fundamental types exist, <literal>text</literal> and
280        <literal>grs</literal>.
281       </para>
282      </listitem>
283     </varlistentry>
284     <varlistentry>
285      <term><emphasis>group</emphasis>.recordId</term>
286      <listitem>
287       <para>
288        Specifies how the records are to be identified when updated. See
289        section <xref linkend="locating-records"/>.
290       </para>
291      </listitem>
292     </varlistentry>
293     <varlistentry>
294      <term><emphasis>group</emphasis>.database</term>
295      <listitem>
296       <para>
297        Specifies the Z39.50 database name.
298       </para>
299      </listitem>
300     </varlistentry>
301     <varlistentry>
302      <term><emphasis>group</emphasis>.storeKeys</term>
303      <listitem>
304       <para>
305        Specifies whether key information should be saved for a given
306        group of records. If you plan to update/delete this type of
307        records later this should be specified as 1; otherwise it
308        should be 0 (default), to save register space. See section
309        <xref linkend="file-ids"/>.
310       </para>
311      </listitem>
312     </varlistentry>
313     <varlistentry>
314      <term><emphasis>group</emphasis>.storeData</term>
315      <listitem>
316       <para>
317        Specifies whether the records should be stored internally
318        in the Zebra system files.
319        If you want to maintain the raw records yourself,
320        this option should be false (0).
321        If you want Zebra to take care of the records for you, it
322        should be true(1).
323       </para>
324      </listitem>
325     </varlistentry>
326     <varlistentry>
327      <term>register</term>
328      <listitem>
329       <para>
330        Specifies the location of the various register files that Zebra uses
331        to represent your databases. See section
332        <xref linkend="register-location"/>.
333       </para>
334      </listitem>
335     </varlistentry>
336     <varlistentry>
337      <term>shadow</term>
338      <listitem>
339       <para>
340        Enables the <emphasis>safe update</emphasis> facility of Zebra, and
341        tells the system where to place the required, temporary files.
342        See section
343        <xref linkend="shadow-registers"/>.
344       </para>
345      </listitem>
346     </varlistentry>
347     <varlistentry>
348      <term>lockDir</term>
349      <listitem>
350       <para>
351        Directory in which various lock files are stored.
352       </para>
353      </listitem>
354     </varlistentry>
355     <varlistentry>
356      <term>keyTmpDir</term>
357      <listitem>
358       <para>
359        Directory in which temporary files used during zebraidx' update
360        phase are stored. 
361       </para>
362      </listitem>
363     </varlistentry>
364     <varlistentry>
365      <term>setTmpDir</term>
366      <listitem>
367       <para>
368        Specifies the directory that the server uses for temporary result sets.
369        If not specified <literal>/tmp</literal> will be used.
370       </para>
371      </listitem>
372     </varlistentry>
373     <varlistentry>
374      <term>profilePath</term>
375      <listitem>
376       <para>
377        Specifies the location of profile specification files.
378       </para>
379      </listitem>
380     </varlistentry>
381     <varlistentry>
382      <term>attset</term>
383      <listitem>
384       <para>
385        Specifies the filename(s) of attribute set files for use in
386        searching. At least the Bib-1 set should be loaded
387        (<literal>bib1.att</literal>).
388        The <literal>profilePath</literal> setting is used to look for
389        the specified files.
390        See section <xref linkend="attset-files"/>
391       </para>
392      </listitem>
393     </varlistentry>
394     <varlistentry>
395      <term>memMax</term>
396      <listitem>
397       <para>
398        Specifies size of internal memory to use for the zebraidx program. The
399        amount is given in megabytes - default is 4 (4 MB).
400       </para>
401      </listitem>
402     </varlistentry>
403    </variablelist>
404   </para>
405   
406  </sect1>
407  
408  <sect1 id="locating-records">
409   <title>Locating Records</title>
410   
411   <para>
412    The default behaviour of the Zebra system is to reference the
413    records from their original location, i.e. where they were found when you
414    ran <literal>zebraidx</literal>.
415    That is, when a client wishes to retrieve a record
416    following a search operation, the files are accessed from the place
417    where you originally put them - if you remove the files (without
418    running <literal>zebraidx</literal> again, the client
419    will receive a diagnostic message.
420   </para>
421   
422   <para>
423    If your input files are not permanent - for example if you retrieve
424    your records from an outside source, or if they were temporarily
425    mounted on a CD-ROM drive,
426    you may want Zebra to make an internal copy of them. To do this,
427    you specify 1 (true) in the <literal>storeData</literal> setting. When
428    the Z39.50 server retrieves the records they will be read from the
429    internal file structures of the system.
430   </para>
431   
432  </sect1>
433  
434  <sect1 id="simple-indexing">
435   <title>Indexing with no Record IDs (Simple Indexing)</title>
436   
437   <para>
438    If you have a set of records that are not expected to change over time
439    you may can build your database without record IDs.
440    This indexing method uses less space than the other methods and
441    is simple to use. 
442   </para>
443   
444   <para>
445    To use this method, you simply omit the <literal>recordId</literal> entry
446    for the group of files that you index. To add a set of records you use
447    <literal>zebraidx</literal> with the <literal>update</literal> command. The
448    <literal>update</literal> command will always add all of the records that it
449    encounters to the index - whether they have already been indexed or
450    not. If the set of indexed files change, you should delete all of the
451    index files, and build a new index from scratch.
452   </para>
453   
454   <para>
455    Consider a system in which you have a group of text files called
456    <literal>simple</literal>.
457    That group of records should belong to a Z39.50 database called
458    <literal>textbase</literal>.
459    The following <literal>zebra.cfg</literal> file will suffice:
460   </para>
461   <para>
462    
463    <screen>
464     profilePath: /usr/local/yaz
465     attset: bib1.att
466     simple.recordType: text
467     simple.database: textbase
468    </screen>
469
470   </para>
471   
472   <para>
473    Since the existing records in an index can not be addressed by their
474    IDs, it is impossible to delete or modify records when using this method.
475   </para>
476   
477  </sect1>
478  
479  <sect1 id="file-ids">
480   <title>Indexing with File Record IDs</title>
481   
482   <para>
483    If you have a set of files that regularly change over time: Old files
484    are deleted, new ones are added, or existing files are modified, you
485    can benefit from using the <emphasis>file ID</emphasis>
486    indexing methodology.
487    Examples of this type of database might include an index of WWW
488    resources, or a USENET news spool area.
489    Briefly speaking, the file key methodology uses the directory paths
490    of the individual records as a unique identifier for each record.
491    To perform indexing of a directory with file keys, again, you specify
492    the top-level directory after the <literal>update</literal> command.
493    The command will recursively traverse the directories and compare
494    each one with whatever have been indexed before in that same directory.
495    If a file is new (not in the previous version of the directory) it
496    is inserted into the registers; if a file was already indexed and
497    it has been modified since the last update, the index is also
498    modified; if a file has been removed since the last
499    visit, it is deleted from the index.
500   </para>
501   
502   <para>
503    The resulting system is easy to administrate. To delete a record you
504    simply have to delete the corresponding file (say, with the
505    <literal>rm</literal> command). And to add records you create new
506    files (or directories with files). For your changes to take effect
507    in the register you must run <literal>zebraidx update</literal> with
508    the same directory root again. This mode of operation requires more
509    disk space than simpler indexing methods, but it makes it easier for
510    you to keep the index in sync with a frequently changing set of data.
511    If you combine this system with the <emphasis>safe update</emphasis>
512    facility (see below), you never have to take your server offline for
513    maintenance or register updating purposes.
514   </para>
515   
516   <para>
517    To enable indexing with pathname IDs, you must specify
518    <literal>file</literal> as the value of <literal>recordId</literal>
519    in the configuration file. In addition, you should set
520    <literal>storeKeys</literal> to <literal>1</literal>, since the Zebra
521    indexer must save additional information about the contents of each record
522    in order to modify the indices correctly at a later time.
523   </para>
524   
525   <para>
526    For example, to update records of group <literal>esdd</literal>
527    located below
528    <literal>/data1/records/</literal> you should type:
529    <screen>
530     $ zebraidx -g esdd update /data1/records
531    </screen>
532   </para>
533   
534   <para>
535    The corresponding configuration file includes:
536    <screen>
537     esdd.recordId: file
538     esdd.recordType: grs.sgml
539     esdd.storeKeys: 1
540    </screen>
541   </para>
542   
543   <note>
544    <para>You cannot start out with a group of records with simple
545     indexing (no record IDs as in the previous section) and then later
546     enable file record Ids. Zebra must know from the first time that you
547     index the group that
548     the files should be indexed with file record IDs.
549    </para>
550    </note>
551   
552   <para>
553    You cannot explicitly delete records when using this method (using the
554    <literal>delete</literal> command to <literal>zebraidx</literal>. Instead
555    you have to delete the files from the file system (or move them to a
556    different location)
557    and then run <literal>zebraidx</literal> with the
558    <literal>update</literal> command.
559   </para>
560 </sect1>
561  
562  <sect1 id="generic-ids">
563   <title>Indexing with General Record IDs</title>
564   
565   <para>
566    When using this method you construct an (almost) arbritrary, internal
567    record key based on the contents of the record itself and other system
568    information. If you have a group of records that explicitly associates
569    an ID with each record, this method is convenient. For example, the
570    record format may contain a title or a ID-number - unique within the group.
571    In either case you specify the Z39.50 attribute set and use-attribute
572    location in which this information is stored, and the system looks at
573    that field to determine the identity of the record.
574   </para>
575   
576   <para>
577    As before, the record ID is defined by the <literal>recordId</literal>
578    setting in the configuration file. The value of the record ID specification
579    consists of one or more tokens separated by whitespace. The resulting
580    ID is represented in the index by concatenating the tokens and
581    separating them by ASCII value (1).
582   </para>
583   
584   <para>
585    There are three kinds of tokens:
586    <variablelist>
587     
588     <varlistentry>
589      <term>Internal record info</term>
590      <listitem>
591       <para>
592        The token refers to a key that is
593        extracted from the record. The syntax of this token is
594        <literal>(</literal> <emphasis>set</emphasis> <literal>,</literal>
595        <emphasis>use</emphasis> <literal>)</literal>,
596        where <emphasis>set</emphasis> is the
597        attribute set name <emphasis>use</emphasis> is the
598        name or value of the attribute.
599       </para>
600      </listitem>
601     </varlistentry>
602     <varlistentry>
603      <term>System variable</term>
604      <listitem>
605       <para>
606        The system variables are preceded by
607        
608        <screen>
609         $
610        </screen>
611        and immediately followed by the system variable name, which
612        may one of
613        <variablelist>
614         
615         <varlistentry>
616          <term>group</term>
617          <listitem>
618           <para>
619            Group name.
620           </para>
621          </listitem>
622         </varlistentry>
623         <varlistentry>
624          <term>database</term>
625          <listitem>
626           <para>
627            Current database specified.
628           </para>
629          </listitem>
630         </varlistentry>
631         <varlistentry>
632          <term>type</term>
633          <listitem>
634           <para>
635            Record type.
636           </para>
637          </listitem>
638         </varlistentry>
639        </variablelist>
640       </para>
641      </listitem>
642     </varlistentry>
643     <varlistentry>
644      <term>Constant string</term>
645      <listitem>
646       <para>
647        A string used as part of the ID &mdash; surrounded
648        by single- or double quotes.
649       </para>
650      </listitem>
651     </varlistentry>
652    </variablelist>
653   </para>
654   
655   <para>
656    For instance, the sample GILS records that come with the Zebra
657    distribution contain a unique ID in the data tagged Control-Identifier.
658    The data is mapped to the Bib-1 use attribute Identifier-standard
659    (code 1007). To use this field as a record id, specify
660    <literal>(bib1,Identifier-standard)</literal> as the value of the
661    <literal>recordId</literal> in the configuration file.
662    If you have other record types that uses the same field for a
663    different purpose, you might add the record type
664    (or group or database name) to the record id of the gils
665    records as well, to prevent matches with other types of records.
666    In this case the recordId might be set like this:
667    
668    <screen>
669     gils.recordId: $type (bib1,Identifier-standard)
670    </screen>
671    
672   </para>
673   
674   <para>
675    (see section <xref linkend="data-model"/>
676     for details of how the mapping between elements of your records and
677     searchable attributes is established).
678   </para>
679   
680   <para>
681    As for the file record ID case described in the previous section,
682    updating your system is simply a matter of running
683    <literal>zebraidx</literal>
684    with the <literal>update</literal> command. However, the update with general
685    keys is considerably slower than with file record IDs, since all files
686    visited must be (re)read to discover their IDs. 
687   </para>
688   
689   <para>
690    As you might expect, when using the general record IDs
691    method, you can only add or modify existing records with the
692    <literal>update</literal> command.
693    If you wish to delete records, you must use the,
694    <literal>delete</literal> command, with a directory as a parameter.
695    This will remove all records that match the files below that root
696    directory.
697   </para>
698   
699  </sect1>
700  
701  <sect1 id="register-location">
702   <title>Register Location</title>
703   
704   <para>
705    Normally, the index files that form dictionaries, inverted
706    files, record info, etc., are stored in the directory where you run
707    <literal>zebraidx</literal>. If you wish to store these, possibly large,
708    files somewhere else, you must add the <literal>register</literal>
709    entry to the <literal>zebra.cfg</literal> file.
710    Furthermore, the Zebra system allows its file
711    structures to span multiple file systems, which is useful for
712    managing very large databases. 
713   </para>
714   
715   <para>
716    The value of the <literal>register</literal> setting is a sequence
717    of tokens. Each token takes the form:
718    
719    <screen>
720     <emphasis>dir</emphasis><literal>:</literal><emphasis>size</emphasis>. 
721    </screen>
722    
723    The <emphasis>dir</emphasis> specifies a directory in which index files
724    will be stored and the <emphasis>size</emphasis> specifies the maximum
725    size of all files in that directory. The Zebra indexer system fills
726    each directory in the order specified and use the next specified
727    directories as needed.
728    The <emphasis>size</emphasis> is an integer followed by a qualifier
729    code, <literal>M</literal> for megabytes,
730    <literal>k</literal> for kilobytes.
731   </para>
732   
733   <para>
734    For instance, if you have allocated two disks for your register, and
735    the first disk is mounted
736    on <literal>/d1</literal> and has 200 Mb of free space and the
737    second, mounted on <literal>/d2</literal> has 300 Mb, you could
738    put this entry in your configuration file:
739    
740    <screen>
741     register: /d1:200M /d2:300M
742    </screen>
743    
744   </para>
745   
746   <para>
747    Note that Zebra does not verify that the amount of space specified is
748    actually available on the directory (file system) specified - it is
749    your responsibility to ensure that enough space is available, and that
750    other applications do not attempt to use the free space. In a large
751    production system, it is recommended that you allocate one or more
752    filesystem exclusively to the Zebra register files.
753   </para>
754   
755  </sect1>
756  
757  <sect1 id="shadow-registers">
758   <title>Safe Updating - Using Shadow Registers</title>
759   
760   <sect2>
761    <title>Description</title>
762    
763    <para>
764     The Zebra server supports <emphasis>updating</emphasis> of the index
765     structures. That is, you can add, modify, or remove records from
766     databases managed by Zebra without rebuilding the entire index.
767     Since this process involves modifying structured files with various
768     references between blocks of data in the files, the update process
769     is inherently sensitive to system crashes, or to process interruptions:
770     Anything but a successfully completed update process will leave the
771     register files in an unknown state, and you will essentially have no
772     recourse but to re-index everything, or to restore the register files
773     from a backup medium.
774     Further, while the update process is active, users cannot be
775     allowed to access the system, as the contents of the register files
776     may change unpredictably.
777    </para>
778    
779    <para>
780     You can solve these problems by enabling the shadow register system in
781     Zebra.
782     During the updating procedure, <literal>zebraidx</literal> will temporarily
783     write changes to the involved files in a set of "shadow
784     files", without modifying the files that are accessed by the
785     active server processes. If the update procedure is interrupted by a
786     system crash or a signal, you simply repeat the procedure - the
787     register files have not been changed or damaged, and the partially
788     written shadow files are automatically deleted before the new updating
789     procedure commences.
790    </para>
791    
792    <para>
793     At the end of the updating procedure (or in a separate operation, if
794     you so desire), the system enters a "commit mode". First,
795     any active server processes are forced to access those blocks that
796     have been changed from the shadow files rather than from the main
797     register files; the unmodified blocks are still accessed at their
798     normal location (the shadow files are not a complete copy of the
799     register files - they only contain those parts that have actually been
800     modified). If the commit process is interrupted at any point during the
801     commit process, the server processes will continue to access the
802     shadow files until you can repeat the commit procedure and complete
803     the writing of data to the main register files. You can perform
804     multiple update operations to the registers before you commit the
805     changes to the system files, or you can execute the commit operation
806     at the end of each update operation. When the commit phase has
807     completed successfully, any running server processes are instructed to
808     switch their operations to the new, operational register, and the
809     temporary shadow files are deleted.
810    </para>
811    
812   </sect2>
813   
814   <sect2>
815    <title>How to Use Shadow Register Files</title>
816    
817    <para>
818     The first step is to allocate space on your system for the shadow
819     files.
820     You do this by adding a <literal>shadow</literal> entry to the
821     <literal>zebra.cfg</literal> file.
822     The syntax of the <literal>shadow</literal> entry is exactly the
823     same as for the <literal>register</literal> entry
824     (see section <xref linkend="register-location"/>).
825      The location of the shadow area should be
826      <emphasis>different</emphasis> from the location of the main register
827      area (if you have specified one - remember that if you provide no
828      <literal>register</literal> setting, the default register area is the
829      working directory of the server and indexing processes).
830    </para>
831    
832    <para>
833     The following excerpt from a <literal>zebra.cfg</literal> file shows
834     one example of a setup that configures both the main register
835     location and the shadow file area.
836     Note that two directories or partitions have been set aside
837     for the shadow file area. You can specify any number of directories
838     for each of the file areas, but remember that there should be no
839     overlaps between the directories used for the main registers and the
840     shadow files, respectively.
841    </para>
842    <para>
843     
844     <screen>
845      register: /d1:500M
846      
847      shadow: /scratch1:100M /scratch2:200M
848     </screen>
849     
850    </para>
851    
852    <para>
853     When shadow files are enabled, an extra command is available at the
854     <literal>zebraidx</literal> command line.
855     In order to make changes to the system take effect for the
856     users, you'll have to submit a "commit" command after a
857     (sequence of) update operation(s).
858     You can ask the indexer to commit the changes immediately
859     after the update operation:
860    </para>
861    
862    <para>
863     
864     <screen>
865      $ zebraidx update /d1/records update /d2/more-records commit
866     </screen>
867     
868    </para>
869    
870    <para>
871     Or you can execute multiple updates before committing the changes:
872    </para>
873    
874    <para>
875     
876     <screen>
877      $ zebraidx -g books update /d1/records update /d2/more-records
878      $ zebraidx -g fun update /d3/fun-records
879      $ zebraidx commit
880     </screen>
881     
882    </para>
883    
884    <para>
885     If one of the update operations above had been interrupted, the commit
886     operation on the last line would fail: <literal>zebraidx</literal>
887     will not let you commit changes that would destroy the running register.
888     You'll have to rerun all of the update operations since your last
889     commit operation, before you can commit the new changes.
890    </para>
891    
892    <para>
893     Similarly, if the commit operation fails, <literal>zebraidx</literal>
894     will not let you start a new update operation before you have
895     successfully repeated the commit operation.
896     The server processes will keep accessing the shadow files rather
897     than the (possibly damaged) blocks of the main register files
898     until the commit operation has successfully completed.
899    </para>
900    
901    <para>
902     You should be aware that update operations may take slightly longer
903     when the shadow register system is enabled, since more file access
904     operations are involved. Further, while the disk space required for
905     the shadow register data is modest for a small update operation, you
906     may prefer to disable the system if you are adding a very large number
907     of records to an already very large database (we use the terms
908     <emphasis>large</emphasis> and <emphasis>modest</emphasis>
909     very loosely here, since every application will have a
910     different perception of size).
911     To update the system without the use of the the shadow files,
912     simply run <literal>zebraidx</literal> with the <literal>-n</literal>
913     option (note that you do not have to execute the
914     <emphasis>commit</emphasis> command of <literal>zebraidx</literal>
915     when you temporarily disable the use of the shadow registers in
916     this fashion.
917     Note also that, just as when the shadow registers are not enabled,
918     server processes will be barred from accessing the main register
919     while the update procedure takes place.
920    </para>
921    
922   </sect2>
923   
924  </sect1>
925  
926 </chapter>
927
928 <chapter id="zebraidx">
929  <title>Running the Maintenance Interface (zebraidx)</title>
930  
931  <para>
932   The following is a complete reference to the command line interface to
933   the <literal>zebraidx</literal> application.
934  </para>
935  
936  <para>
937   Syntax
938   
939   <screen>
940    $ zebraidx &lsqb;options&rsqb; command &lsqb;directory&rsqb; ...
941   </screen>
942   
943   Options:
944   <variablelist>
945    
946    <varlistentry>
947     <term>-t <replaceable>type</replaceable></term>
948     <listitem>
949      <para>
950       Update all files as <replaceable>type</replaceable>. Currently, the
951       types supported are <literal>text</literal> and
952       <literal>grs</literal><replaceable>.subtype</replaceable>.
953       If no <replaceable>subtype</replaceable> is provided for the GRS
954       (General Record Structure) type, the canonical input format
955       is assumed (see section <xref linkend="local-representation"/>).
956        Generally, it is probably advisable to specify the record types
957        in the <literal>zebra.cfg</literal> file (see section
958        <xref linkend="record-types"/>), to avoid confusion at
959         subsequent updates.
960      </para>
961     </listitem>
962    </varlistentry>
963    <varlistentry>
964     <term>-c <replaceable>config-file</replaceable></term>
965     <listitem>
966      <para>
967       Read the configuration file
968       <replaceable>config-file</replaceable> instead of
969       <literal>zebra.cfg</literal>.
970      </para>
971     </listitem>
972    </varlistentry>
973    <varlistentry>
974     <term>-g <replaceable>group</replaceable></term>
975     <listitem>
976      <para>
977       Update the files according to the group
978       settings for <replaceable>group</replaceable> (see section
979       <xref linkend="configuration-file"/>).
980      </para>
981     </listitem>
982    </varlistentry>
983    <varlistentry>
984     <term>-d <replaceable>database</replaceable></term>
985     <listitem>
986      <para>
987       The records located should be associated with the database name
988       <replaceable>database</replaceable> for access through the Z39.50 server.
989      </para>
990     </listitem>
991    </varlistentry>
992    <varlistentry>
993     <term>-m <replaceable>mbytes</replaceable></term>
994     <listitem>
995      <para>
996       Use <replaceable>mbytes</replaceable> of megabytes before flushing
997       keys to background storage. This setting affects performance when
998       updating large databases.
999      </para>
1000     </listitem>
1001    </varlistentry>
1002    <varlistentry>
1003     <term>-n</term>
1004     <listitem>
1005      <para>
1006       Disable the use of shadow registers for this operation
1007       (see section <xref linkend="shadow-registers"/>).
1008      </para>
1009     </listitem>
1010    </varlistentry>
1011    <varlistentry>
1012     <term>-s</term>
1013     <listitem>
1014      <para>
1015       Show analysis of the indexing process. The maintenance
1016       program works in a read-only mode and doesn't change the state
1017       of the index. This options is very useful when you wish to test a
1018       new profile.
1019      </para>
1020     </listitem>
1021    </varlistentry>
1022    <varlistentry>
1023     <term>-V</term>
1024     <listitem>
1025      <para>
1026       Show Zebra version.
1027      </para>
1028     </listitem>
1029    </varlistentry>
1030    <varlistentry>
1031     <term>-v <replaceable>level</replaceable></term>
1032     <listitem>
1033      <para>
1034       Set the log level to <replaceable>level</replaceable>.
1035       <replaceable>level</replaceable> should be one of
1036       <literal>none</literal>, <literal>debug</literal>, and
1037       <literal>all</literal>.
1038      </para>
1039     </listitem>
1040    </varlistentry>
1041   </variablelist>
1042  </para>
1043  
1044  <para>
1045   Commands
1046   <variablelist>
1047    
1048    <varlistentry>
1049     <term>update <replaceable>directory</replaceable></term>
1050     <listitem>
1051      <para>
1052       Update the register with the files contained in
1053       <replaceable>directory</replaceable>.
1054       If no directory is provided, a list of files is read from
1055       <literal>stdin</literal>.
1056       See section <xref linkend="administration"/>.
1057      </para>
1058     </listitem>
1059    </varlistentry>
1060    <varlistentry>
1061     <term>delete <replaceable>directory</replaceable></term>
1062     <listitem>
1063      <para>
1064       Remove the records corresponding to the files found under
1065       <replaceable>directory</replaceable> from the register.
1066      </para>
1067     </listitem>
1068    </varlistentry>
1069    <varlistentry>
1070     <term>commit</term>
1071     <listitem>
1072      <para>
1073       Write the changes resulting from the last <literal>update</literal>
1074       commands to the register. This command is only available if the use of
1075       shadow register files is enabled (see section
1076       <xref linkend="shadow-registers"/>).
1077      </para>
1078     </listitem>
1079    </varlistentry>
1080   </variablelist>
1081  </para>
1082
1083 </chapter>
1084
1085 <chapter id="server">
1086  <title>The Z39.50 Server</title>
1087
1088  <sect1 id="zebrasrv">
1089   <title>Running the Z39.50 Server (zebrasrv)</title>
1090
1091   <para>
1092    <emphasis remap="bf">Syntax</emphasis>
1093
1094    <screen>
1095     zebrasrv &lsqb;options&rsqb; &lsqb;listener-address ...&rsqb;
1096    </screen>
1097
1098   </para>
1099
1100   <para>
1101    <emphasis remap="bf">Options</emphasis>
1102    <variablelist>
1103
1104     <varlistentry>
1105      <term>-a <replaceable>APDU file</replaceable></term>
1106      <listitem>
1107       <para>
1108        Specify a file for dumping PDUs (for diagnostic purposes).
1109        The special name "-" sends output to <literal>stderr</literal>.
1110       </para>
1111      </listitem>
1112     </varlistentry>
1113     <varlistentry>
1114      <term>-c <replaceable>config-file</replaceable></term>
1115      <listitem>
1116       <para>
1117        Read configuration information from
1118        <replaceable>config-file</replaceable>.
1119        The default configuration is <literal>./zebra.cfg</literal>.
1120       </para>
1121      </listitem>
1122     </varlistentry>
1123     <varlistentry>
1124      <term>-S</term>
1125      <listitem>
1126       <para>
1127        Don't fork on connection requests. This can be useful for
1128        symbolic-level debugging. The server can only accept a single
1129        connection in this mode.
1130       </para>
1131      </listitem>
1132     </varlistentry>
1133     <varlistentry>
1134      <term>-s</term>
1135      <listitem>
1136       <para>
1137        Use the SR protocol.
1138       </para>
1139      </listitem>
1140     </varlistentry>
1141     <varlistentry>
1142      <term>-z</term>
1143      <listitem>
1144       <para>
1145        Use the Z39.50 protocol (default). These two options complement
1146        eachother. You can use both multiple times on the same command
1147        line, between listener-specifications (see below). This way, you
1148        can set up the server to listen for connections in both protocols
1149        concurrently, on different local ports.
1150       </para>
1151      </listitem>
1152     </varlistentry>
1153     <varlistentry>
1154      <term>-l <replaceable>logfile</replaceable></term>
1155      <listitem>
1156       <para>
1157        Specify an output file for the diagnostic messages.
1158        The default is to write this information to <literal>stderr</literal>.
1159       </para>
1160      </listitem>
1161     </varlistentry>
1162     <varlistentry>
1163      <term>-v <replaceable>log-level</replaceable></term>
1164      <listitem>
1165       <para>
1166        The log level. Use a comma-separated list of members of the set
1167        &lcub;fatal,debug,warn,log,all,none&rcub;.
1168       </para>
1169      </listitem>
1170     </varlistentry>
1171     <varlistentry>
1172      <term>-u <replaceable>username</replaceable></term>
1173      <listitem>
1174       <para>
1175        Set user ID. Sets the real UID of the server process to that of the
1176        given <replaceable>username</replaceable>.
1177        It's useful if you aren't comfortable with having the
1178        server run as root, but you need to start it as such to bind a
1179        privileged port.
1180       </para>
1181      </listitem>
1182     </varlistentry>
1183     <varlistentry>
1184      <term>-w <replaceable>working-directory</replaceable></term>
1185      <listitem>
1186       <para>
1187        Change working directory.
1188       </para>
1189      </listitem>
1190     </varlistentry>
1191     <varlistentry>
1192      <term>-i</term>
1193      <listitem>
1194       <para>
1195        Run under the Internet superserver, <literal>inetd</literal>.
1196        Make sure you use the logfile option <literal>-l</literal> in
1197        conjunction with this mode and specify the <literal>-l</literal>
1198        option before any other options.
1199       </para>
1200      </listitem>
1201     </varlistentry>
1202     <varlistentry>
1203      <term>-t <replaceable>timeout</replaceable></term>
1204      <listitem>
1205       <para>
1206        Set the idle session timeout (default 60 minutes).
1207       </para>
1208      </listitem>
1209     </varlistentry>
1210     <varlistentry>
1211      <term>-k <replaceable>kilobytes</replaceable></term>
1212      <listitem>
1213       <para>
1214        Set the (approximate) maximum size of
1215        present response messages. Default is 1024 Kb (1 Mb).
1216       </para>
1217      </listitem>
1218     </varlistentry>
1219    </variablelist>
1220   </para>
1221
1222   <para>
1223    A <replaceable>listener-address</replaceable> consists of a transport
1224    mode followed by a colon (:) followed by a listener address.
1225    The transport mode is either <literal>ssl</literal> or
1226    <literal>tcp</literal>.
1227   </para>
1228
1229   <para>
1230    For TCP, an address has the form
1231   </para>
1232
1233   <para>
1234
1235    <screen>
1236     hostname | IP-number &lsqb;: portnumber&rsqb;
1237    </screen>
1238
1239   </para>
1240
1241   <para>
1242    The port number defaults to 210 (standard Z39.50 port).
1243   </para>
1244
1245   <para>
1246    Examples
1247   </para>
1248
1249   <para>
1250
1251    <screen>
1252     tcp:dranet.dra.com
1253
1254     ssl:secure.lib.com:3000
1255    </screen>
1256
1257   </para>
1258
1259   <para>
1260    In both cases, the special hostname "@" is mapped to
1261    the address INADDR_ANY, which causes the server to listen on any local
1262    interface. To start the server listening on the registered port for
1263    Z39.50, and to drop root privileges once the ports are bound, execute
1264    the server like this (from a root shell):
1265   </para>
1266
1267   <para>
1268
1269    <screen>
1270     zebrasrv -u daemon tcp:@
1271    </screen>
1272
1273   </para>
1274
1275   <para>
1276    You can replace <literal>daemon</literal> with another user, eg.
1277    your own account, or a dedicated IR server account.
1278   </para>
1279
1280   <para>
1281    The default behavior for <literal>zebrasrv</literal> is to establish
1282    a single TCP/IP listener, for the Z39.50 protocol, on port 9999.
1283   </para>
1284
1285  </sect1>
1286
1287  <sect1 id="protocol-support">
1288   <title>Z39.50 Protocol Support and Behavior</title>
1289
1290   <sect2>
1291    <title>Initialization</title>
1292
1293    <para>
1294     During initialization, the server will negotiate to version 3 of the
1295     Z39.50 protocol, and the option bits for Search, Present, Scan,
1296     NamedResultSets, and concurrentOperations will be set, if requested by
1297     the client. The maximum PDU size is negotiated down to a maximum of
1298     1Mb by default.
1299    </para>
1300
1301   </sect2>
1302
1303   <sect2 id="search">
1304    <title>Search</title>
1305
1306    <para>
1307     The supported query type are 1 and 101. All operators are currently
1308     supported with the restriction that only proximity units of type "word"
1309     are supported for the proximity operator.
1310     Queries can be arbitrarily complex.
1311     Named result sets are supported, and result sets can be used as operands
1312     without limitations.
1313     Searches may span multiple databases.
1314    </para>
1315
1316    <para>
1317     The server has full support for piggy-backed present requests (see
1318     also the following section).
1319    </para>
1320
1321    <para>
1322     <emphasis>Use</emphasis> attributes are interpreted according to the
1323     attribute sets which have been loaded in the
1324     <literal>zebra.cfg</literal> file, and are matched against specific
1325     fields as specified in the <literal>.abs</literal> file which
1326     describes the profile of the records which have been loaded.
1327     If no Use attribute is provided, a default of Bib-1 Any is assumed.
1328    </para>
1329
1330    <para>
1331     If a <emphasis>Structure</emphasis> attribute of
1332     <emphasis>Phrase</emphasis> is used in conjunction with a
1333     <emphasis>Completeness</emphasis> attribute of
1334     <emphasis>Complete (Sub)field</emphasis>, the term is matched
1335     against the contents of the phrase (long word) register, if one
1336     exists for the given <emphasis>Use</emphasis> attribute.
1337     A phrase register is created for those fields in the
1338     <literal>.abs</literal> file that contains a
1339     <literal>p</literal>-specifier.
1340    </para>
1341
1342    <para>
1343     If <emphasis>Structure</emphasis>=<emphasis>Phrase</emphasis> is
1344     used in conjunction with <emphasis>Incomplete Field</emphasis> - the
1345     default value for <emphasis>Completeness</emphasis>, the
1346     search is directed against the normal word registers, but if the term
1347     contains multiple words, the term will only match if all of the words
1348     are found immediately adjacent, and in the given order.
1349     The word search is performed on those fields that are indexed as
1350     type <literal>w</literal> in the <literal>.abs</literal> file.
1351    </para>
1352
1353    <para>
1354     If the <emphasis>Structure</emphasis> attribute is
1355     <emphasis>Word List</emphasis>,
1356     <emphasis>Free-form Text</emphasis>, or
1357     <emphasis>Document Text</emphasis>, the term is treated as a
1358     natural-language, relevance-ranked query.
1359     This search type uses the word register, i.e. those fields
1360     that are indexed as type <literal>w</literal> in the
1361     <literal>.abs</literal> file.
1362    </para>
1363
1364    <para>
1365     If the <emphasis>Structure</emphasis> attribute is
1366     <emphasis>Numeric String</emphasis> the term is treated as an integer.
1367     The search is performed on those fields that are indexed
1368     as type <literal>n</literal> in the <literal>.abs</literal> file.
1369    </para>
1370
1371    <para>
1372     If the <emphasis>Structure</emphasis> attribute is
1373     <emphasis>URx</emphasis> the term is treated as a URX (URL) entity.
1374     The search is performed on those fields that are indexed as type
1375     <literal>u</literal> in the <literal>.abs</literal> file.
1376    </para>
1377
1378    <para>
1379     If the <emphasis>Structure</emphasis> attribute is
1380     <emphasis>Local Number</emphasis> the term is treated as
1381     native Zebra Record Identifier.
1382    </para>
1383
1384    <para>
1385     If the <emphasis>Relation</emphasis> attribute is
1386     <emphasis>Equals</emphasis> (default), the term is matched
1387     in a normal fashion (modulo truncation and processing of
1388     individual words, if required).
1389     If <emphasis>Relation</emphasis> is <emphasis>Less Than</emphasis>,
1390     <emphasis>Less Than or Equal</emphasis>,
1391     <emphasis>Greater than</emphasis>, or <emphasis>Greater than or
1392      Equal</emphasis>, the term is assumed to be numerical, and a
1393     standard regular expression is constructed to match the given
1394     expression.
1395     If <emphasis>Relation</emphasis> is <emphasis>Relevance</emphasis>,
1396     the standard natural-language query processor is invoked.
1397    </para>
1398
1399    <para>
1400     For the <emphasis>Truncation</emphasis> attribute,
1401     <emphasis>No Truncation</emphasis> is the default.
1402     <emphasis>Left Truncation</emphasis> is not supported.
1403     <emphasis>Process &num;</emphasis> is supported, as is
1404     <emphasis>Regxp-1</emphasis>.
1405     <emphasis>Regxp-2</emphasis> enables the fault-tolerant (fuzzy)
1406     search. As a default, a single error (deletion, insertion, 
1407     replacement) is accepted when terms are matched against the register
1408     contents.
1409    </para>
1410
1411    <sect3>
1412     <title>Regular expressions</title>
1413     
1414     <para>
1415      Each term in a query is interpreted as a regular expression if
1416      the truncation value is either <emphasis>Regxp-1</emphasis> (102)
1417      or <emphasis>Regxp-2</emphasis> (103).
1418      Both query types follow the same syntax with the operands:
1419      <variablelist>
1420
1421       <varlistentry>
1422        <term>x</term>
1423        <listitem>
1424         <para>
1425          Matches the character <emphasis>x</emphasis>.
1426         </para>
1427        </listitem>
1428       </varlistentry>
1429       <varlistentry>
1430        <term>.</term>
1431        <listitem>
1432         <para>
1433          Matches any character.
1434         </para>
1435        </listitem>
1436       </varlistentry>
1437       <varlistentry>
1438        <term><literal>[</literal>..<literal>]</literal></term>
1439        <listitem>
1440         <para>
1441          Matches the set of characters specified;
1442          such as <literal>[abc]</literal> or <literal>[a-c]</literal>.
1443         </para>
1444        </listitem>
1445       </varlistentry>
1446      </variablelist>
1447      and the operators:
1448      <variablelist>
1449       
1450       <varlistentry>
1451        <term>x*</term>
1452        <listitem>
1453         <para>
1454          Matches <emphasis>x</emphasis> zero or more times. Priority: high.
1455         </para>
1456        </listitem>
1457       </varlistentry>
1458       <varlistentry>
1459        <term>x+</term>
1460        <listitem>
1461         <para>
1462          Matches <emphasis>x</emphasis> one or more times. Priority: high.
1463         </para>
1464        </listitem>
1465       </varlistentry>
1466       <varlistentry>
1467        <term>x?</term>
1468        <listitem>
1469         <para>
1470          Matches <emphasis>x</emphasis> once or twice. Priority: high.
1471         </para>
1472        </listitem>
1473       </varlistentry>
1474       <varlistentry>
1475        <term>xy</term>
1476        <listitem>
1477         <para>
1478          Matches <emphasis>x</emphasis>, then <emphasis>y</emphasis>.
1479          Priority: medium.
1480         </para>
1481        </listitem>
1482       </varlistentry>
1483       <varlistentry>
1484        <term>x&verbar;y</term>
1485        <listitem>
1486         <para>
1487          Matches either <emphasis>x</emphasis> or <emphasis>y</emphasis>.
1488          Priority: low.
1489         </para>
1490        </listitem>
1491       </varlistentry>
1492      </variablelist>
1493      The order of evaluation may be changed by using parentheses.
1494     </para>
1495
1496     <para>
1497      If the first character of the <emphasis>Regxp-2</emphasis> query
1498      is a plus character (<literal>+</literal>) it marks the
1499      beginning of a section with non-standard specifiers.
1500      The next plus character marks the end of the section.
1501      Currently Zebra only supports one specifier, the error tolerance,
1502      which consists one digit. 
1503     </para>
1504
1505     <para>
1506      Since the plus operator is normally a suffix operator the addition to
1507      the query syntax doesn't violate the syntax for standard regular
1508      expressions.
1509     </para>
1510
1511    </sect3>
1512
1513    <sect3>
1514     <title>Query examples</title>
1515
1516     <para>
1517      Phrase search for <emphasis>information retrieval</emphasis> in
1518      the title-register:
1519      <screen>
1520       @attr 1=4 "information retrieval"
1521      </screen>
1522     </para>
1523
1524     <para>
1525      Ranked search for the same thing:
1526      <screen>
1527       @attr 1=4 @attr 2=102 "Information retrieval"
1528      </screen>
1529     </para>
1530
1531     <para>
1532      Phrase search with a regular expression:
1533      <screen>
1534       @attr 1=4 @attr 5=102 "informat.* retrieval"
1535      </screen>
1536     </para>
1537
1538     <para>
1539      Ranked search with a regular expression:
1540      <screen>
1541       @attr 1=4 @attr 5=102 @attr 2=102 "informat.* retrieval"
1542      </screen>
1543     </para>
1544
1545     <para>
1546      In the GILS schema (<literal>gils.abs</literal>), the
1547      west-bounding-coordinate is indexed as type <literal>n</literal>,
1548      and is therefore searched by specifying
1549      <emphasis>structure</emphasis>=<emphasis>Numeric String</emphasis>.
1550      To match all those records with west-bounding-coordinate greater
1551      than -114 we use the following query:
1552      <screen>
1553       @attr 4=109 @attr 2=5 @attr gils 1=2038 -114
1554      </screen> 
1555     </para>
1556    </sect3>
1557   </sect2>
1558
1559   <sect2>
1560    <title>Present</title>
1561    <para>
1562     The present facility is supported in a standard fashion. The requested
1563     record syntax is matched against the ones supported by the profile of
1564     each record retrieved. If no record syntax is given, SUTRS is the
1565     default. The requested element set name, again, is matched against any
1566     provided by the relevant record profiles.
1567    </para>
1568   </sect2>
1569   <sect2>
1570    <title>Scan</title>
1571    <para>
1572     The attribute combinations provided with the termListAndStartPoint are
1573     processed in the same way as operands in a query (see above).
1574     Currently, only the term and the globalOccurrences are returned with
1575     the termInfo structure.
1576    </para>
1577   </sect2>
1578   <sect2>
1579    <title>Sort</title>
1580
1581    <para>
1582     Z39.50 specifies three diffent types of sort criterias.
1583     Of these Zebra supports the attribute specification type in which
1584     case the use attribute specifies the "Sort register".
1585     Sort registers are created for those fields that are of type "sort" in
1586     the default.idx file. 
1587     The corresponding character mapping file in default.idx specifies the
1588     ordinal of each character used in the actual sort.
1589    </para>
1590
1591    <para>
1592     Z39.50 allows the client to specify sorting on one or more input
1593     result sets and one output result set.
1594     Zebra supports sorting on one result set only which may or may not
1595     be the same as the output result set.
1596    </para>
1597   </sect2>
1598   <sect2>
1599    <title>Close</title>
1600    <para>
1601     If a Close PDU is received, the server will respond with a Close PDU
1602     with reason=FINISHED, no matter which protocol version was negotiated
1603     during initialization. If the protocol version is 3 or more, the
1604     server will generate a Close PDU under certain circumstances,
1605     including a session timeout (60 minutes by default), and certain kinds of
1606     protocol errors. Once a Close PDU has been sent, the protocol
1607     association is considered broken, and the transport connection will be
1608     closed immediately upon receipt of further data, or following a short
1609     timeout.
1610    </para>
1611   </sect2>
1612  </sect1>
1613 </chapter>
1614
1615 <chapter id="record-model">
1616  <title>The Record Model</title>
1617
1618  <para>
1619   The Zebra system is designed to support a wide range of data management
1620   applications. The system can be configured to handle virtually any
1621   kind of structured data. Each record in the system is associated with
1622   a <emphasis>record schema</emphasis> which lends context to the data
1623   elements of the record.
1624   Any number of record schema can coexist in the system.
1625   Although it may be wise to use only a single schema within
1626   one database, the system poses no such restrictions.
1627  </para>
1628
1629  <para>
1630   The record model described in this chapter applies to the fundamental,
1631   structured
1632   record type <literal>grs</literal> as introduced in
1633   section <xref linkend="record-types"/>.
1634  </para>
1635
1636  <para>
1637   Records pass through three different states during processing in the
1638   system.
1639  </para>
1640
1641  <para>
1642
1643   <itemizedlist>
1644    <listitem>
1645
1646     <para>
1647      When records are accessed by the system, they are represented
1648      in their local, or native format. This might be SGML or HTML files,
1649      News or Mail archives, MARC records. If the system doesn't already
1650      know how to read the type of data you need to store, you can set up an
1651      input filter by preparing conversion rules based on regular
1652      expressions and possibly augmented by a flexible scripting language
1653      (Tcl).
1654      The input filter produces as output an internal representation:
1655
1656     </para>
1657    </listitem>
1658    <listitem>
1659
1660     <para>
1661      When records are processed by the system, they are represented
1662      in a tree-structure, constructed by tagged data elements hanging off a
1663      root node. The tagged elements may contain data or yet more tagged
1664      elements in a recursive structure. The system performs various
1665      actions on this tree structure (indexing, element selection, schema
1666      mapping, etc.),
1667
1668     </para>
1669    </listitem>
1670    <listitem>
1671
1672     <para>
1673      Before transmitting records to the client, they are first
1674      converted from the internal structure to a form suitable for exchange
1675      over the network - according to the Z39.50 standard.
1676     </para>
1677    </listitem>
1678
1679   </itemizedlist>
1680
1681  </para>
1682
1683  <sect1 id="local-representation">
1684   <title>Local Representation</title>
1685
1686   <para>
1687    As mentioned earlier, Zebra places few restrictions on the type of
1688    data that you can index and manage. Generally, whatever the form of
1689    the data, it is parsed by an input filter specific to that format, and
1690    turned into an internal structure that Zebra knows how to handle. This
1691    process takes place whenever the record is accessed - for indexing and
1692    retrieval.
1693   </para>
1694
1695   <para>
1696    The RecordType parameter in the <literal>zebra.cfg</literal> file, or
1697    the <literal>-t</literal> option to the indexer tells Zebra how to
1698    process input records.
1699    Two basic types of processing are available - raw text and structured
1700    data. Raw text is just that, and it is selected by providing the
1701    argument <emphasis>text</emphasis> to Zebra. Structured records are
1702    all handled internally using the basic mechanisms described in the
1703    subsequent sections.
1704    Zebra can read structured records in many different formats.
1705    How this is done is governed by additional parameters after the
1706    "grs" keyboard, separated by "." characters.
1707   </para>
1708
1709   <para>
1710    Three basic subtypes to the <emphasis>grs</emphasis> type are
1711    currently available:
1712   </para>
1713
1714   <para>
1715    <variablelist>
1716     <varlistentry>
1717      <term>grs.sgml</term>
1718      <listitem>
1719       <para>
1720        This is the canonical input format &mdash;
1721        described below. It is a simple SGML-like syntax.
1722       </para>
1723      </listitem>
1724     </varlistentry>
1725     <varlistentry>
1726      <term>grs.regx.<emphasis>filter</emphasis></term>
1727      <listitem>
1728       <para>
1729        This enables a user-supplied input
1730        filter. The mechanisms of these filters are described below.
1731       </para>
1732      </listitem>
1733     </varlistentry>
1734     <varlistentry>
1735      <term>grs.marc.<emphasis>abstract syntax</emphasis></term>
1736      <listitem>
1737       <para>
1738        This allows Zebra to read
1739        records in the ISO2709 (MARC) encoding standard. In this case, the
1740        last paramemeter <emphasis>abstract syntax</emphasis> names the
1741        <literal>.abs</literal> file (see below)
1742        which describes the specific MARC structure of the input record as
1743        well as the indexing rules.
1744       </para>
1745      </listitem>
1746     </varlistentry>
1747    </variablelist>
1748   </para>
1749
1750   <sect2>
1751    <title>Canonical Input Format</title>
1752
1753    <para>
1754     Although input data can take any form, it is sometimes useful to
1755     describe the record processing capabilities of the system in terms of
1756     a single, canonical input format that gives access to the full
1757     spectrum of structure and flexibility in the system. In Zebra, this
1758     canonical format is an "SGML-like" syntax.
1759    </para>
1760
1761    <para>
1762     To use the canonical format specify <literal>grs.sgml</literal> as
1763     the record type.
1764    </para>
1765
1766    <para>
1767     Consider a record describing an information resource (such a record is
1768     sometimes known as a <emphasis>locator record</emphasis>).
1769     It might contain a field describing the distributor of the
1770     information resource, which might in turn be partitioned into
1771     various fields providing details about the distributor, like this:
1772    </para>
1773
1774    <para>
1775
1776     <screen>
1777      &#60;Distributor&#62;
1778      &#60;Name&#62; USGS/WRD &#60;/Name&#62;
1779      &#60;Organization&#62; USGS/WRD &#60;/Organization&#62;
1780      &#60;Street-Address&#62;
1781      U.S. GEOLOGICAL SURVEY, 505 MARQUETTE, NW
1782      &#60;/Street-Address&#62;
1783      &#60;City&#62; ALBUQUERQUE &#60;/City&#62;
1784      &#60;State&#62; NM &#60;/State&#62;
1785      &#60;Zip-Code&#62; 87102 &#60;/Zip-Code&#62;
1786      &#60;Country&#62; USA &#60;/Country&#62;
1787      &#60;Telephone&#62; (505) 766-5560 &#60;/Telephone&#62;
1788      &#60;/Distributor&#62;
1789     </screen>
1790
1791    </para>
1792
1793    <note>
1794    <para>
1795     The indentation used above is used to illustrate how Zebra
1796      interprets the markup. The indentation, in itself, has no
1797      significance to the parser for the canonical input format, which
1798      discards superfluous whitespace.
1799     </para>
1800    </note>
1801    <para>
1802     The keywords surrounded by &lt;...&gt; are
1803     <emphasis>tags</emphasis>, while the sections of text
1804     in between are the <emphasis>data elements</emphasis>.
1805     A data element is characterized by its location in the tree
1806     that is made up by the nested elements.
1807     Each element is terminated by a closing tag - beginning
1808     with <literal>&#60;</literal>/, and containing the same symbolic
1809     tag-name as the corresponding opening tag.
1810     The general closing tag - <literal>&#60;</literal>&gt;/ -
1811     terminates the element started by the last opening tag. The
1812     structuring of elements is significant.
1813     The element <emphasis>Telephone</emphasis>,
1814     for instance, may be indexed and presented to the client differently,
1815     depending on whether it appears inside the
1816     <emphasis>Distributor</emphasis> element, or some other,
1817     structured data element such a <emphasis>Supplier</emphasis> element.
1818    </para>
1819
1820    <sect3>
1821     <title>Record Root</title>
1822
1823     <para>
1824      The first tag in a record describes the root node of the tree that
1825      makes up the total record. In the canonical input format, the root tag
1826      should contain the name of the schema that lends context to the
1827      elements of the record (see section
1828      <xref linkend="internal-representation"/>).
1829       The following is a GILS record that
1830       contains only a single element (strictly speaking, that makes it an
1831       illegal GILS record, since the GILS profile includes several mandatory
1832       elements - Zebra does not validate the contents of a record against
1833       the Z39.50 profile, however - it merely attempts to match up elements
1834       of a local representation with the given schema):
1835     </para>
1836
1837     <para>
1838
1839      <screen>
1840       &#60;gils&#62;
1841       &#60;title&#62;Zen and the Art of Motorcycle Maintenance&#60;/title&#62;
1842       &#60;/gils&#62;
1843      </screen>
1844
1845     </para>
1846
1847    </sect3>
1848
1849    <sect3>
1850     <title>Variants</title>
1851
1852     <para>
1853      Zebra allows you to provide individual data elements in a number of
1854      <emphasis>variant forms</emphasis>. Examples of variant forms are
1855      textual data elements which might appear in different languages, and
1856      images which may appear in different formats or layouts.
1857      The variant system in Zebra is essentially a representation of
1858      the variant mechanism of Z39.50-1995.
1859     </para>
1860
1861     <para>
1862      The following is an example of a title element which occurs in two
1863      different languages.
1864     </para>
1865
1866     <para>
1867
1868      <screen>
1869       &#60;title&#62;
1870       &#60;var lang lang "eng"&#62;
1871       Zen and the Art of Motorcycle Maintenance&#60;/&#62;
1872       &#60;var lang lang "dan"&#62;
1873       Zen og Kunsten at Vedligeholde en Motorcykel&#60;/&#62;
1874       &#60;/title&#62;
1875      </screen>
1876
1877     </para>
1878
1879     <para>
1880      The syntax of the <emphasis>variant element</emphasis> is
1881      <literal>&lt;var class type value&gt;</literal>.
1882      The available values for the <emphasis>class</emphasis> and
1883      <emphasis>type</emphasis> fields are given by the variant set
1884      that is associated with the current schema
1885      (see section <xref linkend="variant-set"/>).
1886     </para>
1887
1888     <para>
1889      Variant elements are terminated by the general end-tag &#60;/&#62;, by
1890      the variant end-tag &#60;/var&#62;, by the appearance of another variant
1891      tag with the same <emphasis>class</emphasis> and
1892      <emphasis>value</emphasis> settings, or by the
1893      appearance of another, normal tag. In other words, the end-tags for
1894      the variants used in the example above could have been saved.
1895     </para>
1896
1897     <para>
1898      Variant elements can be nested. The element
1899     </para>
1900
1901     <para>
1902
1903      <screen>
1904       &#60;title&#62;
1905       &#60;var lang lang "eng"&#62;&#60;var body iana "text/plain"&#62;
1906       Zen and the Art of Motorcycle Maintenance
1907       &#60;/title&#62;
1908      </screen>
1909
1910     </para>
1911
1912     <para>
1913      Associates two variant components to the variant list for the title
1914      element.
1915     </para>
1916
1917     <para>
1918      Given the nesting rules described above, we could write
1919     </para>
1920
1921     <para>
1922
1923      <screen>
1924       &#60;title&#62;
1925       &#60;var body iana "text/plain&#62;
1926       &#60;var lang lang "eng"&#62;
1927       Zen and the Art of Motorcycle Maintenance
1928       &#60;var lang lang "dan"&#62;
1929       Zen og Kunsten at Vedligeholde en Motorcykel
1930       &#60;/title&#62;
1931      </screen>
1932
1933     </para>
1934
1935     <para>
1936      The title element above comes in two variants. Both have the IANA body
1937      type "text/plain", but one is in English, and the other in
1938      Danish. The client, using the element selection mechanism of Z39.50,
1939      can retrieve information about the available variant forms of data
1940      elements, or it can select specific variants based on the requirements
1941      of the end-user.
1942     </para>
1943
1944    </sect3>
1945
1946   </sect2>
1947
1948   <sect2>
1949    <title>Input Filters</title>
1950
1951    <para>
1952     In order to handle general input formats, Zebra allows the
1953     operator to define filters which read individual records in their
1954     native format and produce an internal representation that the system
1955     can work with.
1956    </para>
1957
1958    <para>
1959     Input filters are ASCII files, generally with the suffix
1960     <literal>.flt</literal>.
1961     The system looks for the files in the directories given in the
1962     <emphasis>profilePath</emphasis> setting in the
1963     <literal>zebra.cfg</literal> files.
1964     The record type for the filter is
1965     <literal>grs.regx.</literal><emphasis>filter-filename</emphasis>
1966     (fundamental type <literal>grs</literal>, file read
1967     type <literal>regx</literal>, argument
1968     <emphasis>filter-filename</emphasis>).
1969    </para>
1970    
1971    <para>
1972     Generally, an input filter consists of a sequence of rules, where each
1973     rule consists of a sequence of expressions, followed by an action. The
1974     expressions are evaluated against the contents of the input record,
1975     and the actions normally contribute to the generation of an internal
1976     representation of the record.
1977    </para>
1978    
1979    <para>
1980     An expression can be either of the following:
1981    </para>
1982
1983    <para>
1984     <variablelist>
1985
1986      <varlistentry>
1987       <term>INIT</term>
1988       <listitem>
1989        <para>
1990         The action associated with this expression is evaluated
1991         exactly once in the lifetime of the application, before any records
1992         are read. It can be used in conjunction with an action that
1993         initializes tables or other resources that are used in the processing
1994         of input records.
1995        </para>
1996       </listitem>
1997      </varlistentry>
1998      <varlistentry>
1999       <term>BEGIN</term>
2000       <listitem>
2001        <para>
2002         Matches the beginning of the record. It can be used to
2003         initialize variables, etc. Typically, the
2004         <emphasis>BEGIN</emphasis> rule is also used
2005         to establish the root node of the record.
2006        </para>
2007       </listitem>
2008      </varlistentry>
2009      <varlistentry>
2010       <term>END</term>
2011       <listitem>
2012        <para>
2013         Matches the end of the record - when all of the contents
2014         of the record has been processed.
2015        </para>
2016       </listitem>
2017      </varlistentry>
2018      <varlistentry>
2019       <term>/pattern/</term>
2020       <listitem>
2021        <para>
2022         Matches a string of characters from the input record.
2023        </para>
2024       </listitem>
2025      </varlistentry>
2026      <varlistentry>
2027       <term>BODY</term>
2028       <listitem>
2029        <para>
2030         This keyword may only be used between two patterns.
2031         It matches everything between (not including) those patterns.
2032        </para>
2033       </listitem>
2034      </varlistentry>
2035      <varlistentry>
2036       <term>FINISH</term>
2037       <listitem>
2038        <para>
2039         The expression asssociated with this pattern is evaluated
2040         once, before the application terminates. It can be used to release
2041         system resources - typically ones allocated in the
2042         <emphasis>INIT</emphasis> step.
2043        </para>
2044       </listitem>
2045      </varlistentry>
2046     </variablelist>
2047    </para>
2048
2049    <para>
2050     An action is surrounded by curly braces (&lcub;...&rcub;), and
2051     consists of a sequence of statements. Statements may be separated
2052     by newlines or semicolons (;).
2053     Within actions, the strings that matched the expressions
2054     immediately preceding the action can be referred to as
2055     &dollar;0, &dollar;1, &dollar;2, etc.
2056    </para>
2057
2058    <para>
2059     The available statements are:
2060    </para>
2061
2062    <para>
2063     <variablelist>
2064
2065      <varlistentry>
2066       <term>begin <emphasis>type &lsqb;parameter ... &rsqb;</emphasis></term>
2067       <listitem>
2068        <para>
2069         Begin a new
2070         data element. The type is one of the following:
2071         <variablelist>
2072
2073          <varlistentry>
2074           <term>record</term>
2075           <listitem>
2076            <para>
2077             Begin a new record. The followingparameter should be the
2078             name of the schema that describes the structure of the record, eg.
2079             <literal>gils</literal> or <literal>wais</literal> (see below).
2080             The <literal>begin record</literal> call should precede
2081             any other use of the <emphasis>begin</emphasis> statement.
2082            </para>
2083           </listitem>
2084          </varlistentry>
2085          <varlistentry>
2086           <term>element</term>
2087           <listitem>
2088            <para>
2089             Begin a new tagged element. The parameter is the
2090             name of the tag. If the tag is not matched anywhere in the tagsets
2091             referenced by the current schema, it is treated as a local string
2092             tag.
2093            </para>
2094           </listitem>
2095          </varlistentry>
2096          <varlistentry>
2097           <term>variant</term>
2098           <listitem>
2099            <para>
2100             Begin a new node in a variant tree. The parameters are
2101             <emphasis>class type value</emphasis>.
2102            </para>
2103           </listitem>
2104          </varlistentry>
2105         </variablelist>
2106        </para>
2107       </listitem>
2108      </varlistentry>
2109      <varlistentry>
2110       <term>data</term>
2111       <listitem>
2112        <para>
2113         Create a data element. The concatenated arguments make
2114         up the value of the data element.
2115         The option <literal>-text</literal> signals that
2116         the layout (whitespace) of the data should be retained for
2117         transmission.
2118         The option <literal>-element</literal>
2119         <emphasis>tag</emphasis> wraps the data up in
2120         the <emphasis>tag</emphasis>.
2121         The use of the <literal>-element</literal> option is equivalent to
2122         preceding the command with a <emphasis>begin
2123          element</emphasis> command, and following
2124         it with the <emphasis>end</emphasis> command.
2125        </para>
2126       </listitem>
2127      </varlistentry>
2128      <varlistentry>
2129       <term>end <emphasis>&lsqb;type&rsqb;</emphasis></term>
2130       <listitem>
2131        <para>
2132         Close a tagged element. If no parameter is given,
2133         the last element on the stack is terminated.
2134         The first parameter, if any, is a type name, similar
2135         to the <emphasis>begin</emphasis> statement.
2136         For the <emphasis>element</emphasis> type, a tag
2137         name can be provided to terminate a specific tag.
2138        </para>
2139       </listitem>
2140      </varlistentry>
2141     </variablelist>
2142    </para>
2143
2144    <para>
2145     The following input filter reads a Usenet news file, producing a
2146     record in the WAIS schema. Note that the body of a news posting is
2147     separated from the list of headers by a blank line (or rather a
2148     sequence of two newline characters.
2149    </para>
2150
2151    <para>
2152
2153     <screen>
2154      BEGIN                { begin record wais }
2155
2156      /^From:/ BODY /$/    { data -element name $1 }
2157      /^Subject:/ BODY /$/ { data -element title $1 }
2158      /^Date:/ BODY /$/    { data -element lastModified $1 }
2159      /\n\n/ BODY END      {
2160          begin element bodyOfDisplay
2161          begin variant body iana "text/plain"
2162          data -text $1
2163          end record
2164        }
2165     </screen>
2166
2167    </para>
2168
2169    <para>
2170     If Zebra is compiled with support for Tcl (Tool Command Language)
2171     enabled, the statements described above are supplemented with a complete
2172     scripting environment, including control structures (conditional
2173     expressions and loop constructs), and powerful string manipulation
2174     mechanisms for modifying the elements of a record. Tcl is a popular
2175     scripting environment, with several tutorials available both online
2176     and in hardcopy.
2177    </para>
2178
2179    <para>
2180     <emphasis>NOTE: Tcl support is not currently available, but will be
2181      included with one of the next alpha or beta releases.</emphasis>
2182    </para>
2183
2184    <para>
2185     <emphasis>NOTE: Variant support is not currently available in the input
2186      filter, but will be included with one of the next alpha or beta
2187      releases.</emphasis>
2188    </para>
2189
2190   </sect2>
2191
2192  </sect1>
2193
2194  <sect1 id="internal-representation">
2195   <title>Internal Representation</title>
2196
2197   <para>
2198    When records are manipulated by the system, they're represented in a
2199    tree-structure, with data elements at the leaf nodes, and tags or
2200    variant components at the non-leaf nodes. The root-node identifies the
2201    schema that lends context to the tagging and structuring of the
2202    record. Imagine a simple record, consisting of a 'title' element and
2203    an 'author' element:
2204   </para>
2205
2206   <para>
2207
2208    <screen>
2209     TITLE     "Zen and the Art of Motorcycle Maintenance"
2210     ROOT 
2211     AUTHOR    "Robert Pirsig"
2212    </screen>
2213
2214   </para>
2215
2216   <para>
2217    A slightly more complex record would have the author element consist
2218    of two elements, a surname and a first name:
2219   </para>
2220
2221   <para>
2222
2223    <screen>
2224     TITLE     "Zen and the Art of Motorcycle Maintenance"
2225     ROOT  
2226     FIRST-NAME "Robert"
2227     AUTHOR
2228     SURNAME    "Pirsig"
2229    </screen>
2230
2231   </para>
2232
2233   <para>
2234    The root of the record will refer to the record schema that describes
2235    the structuring of this particular record. The schema defines the
2236    element tags (TITLE, FIRST-NAME, etc.) that may occur in the record, as
2237    well as the structuring (SURNAME should appear below AUTHOR, etc.). In
2238    addition, the schema establishes element set names that are used by
2239    the client to request a subset of the elements of a given record. The
2240    schema may also establish rules for converting the record to a
2241    different schema, by stating, for each element, a mapping to a
2242    different tag path.
2243   </para>
2244
2245   <sect2>
2246    <title>Tagged Elements</title>
2247
2248    <para>
2249     A data element is characterized by its tag, and its position in the
2250     structure of the record. For instance, while the tag "telephone
2251     number" may be used different places in a record, we may need to
2252     distinguish between these occurrences, both for searching and
2253     presentation purposes. For instance, while the phone numbers for the
2254     "customer" and the "service provider" are both
2255     representatives for the same type of resource (a telephone number), it
2256     is essential that they be kept separate. The record schema provides
2257     the structure of the record, and names each data element (defined by
2258     the sequence of tags - the tag path - by which the element can be
2259     reached from the root of the record).
2260    </para>
2261
2262   </sect2>
2263
2264   <sect2>
2265    <title>Variants</title>
2266
2267    <para>
2268     The children of a tag node may be either more tag nodes, a data node
2269     (possibly accompanied by tag nodes),
2270     or a tree of variant nodes. The children of  variant nodes are either
2271     more variant nodes or a data node (possibly accompanied by more
2272     variant nodes). Each leaf node, which is normally a
2273     data node, corresponds to a <emphasis>variant form</emphasis> of the
2274     tagged element identified by the tag which parents the variant tree.
2275     The following title element occurs in two different languages:
2276    </para>
2277
2278    <para>
2279
2280     <screen>
2281      VARIANT LANG=ENG  "War and Peace"
2282      TITLE
2283      VARIANT LANG=DAN  "Krig og Fred"
2284     </screen>
2285
2286    </para>
2287
2288    <para>
2289     Which of the two elements are transmitted to the client by the server
2290     depends on the specifications provided by the client, if any.
2291    </para>
2292
2293    <para>
2294     In practice, each variant node is associated with a triple of class,
2295     type, value, corresponding to the variant mechanism of Z39.50.
2296    </para>
2297
2298   </sect2>
2299
2300   <sect2>
2301    <title>Data Elements</title>
2302
2303    <para>
2304     Data nodes have no children (they are always leaf nodes in the record
2305     tree).
2306    </para>
2307
2308    <note>
2309     <para>
2310      Documentation needs extension here about types of nodes - numerical,
2311      textual, etc., plus the various types of inclusion notes.
2312     </para>
2313    </note>
2314    
2315   </sect2>
2316
2317  </sect1>
2318
2319  <sect1 id="data-model">
2320   <title>Configuring Your Data Model</title>
2321
2322   <para>
2323    The following sections describe the configuration files that govern
2324    the internal management of data records. The system searches for the files
2325    in the directories specified by the <emphasis>profilePath</emphasis>
2326    setting in the <literal>zebra.cfg</literal> file.
2327   </para>
2328
2329   <sect2>
2330    <title>The Abstract Syntax</title>
2331
2332    <para>
2333     The abstract syntax definition (also known as an Abstract Record
2334     Structure, or ARS) is the focal point of the
2335     record schema description. For a given schema, the ABS file may state any
2336     or all of the following:
2337    </para>
2338
2339    <para>
2340
2341     <itemizedlist>
2342      <listitem>
2343
2344       <para>
2345        The object identifier of the Z39.50 schema associated
2346        with the ARS, so that it can be referred to by the client.
2347       </para>
2348      </listitem>
2349
2350      <listitem>
2351       <para>
2352        The attribute set (which can possibly be a compound of multiple
2353        sets) which applies in the profile. This is used when indexing and
2354        searching the records belonging to the given profile.
2355       </para>
2356      </listitem>
2357
2358      <listitem>
2359       <para>
2360        The Tag set (again, this can consist of several different sets).
2361        This is used when reading the records from a file, to recognize the
2362        different tags, and when transmitting the record to the client -
2363        mapping the tags to their numerical representation, if they are
2364        known.
2365       </para>
2366      </listitem>
2367
2368      <listitem>
2369       <para>
2370        The variant set which is used in the profile. This provides a
2371        vocabulary for specifying the <emphasis>forms</emphasis> of data that appear inside
2372        the records.
2373       </para>
2374      </listitem>
2375
2376      <listitem>
2377       <para>
2378        Element set names, which are a shorthand way for the client to
2379        ask for a subset of the data elements contained in a record. Element
2380        set names, in the retrieval module, are mapped to <emphasis>element
2381         specifications</emphasis>, which contain information equivalent to the
2382        <emphasis>Espec-1</emphasis> syntax of Z39.50.
2383       </para>
2384      </listitem>
2385
2386      <listitem>
2387       <para>
2388        Map tables, which may specify mappings to
2389        <emphasis>other</emphasis> database profiles, if desired.
2390       </para>
2391      </listitem>
2392
2393      <listitem>
2394       <para>
2395        Possibly, a set of rules describing the mapping of elements to a
2396        MARC representation.
2397
2398       </para>
2399      </listitem>
2400
2401      <listitem>      
2402       <para>
2403        A list of element descriptions (this is the actual ARS of the
2404        schema, in Z39.50 terms), which lists the ways in which the various
2405        tags can be used and organized hierarchically.
2406       </para>
2407      </listitem>
2408
2409     </itemizedlist>
2410
2411    </para>
2412
2413    <para>
2414     Several of the entries above simply refer to other files, which
2415     describe the given objects.
2416    </para>
2417
2418   </sect2>
2419
2420   <sect2>
2421    <title>The Configuration Files</title>
2422
2423    <para>
2424     This section describes the syntax and use of the various tables which
2425     are used by the retrieval module.
2426    </para>
2427
2428    <para>
2429     The number of different file types may appear daunting at first, but
2430     each type corresponds fairly clearly to a single aspect of the Z39.50
2431     retrieval facilities. Further, the average database administrator,
2432     who is simply reusing an existing profile for which tables already
2433     exist, shouldn't have to worry too much about the contents of these tables.
2434    </para>
2435
2436    <para>
2437     Generally, the files are simple ASCII files, which can be maintained
2438     using any text editor. Blank lines, and lines beginning with a (&num;) are
2439     ignored. Any characters on a line followed by a (&num;) are also ignored.
2440     All other lines contain <emphasis>directives</emphasis>, which provide
2441     some setting or value to the system.
2442     Generally, settings are characterized by a single
2443     keyword, identifying the setting, followed by a number of parameters.
2444     Some settings are repeatable (r), while others may occur only once in a
2445     file. Some settings are optional (o), whicle others again are
2446     mandatory (m).
2447    </para>
2448    
2449   </sect2>
2450   
2451   <sect2>
2452    <title>The Abstract Syntax (.abs) Files</title>
2453    
2454    <para>
2455     The name of this file type is slightly misleading in Z39.50 terms,
2456     since, apart from the actual abstract syntax of the profile, it also
2457     includes most of the other definitions that go into a database
2458     profile.
2459    </para>
2460    
2461    <para>
2462     When a record in the canonical, SGML-like format is read from a file
2463     or from the database, the first tag of the file should reference the
2464     profile that governs the layout of the record. If the first tag of the
2465     record is, say, <literal>&lt;gils&gt;</literal>, the system will look
2466     for the profile definition in the file <literal>gils.abs</literal>.
2467     Profile definitions are cached, so they only have to be read once
2468     during the lifespan of the current process. 
2469    </para>
2470
2471    <para>
2472     When writing your own input filters, the
2473     <emphasis>record-begin</emphasis> command
2474     introduces the profile, and should always be called first thing when
2475     introducing a new record.
2476    </para>
2477    
2478    <para>
2479     The file may contain the following directives:
2480    </para>
2481
2482    <para>
2483     <variablelist>
2484
2485      <varlistentry>
2486       <term>name <emphasis>symbolic-name</emphasis></term>
2487       <listitem>
2488        <para>
2489         (m) This provides a shorthand name or
2490         description for the profile. Mostly useful for diagnostic purposes.
2491        </para>
2492       </listitem>
2493      </varlistentry>
2494      <varlistentry>
2495       <term>reference <emphasis>OID-name</emphasis></term>
2496       <listitem>
2497        <para>
2498         (m) The reference name of the OID for the profile.
2499         The reference names can be found in the <emphasis>util</emphasis>
2500         module of <emphasis>YAZ</emphasis>.
2501        </para>
2502       </listitem>
2503      </varlistentry>
2504      <varlistentry>
2505       <term>attset <emphasis>filename</emphasis></term>
2506       <listitem>
2507        <para>
2508         (m) The attribute set that is used for
2509         indexing and searching records belonging to this profile.
2510        </para>
2511       </listitem>
2512      </varlistentry>
2513      <varlistentry>
2514       <term>tagset <emphasis>filename</emphasis></term>
2515       <listitem>
2516        <para>
2517         (o) The tag set (if any) that describe
2518         that fields of the records.
2519        </para>
2520       </listitem>
2521      </varlistentry>
2522      <varlistentry>
2523       <term>varset <emphasis>filename</emphasis></term>
2524       <listitem>
2525        <para>
2526         (o) The variant set used in the profile.
2527        </para>
2528       </listitem>
2529      </varlistentry>
2530      <varlistentry>
2531       <term>maptab <emphasis>filename</emphasis></term>
2532       <listitem>
2533        <para>
2534         (o,r) This points to a
2535         conversion table that might be used if the client asks for the record
2536         in a different schema from the native one.
2537        </para>
2538       </listitem></varlistentry>
2539      <varlistentry>
2540       <term>marc <emphasis>filename</emphasis></term>
2541       <listitem>
2542        <para>
2543         (o) Points to a file containing parameters
2544         for representing the record contents in the ISO2709 syntax. Read the
2545         description of the MARC representation facility below.
2546        </para>
2547       </listitem></varlistentry>
2548      <varlistentry>
2549       <term>esetname <emphasis>name filename</emphasis></term>
2550       <listitem>
2551        <para>
2552         (o,r) Associates the
2553         given element set name with an element selection file. If an (@) is
2554         given in place of the filename, this corresponds to a null mapping for
2555         the given element set name.
2556        </para>
2557       </listitem></varlistentry>
2558      <varlistentry>
2559       <term>any <emphasis>tags</emphasis></term>
2560       <listitem>
2561        <para>
2562         (o) This directive specifies a list of attributes
2563         which should be appended to the attribute list given for each
2564         element. The effect is to make every single element in the abstract
2565         syntax searchable by way of the given attributes. This directive
2566         provides an efficient way of supporting free-text searching across all
2567         elements. However, it does increase the size of the index
2568         significantly. The attributes can be qualified with a structure, as in
2569         the <emphasis>elm</emphasis> directive below.
2570        </para>
2571       </listitem></varlistentry>
2572      <varlistentry>
2573       <term>elm <emphasis>path name attributes</emphasis></term>
2574       <listitem>
2575        <para>
2576         (o,r) Adds an element to the abstract record syntax of the schema.
2577         The <emphasis>path</emphasis> follows the
2578         syntax which is suggested by the Z39.50 document - that is, a sequence
2579         of tags separated by slashes (/). Each tag is given as a
2580         comma-separated pair of tag type and -value surrounded by parenthesis.
2581         The <emphasis>name</emphasis> is the name of the element, and
2582         the <emphasis>attributes</emphasis>
2583         specifies which attributes to use when indexing the element in a
2584         comma-separated list.
2585         A ! in place of the attribute name is equivalent to
2586         specifying an attribute name identical to the element name.
2587         A - in place of the attribute name
2588         specifies that no indexing is to take place for the given element.
2589         The attributes can be qualified with <emphasis>field
2590          types</emphasis> to specify which
2591         character set should govern the indexing procedure for that field.
2592         The same data element may be indexed into several different
2593         fields, using different character set definitions.
2594         See the section <xref linkend="field-structure-and-character-sets"/>.
2595          The default field type is "w" for <emphasis>word</emphasis>.
2596        </para>
2597       </listitem></varlistentry>
2598     </variablelist>
2599    </para>
2600
2601    <note>
2602    <para>
2603      The mechanism for controlling indexing is not adequate for
2604      complex databases, and will probably be moved into a separate
2605      configuration table eventually.
2606     </para>
2607    </note>
2608    
2609    <para>
2610     The following is an excerpt from the abstract syntax file for the GILS
2611     profile.
2612    </para>
2613
2614    <para>
2615
2616     <screen>
2617      name gils
2618      reference GILS-schema
2619      attset gils.att
2620      tagset gils.tag
2621      varset var1.var
2622
2623      maptab gils-usmarc.map
2624
2625      # Element set names
2626
2627      esetname VARIANT gils-variant.est  # for WAIS-compliance
2628      esetname B gils-b.est
2629      esetname G gils-g.est
2630      esetname F @
2631
2632      elm (1,10)              rank                        -
2633      elm (1,12)              url                         -
2634      elm (1,14)              localControlNumber     Local-number
2635      elm (1,16)              dateOfLastModification Date/time-last-modified
2636      elm (2,1)               title                       w:!,p:!
2637      elm (4,1)               controlIdentifier      Identifier-standard
2638      elm (2,6)               abstract               Abstract
2639      elm (4,51)              purpose                     !
2640      elm (4,52)              originator                  - 
2641      elm (4,53)              accessConstraints           !
2642      elm (4,54)              useConstraints              !
2643      elm (4,70)              availability                -
2644      elm (4,70)/(4,90)       distributor                 -
2645      elm (4,70)/(4,90)/(2,7) distributorName             !
2646      elm (4,70)/(4,90)/(2,10 distributorOrganization     !
2647      elm (4,70)/(4,90)/(4,2) distributorStreetAddress    !
2648      elm (4,70)/(4,90)/(4,3) distributorCity             !
2649     </screen>
2650
2651    </para>
2652
2653   </sect2>
2654
2655   <sect2 id="attset-files">
2656    <title>The Attribute Set (.att) Files</title>
2657
2658    <para>
2659     This file type describes the <emphasis>Use</emphasis> elements of
2660     an attribute set. 
2661     It contains the following directives. 
2662    </para>
2663    
2664    <para>
2665     <variablelist>
2666      <varlistentry>
2667       <term>name <emphasis>symbolic-name</emphasis></term>
2668       <listitem>
2669        <para>
2670         (m) This provides a shorthand name or
2671         description for the attribute set.
2672         Mostly useful for diagnostic purposes.
2673        </para>
2674       </listitem></varlistentry>
2675      <varlistentry>
2676       <term>reference <emphasis>OID-name</emphasis></term>
2677       <listitem>
2678        <para>
2679         (m) The reference name of the OID for
2680         the attribute set.
2681         The reference names can be found in the <emphasis>util</emphasis>
2682         module of <emphasis>YAZ</emphasis>.
2683        </para>
2684       </listitem></varlistentry>
2685      <varlistentry>
2686       <term>include <emphasis>filename</emphasis></term>
2687       <listitem>
2688        <para>
2689         (o,r) This directive is used to
2690         include another attribute set as a part of the current one. This is
2691         used when a new attribute set is defined as an extension to another
2692         set. For instance, many new attribute sets are defined as extensions
2693         to the <emphasis>bib-1</emphasis> set.
2694         This is an important feature of the retrieval
2695         system of Z39.50, as it ensures the highest possible level of
2696         interoperability, as those access points of your database which are
2697         derived from the external set (say, bib-1) can be used even by clients
2698         who are unaware of the new set.
2699        </para>
2700       </listitem></varlistentry>
2701      <varlistentry>
2702       <term>att
2703        <emphasis>att-value att-name &lsqb;local-value&rsqb;</emphasis></term>
2704       <listitem>
2705        <para>
2706         (o,r) This
2707         repeatable directive introduces a new attribute to the set. The
2708         attribute value is stored in the index (unless a
2709         <emphasis>local-value</emphasis> is
2710         given, in which case this is stored). The name is used to refer to the
2711         attribute from the <emphasis>abstract syntax</emphasis>. 
2712        </para>
2713       </listitem></varlistentry>
2714     </variablelist>
2715    </para>
2716
2717    <para>
2718     This is an excerpt from the GILS attribute set definition.
2719     Notice how the file describing the <emphasis>bib-1</emphasis>
2720     attribute set is referenced.
2721    </para>
2722
2723    <para>
2724
2725     <screen>
2726      name gils
2727      reference GILS-attset
2728      include bib1.att
2729
2730      att 2001           distributorName
2731      att 2002           indextermsControlled
2732      att 2003           purpose
2733      att 2004           accessConstraints
2734      att 2005           useConstraints
2735     </screen>
2736
2737    </para>
2738
2739   </sect2>
2740
2741   <sect2>
2742    <title>The Tag Set (.tag) Files</title>
2743
2744    <para>
2745     This file type defines the tagset of the profile, possibly by
2746     referencing other tag sets (most tag sets, for instance, will include
2747     tagsetG and tagsetM from the Z39.50 specification. The file may
2748     contain the following directives.
2749    </para>
2750
2751    <para>
2752     <variablelist>
2753
2754      <varlistentry>
2755       <term>name <emphasis>symbolic-name</emphasis></term>
2756       <listitem>
2757        <para>
2758         (m) This provides a shorthand name or
2759         description for the tag set. Mostly useful for diagnostic purposes.
2760        </para>
2761       </listitem></varlistentry>
2762      <varlistentry>
2763       <term>reference <emphasis>OID-name</emphasis></term>
2764       <listitem>
2765        <para>
2766         (o) The reference name of the OID for the tag set.
2767         The reference names can be found in the <emphasis>util</emphasis>
2768         module of <emphasis>YAZ</emphasis>.
2769         The directive is optional, since not all tag sets
2770         are registered outside of their schema.
2771        </para>
2772       </listitem></varlistentry>
2773      <varlistentry>
2774       <term>type <emphasis>integer</emphasis></term>
2775       <listitem>
2776        <para>
2777         (m) The type number of the tagset within the schema
2778         profile (note: this specification really should belong to the .abs
2779         file. This will be fixed in a future release).
2780        </para>
2781       </listitem></varlistentry>
2782      <varlistentry>
2783       <term>include <emphasis>filename</emphasis></term>
2784       <listitem>
2785        <para>
2786         (o,r) This directive is used
2787         to include the definitions of other tag sets into the current one.
2788        </para>
2789       </listitem></varlistentry>
2790      <varlistentry>
2791       <term>tag <emphasis>number names type</emphasis></term>
2792       <listitem>
2793        <para>
2794         (o,r) Introduces a new tag to the set.
2795         The <emphasis>number</emphasis> is the tag number as used
2796         in the protocol (there is currently no mechanism for
2797         specifying string tags at this point, but this would be quick
2798         work to add).
2799         The <emphasis>names</emphasis> parameter is a list of names
2800         by which the tag should be recognized in the input file format.
2801         The names should be separated by slashes (/).
2802         The <emphasis>type</emphasis> is th recommended datatype of
2803         the tag.
2804         It should be one of the following:
2805
2806         <itemizedlist>
2807          <listitem>
2808           <para>
2809            structured
2810           </para>
2811          </listitem>
2812
2813          <listitem>
2814           <para>
2815            string
2816           </para>
2817          </listitem>
2818
2819          <listitem>
2820           <para>
2821            numeric
2822           </para>
2823          </listitem>
2824
2825          <listitem>
2826           <para>
2827            bool
2828           </para>
2829          </listitem>
2830
2831          <listitem>
2832           <para>
2833            oid
2834           </para>
2835          </listitem>
2836
2837          <listitem>
2838           <para>
2839            generalizedtime
2840           </para>
2841          </listitem>
2842
2843          <listitem>
2844           <para>
2845            intunit
2846           </para>
2847          </listitem>
2848
2849          <listitem>
2850           <para>
2851            int
2852           </para>
2853          </listitem>
2854
2855          <listitem>
2856           <para>
2857            octetstring
2858           </para>
2859          </listitem>
2860
2861          <listitem>
2862           <para>
2863            null
2864           </para>
2865          </listitem>
2866
2867         </itemizedlist>
2868
2869        </para>
2870       </listitem></varlistentry>
2871     </variablelist>
2872    </para>
2873
2874    <para>
2875     The following is an excerpt from the TagsetG definition file.
2876    </para>
2877
2878    <para>
2879     <screen>
2880      name tagsetg
2881      reference TagsetG
2882      type 2
2883
2884      tag        1       title           string
2885      tag        2       author          string
2886      tag        3       publicationPlace string
2887      tag        4       publicationDate string
2888      tag        5       documentId      string
2889      tag        6       abstract        string
2890      tag        7       name            string
2891      tag        8       date            generalizedtime
2892      tag        9       bodyOfDisplay   string
2893      tag        10      organization    string
2894     </screen>
2895    </para>
2896
2897   </sect2>
2898
2899   <sect2 id="variant-set">
2900    <title>The Variant Set (.var) Files</title>
2901
2902    <para>
2903     The variant set file is a straightforward representation of the
2904     variant set definitions associated with the protocol. At present, only
2905     the <emphasis>Variant-1</emphasis> set is known.
2906    </para>
2907
2908    <para>
2909     These are the directives allowed in the file.
2910    </para>
2911
2912    <para>
2913     <variablelist>
2914
2915      <varlistentry>
2916       <term>name <emphasis>symbolic-name</emphasis></term>
2917       <listitem>
2918        <para>
2919         (m) This provides a shorthand name or
2920         description for the variant set. Mostly useful for diagnostic purposes.
2921        </para>
2922       </listitem></varlistentry>
2923      <varlistentry>
2924       <term>reference <emphasis>OID-name</emphasis></term>
2925       <listitem>
2926        <para>
2927         (o) The reference name of the OID for
2928         the variant set, if one is required. The reference names can be found
2929         in the <emphasis>util</emphasis> module of <emphasis>YAZ</emphasis>.
2930        </para>
2931       </listitem></varlistentry>
2932      <varlistentry>
2933       <term>class <emphasis>integer class-name</emphasis></term>
2934       <listitem>
2935        <para>
2936         (m,r) Introduces a new
2937         class to the variant set.
2938        </para>
2939       </listitem></varlistentry>
2940      <varlistentry>
2941       <term>type <emphasis>integer type-name datatype</emphasis></term>
2942       <listitem>
2943        <para>
2944         (m,r) Addes a
2945         new type to the current class (the one introduced by the most recent
2946         <emphasis>class</emphasis> directive).
2947         The type names belong to the same name space as the one used
2948         in the tag set definition file.
2949        </para>
2950       </listitem></varlistentry>
2951     </variablelist>
2952    </para>
2953
2954    <para>
2955     The following is an excerpt from the file describing the variant set
2956     <emphasis>Variant-1</emphasis>.
2957    </para>
2958
2959    <para>
2960
2961     <screen>
2962      name variant-1
2963      reference Variant-1
2964
2965      class 1 variantId
2966
2967      type       1       variantId               octetstring
2968
2969      class 2 body
2970
2971      type       1       iana                    string
2972      type       2       z39.50                  string
2973      type       3       other                   string
2974     </screen>
2975
2976    </para>
2977
2978   </sect2>
2979
2980   <sect2>
2981    <title>The Element Set (.est) Files</title>
2982
2983    <para>
2984     The element set specification files describe a selection of a subset
2985     of the elements of a database record. The element selection mechanism
2986     is equivalent to the one supplied by the <emphasis>Espec-1</emphasis>
2987     syntax of the Z39.50 specification.
2988     In fact, the internal representation of an element set
2989     specification is identical to the <emphasis>Espec-1</emphasis> structure,
2990     and we'll refer you to the description of that structure for most of
2991     the detailed semantics of the directives below.
2992    </para>
2993
2994    <note>
2995     <para>
2996      Not all of the Espec-1 functionality has been implemented yet.
2997      The fields that are mentioned below all work as expected, unless
2998      otherwise is noted.
2999     </para>
3000    </note>
3001    
3002    <para>
3003     The directives available in the element set file are as follows:
3004    </para>
3005
3006    <para>
3007     <variablelist>
3008      <varlistentry>
3009       <term>defaultVariantSetId <emphasis>OID-name</emphasis></term>
3010       <listitem>
3011        <para>
3012         (o) If variants are used in
3013         the following, this should provide the name of the variantset used
3014         (it's not currently possible to specify a different set in the
3015         individual variant request). In almost all cases (certainly all
3016         profiles known to us), the name
3017         <literal>Variant-1</literal> should be given here.
3018        </para>
3019       </listitem></varlistentry>
3020      <varlistentry>
3021       <term>defaultVariantRequest <emphasis>variant-request</emphasis></term>
3022       <listitem>
3023        <para>
3024         (o) This directive
3025         provides a default variant request for
3026         use when the individual element requests (see below) do not contain a
3027         variant request. Variant requests consist of a blank-separated list of
3028         variant components. A variant compont is a comma-separated,
3029         parenthesized triple of variant class, type, and value (the two former
3030         values being represented as integers). The value can currently only be
3031         entered as a string (this will change to depend on the definition of
3032         the variant in question). The special value (@) is interpreted as a
3033         null value, however.
3034        </para>
3035       </listitem></varlistentry>
3036      <varlistentry>
3037       <term>simpleElement
3038        <emphasis>path &lsqb;'variant' variant-request&rsqb;</emphasis></term>
3039       <listitem>
3040        <para>
3041         (o,r) This corresponds to a simple element request
3042         in <emphasis>Espec-1</emphasis>.
3043         The path consists of a sequence of tag-selectors, where each of
3044         these can consist of either:
3045        </para>
3046
3047        <para>
3048         <itemizedlist>
3049          <listitem>
3050           <para>
3051            A simple tag, consisting of a comma-separated type-value pair in
3052            parenthesis, possibly followed by a colon (:) followed by an
3053            occurrences-specification (see below). The tag-value can be a number
3054            or a string. If the first character is an apostrophe ('), this
3055            forces the value to be interpreted as a string, even if it
3056            appears to be numerical.
3057           </para>
3058          </listitem>
3059
3060          <listitem>
3061           <para>
3062            A WildThing, represented as a question mark (?), possibly
3063            followed by a colon (:) followed by an occurrences
3064            specification (see below).
3065           </para>
3066          </listitem>
3067
3068          <listitem>
3069           <para>
3070            A WildPath, represented as an asterisk (*). Note that the last
3071            element of the path should not be a wildPath (wildpaths don't
3072            work in this version).
3073           </para>
3074          </listitem>
3075
3076         </itemizedlist>
3077
3078        </para>
3079
3080        <para>
3081         The occurrences-specification can be either the string
3082         <literal>all</literal>, the string <literal>last</literal>, or
3083         an explicit value-range. The value-range is represented as
3084         an integer (the starting point), possibly followed by a
3085         plus (+) and a second integer (the number of elements, default
3086         being one).
3087        </para>
3088
3089        <para>
3090         The variant-request has the same syntax as the defaultVariantRequest
3091         above. Note that it may sometimes be useful to give an empty variant
3092         request, simply to disable the default for a specific set of fields
3093         (we aren't certain if this is proper <emphasis>Espec-1</emphasis>,
3094         but it works in this implementation).
3095        </para>
3096       </listitem></varlistentry>
3097     </variablelist>
3098    </para>
3099
3100    <para>
3101     The following is an example of an element specification belonging to
3102     the GILS profile.
3103    </para>
3104
3105    <para>
3106
3107     <screen>
3108      simpleelement (1,10)
3109      simpleelement (1,12)
3110      simpleelement (2,1)
3111      simpleelement (1,14)
3112      simpleelement (4,1)
3113      simpleelement (4,52)
3114     </screen>
3115
3116    </para>
3117
3118   </sect2>
3119
3120   <sect2 id="schema-mapping">
3121    <title>The Schema Mapping (.map) Files</title>
3122
3123    <para>
3124     Sometimes, the client might want to receive a database record in
3125     a schema that differs from the native schema of the record. For
3126     instance, a client might only know how to process WAIS records, while
3127     the database record is represented in a more specific schema, such as
3128     GILS. In this module, a mapping of data to one of the MARC formats is
3129     also thought of as a schema mapping (mapping the elements of the
3130     record into fields consistent with the given MARC specification, prior
3131     to actually converting the data to the ISO2709). This use of the
3132     object identifier for USMARC as a schema identifier represents an
3133     overloading of the OID which might not be entirely proper. However,
3134     it represents the dual role of schema and record syntax which
3135     is assumed by the MARC family in Z39.50.
3136    </para>
3137
3138    <para>
3139     <emphasis>NOTE: The schema-mapping functions are so far limited to a
3140      straightforward mapping of elements. This should be extended with
3141      mechanisms for conversions of the element contents, and conditional
3142      mappings of elements based on the record contents.</emphasis>
3143    </para>
3144
3145    <para>
3146     These are the directives of the schema mapping file format:
3147    </para>
3148
3149    <para>
3150     <variablelist>
3151
3152      <varlistentry>
3153       <term>targetName <emphasis>name</emphasis></term>
3154       <listitem>
3155        <para>
3156         (m) A symbolic name for the target schema
3157         of the table. Useful mostly for diagnostic purposes.
3158        </para>
3159       </listitem></varlistentry>
3160      <varlistentry>
3161       <term>targetRef <emphasis>OID-name</emphasis></term>
3162       <listitem>
3163        <para>
3164         (m) An OID name for the target schema.
3165         This is used, for instance, by a server receiving a request to present
3166         a record in a different schema from the native one.
3167         The name, again, is found in the <emphasis>oid</emphasis>
3168         module of <emphasis>YAZ</emphasis>.
3169        </para>
3170       </listitem></varlistentry>
3171      <varlistentry>
3172       <term>map <emphasis>element-name target-path</emphasis></term>
3173       <listitem>
3174        <para>
3175         (o,r) Adds
3176         an element mapping rule to the table.
3177        </para>
3178       </listitem></varlistentry>
3179     </variablelist>
3180    </para>
3181
3182   </sect2>
3183
3184   <sect2>
3185    <title>The MARC (ISO2709) Representation (.mar) Files</title>
3186
3187    <para>
3188     This file provides rules for representing a record in the ISO2709
3189     format. The rules pertain mostly to the values of the constant-length
3190     header of the record.
3191    </para>
3192
3193    <para>
3194     <emphasis>NOTE: This will be described better. We're in the process of
3195      re-evaluating and most likely changing the way that MARC records are
3196      handled by the system.</emphasis>
3197    </para>
3198
3199   </sect2>
3200
3201   <sect2 id="field-structure-and-character-sets">
3202    <title>Field Structure and Character Sets
3203    </title>
3204
3205    <para>
3206     In order to provide a flexible approach to national character set
3207     handling, Zebra allows the administrator to configure the set up the
3208     system to handle any 8-bit character set &mdash; including sets that
3209     require multi-octet diacritics or other multi-octet characters. The
3210     definition of a character set includes a specification of the
3211     permissible values, their sort order (this affects the display in the
3212     SCAN function), and relationships between upper- and lowercase
3213     characters. Finally, the definition includes the specification of
3214     space characters for the set.
3215    </para>
3216
3217    <para>
3218     The operator can define different character sets for different fields,
3219     typical examples being standard text fields, numerical fields, and
3220     special-purpose fields such as WWW-style linkages (URx).
3221    </para>
3222
3223    <para>
3224     The field types, and hence character sets, are associated with data
3225     elements by the .abs files (see above).
3226     The file <literal>default.idx</literal>
3227     provides the association between field type codes (as used in the .abs
3228     files) and the character map files (with the .chr suffix). The format
3229     of the .idx file is as follows
3230    </para>
3231
3232    <para>
3233     <variablelist>
3234
3235      <varlistentry>
3236       <term>index <emphasis>field type code</emphasis></term>
3237       <listitem>
3238        <para>
3239         This directive introduces a new search index code.
3240         The argument is a one-character code to be used in the
3241         .abs files to select this particular index type. An index, roughly,
3242         corresponds to a particular structure attribute during search. Refer
3243         to section <xref linkend="search"/>.
3244        </para>
3245       </listitem></varlistentry>
3246      <varlistentry>
3247       <term>sort <emphasis>field code type</emphasis></term>
3248       <listitem>
3249        <para>
3250         This directive introduces a 
3251         sort index. The argument is a one-character code to be used in the
3252         .abs fie to select this particular index type. The corresponding
3253         use attribute must be used in the sort request to refer to this
3254         particular sort index. The corresponding character map (see below)
3255         is used in the sort process.
3256        </para>
3257       </listitem></varlistentry>
3258      <varlistentry>
3259       <term>completeness <emphasis>boolean</emphasis></term>
3260       <listitem>
3261        <para>
3262         This directive enables or disables complete field indexing.
3263         The value of the <emphasis>boolean</emphasis> should be 0
3264         (disable) or 1. If completeness is enabled, the index entry will
3265         contain the complete contents of the field (up to a limit), with words
3266         (non-space characters) separated by single space characters
3267         (normalized to " " on display). When completeness is
3268         disabled, each word is indexed as a separate entry. Complete subfield
3269         indexing is most useful for fields which are typically browsed (eg.
3270         titles, authors, or subjects), or instances where a match on a
3271         complete subfield is essential (eg. exact title searching). For fields
3272         where completeness is disabled, the search engine will interpret a
3273         search containing space characters as a word proximity search.
3274        </para>
3275       </listitem></varlistentry>
3276      <varlistentry>
3277       <term>charmap <emphasis>filename</emphasis></term>
3278       <listitem>
3279        <para>
3280         This is the filename of the character
3281         map to be used for this index for field type.
3282        </para>
3283       </listitem></varlistentry>
3284     </variablelist>
3285    </para>
3286
3287    <para>
3288     The contents of the character map files are structured as follows:
3289    </para>
3290
3291    <para>
3292     <variablelist>
3293
3294      <varlistentry>
3295       <term>lowercase <emphasis>value-set</emphasis></term>
3296       <listitem>
3297        <para>
3298         This directive introduces the basic value set of the field type.
3299         The format is an ordered list (without spaces) of the
3300         characters which may occur in "words" of the given type.
3301         The order of the entries in the list determines the
3302         sort order of the index. In addition to single characters, the
3303         following combinations are legal:
3304        </para>
3305
3306        <para>
3307
3308         <itemizedlist>
3309          <listitem>
3310           <para>
3311            Backslashes may be used to introduce three-digit octal, or
3312            two-digit hex representations of single characters
3313            (preceded by <literal>x</literal>).
3314            In addition, the combinations
3315            \\, \\r, \\n, \\t, \\s (space &mdash; remember that real
3316            space-characters may ot occur in the value definition), and
3317            \\ are recognised, with their usual interpretation.
3318           </para>
3319          </listitem>
3320
3321          <listitem>
3322           <para>
3323            Curly braces &lcub;&rcub; may be used to enclose ranges of single
3324            characters (possibly using the escape convention described in the
3325            preceding point), eg. &lcub;a-z&rcub; to entroduce the
3326            standard range of ASCII characters.
3327            Note that the interpretation of such a range depends on
3328            the concrete representation in your local, physical character set.
3329           </para>
3330          </listitem>
3331
3332          <listitem>
3333           <para>
3334            paranthesises () may be used to enclose multi-byte characters -
3335            eg. diacritics or special national combinations (eg. Spanish
3336            "ll"). When found in the input stream (or a search term),
3337            these characters are viewed and sorted as a single character, with a
3338            sorting value depending on the position of the group in the value
3339            statement.
3340           </para>
3341          </listitem>
3342
3343         </itemizedlist>
3344
3345        </para>
3346       </listitem></varlistentry>
3347      <varlistentry>
3348       <term>uppercase <emphasis>value-set</emphasis></term>
3349       <listitem>
3350        <para>
3351         This directive introduces the
3352         upper-case equivalencis to the value set (if any). The number and
3353         order of the entries in the list should be the same as in the
3354         <literal>lowercase</literal> directive.
3355        </para>
3356       </listitem></varlistentry>
3357      <varlistentry>
3358       <term>space <emphasis>value-set</emphasis></term>
3359       <listitem>
3360        <para>
3361         This directive introduces the character
3362         which separate words in the input stream. Depending on the
3363         completeness mode of the field in question, these characters either
3364         terminate an index entry, or delimit individual "words" in
3365         the input stream. The order of the elements is not significant &mdash;
3366         otherwise the representation is the same as for the
3367         <literal>uppercase</literal> and <literal>lowercase</literal>
3368         directives.
3369        </para>
3370       </listitem></varlistentry>
3371      <varlistentry>
3372       <term>map <emphasis>value-set</emphasis>
3373        <emphasis>target</emphasis></term>
3374       <listitem>
3375        <para>
3376         This directive introduces a
3377         mapping between each of the members of the value-set on the left to
3378         the character on the right. The character on the right must occur in
3379         the value set (the <literal>lowercase</literal> directive) of
3380         the character set, but
3381         it may be a paranthesis-enclosed multi-octet character. This directive
3382         may be used to map diacritics to their base characters, or to map
3383         HTML-style character-representations to their natural form, etc.
3384        </para>
3385       </listitem></varlistentry>
3386     </variablelist>
3387    </para>
3388
3389   </sect2>
3390
3391  </sect1>
3392
3393  <sect1 id="formats">
3394   <title>Exchange Formats</title>
3395
3396   <para>
3397    Converting records from the internal structure to en exchange format
3398    is largely an automatic process. Currently, the following exchange
3399    formats are supported:
3400   </para>
3401
3402   <para>
3403    <itemizedlist>
3404     <listitem>
3405      <para>
3406       GRS-1. The internal representation is based on GRS-1, so the
3407       conversion here is straightforward. The system will create
3408       applied variant and supported variant lists as required, if a record
3409       contains variant information.
3410      </para>
3411     </listitem>
3412
3413     <listitem>
3414      <para>
3415       SUTRS. Again, the mapping is fairly straighforward. Indentation
3416       is used to show the hierarchical structure of the record. All
3417       "GRS" type records support both the GRS-1 and SUTRS
3418       representations.
3419      </para>
3420     </listitem>
3421
3422     <listitem>
3423      <para>
3424       ISO2709-based formats (USMARC, etc.). Only records with a
3425       two-level structure (corresponding to fields and subfields) can be
3426       directly mapped to ISO2709. For records with a different structuring
3427       (eg., GILS), the representation in a structure like USMARC involves a
3428       schema-mapping (see section <xref linkend="schema-mapping"/>), to an
3429        "implied" USMARC schema (implied,
3430        because there is no formal schema which specifies the use of the
3431        USMARC fields outside of ISO2709). The resultant, two-level record is
3432        then mapped directly from the internal representation to ISO2709. See
3433        the GILS schema definition files for a detailed example of this
3434        approach.
3435      </para>
3436     </listitem>
3437
3438     <listitem>
3439      <para>
3440       Explain. This representation is only available for records
3441       belonging to the Explain schema.
3442      </para>
3443     </listitem>
3444
3445     <listitem>
3446      <para>
3447       Summary.  This ASN-1 based structure is only available for records
3448       belonging to the Summary schema - or schema which provide a mapping
3449       to this schema (see the description of the schema mapping facility
3450       above).
3451      </para>
3452     </listitem>
3453
3454     <listitem>
3455      <para>
3456       SOIF. Support for this syntax is experimental, and is currently
3457       keyed to a private Index Data OID (1.2.840.10003.5.1000.81.2). All
3458       abstract syntaxes can be mapped to the SOIF format, although nested
3459       elements are represented by concatenation of the tag names at each
3460       level.
3461      </para>
3462     </listitem>
3463
3464    </itemizedlist>
3465
3466   </para>
3467
3468  </sect1>
3469
3470 </chapter>
3471  <!-- Keep this comment at the end of the file
3472  Local variables:
3473  mode: sgml
3474  sgml-omittag:t
3475  sgml-shorttag:t
3476  sgml-minimize-attributes:nil
3477  sgml-always-quote-attributes:t
3478  sgml-indent-step:1
3479  sgml-indent-data:t
3480  sgml-parent-document: "zebra.xml"
3481  sgml-local-catalogs: nil
3482  sgml-namecase-general:t
3483  End:
3484  -->