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