Updated doc.
[idzebra-moved-to-github.git] / doc / zebra.sgml
1 <!doctype linuxdoc system>
2
3 <!--
4   $Id: zebra.sgml,v 1.39 1998-01-30 15:30:57 adam Exp $
5 -->
6
7 <article>
8 <title>Zebra Server - Administrators's Guide and Reference
9 <author><htmlurl url="http://www.indexdata.dk/" name="Index Data">,
10 <tt><htmlurl url="mailto:info@indexdata.dk" name="info@indexdata.dk"></>
11 <date>$Revision: 1.39 $
12 <abstract>
13 The Zebra information server combines a versatile fielded/free-text
14 search engine with a Z39.50-1995 frontend to provide a powerful and flexible
15 information management system. This document explains the procedure for
16 installing and configuring the system, and outlines the possibilities
17 for managing data and providing Z39.50
18 services with the software.
19 </abstract>
20
21 <toc>
22
23 <sect>Introduction
24
25 <sect1>Overview
26
27 <p>
28 The Zebra system is a fielded free-text indexing and retrieval engine with a
29 Z39.50 frontend. You can use any commercial or freeware Z39.50 client
30 to access data stored in Zebra.
31
32 The Zebra server is our first step towards the development of a fully
33 configurable, open information system. Eventually, it will be paired
34 off with a powerful Z39.50 client to support complex information
35 management tasks within almost any application domain. We're making
36 the server available now because it's no fun to be in the open
37 information retrieval business all by yourself. We want to allow
38 people with interesting data to make their things
39 available in interesting ways, without having to start out
40 by implementing yet another protocol stack from scratch.
41
42 This document is an introduction to the Zebra system. It will tell you
43 how to compile the software, and how to prepare your first database.
44 It also explains how the server can be configured to give you the
45 functionality that you need.
46
47 If you find the software interesting, you should join the support
48 mailing-list by sending email to <tt/zebra-request@indexdata.dk/.
49
50 <sect1>Features
51
52 <p>
53 This is a list of some of the most important features of the
54 system.
55
56 <itemize>
57
58 <item>
59 Supports updating - records can be added and deleted without
60 rebuilding the index from scratch.
61 The update procedure is tolerant to crashes or hard interrupts
62 during register updating - registers can be reconstructed following a crash.
63 Registers can be safely updated even while users are accessing the server.
64
65 <item>
66 Supports large databases - files for indices, etc. can be
67 automatically partitioned over multiple disks.
68
69 <item>
70 Supports arbitrarily complex records - base input format is an
71 SGML-like syntax which allows nested (structured) data elements, as
72 well as variant forms of data.
73
74 <item>
75 Supports random storage formats. A system of input filters driven by
76 regular expressions allows you to easily process most ASCII-based
77 data formats. SGML, ISO2709 (MARC), and raw text are also supported.
78
79 <item>
80 Supports boolean queries as well as relevance-ranking (free-text)
81 searching. Right truncation and masking in terms are supported, as
82 well as full regular expressions.
83
84 <item>
85 Supports multiple concrete syntaxes
86 for record exchange (depending on the configuration): GRS-1, SUTRS,
87 ISO2709 (*MARC). Records can be mapped between record syntaxes and
88 schema on the fly.
89
90 <item>
91 Supports approximate matching in registers (ie. spelling mistakes,
92 etc).
93
94 <item>
95 Protocol support:
96
97 <itemize>
98
99 <item>
100 Protocol facilities: Init, Search, Retrieve, Browse.
101
102 <item>
103 Piggy-backed presents are honored in the search-request.
104
105 <item>
106 Named result sets are supported.
107
108 <item>
109 Easily configured to support different application profiles, with
110 tables for attribute sets, tag sets, and abstract syntaxes.
111 Additional tables control facilities such as element mappings to
112 different schema (eg., GILS-to-USMARC).
113
114 <item>
115 Complex composition specifications using Espec-1 are partially
116 supported (simple element requests only).
117
118 <item>
119 Element Set Names are defined using the Espec-1 capability of the
120 system, and are given in configuration files as simple element
121 requests (and possibly variant requests).
122
123 <item>
124 Some variant support (not fully implemented yet).
125
126 <item>
127 Using the YAZ toolkit for the protocol implementation, the
128 server can utilise a plug-in XTI/mOSI implementation (not included) to
129 provide SR services over an OSI stack, as well as Z39.50 over TCP/IP.
130
131 <item>
132 Zebra runs on most Unix-like systems as well as Windows NT - a binary
133 distribution for Windows NT is forthcoming - so far, the installation
134 requires MSVC++ to compile the system (we use version 5.0).
135
136 </itemize>
137
138 </itemize>
139
140 <sect1>Future Work
141
142 <p>
143 This is a beta-release of the software, to allow you to look at
144 it - try it out, and assess whether it can be of use to you.
145
146 These are some of the plans that we have for the software in the near
147 and far future, approximately ordered after their relative importance.
148 Items marked with an
149 asterisk will be implemented before the
150 last beta release.
151
152 <itemize>
153
154 <item>
155 *Complete the support for variants.
156
157 <item>
158 *Finalize the data element <it/include/ facility to support multimedia
159 data elements in records.
160
161 <item>
162 Add more sophisticated relevance ranking mechanisms. Add support for soundex
163 and stemming. Add relevance <it/feedback/ support.
164
165 <item>
166 Complete EXPLAIN support.
167
168 <item>
169 Add support for very large records by implementing segmentation and/or
170 variant pieces.
171
172 <item>
173 Support the Item Update extended service of the protocol.
174
175 <item>
176 We want to add a management system that allows you to
177 control your databases and configuration tables from a graphical
178 interface. We'll probably use Tcl/Tk to stay platform-independent.
179
180 </itemize>
181
182 Programmers thrive on user feedback. If you are interested in a facility that
183 you don't see mentioned here, or if there's something you think we
184 could do better, please drop us a mail. If you think it's all really
185 neat, you're welcome to drop us a line saying that, too. You'll find
186 contact info at the end of this file.
187
188 <sect>Compiling the software
189
190 <p>
191 An ANSI C compiler is required to compile the Zebra
192 server system &mdash; <tt/gcc/ works fine if your own system doesn't
193 provide an adequate compiler.
194
195 Unpack the distribution archive. In some cases, you may want to edit
196 the top-level <tt/Makefile/, eg. to select a different C compiler, or
197 to specify machine-specific libraries in the <bf/ELIBS/ variable.
198
199 When you are done editing the <tt>Makefile</tt> type:
200 <tscreen><verb>
201 $ make
202 </verb></tscreen>
203
204 If successful, two executables have been created in the sub-directory
205 <tt/index/.
206 <descrip>
207 <tag><tt>zebrasrv</tt></tag> The Z39.50 server and search engine.
208 <tag><tt>zebraidx</tt></tag> The administrative tool for the search index.
209 </descrip>
210
211 <sect>Quick Start 
212 <p>
213 In this section, we will test the system by indexing a small set of sample
214 GILS records that are included with the software distribution. Go to the
215 <tt>test/gils</tt> subdirectory of the distribution archive. There you will
216 find a configuration
217 file named <tt>zebra.cfg</tt> with the following contents:
218 <tscreen><verb>
219 # Where are the YAZ tables located.
220 profilePath: ../../../yaz/tab ../../tab
221
222 # Files that describe the attribute sets supported.
223 attset: bib1.att
224 attset: gils.att
225 </verb></tscreen>
226
227 Now, edit the file and set <tt>profilePath</tt> to the path of the
228 YAZ profile tables (sub directory <tt>tab</tt> of the YAZ distribution
229 archive).
230
231 The 48 test records are located in the sub directory <tt>records</tt>.
232 To index these, type:
233 <tscreen><verb>
234 $ ../../index/zebraidx -t grs.sgml update records
235 </verb></tscreen>
236
237 In the command above the option <tt>-t</tt> specified the record
238 type &mdash; in this case <tt>grs.sgml</tt>. The word <tt>update</tt> followed
239 by a directory root updates all files below that directory node.
240
241 If your indexing command was successful, you are now ready to
242 fire up a server. To start a server on port 2100, type:
243 <tscreen><verb>
244 $ ../../index/zebrasrv tcp:@:2100
245 </verb></tscreen>
246
247 The Zebra index that you have just created has a single database
248 named <tt/Default/. The database contains records structured according to
249 the GILS profile, and the server will
250 return records in either either USMARC, GRS-1, or SUTRS depending
251 on what your client asks
252 for.
253
254 To test the server, you can use any Z39.50 client (1992 or later). For
255 instance, you can use the demo client that comes with YAZ: Just cd to
256 the <tt/client/ subdirectory of the YAZ distribution and type:
257
258 <tscreen><verb>
259 $ client tcp:localhost:2100
260 </verb></tscreen>
261
262 When the client has connected, you can type:
263
264 <tscreen><verb>
265 Z> find surficial
266 Z> show 1
267 </verb></tscreen>
268
269 The default retrieval syntax for the client is USMARC. To try other
270 formats for the same record, try:
271
272 <tscreen><verb>
273 Z>format sutrs
274 Z>show 1
275 Z>format grs-1
276 Z>show 1
277 Z>elements B
278 Z>show 1
279 </verb></tscreen>
280
281 <it>NOTE: You may notice that more fields are returned when your
282 client requests SUTRS or GRS-1 records. When retrieving GILS records,
283 this is normal - not all of the GILS data elements have mappings in
284 the USMARC record format.</it>
285
286 If you've made it this far, there's a good chance that
287 you've got through the compilation OK.
288
289 <sect>Administrating Zebra<label id="administrating">
290
291 <p>
292 Unlike many simpler retrieval systems, Zebra supports safe, incremental
293 updates to an existing index.
294
295 Normally, when Zebra modifies the index it reads a number of records
296 that you specify.
297 Depending on your specifications and on the contents of each record
298 one the following events take place for each record:
299 <descrip>
300 <tag>Insert</tag> The record is indexed as if it never occurred
301 before. Either the Zebra system doesn't know how to identify the record or
302 Zebra can identify the record but didn't find it to be already indexed.
303 <tag>Modify</tag> The record has already been indexed. In this case
304 either the contents of the record or the location (file) of the record
305 indicates that it has been indexed before.
306 <tag>Delete</tag> The record is deleted from the index. As in the
307 update-case it must be able to identify the record.
308 </descrip>
309
310 Please note that in both the modify- and delete- case the Zebra
311 indexer must be able to generate a unique key that identifies the record in
312 question (more on this below).
313
314 To administrate the Zebra retrieval system, you run the
315 <tt>zebraidx</tt> program. This program supports a number of options
316 which are preceded by a minus, and a few commands (not preceded by
317 minus).
318
319 Both the Zebra administrative tool and the Z39.50 server share a
320 set of index files and a global configuration file. The
321 name of the configuration file defaults to <tt>zebra.cfg</tt>.
322 The configuration file includes specifications on how to index
323 various kinds of records and where the other configuration files
324 are located. <tt>zebrasrv</tt> and <tt>zebraidx</tt> <em>must</em>
325 be run in the directory where the configuration file lives unless you
326 indicate the location of the configuration file by option
327 <tt>-c</tt>.
328
329 <sect1>Record Types<label id="record-types">
330 <p>
331 Indexing is a per-record process, in which either insert/modify/delete
332 will occur. Before a record is indexed search keys are extracted from
333 whatever might be the layout the original record (sgml,html,text, etc..).
334 The Zebra system currently supports two fundamantal types of records:
335 structured and simple text.
336 To specify a particular extraction process, use either the
337 command line option <tt>-t</tt> or specify a
338 <tt>recordType</tt> setting in the configuration file.
339
340 <sect1>The Zebra Configuration File<label id="configuration-file">
341 <p>
342 The Zebra configuration file, read by <tt>zebraidx</tt> and
343 <tt>zebrasrv</tt> defaults to <tt>zebra.cfg</tt> unless specified
344 by <tt>-c</tt> option.
345
346 You can edit the configuration file with a normal text editor.
347 Parameter names and values are seperated by colons in the file. Lines
348 starting with a hash sign (<tt/&num;/) are treated as comments.
349
350 If you manage different sets of records that share common
351 characteristics, you can organize the configuration settings for each
352 type into &dquot;groups&dquot;.
353 When <tt>zebraidx</tt> is run and you wish to address a given group
354 you specify the group name with the <tt>-g</tt> option. In this case
355 settings that have the group name as their prefix will be used
356 by <tt>zebraidx</tt>. If no <tt/-g/ option is specified, the settings
357 with no prefix are used.
358
359 In the configuration file, the group name is placed before the option
360 name itself, separated by a dot (.). For instance, to set the record type
361 for group <tt/public/ to <tt/grs.sgml/ (the SGML-like format for structured
362 records) you would write:
363
364 <tscreen><verb>
365 public.recordType: grs.sgml
366 </verb></tscreen>
367
368 To set the default value of the record type to <tt/text/ write:
369
370 <tscreen><verb>
371 recordType: text
372 </verb></tscreen>
373
374 The available configuration settings are summarized below. They will be
375 explained further in the following sections.
376
377 <descrip>
378 <tag><it>group</it>.recordType&lsqb;<it>.name</it>&rsqb;</tag>
379  Specifies how records with the file extension <it>name</it> should
380  be handled by the indexer. This option may also be specified
381  as a command line option (<tt>-t</tt>). Note that if you do not
382  specify a <it/name/, the setting applies to all files. In general,
383  the record type specifier consists of the elements (each
384  element separated by dot), <it>fundamental-type</it>,
385  <it>file-read-type</it> and arguments. Currently, two
386  fundamental types exist, <tt>text</tt> and <tt>grs</tt>.
387  <tag><it>group</it>.recordId</tag>
388  Specifies how the records are to be identified when updated. See
389 section <ref id="locating-records" name="Locating Records">.
390 <tag><it>group</it>.database</tag>
391  Specifies the Z39.50 database name.
392 <tag><it>group</it>.storeKeys</tag>
393  Specifies whether key information should be saved for a given
394  group of records. If you plan to update/delete this type of
395  records later this should be specified as 1; otherwise it
396  should be 0 (default), to save register space. See section
397 <ref id="file-ids" name="Indexing With File Record IDs">.
398 <tag><it>group</it>.storeData</tag>
399  Specifies whether the records should be stored internally
400  in the Zebra system files. If you want to maintain the raw records yourself,
401  this option should be false (0). If you want Zebra to take care of the records
402  for you, it should be true(1).
403 <tag>register</tag> 
404  Specifies the location of the various register files that Zebra uses
405  to represent your databases. See section
406 <ref id="register-location" name="Register Location">.
407 <tag>shadow</tag>
408  Enables the <it/safe update/ facility of Zebra, and tells the system
409  where to place the required, temporary files. See section
410 <ref id="shadow-registers" name="Safe Updating - Using Shadow Registers">.
411 <tag>lockDir</tag>
412  Directory in which various lock files are stored.
413 <tag>keyTmpDir</tag>
414  Directory in which temporary files used during zebraidx' update
415  phase are stored. 
416 <tag>setTmpDir</tag>
417  Specifies the directory that the server uses for temporary result sets.
418  If not specified <tt>/tmp</tt> will be used.
419 <tag>profilePath</tag>
420  Specifies the location of profile specification files.
421 <tag>attset</tag> 
422  Specifies the filename(s) of attribute set files for use in
423  searching. At least the Bib-1 set should be loaded (<tt/bib1.att/).
424  The <tt/profilePath/ setting is used to look for the specified files.
425  See section <ref id="attset-files" name="The Attribute Set Files">
426 <tag>memMax</tag>
427  Specifies size of internal memory to use for the zebraidx program. The
428  amount is given in megabytes - default is 4 (4 MB).
429 </descrip>
430 <sect1>Locating Records<label id="locating-records">
431 <p>
432 The default behaviour of the Zebra system is to reference the
433 records from their original location, i.e. where they were found when you
434 ran <tt/zebraidx/. That is, when a client wishes to retrieve a record
435 following a search operation, the files are accessed from the place
436 where you originally put them - if you remove the files (without
437 running <tt/zebraidx/ again, the client will receive a diagnostic
438 message.
439
440 If your input files are not permanent - for example if you retrieve
441 your records from an outside source, or if they were temporarily
442 mounted on a CD-ROM drive,
443 you may want Zebra to make an internal copy of them. To do this,
444 you specify 1 (true) in the <tt>storeData</tt> setting. When
445 the Z39.50 server retrieves the records they will be read from the
446 internal file structures of the system.
447
448 <sect1>Indexing with no Record IDs (Simple Indexing)
449
450 <p>
451 If you have a set of records that are not expected to change over time
452 you may can build your database without record IDs.
453 This indexing method uses less space than the other methods and
454 is simple to use. 
455
456 To use this method, you simply omit the <tt>recordId</tt> entry
457 for the group of files that you index. To add a set of records you use
458 <tt>zebraidx</tt> with the <tt>update</tt> command. The
459 <tt>update</tt> command will always add all of the records that it
460 encounters to the index - whether they have already been indexed or
461 not. If the set of indexed files change, you should delete all of the
462 index files, and build a new index from scratch.
463
464 Consider a system in which you have a group of text files called
465 <tt>simple</tt>. That group of records should belong to a Z39.50 database
466 called <tt>textbase</tt>. The following <tt/zebra.cfg/ file will suffice:
467
468 <tscreen><verb>
469 profilePath: /usr/local/yaz
470 attset: bib1.att
471 simple.recordType: text
472 simple.database: textbase
473 </verb></tscreen>
474
475 Since the existing records in an index can not be addressed by their
476 IDs, it is impossible to delete or modify records when using this method.
477
478 <sect1>Indexing with File Record IDs<label id="file-ids">
479
480 <p>
481 If you have a set of files that regularly change over time: Old files
482 are deleted, new ones are added, or existing files are modified, you
483 can benefit from using the <it/file ID/ indexing methodology. Examples
484 of this type of database might include an index of WWW resources, or a
485 USENET news spool area. Briefly speaking, the file key methodology
486 uses the directory paths of the individual records as a unique
487 identifier for each record. To perform indexing of a directory with
488 file keys, again, you specify the top-level directory after the
489 <tt>update</tt> command. The command will recursively traverse the
490 directories and compare each one with whatever have been indexed before in
491 that same directory. If a file is new (not in the previous version of
492 the directory) it is inserted into the registers; if a file was
493 already indexed and it has been modified since the last update,
494 the index is also modified; if a file has been removed since the last
495 visit, it is deleted from the index.
496
497 The resulting system is easy to administrate. To delete a record you
498 simply have to delete the corresponding file (say, with the <tt/rm/
499 command). And to add records you create new files (or directories with
500 files). For your changes to take effect in the register you must run
501 <tt>zebraidx update</tt> with the same directory root again. This mode
502 of operation requires more disk space than simpler indexing methods,
503 but it makes it easier for you to keep the index in sync with a
504 frequently changing set of data. If you combine this system with the
505 <it/safe update/ facility (see below), you never have to take your
506 server offline for maintenance or register updating purposes.
507
508 To enable indexing with pathname IDs, you must specify <tt>file</tt> as
509 the value of <tt>recordId</tt> in the configuration file. In addition,
510 you should set <tt>storeKeys</tt> to <tt>1</tt>, since the Zebra
511 indexer must save additional information about the contents of each record
512 in order to modify the indices correctly at a later time.
513
514 For example, to update records of group <tt>esdd</tt> located below
515 <tt>/data1/records/</tt> you should type:
516 <tscreen><verb>
517 $ zebraidx -g esdd update /data1/records
518 </verb></tscreen>
519
520 The corresponding configuration file includes:
521 <tscreen><verb>
522 esdd.recordId: file
523 esdd.recordType: grs.sgml
524 esdd.storeKeys: 1
525 </verb></tscreen>
526
527 <em>Important note: You cannot start out with a group of records with simple
528 indexing (no record IDs as in the previous section) and then later
529 enable file record Ids. Zebra must know from the first time that you
530 index the group that
531 the files should be indexed with file record IDs.
532 </em>
533
534 You cannot explicitly delete records when using this method (using the
535 <bf/delete/ command to <tt/zebraidx/. Instead
536 you have to delete the files from the file system (or move them to a
537 different location)
538 and then run <tt>zebraidx</tt> with the <bf/update/ command.
539
540 <sect1>Indexing with General Record IDs
541 <p>
542 When using this method you construct an (almost) arbritrary, internal
543 record key based on the contents of the record itself and other system
544 information. If you have a group of records that explicitly associates
545 an ID with each record, this method is convenient. For example, the
546 record format may contain a title or a ID-number - unique within the group.
547 In either case you specify the Z39.50 attribute set and use-attribute
548 location in which this information is stored, and the system looks at
549 that field to determine the identity of the record.
550
551 As before, the record ID is defined by the <tt>recordId</tt> setting
552 in the configuration file. The value of the record ID specification
553 consists of one or more tokens separated by whitespace. The resulting
554 ID is
555 represented in the index by concatenating the tokens and separating them by
556 ASCII value (1).
557
558 There are three kinds of tokens:
559 <descrip>
560 <tag>Internal record info</tag> The token refers to a key that is
561 extracted from the record. The syntax of this token is
562  <tt/(/ <em/set/ <tt/,/ <em/use/ <tt/)/, where <em/set/ is the
563 attribute set ordinal number and <em/use/ is the use value of the attribute.
564 <tag>System variable</tag> The system variables are preceded by
565 <verb>$</verb> and immediately followed by the system variable name, which
566 may one of
567  <descrip>
568  <tag>group</tag> Group name.
569  <tag>database</tag> Current database specified.
570  <tag>type</tag> Record type.
571  </descrip>
572 <tag>Constant string</tag> A string used as part of the ID &mdash; surrounded
573  by single- or double quotes.
574 </descrip>
575
576 For instance, the sample GILS records that come with the Zebra
577 distribution contain a
578 unique ID
579 in the Control-Identifier field. This field is mapped to the Bib-1
580 use attribute 1007. To use this field as a record id, specify
581 <tt>(1,1007)</tt> as the value of the <tt>recordId</tt> in the
582 configuration file. If you have other record types that uses
583 the same field for a different purpose, you might add the record type (or group or database name)
584 to the record id of the gils records as well, to prevent matches
585 with other types of records. In this case the recordId might be
586 set like this:
587 <tscreen><verb>
588 gils.recordId: $type (1,1007)
589 </verb></tscreen>
590
591 (see section <ref id="data-model" name="Configuring Your Data Model">
592 for details of how the mapping between elements of your records and
593 searchable attributes is established).
594
595 As for the file record ID case described in the previous section,
596 updating your system is simply a matter of running <tt>zebraidx</tt>
597 with the <tt>update</tt> command. However, the update with general
598 keys is considerably slower than with file record IDs, since all files
599 visited must be (re)read to discover their IDs. 
600
601 As you might expect, when using the general record IDs
602 method, you can only add or modify existing records with the <tt>update</tt>
603 command. If you wish to delete records, you must use the,
604 <tt>delete</tt> command, with a directory as a parameter.
605 This will remove all records that match the files below that root
606 directory.
607
608 <sect1>Register Location<label id="register-location">
609
610 <p>
611 Normally, the index files that form dictionaries, inverted
612 files, record info, etc., are stored in the directory where you run
613 <tt>zebraidx</tt>. If you wish to store these, possibly large, files
614 somewhere else, you must add the <tt>register</tt> entry to the
615 <tt/zebra.cfg/ file. Furthermore, the Zebra system allows its file
616 structures to
617 span multiple file systems, which is useful for managing very large
618 databases. 
619
620 The value of the <tt>register</tt> setting is a sequence of tokens.
621 Each token takes the form:
622 <tscreen>
623 <em>dir</em><tt>:</tt><em>size</em>. 
624 </tscreen>
625 The <em>dir</em> specifies a directory in which index files will be
626 stored and the <em>size</em> specifies the maximum size of all
627 files in that directory. The Zebra indexer system fills each directory
628 in the order specified and use the next specified directories as needed.
629 The <em>size</em> is an integer followed by a qualifier
630 code, <tt>M</tt> for megabytes, <tt>k</tt> for kilobytes.
631
632 For instance, if you have allocated two disks for your register, and
633 the first disk is mounted
634 on <tt>/d1</tt> and has 200 Mb of free space and the
635 second, mounted on <tt>/d2</tt> has 300 Mb, you could
636 put this entry in your configuration file:
637 <tscreen><verb>
638 register: /d1:200M /d2:300M
639 </verb></tscreen>
640
641 Note that Zebra does not verify that the amount of space specified is
642 actually available on the directory (file system) specified - it is
643 your responsibility to ensure that enough space is available, and that
644 other applications do not attempt to use the free space. In a large production system,
645 it is recommended that you allocate one or more filesystem exclusively
646 to the Zebra register files.
647
648 <sect1>Safe Updating - Using Shadow Registers<label id="shadow-registers">
649
650 <sect2>Description
651
652 <p>
653 The Zebra server supports <it/updating/ of the index structures. That is,
654 you can add, modify, or remove records from databases managed by Zebra
655 without rebuilding the entire index. Since this process involves
656 modifying structured files with various references between blocks of
657 data in the files, the update process is inherently sensitive to
658 system crashes, or to process interruptions: Anything but a
659 successfully completed update process will leave the register files in
660 an unknown state, and you will essentially have no recourse but to
661 re-index everything, or to restore the register files from a backup
662 medium. Further, while the update process is active, users cannot be
663 allowed to access the system, as the contents of the register files
664 may change unpredictably.
665
666 You can solve these problems by enabling the shadow register system in
667 Zebra. During the updating procedure, <tt/zebraidx/ will temporarily
668 write changes to the involved files in a set of &dquot;shadow
669 files&dquot;, without modifying the files that are accessed by the
670 active server processes. If the update procedure is interrupted by a
671 system crash or a signal, you simply repeat the procedure - the
672 register files have not been changed or damaged, and the partially
673 written shadow files are automatically deleted before the new updating
674 procedure commences.
675
676 At the end of the updating procedure (or in a separate operation, if
677 you so desire), the system enters a &dquot;commit mode&dquot;. First,
678 any active server processes are forced to access those blocks that
679 have been changed from the shadow files rather than from the main
680 register files; the unmodified blocks are still accessed at their
681 normal location (the shadow files are not a complete copy of the
682 register files - they only contain those parts that have actually been
683 modified). If the commit process is interrupted at any point during the
684 commit process, the server processes will continue to access the
685 shadow files until you can repeat the commit procedure and complete
686 the writing of data to the main register files. You can perform
687 multiple update operations to the registers before you commit the
688 changes to the system files, or you can execute the commit operation
689 at the end of each update operation. When the commit phase has
690 completed successfully, any running server processes are instructed to
691 switch their operations to the new, operational register, and the
692 temporary shadow files are deleted.
693
694 <sect2>How to Use Shadow Register Files
695
696 <p>
697 The first step is to allocate space on your system for the shadow
698 files. You do this by adding a <tt/shadow/ entry to the <tt/zebra.cfg/
699 file. The syntax of the <tt/shadow/ entry is exactly the same as for
700 the <tt/register/ entry (see section <ref name="Register Location"
701 id="register-location">). The location of the shadow area should be
702 <it/different/ from the location of the main register area (if you
703 have specified one - remember that if you provide no <tt/register/
704 setting, the default register area is the
705 working directory of the server and indexing processes).
706
707 The following excerpt from a <tt/zebra.cfg/ file shows one example of
708 a setup that configures both the main register location and the shadow
709 file area. Note that two directories or partitions have been set aside
710 for the shadow file area. You can specify any number of directories
711 for each of the file areas, but remember that there should be no
712 overlaps between the directories used for the main registers and the
713 shadow files, respectively.
714
715 <tscreen><verb>
716 register: /d1:500M
717
718 shadow: /scratch1:100M /scratch2:200M
719 </verb></tscreen>
720
721 When shadow files are enabled, an extra command is available at the
722 <tt/zebraidx/ command line. In order to make changes to the system
723 take effect for the users, you'll have to submit a
724 &dquot;commit&dquot; command after a (sequence of) update
725 operation(s). You can ask the indexer to commit the changes
726 immediately after the update operation:
727
728 <tscreen><verb>
729 $ zebraidx update /d1/records update /d2/more-records commit
730 </verb></tscreen>
731
732 Or you can execute multiple updates before committing the changes:
733
734 <tscreen><verb>
735 $ zebraidx -g books update /d1/records update /d2/more-records
736 $ zebraidx -g fun update /d3/fun-records
737 $ zebraidx commit
738 </verb></tscreen>
739
740 If one of the update operations above had been interrupted, the commit
741 operation on the last line would fail: <tt/zebraidx/ will not let you
742 commit changes that would destroy the running register. You'll have to
743 rerun all of the update operations since your last commit operation,
744 before you can commit the new changes.
745
746 Similarly, if the commit operation fails, <tt/zebraidx/ will not let
747 you start a new update operation before you have successfully repeated
748 the commit operation. The server processes will keep accessing the
749 shadow files rather than the (possibly damaged) blocks of the main
750 register files until the commit operation has successfully completed.
751
752 You should be aware that update operations may take slightly longer
753 when the shadow register system is enabled, since more file access
754 operations are involved. Further, while the disk space required for
755 the shadow register data is modest for a small update operation, you
756 may prefer to disable the system if you are adding a very large number
757 of records to an already very large database (we use the terms
758 <it/large/ and <it/modest/ very loosely here, since every
759 application will have a different perception of size). To update the system
760 without the use of the the shadow files, simply run <tt/zebraidx/ with
761 the <tt/-n/ option (note that you do not have to execute the
762 <bf/commit/ command of <tt/zebraidx/ when you temporarily disable the
763 use of the shadow registers in this fashion. Note also that, just as
764 when the shadow registers are not enabled, server processes will be
765 barred from accessing the main register while the update procedure
766 takes place.
767
768 <sect>Running the Maintenance Interface (zebraidx)
769
770 <p>
771 The following is a complete reference to the command line interface to
772 the <tt/zebraidx/ application.
773
774 <bf/Syntax/
775 <tscreen><verb>
776 $ zebraidx &lsqb;options&rsqb; command &lsqb;directory&rsqb; ...
777 </verb></tscreen>
778 <bf/Options/
779 <descrip>
780 <tag>-t <it/type/</tag>Update all files as <it/type/. Currently, the
781 types supported are <tt/text/ and <tt/grs/<it/.subtype/. If no
782 <it/subtype/ is provided for the GRS (General Record Structure) type,
783 the canonical input format is assumed (see section <ref
784 id="local-representation" name="Local Representation">). Generally, it
785 is probably advisable to specify the record types in the
786 <tt/zebra.cfg/ file (see section <ref id="record-types" name="Record
787 Types">), to avoid confusion at subsequent updates.
788
789 <tag>-c <it/config-file/</tag>Read the configuration file
790 <it/config-file/ instead of <tt/zebra.cfg/.
791
792 <tag>-g <it/group/</tag>Update the files according to the group
793 settings for <it/group/ (see section <ref id="configuration-file"
794 name="The Zebra Configuration File">).
795
796 <tag>-d <it/database/</tag>The records located should be associated
797 with the database name <it/database/ for access through the Z39.50
798 server.
799
800 <tag>-m <it/mbytes/</tag>Use <it/mbytes/ of megabytes before flushing
801 keys to background storage. This setting affects performance when
802 updating large databases.
803
804 <tag>-n</tag>Disable the use of shadow registers for this operation
805 (see section <ref id="shadow-registers" name="Robust Updating - Using
806 Shadow Registers">).
807
808 <tag>-s</tag>Show analysis of the indexing process. The maintenance
809 program works in a read-only mode and doesn't change the state
810 of the index. This options is very useful when you wish to test a
811 new profile.
812
813 <tag>-V</tag>Show Zebra version.
814
815 <tag>-v <it/level/</tag>Set the log level to <it/level/. <it/level/
816 should be one of <tt/none/, <tt/debug/, and <tt/all/.
817
818 </descrip>
819
820 <bf/Commands/
821 <descrip>
822 <tag>Update <it/directory/</tag>Update the register with the files
823 contained in <it/directory/. If no directory is provided, a list of
824 files is read from <tt/stdin/. See section <ref
825 id="administrating" name="Administrating Zebra">.
826
827 <tag>Delete <it/directory/</tag>Remove the records corresponding to
828 the files found under <it/directory/ from the register.
829
830 <tag/Commit/Write the changes resulting from the last <bf/update/
831 commands to the register. This command is only available if the use of
832 shadow register files is enabled (see section <ref
833 id="shadow-registers" name="Robust Updating - Using Shadow
834 Registers">).
835
836 </descrip>
837
838 <sect>The Z39.50 Server
839
840 <sect1>Running the Z39.50 Server (zebrasrv)
841
842 <p>
843 <bf/Syntax/
844 <tscreen><verb>
845 zebrasrv &lsqb;options&rsqb; &lsqb;listener-address ...&rsqb;
846 </verb></tscreen>
847
848 <bf/Options/
849 <descrip>
850 <tag>-a <it/APDU file/</tag> Specify a file for dumping PDUs (for diagnostic purposes).
851 The special name &dquot;-&dquot; sends output to <tt/stderr/.
852
853 <tag>-c <it/config-file/</tag> Read configuration information from <it/config-file/. The default configuration is <tt>./zebra.cfg</tt>.
854
855 <tag/-S/Don't fork on connection requests. This can be useful for
856 symbolic-level debugging. The server can only accept a single
857 connection in this mode.
858
859 <tag/-s/Use the SR protocol.
860
861 <tag/-z/Use the Z39.50 protocol (default). These two options complement
862 eachother. You can use both multiple times on the same command
863 line, between listener-specifications (see below). This way, you
864 can set up the server to listen for connections in both protocols
865 concurrently, on different local ports.
866
867 <tag>-l <it/logfile/</tag>Specify an output file for the diagnostic
868 messages. The default is to write this information to <tt/stderr/.
869
870 <tag>-v <it/log-level/</tag>The log level. Use a comma-separated list of members of the set
871 {fatal,debug,warn,log,all,none}.
872
873 <tag>-u <it/username/</tag>Set user ID. Sets the real UID of the server process to that of the
874 given <it/username/. It's useful if you aren't comfortable with having the
875 server run as root, but you need to start it as such to bind a
876 privileged port.
877
878 <tag>-w <it/working-directory/</tag>Change working directory.
879
880 <tag>-i</tag>Run under the Internet superserver, <tt/inetd/. Make
881 sure you use the logfile option <tt/-l/ in conjunction with this
882 mode and specify the <tt/-l/ option before any other options.
883
884 <tag>-t <it/timeout/</tag>Set the idle session timeout (default 60 minutes).
885
886 <tag>-k <it/kilobytes/</tag>Set the (approximate) maximum size of
887 present response messages. Default is 1024 Kb (1 Mb).
888 </descrip>
889
890 A <it/listener-address/ consists of a transport mode followed by a
891 colon (:) followed by a listener address. The transport mode is
892 either <tt/osi/ or <tt/tcp/.
893
894 For TCP, an address has the form
895
896 <tscreen><verb>
897 hostname | IP-number &lsqb;: portnumber&rsqb;
898 </verb></tscreen>
899
900 The port number defaults to 210 (standard Z39.50 port).
901
902 For OSI (only available if the server is compiled with XTI/mOSI
903 support enabled), the address form is
904
905 <tscreen><verb>
906 &lsqb;t-selector /&rsqb; hostname | IP-number &lsqb;: portnumber&rsqb;
907 </verb></tscreen>
908
909 The transport selector is given as a string of hex digits (with an even
910 number of digits). The default port number is 102 (RFC1006 port).
911
912 Examples
913
914 <tscreen>
915 <verb>
916 tcp:dranet.dra.com
917
918 osi:0402/dbserver.osiworld.com:3000
919 </verb>
920 </tscreen>
921
922 In both cases, the special hostname &dquot;@&dquot; is mapped to
923 the address INADDR_ANY, which causes the server to listen on any local
924 interface. To start the server listening on the registered ports for
925 Z39.50 and SR over OSI/RFC1006, and to drop root privileges once the
926 ports are bound, execute the server like this (from a root shell):
927
928 <tscreen><verb>
929 zebrasrv -u daemon tcp:@ -s osi:@
930 </verb></tscreen>
931
932 You can replace <tt/daemon/ with another user, eg. your own account, or
933 a dedicated IR server account.
934
935 The default behavior for <tt/zebrasrv/ is to establish a single TCP/IP
936 listener, for the Z39.50 protocol, on port 9999.
937
938 <sect1>Z39.50 Protocol Support and Behavior
939
940 <sect2>Initialization
941
942 <p>
943 During initialization, the server will negotiate to version 3 of the
944 Z39.50 protocol, and the option bits for Search, Present, Scan,
945 NamedResultSets, and concurrentOperations will be set, if requested by
946 the client. The maximum PDU size is negotiated down to a maximum of
947 1Mb by default.
948
949 <sect2>Search<label id="search">
950
951 <p>
952 The supported query type are 1 and 101. All operators are currently
953 supported with the restriction that only proximity units of type "word" are
954 supported for the proximity operator.
955 Queries can be arbitrarily complex.
956 Named result sets are supported, and result sets can be used as operands
957 without limitations.
958 Searches may span multiple databases.
959
960 The server has full support for piggy-backed present requests (see
961 also the following section).
962
963 <bf/Use/ attributes are interpreted according to the attribute sets which
964 have been loaded in the <tt/zebra.cfg/ file, and are matched against
965 specific fields as specified in the <tt/.abs/ file which describes the
966 profile of the records which have been loaded. If no <bf/Use/
967 attribute is provided, a default of Bib-1 <bf/Any/ is assumed.
968
969 If a <bf/Structure/ attribute of <bf/Phrase/ is used in conjunction with a
970 <bf/Completeness/ attribute of <bf/Complete (Sub)field/, the term is
971 matched against the contents of the phrase (long word) register, if one
972 exists for the given <bf/Use/ attribute.
973 A phrase register is created for those fields in the <tt/.abs/
974 file that contains a <tt/p/-specifier.
975
976 If <bf/Structure/=<bf/Phrase/ is used in conjunction with
977 <bf/Incomplete Field/ - the default value for <bf/Completeness/, the
978 search is directed against the normal word registers, but if the term
979 contains multiple words, the term will only match if all of the words
980 are found immediately adjacent, and in the given order.
981 The word search is performed on those fields that are indexed as
982 type <tt/w/ in the <tt/.abs/ file.
983
984 If the <bf/Structure/ attribute is <bf/Word List/,
985 <bf/Free-form Text/, or <bf/Document Text/, the term is treated as a
986 natural-language, relevance-ranked query.
987 This search type uses the word register, i.e. those fields
988 that are indexed as type <tt/w/ in the <tt/.abs/ file.
989
990 If the <bf/Structure/ attribute is <bf/Numeric String/ the
991 term is treated as an integer. The search is performed on those
992 fields that are indexed as type <tt/n/ in the <tt/.abs/ file.
993
994 If the <bf/Structure/ attribute is <bf/URx/ the
995 term is treated as a URX (URL) entity. The search is performed on those
996 fields that are indexed as type <tt/u/ in the <tt/.abs/ file.
997
998 If the <bf/Structure/ attribute is <bf/Local Number/ the
999 term is treated as native Zebra Record Identifier.
1000
1001 If the <bf/Relation/ attribute is <bf/Equals/ (default), the term is
1002 matched in a normal fashion (modulo truncation and processing of
1003 individual words, if required). If <bf/Relation/ is <bf/Less Than/,
1004 <bf/Less Than or Equal/, <bf/Greater than/, or <bf/Greater than or
1005 Equal/, the term is assumed to be numerical, and a standard regular
1006 expression is constructed to match the given expression. If
1007 <bf/Relation/ is <bf/Relevance/, the standard natural-language query
1008 processor is invoked.
1009
1010 For the <bf/Truncation/ attribute, <bf/No Truncation/ is the default.
1011 <bf/Left Truncation/ is not supported. <bf/Process &num;/ is supported, as
1012 is <bf/Regxp-1/. <bf/Regxp-2/ enables the fault-tolerant (fuzzy)
1013 search. As a default, a single error (deletion, insertion,
1014 replacement) is accepted when terms are matched against the register
1015 contents.
1016
1017 <sect3>Regular expressions
1018 <p>
1019
1020 Each term in a query is interpreted as a regular expression if
1021 the truncation value is either <bf/Regxp-1/ (102) or <bf/Regxp-2/ (103).
1022 Both query types follow the same syntax with the operands:
1023 <descrip>
1024 <tag/x/ Matches the character <it/x/.
1025 <tag/./ Matches any character.
1026 <tag><tt/[/..<tt/]/</tag> Matches the set of characters specified;
1027  such as <tt/[abc]/ or <tt/[a-c]/.
1028 </descrip>
1029 and the operators:
1030 <descrip>
1031 <tag/x*/ Matches <it/x/ zero or more times. Priority: high.
1032 <tag/x+/ Matches <it/x/ one or more times. Priority: high.
1033 <tag/x?/ Matches <it/x/ once or twice. Priority: high.
1034 <tag/xy/ Matches <it/x/, then <it/y/. Priority: medium.
1035 <tag/x|y/ Matches either <it/x/ or <it/y/. Priority: low.
1036 </descrip>
1037 The order of evaluation may be changed by using parentheses.
1038
1039 If the first character of the <bf/Regxp-2/ query is a plus character
1040 (<tt/+/) it marks the beginning of a section with non-standard
1041 specifiers. The next plus character marks the end of the section.
1042 Currently Zebra only supports one specifier, the error tolerance,
1043 which consists one digit. 
1044
1045 Since the plus operator is normally a suffix operator the addition to
1046 the query syntax doesn't violate the syntax for standard regular
1047 expressions.
1048
1049 <sect3>Query examples
1050 <p>
1051
1052 Phrase search for <bf/information retrieval/ in the title-register:
1053 <verb>
1054  @attr 1=4 "information retrieval"
1055 </verb>
1056
1057 Ranked search for the same thing:
1058 <verb>
1059  @attr 1=4 @attr 2=102 "Information retrieval"
1060 </verb>
1061
1062 Phrase search with a regular expression:
1063 <verb>
1064  @attr 1=4 @attr 5=102 "informat.* retrieval"
1065 </verb>
1066
1067 Ranked search with a regular expression:
1068 <verb>
1069  @attr 1=4 @attr 5=102 @attr 2=102 "informat.* retrieval"
1070 </verb>
1071
1072 In the GILS schema (<tt/gils.abs/), the west-bounding-coordinate is
1073 indexed as type <tt/n/, and is therefore searched by specifying
1074 <bf/structure/=<bf/Numeric String/.
1075 To match all those records with west-bounding-coordinate greater
1076 than -114 we use the following query:
1077 <verb>
1078  @attr 4=109 @attr 2=5 @attr gils 1=2038 -114
1079 </verb>
1080
1081 <sect2>Present
1082 <p>
1083 The present facility is supported in a standard fashion. The requested
1084 record syntax is matched against the ones supported by the profile of
1085 each record retrieved. If no record syntax is given, SUTRS is the
1086 default. The requested element set name, again, is matched against any
1087 provided by the relevant record profiles.
1088
1089 <sect2>Scan
1090
1091 <p>
1092 The attribute combinations provided with the TermListAndStartPoint are
1093 processed in the same way as operands in a query (see above).
1094 Currently, only the term and the globalOccurrences are returned with
1095 the TermInfo structure.
1096
1097 <sect2>Close
1098
1099 <p>
1100 If a Close PDU is received, the server will respond with a Close PDU
1101 with reason=FINISHED, no matter which protocol version was negotiated
1102 during initialization. If the protocol version is 3 or more, the
1103 server will generate a Close PDU under certain circumstances,
1104 including a session timeout (60 minutes by default), and certain kinds of
1105 protocol errors. Once a Close PDU has been sent, the protocol
1106 association is considered broken, and the transport connection will be
1107 closed immediately upon receipt of further data, or following a short
1108 timeout.
1109
1110 <sect>The Record Model
1111
1112 <p>
1113 The Zebra system is designed to support a wide range of data management
1114 applications. The system can be configured to handle virtually any
1115 kind of structured data. Each record in the system is associated with
1116 a <it/record schema/ which lends context to the data elements of the
1117 record. Any number of record schema can coexist in the system.
1118 Although it may be wise to use only a single schema within
1119 one database, the system poses no such restrictions.
1120
1121 The record model described in this chapter applies to the fundamental,
1122 structured
1123 record type <tt>grs</tt> as introduced in
1124 section <ref id="record-types" name="Record Types">.
1125
1126 Records pass through three different states during processing in the
1127 system.
1128
1129 <itemize>
1130 <item>When records are accessed by the system, they are represented
1131 in their local, or native format. This might be SGML or HTML files,
1132 News or Mail archives, MARC records. If the system doesn't already
1133 know how to read the type of data you need to store, you can set up an
1134 input filter by preparing conversion rules based on regular
1135 expressions and possibly augmented by a flexible scripting language (Tcl). The input filter
1136 produces as output an internal representation:
1137
1138 <item>When records are processed by the system, they are represented
1139 in a tree-structure, constructed by tagged data elements hanging off a
1140 root node. The tagged elements may contain data or yet more tagged
1141 elements in a recursive structure. The system performs various
1142 actions on this tree structure (indexing, element selection, schema
1143 mapping, etc.),
1144
1145 <item>Before transmitting records to the client, they are first
1146 converted from the internal structure to a form suitable for exchange
1147 over the network - according to the Z39.50 standard.
1148 </itemize>
1149
1150 <sect1>Local Representation<label id="local-representation">
1151
1152 <p>
1153 As mentioned earlier, Zebra places few restrictions on the type of
1154 data that you can index and manage. Generally, whatever the form of
1155 the data, it is parsed by an input filter specific to that format, and
1156 turned into an internal structure that Zebra knows how to handle. This
1157 process takes place whenever the record is accessed - for indexing and
1158 retrieval.
1159
1160 <p>
1161 The RecordType parameter in the <tt/zebra.cfg/ file, or the <tt/-t/
1162 option to the indexer tells Zebra how to process input records. Two
1163 basic types of processing are available - raw text and structured
1164 data. Raw text is just that, and it is selected by providing the
1165 argument <bf/text/ to Zebra. Structured records are all handled
1166 internally using the basic mechanisms described in the subsequent
1167 sections. Zebra can read structured records in many different formats.
1168 How this is done is governed by additional parameters after the
1169 &dquot;grs&dquot; keyboard, separated by &dquot;.&dquot; characters.
1170
1171 Three basic subtypes to the <bf/grs/ type are currently available:
1172
1173 <descrip>
1174 <tag>grs.sgml</tag>This is the canonical input format &mdash;
1175 described below. It is a simple SGML-like syntax.
1176
1177 <tag>grs.regx.<it/filter/</tag>This enables a user-supplied input
1178 filter. The mechanisms of these filters are described below.
1179
1180 <tag>grs.marc.<it/abstract syntax/</tag>This allows Zebra to read
1181 records in the ISO2709 (MARC) encoding standard. In this case, the
1182 last paramemeter <it/abstract syntax/ names the .abs file (see below)
1183 which describes the specific MARC structure of the input record as
1184 well as the indexing rules.
1185 </descrip>
1186
1187 <sect2>Canonical Input Format
1188
1189 <p>
1190 Although input data can take any form, it is sometimes useful to
1191 describe the record processing capabilities of the system in terms of
1192 a single, canonical input format that gives access to the full
1193 spectrum of structure and flexibility in the system. In Zebra, this
1194 canonical format is an &dquot;SGML-like&dquot; syntax.
1195
1196 To use the canonical format specify <tt>grs.sgml</tt> as the record
1197 type,
1198
1199 Consider a record describing an information resource (such a record is
1200 sometimes known as a <it/locator record/). It might contain a field
1201 describing the distributor of the information resource, which might in
1202 turn be partitioned into various fields providing details about the
1203 distributor, like this:
1204
1205 <tscreen><verb>
1206 <Distributor>
1207     <Name> USGS/WRD &etago;Name>
1208     <Organization> USGS/WRD &etago;Organization>
1209     <Street-Address>
1210         U.S. GEOLOGICAL SURVEY, 505 MARQUETTE, NW
1211     &etago;Street-Address>
1212     <City> ALBUQUERQUE &etago;City>
1213     <State> NM &etago;State>
1214     <Zip-Code> 87102 &etago;Zip-Code>
1215     <Country> USA &etago;Country>
1216     <Telephone> (505) 766-5560 &etago;Telephone>
1217 &etago;Distributor>
1218 </verb></tscreen>
1219
1220 <it>NOTE: The indentation used above is used to illustrate how Zebra
1221 interprets the markup. The indentation, in itself, has no
1222 significance to the parser for the canonical input format, which
1223 discards superfluous whitespace.</it>
1224
1225 The keywords surrounded by &lt;...&gt; are <it/tags/, while the
1226 sections of text in between are the <it/data elements/. A data element
1227 is characterized by its location in the tree that is made up by the
1228 nested elements. Each element is terminated by a closing tag -
1229 beginning with <tt/&etago;/, and containing the same symbolic tag-name as
1230 the corresponding opening tag. The general closing tag - <tt/&etago;&gt;/ -
1231 terminates the element started by the last opening tag. The
1232 structuring of elements is significant. The element <bf/Telephone/,
1233 for instance, may be indexed and presented to the client differently,
1234 depending on whether it appears inside the <bf/Distributor/ element,
1235 or some other, structured data element such a <bf/Supplier/ element.
1236
1237 <sect3>Record Root
1238
1239 <p>
1240 The first tag in a record describes the root node of the tree that
1241 makes up the total record. In the canonical input format, the root tag
1242 should contain the name of the schema that lends context to the
1243 elements of the record (see section <ref id="internal-representation"
1244 name="Internal Representation">). The following is a GILS record that
1245 contains only a single element (strictly speaking, that makes it an
1246 illegal GILS record, since the GILS profile includes several mandatory
1247 elements - Zebra does not validate the contents of a record against
1248 the Z39.50 profile, however - it merely attempts to match up elements
1249 of a local representation with the given schema):
1250
1251 <tscreen><verb>
1252 <gils>
1253     <title>Zen and the Art of Motorcycle Maintenance&etago;title>
1254 &etago;gils>
1255 </verb></tscreen>
1256
1257 <sect3>Variants
1258
1259 <p>
1260 Zebra allows you to provide individual data elements in a number of
1261 <it/variant forms/. Examples of variant forms are textual data
1262 elements which might appear in different languages, and images which
1263 may appear in different formats or layouts. The variant system in
1264 Zebra is
1265 essentially a representation of the variant mechanism of
1266 Z39.50-1995.
1267
1268 The following is an example of a title element which occurs in two
1269 different languages.
1270
1271 <tscreen><verb>
1272 <title>
1273   <var lang lang "eng">
1274     Zen and the Art of Motorcycle Maintenance&etago;>
1275   <var lang lang "dan">
1276     Zen og Kunsten at Vedligeholde en Motorcykel&etago;>
1277 &etago;title>
1278 </verb></tscreen>
1279
1280 The syntax of the <it/variant element/ is <tt>&lt;<bf/var/ <it/class
1281 type value/&gt;</tt>. The available values for the <it/class/ and
1282 <it/type/ fields are given by the variant set that is associated with the
1283 current schema (see section <ref id="variant-set" name="Variant Set
1284 File">).
1285
1286 Variant elements are terminated by the general end-tag &etago;>, by
1287 the variant end-tag &etago;var>, by the appearance of another variant
1288 tag with the same <it/class/ and <it/value/ settings, or by the
1289 appearance of another, normal tag. In other words, the end-tags for
1290 the variants used in the example above could have been saved.
1291
1292 Variant elements can be nested. The element
1293
1294 <tscreen><verb>
1295 <title>
1296   <var lang lang "eng"><var body iana "text/plain">
1297     Zen and the Art of Motorcycle Maintenance
1298 &etago;title>
1299 </verb></tscreen>
1300
1301 Associates two variant components to the variant list for the title
1302 element.
1303
1304 Given the nesting rules described above, we could write
1305
1306 <tscreen><verb>
1307 <title>
1308   <var body iana "text/plain>
1309     <var lang lang "eng">
1310       Zen and the Art of Motorcycle Maintenance
1311     <var lang lang "dan">
1312       Zen og Kunsten at Vedligeholde en Motorcykel
1313 &etago;title>
1314 </verb></tscreen>
1315
1316 The title element above comes in two variants. Both have the IANA body
1317 type &dquot;text/plain&dquot;, but one is in English, and the other in
1318 Danish. The client, using the element selection mechanism of Z39.50,
1319 can retrieve information about the available variant forms of data
1320 elements, or it can select specific variants based on the requirements
1321 of the end-user.
1322
1323 <sect2>Input Filters
1324
1325 <p>
1326 In order to handle general input formats, Zebra allows the
1327 operator to define filters which read individual records in their native format
1328 and produce an internal representation that the system can
1329 work with.
1330
1331 Input filters are ASCII files, generally with the suffix <tt/.flt/.
1332 The system looks for the files in the directories given in the
1333 <bf/profilePath/ setting in the <tt/zebra.cfg/ files. The record type
1334 for the filter is <tt>grs.regx.</tt><it>filter-filename</it>
1335 (fundamental type <tt>grs</tt>, file read type <tt>regx</tt>, argument
1336 <it>filter-filename</it>).
1337
1338 Generally, an input filter consists of a sequence of rules, where each
1339 rule consists of a sequence of expressions, followed by an action. The
1340 expressions are evaluated against the contents of the input record,
1341 and the actions normally contribute to the generation of an internal
1342 representation of the record.
1343
1344 An expression can be either of the following:
1345
1346 <descrip>
1347 <tag/INIT/The action associated with this expression is evaluated
1348 exactly once in the lifetime of the application, before any records
1349 are read. It can be used in conjunction with an action that
1350 initializes tables or other resources that are used in the processing
1351 of input records.
1352
1353 <tag/BEGIN/Matches the beginning of the record. It can be used to
1354 initialize variables, etc. Typically, the <bf/BEGIN/ rule is also used
1355 to establish the root node of the record.
1356
1357 <tag/END/Matches the end of the record - when all of the contents
1358 of the record has been processed.
1359
1360 <tag>/pattern/</tag>Matches a string of characters from the input
1361 record.
1362
1363 <tag/BODY/This keyword may only be used between two patterns. It
1364 matches everything between (not including) those patterns.
1365
1366 <tag/FINISH/THe expression asssociated with this pattern is evaluated
1367 once, before the application terminates. It can be used to release
1368 system resources - typically ones allocated in the <bf/INIT/ step.
1369
1370 </descrip>
1371
1372 An action is surrounded by curly braces ({...}), and consists of a
1373 sequence of statements. Statements may be separated by newlines or
1374 semicolons (;). Within actions, the strings that matched the
1375 expressions immediately preceding the action can be referred to as
1376 &dollar;0, &dollar;1, &dollar;2, etc.
1377
1378 The available statements are:
1379
1380 <descrip>
1381
1382 <tag>begin <it/type &lsqb;parameter ... &rsqb;/</tag>Begin a new
1383 data element. The type is one of the following:
1384 <descrip>
1385 <tag/record/Begin a new record. The followingparameter should be the
1386 name of the schema that describes the structure of the record, eg.
1387 <tt/gils/ or <tt/wais/ (see below). The <tt/begin record/ call should
1388 precede
1389 any other use of the <bf/begin/ statement.
1390
1391 <tag/element/Begin a new tagged element. The parameter is the
1392 name of the tag. If the tag is not matched anywhere in the tagsets
1393 referenced by the current schema, it is treated as a local string
1394 tag.
1395
1396 <tag/variant/Begin a new node in a variant tree. The parameters are
1397 <it/class type value/.
1398
1399 </descrip>
1400
1401 <tag/data/Create a data element. The concatenated arguments make
1402 up the value of the data element. The option <tt/-text/ signals that
1403 the layout (whitespace) of the data should be retained for
1404 transmission. The option <tt/-element/ <it/tag/ wraps the data up in
1405 the <it/tag/. The use of the <tt/-element/ option is equivalent to
1406 preceding the command with a <bf/begin element/ command, and following
1407 it with the <bf/end/ command.
1408
1409 <tag>end <it/&lsqb;type&rsqb;/</tag>Close a tagged element. If no parameter is given,
1410 the last element on the stack is terminated. The first parameter, if
1411 any, is a type name, similar to the <bf/begin/ statement. For the
1412 <bf/element/ type, a tag name can be provided to terminate a specific tag.
1413
1414 </descrip>
1415
1416 The following input filter reads a Usenet news file, producing a
1417 record in the WAIS schema. Note that the body of a news posting is
1418 separated from the list of headers by a blank line (or rather a
1419 sequence of two newline characters.
1420
1421 <tscreen><verb>
1422 BEGIN                { begin record wais }
1423
1424 /^From:/ BODY /$/    { data -element name $1 }
1425 /^Subject:/ BODY /$/ { data -element title $1 }
1426 /^Date:/ BODY /$/    { data -element lastModified $1 }
1427 /\n\n/ BODY END      {
1428                         begin element bodyOfDisplay
1429                         begin variant body iana "text/plain"
1430                         data -text $1
1431                         end record
1432                      }
1433 </verb></tscreen>
1434
1435 If Zebra is compiled with support for Tcl (Tool Command Language)
1436 enabled, the statements described above are supplemented with a complete
1437 scripting environment, including control structures (conditional
1438 expressions and loop constructs), and powerful string manipulation
1439 mechanisms for modifying the elements of a record. Tcl is a popular
1440 scripting environment, with several tutorials available both online
1441 and in hardcopy.
1442
1443 <it>NOTE: Tcl support is not currently available, but will be
1444 included with one of the next alpha or beta releases.</it>
1445
1446 <it>NOTE: Variant support is not currently available in the input
1447 filter, but will be included with one of the next alpha or beta
1448 releases.</it>
1449
1450 <sect1>Internal Representation<label id="internal-representation">
1451
1452 <p>
1453 When records are manipulated by the system, they're represented in a
1454 tree-structure, with data elements at the leaf nodes, and tags or
1455 variant components at the non-leaf nodes. The root-node identifies the
1456 schema that lends context to the tagging and structuring of the
1457 record. Imagine a simple record, consisting of a 'title' element and
1458 an 'author' element:
1459
1460 <tscreen><verb>
1461         TITLE     "Zen and the Art of Motorcycle Maintenance"
1462 ROOT 
1463         AUTHOR    "Robert Pirsig"
1464 </verb></tscreen>
1465
1466 A slightly more complex record would have the author element consist
1467 of two elements, a surname and a first name:
1468
1469 <tscreen><verb>
1470         TITLE     "Zen and the Art of Motorcycle Maintenance"
1471 ROOT  
1472                   FIRST-NAME "Robert"
1473         AUTHOR
1474                   SURNAME    "Pirsig"
1475 </verb></tscreen>
1476
1477 The root of the record will refer to the record schema that describes
1478 the structuring of this particular record. The schema defines the
1479 element tags (TITLE, FIRST-NAME, etc.) that may occur in the record, as
1480 well as the structuring (SURNAME should appear below AUTHOR, etc.). In
1481 addition, the schema establishes element set names that are used by
1482 the client to request a subset of the elements of a given record. The
1483 schema may also establish rules for converting the record to a
1484 different schema, by stating, for each element, a mapping to a
1485 different tag path.
1486
1487 <sect2>Tagged Elements
1488
1489 <p>
1490 A data element is characterized by its tag, and its position in the
1491 structure of the record. For instance, while the tag &dquot;telephone
1492 number&dquot; may be used different places in a record, we may need to
1493 distinguish between these occurrences, both for searching and
1494 presentation purposes. For instance, while the phone numbers for the
1495 &dquot;customer&dquot; and the &dquot;service provider&dquot; are both
1496 representatives for the same type of resource (a telephone number), it
1497 is essential that they be kept separate. The record schema provides
1498 the structure of the record, and names each data element (defined by
1499 the sequence of tags - the tag path - by which the element can be
1500 reached from the root of the record).
1501
1502 <sect2>Variants
1503
1504 <p>
1505 The children of a tag node may be either more tag nodes, a data node
1506 (possibly accompanied by tag nodes),
1507 or a tree of variant nodes. The children of  variant nodes are either
1508 more variant nodes or a data node (possibly accompanied by more
1509 variant nodes). Each leaf node, which is normally a
1510 data node, corresponds to a <it/variant form/ of the tagged element
1511 identified by the tag which parents the variant tree. The following
1512 title element occurs in two different languages:
1513
1514 <tscreen><verb>
1515       VARIANT LANG=ENG  "War and Peace"
1516 TITLE
1517       VARIANT LANG=DAN  "Krig og Fred"
1518 </verb></tscreen>
1519
1520 Which of the two elements are transmitted to the client by the server
1521 depends on the specifications provided by the client, if any.
1522
1523 In practice, each variant node is associated with a triple of class,
1524 type, value, corresponding to the variant mechanism of Z39.50.
1525
1526 <sect2>Data Elements
1527
1528 <p>
1529 Data nodes have no children (they are always leaf nodes in the record
1530 tree).
1531
1532 <it>NOTE: Documentation needs extension here about types of nodes - numerical,
1533 textual, etc., plus the various types of inclusion notes.</it>
1534
1535 <sect1>Configuring Your Data Model<label id="data-model">
1536
1537 <p>
1538 The following sections describe the configuration files that govern
1539 the internal management of data records. The system searches for the files
1540 in the directories specified by the <bf/profilePath/ setting in the
1541 <tt/zebra.cfg/ file.
1542
1543 <sect2>The Abstract Syntax
1544
1545 <p>
1546 The abstract syntax definition (also known as an Abstract Record
1547 Structure, or ARS) is the focal point of the
1548 record schema description. For a given schema, the ABS file may state any
1549 or all of the following:
1550
1551 <itemize>
1552 <item>The object identifier of the Z39.50 schema associated
1553 with the ARS, so that it can be referred to by the client.
1554
1555 <item>The attribute set (which can possibly be a compound of multiple
1556 sets) which applies in the profile. This is used when indexing and
1557 searching the records belonging to the given profile.
1558
1559 <item>The Tag set (again, this can consist of several different sets).
1560 This is used when reading the records from a file, to recognize the
1561 different tags, and when transmitting the record to the client -
1562 mapping the tags to their numerical representation, if they are
1563 known.
1564
1565 <item>The variant set which is used in the profile. This provides a
1566 vocabulary for specifying the <it/forms/ of data that appear inside
1567 the records.
1568
1569 <item>Element set names, which are a shorthand way for the client to
1570 ask for a subset of the data elements contained in a record. Element
1571 set names, in the retrieval module, are mapped to <it/element
1572 specifications/, which contain information equivalent to the
1573 <it/Espec-1/ syntax of Z39.50.
1574
1575 <item>Map tables, which may specify mappings to <it/other/ database
1576 profiles, if desired.
1577
1578 <item>Possibly, a set of rules describing the mapping of elements to a
1579 MARC representation.
1580
1581 <item>A list of element descriptions (this is the actual ARS of the
1582 schema, in Z39.50 terms), which lists the ways in which the various
1583 tags can be used and organized hierarchically.
1584 </itemize>
1585
1586 Several of the entries above simply refer to other files, which
1587 describe the given objects.
1588
1589 <sect2>The Configuration Files
1590
1591 <p>
1592 This section describes the syntax and use of the various tables which
1593 are used by the retrieval module.
1594
1595 The number of different file types may appear daunting at first, but
1596 each type corresponds fairly clearly to a single aspect of the Z39.50
1597 retrieval facilities. Further, the average database administrator,
1598 who is simply reusing an existing profile for which tables already
1599 exist, shouldn't have to worry too much about the contents of these tables.
1600
1601 Generally, the files are simple ASCII files, which can be maintained
1602 using any text editor. Blank lines, and lines beginning with a (&num;) are
1603 ignored. Any characters on a line followed by a (&num;) are also ignored.
1604 All other
1605 lines contain <it/directives/, which provide some setting or value
1606 to the system. Generally, settings are characterized by a single
1607 keyword, identifying the setting, followed by a number of parameters.
1608 Some settings are repeatable (r), while others may occur only once in a
1609 file. Some settings are optional (o), whicle others again are
1610 mandatory (m).
1611
1612 <sect2>The Abstract Syntax (.abs) Files
1613
1614 <p>
1615 The name of this file type is slightly misleading in Z39.50 terms,
1616 since, apart from the actual abstract syntax of the profile, it also
1617 includes most of the other definitions that go into a database
1618 profile.
1619
1620 When a record in the canonical, SGML-like format is read from a file
1621 or from the database, the first tag of the file should reference the
1622 profile that governs the layout of the record. If the first tag of the
1623 record is, say, <tt>&lt;gils&gt;</tt>, the system will look for the profile
1624 definition in the file <tt/gils.abs/. Profile definitions are cached,
1625 so they only have to be read once during the lifespan of the current
1626 process. 
1627
1628 When writing your own input filters, the <bf/record-begin/ command
1629 introduces the profile, and should always be called first thing when
1630 introducing a new record.
1631
1632 The file may contain the following directives:
1633
1634 <descrip>
1635 <tag>name <it/symbolic-name/</tag> (m) This provides a shorthand name or
1636 description for the profile. Mostly useful for diagnostic purposes.
1637
1638 <tag>reference <it/OID-name/</tag> (m) The reference name of the OID for
1639 the profile. The reference names can be found in the <bf/util/
1640 module of <bf/YAZ/.
1641
1642 <tag>attset <it/filename/</tag> (m) The attribute set that is used for
1643 indexing and searching records belonging to this profile.
1644
1645 <tag>tagset <it/filename/</tag> (o) The tag set (if any) that describe
1646 that fields of the records.
1647
1648 <tag>varset <it/filename/</tag> (o) The variant set used in the profile.
1649
1650 <tag>maptab <it/filename/</tag> (o,r) This points to a
1651 conversion table that might be used if the client asks for the record
1652 in a different schema from the native one.
1653
1654 <tag>marc <it/filename/</tag> (o) Points to a file containing parameters
1655 for representing the record contents in the ISO2709 syntax. Read the
1656 description of the MARC representation facility below.
1657
1658 <tag>esetname <it/name filename/</tag> (o,r) Associates the
1659 given element set name with an element selection file. If an (@) is
1660 given in place of the filename, this corresponds to a null mapping for
1661 the given element set name.
1662
1663 <tag>any <it/tags/</tag> (o) This directive specifies a list of
1664 attributes which should be appended to the attribute list given for each
1665 element. The effect is to make every single element in the abstract
1666 syntax searchable by way of the given attributes. This directive
1667 provides an efficient way of supporting free-text searching across all
1668 elements. However, it does increase the size of the index
1669 significantly. The attributes can be qualified with a structure, as in
1670 the <bf/elm/ directive below.
1671
1672 <tag>elm <it/path name attributes/</tag> (o,r) Adds an element
1673 to the abstract record syntax of the schema. The <it/path/ follows the
1674 syntax which is suggested by the Z39.50 document - that is, a sequence
1675 of tags separated by slashes (/). Each tag is given as a
1676 comma-separated pair of tag type and -value surrounded by parenthesis.
1677 The <it/name/ is the name of the element, and the <it/attributes/
1678 specifies which attributes to use when indexing the element in a
1679 comma-separated list. A ! in
1680 place of the attribute name is equivalent to specifying an attribute
1681 name identical to the element name. A - in place of the attribute name
1682 specifies that no indexing is to take place for the given element. The
1683 attributes can be qualified with <it/field types/ to specify which
1684 character set should govern the indexing procedure for that field. The
1685 same data element may be indexed into several different fields, using
1686 different character set definitions. See the section
1687 <ref id="field structure and character sets"
1688 name="Field Structure and Character Sets">.
1689 The default field type is &dquot;w&dquot; for
1690 <it/word/.
1691 </descrip>
1692
1693 <it>
1694 NOTE: The mechanism for controlling indexing is not adequate for
1695 complex databases, and will probably be moved into a separate
1696 configuration table eventually.
1697 </it>
1698
1699 The following is an excerpt from the abstract syntax file for the GILS
1700 profile.
1701
1702 <tscreen><verb>
1703 name gils
1704 reference GILS-schema
1705 attset gils.att
1706 tagset gils.tag
1707 varset var1.var
1708
1709 maptab gils-usmarc.map
1710
1711 # Element set names
1712
1713 esetname VARIANT gils-variant.est  # for WAIS-compliance
1714 esetname B gils-b.est
1715 esetname G gils-g.est
1716 esetname F @
1717
1718 elm (1,10)              rank                        -
1719 elm (1,12)              url                         -
1720 elm (1,14)              localControlNumber     Local-number
1721 elm (1,16)              dateOfLastModification Date/time-last-modified
1722 elm (2,1)               Title                       w:!,p:!
1723 elm (4,1)               controlIdentifier      Identifier-standard
1724 elm (2,6)               abstract               Abstract
1725 elm (4,51)              purpose                     !
1726 elm (4,52)              originator                  - 
1727 elm (4,53)              accessConstraints           !
1728 elm (4,54)              useConstraints              !
1729 elm (4,70)              availability                -
1730 elm (4,70)/(4,90)       distributor                 -
1731 elm (4,70)/(4,90)/(2,7) distributorName             !
1732 elm (4,70)/(4,90)/(2,10 distributorOrganization     !
1733 elm (4,70)/(4,90)/(4,2) distributorStreetAddress    !
1734 elm (4,70)/(4,90)/(4,3) distributorCity             !
1735 </verb></tscreen>
1736
1737 <sect2>The Attribute Set (.att) Files<label id="attset-files">
1738
1739 <p>
1740 This file type describes the <bf/Use/ elements of an attribute set.
1741 It contains the following directives. 
1742
1743 <descrip>
1744
1745 <tag>name <it/symbolic-name/</tag> (m) This provides a shorthand name or
1746 description for the attribute set. Mostly useful for diagnostic purposes.
1747
1748 <tag>reference <it/OID-name/</tag> (m) The reference name of the OID for
1749 the attribute set. The reference names can be found in the <bf/util/
1750 module of <bf/YAZ/.
1751
1752 <tag>ordinal <it/integer/</tag> (m) This value will be used to represent the
1753 attribute set in the index. Care should be taken that each attribute
1754 set has a unique ordinal value.
1755
1756 <tag>include <it/filename/</tag> (o,r) This directive is used to
1757 include another attribute set as a part of the current one. This is
1758 used when a new attribute set is defined as an extension to another
1759 set. For instance, many new attribute sets are defined as extensions
1760 to the <bf/bib-1/ set. This is an important feature of the retrieval
1761 system of Z39.50, as it ensures the highest possible level of
1762 interoperability, as those access points of your database which are
1763 derived from the external set (say, bib-1) can be used even by clients
1764 who are unaware of the new set.
1765
1766 <tag>att <it/att-value att-name &lsqb;local-value&rsqb;/</tag> (o,r) This
1767 repeatable directive introduces a new attribute to the set. The
1768 attribute value is stored in the index (unless a <it/local-value/ is
1769 given, in which case this is stored). The name is used to refer to the
1770 attribute from the <it/abstract syntax/. </descrip>
1771
1772 This is an excerpt from the GILS attribute set definition. Notice how
1773 the file describing the <it/bib-1/ attribute set is referenced.
1774
1775 <tscreen><verb>
1776 name gils
1777 reference GILS-attset
1778 include bib1.att
1779 ordinal 2
1780
1781 att 2001                distributorName
1782 att 2002                indexTermsControlled
1783 att 2003                purpose
1784 att 2004                accessConstraints
1785 att 2005                useConstraints
1786 </verb></tscreen>
1787
1788 <sect2>The Tag Set (.tag) Files
1789
1790 <p>
1791 This file type defines the tagset of the profile, possibly by
1792 referencing other tag sets (most tag sets, for instance, will include
1793 tagsetG and tagsetM from the Z39.50 specification. The file may
1794 contain the following directives.
1795
1796 <descrip>
1797 <tag>name <it/symbolic-name/</tag> (m) This provides a shorthand name or
1798 description for the tag set. Mostly useful for diagnostic purposes.
1799
1800 <tag>reference <it/OID-name/</tag> (o) The reference name of the OID for
1801 the tag set. The reference names can be found in the <bf/util/
1802 module of <bf/YAZ/. The directive is optional, since not all tag sets
1803 are registered outside of their schema.
1804
1805 <tag>type <it/integer/</tag> (m) The type number of the tagset within the schema
1806 profile (note: this specification really should belong to the .abs
1807 file. This will be fixed in a future release).
1808
1809 <tag>include <it/filename/</tag> (o,r) This directive is used
1810 to include the definitions of other tag sets into the current one.
1811
1812 <tag>tag <it/number names type/</tag> (o,r) Introduces a new
1813 tag to the set. The <it/number/ is the tag number as used in the protocol
1814 (there is currently no mechanism for specifying string tags at this
1815 point, but this would be quick work to add). The <it/names/ parameter
1816 is a list of names by which the tag should be recognized in the input
1817 file format. The names should be separated by slashes (/). The
1818 <it/type/ is th recommended datatype of the tag. It should be one of
1819 the following:
1820 <itemize>
1821 <item>structured
1822 <item>string
1823 <item>numeric
1824 <item>bool
1825 <item>oid
1826 <item>generalizedtime
1827 <item>intunit
1828 <item>int
1829 <item>octetstring
1830 <item>null
1831 </itemize>
1832 </descrip>
1833
1834 The following is an excerpt from the TagsetG definition file.
1835
1836 <tscreen><verb>
1837 name tagsetg
1838 reference TagsetG
1839 type 2
1840
1841 tag     1       title           string
1842 tag     2       author          string
1843 tag     3       publicationPlace string
1844 tag     4       publicationDate string
1845 tag     5       documentId      string
1846 tag     6       abstract        string
1847 tag     7       name            string
1848 tag     8       date            generalizedtime
1849 tag     9       bodyOfDisplay   string
1850 tag     10      organization    string
1851 </verb></tscreen>
1852
1853 <sect2>The Variant Set (.var) Files<label id="variant-set">
1854
1855 <p>
1856 The variant set file is a straightforward representation of the
1857 variant set definitions associated with the protocol. At present, only
1858 the <it/Variant-1/ set is known.
1859
1860 These are the directives allowed in the file.
1861
1862 <descrip>
1863 <tag>name <it/symbolic-name/</tag> (m) This provides a shorthand name or
1864 description for the variant set. Mostly useful for diagnostic purposes.
1865
1866 <tag>reference <it/OID-name/</tag> (o) The reference name of the OID for
1867 the variant set, if one is required. The reference names can be found
1868 in the <bf/util/ module of <bf/YAZ/.
1869
1870 <tag>class <it/integer class-name/</tag> (m,r) Introduces a new
1871 class to the variant set.
1872
1873 <tag>type <it/integer type-name datatype/</tag> (m,r) Addes a
1874 new type to the current class (the one introduced by the most recent
1875 <bf/class/ directive). The type names belong to the same name space as
1876 the one used in the tag set definition file.
1877 </descrip>
1878
1879 The following is an excerpt from the file describing the variant set
1880 <it/Variant-1/.
1881
1882 <tscreen><verb>
1883 name variant-1
1884 reference Variant-1
1885
1886 class 1 variantId
1887
1888   type  1       variantId               octetstring
1889
1890 class 2 body
1891
1892   type  1       iana                    string
1893   type  2       z39.50                  string
1894   type  3       other                   string
1895 </verb></tscreen>
1896
1897 <sect2>The Element Set (.est) Files
1898
1899 <p>
1900 The element set specification files describe a selection of a subset
1901 of the elements of a database record. The element selection mechanism
1902 is equivalent to the one supplied by the <it/Espec-1/ syntax of the
1903 Z39.50 specification. In fact, the internal representation of an
1904 element set specification is identical to the <it/Espec-1/ structure,
1905 and we'll refer you to the description of that structure for most of
1906 the detailed semantics of the directives below.
1907
1908 <it>
1909 NOTE: Not all of the Espec-1 functionality has been implemented yet.
1910 The fields that are mentioned below all work as expected, unless
1911 otherwise is noted.
1912 </it>
1913
1914 The directives available in the element set file are as follows:
1915
1916 <descrip>
1917 <tag>defaultVariantSetId <it/OID-name/</tag> (o) If variants are used in
1918 the following, this should provide the name of the variantset used
1919 (it's not currently possible to specify a different set in the
1920 individual variant request). In almost all cases (certainly all
1921 profiles known to us), the name <tt/Variant-1/ should be given here.
1922
1923 <tag>defaultVariantRequest <it/variant-request/</tag> (o) This directive
1924 provides a default variant request for
1925 use when the individual element requests (see below) do not contain a
1926 variant request. Variant requests consist of a blank-separated list of
1927 variant components. A variant compont is a comma-separated,
1928 parenthesized triple of variant class, type, and value (the two former
1929 values being represented as integers). The value can currently only be
1930 entered as a string (this will change to depend on the definition of
1931 the variant in question). The special value (@) is interpreted as a
1932 null value, however.
1933
1934 <tag>simpleElement <it/path &lsqb;'variant' variant-request&rsqb;/</tag>
1935 (o,r) This corresponds to a simple element request in <it/Espec-1/. The
1936 path consists of a sequence of tag-selectors, where each of these can
1937 consist of either:
1938
1939 <itemize>
1940 <item>A simple tag, consisting of a comma-separated type-value pair in
1941 parenthesis, possibly followed by a colon (:) followed by an
1942 occurrences-specification (see below). The tag-value can be a number
1943 or a string. If the first character is an apostrophe ('), this forces
1944 the value to be interpreted as a string, even if it appears to be numerical.
1945
1946 <item>A WildThing, represented as a question mark (?), possibly
1947 followed by a colon (:) followed by an occurrences specification (see
1948 below).
1949
1950 <item>A WildPath, represented as an asterisk (*). Note that the last
1951 element of the path should not be a wildPath (wildpaths don't work in
1952 this version).
1953 </itemize>
1954
1955 The occurrences-specification can be either the string <tt/all/, the
1956 string <tt/last/, or an explicit value-range. The value-range is
1957 represented as an integer (the starting point), possibly followed by a
1958 plus (+) and a second integer (the number of elements, default being
1959 one).
1960
1961 The variant-request has the same syntax as the defaultVariantRequest
1962 above. Note that it may sometimes be useful to give an empty variant
1963 request, simply to disable the default for a specific set of fields
1964 (we aren't certain if this is proper <it/Espec-1/, but it works in
1965 this implementation).
1966 </descrip>
1967
1968 The following is an example of an element specification belonging to
1969 the GILS profile.
1970
1971 <tscreen><verb>
1972 simpleelement (1,10)
1973 simpleelement (1,12)
1974 simpleelement (2,1)
1975 simpleelement (1,14)
1976 simpleelement (4,1)
1977 simpleelement (4,52)
1978 </verb></tscreen>
1979
1980 <sect2>The Schema Mapping (.map) Files<label id="schema-mapping">
1981
1982 <p>
1983 Sometimes, the client might want to receive a database record in
1984 a schema that differs from the native schema of the record. For
1985 instance, a client might only know how to process WAIS records, while
1986 the database record is represented in a more specific schema, such as
1987 GILS. In this module, a mapping of data to one of the MARC formats is
1988 also thought of as a schema mapping (mapping the elements of the
1989 record into fields consistent with the given MARC specification, prior
1990 to actually converting the data to the ISO2709). This use of the
1991 object identifier for USMARC as a schema identifier represents an
1992 overloading of the OID which might not be entirely proper. However,
1993 it represents the dual role of schema and record syntax which
1994 is assumed by the MARC family in Z39.50.
1995
1996 <it>
1997 NOTE: The schema-mapping functions are so far limited to a
1998 straightforward mapping of elements. This should be extended with
1999 mechanisms for conversions of the element contents, and conditional
2000 mappings of elements based on the record contents.
2001 </it>
2002
2003 These are the directives of the schema mapping file format:
2004
2005 <descrip>
2006 <tag>targetName <it/name/</tag> (m) A symbolic name for the target schema
2007 of the table. Useful mostly for diagnostic purposes.
2008
2009 <tag>targetRef <it/OID-name/</tag> (m) An OID name for the target schema.
2010 This is used, for instance, by a server receiving a request to present
2011 a record in a different schema from the native one. The name, again,
2012 is found in the <bf/oid/ module of <bf/YAZ/.
2013
2014 <tag>map <it/element-name target-path/</tag> (o,r) Adds
2015 an element mapping rule to the table.
2016 </descrip>
2017
2018 <sect2>The MARC (ISO2709) Representation (.mar) Files
2019
2020 <p>
2021 This file provides rules for representing a record in the ISO2709
2022 format. The rules pertain mostly to the values of the constant-length
2023 header of the record.
2024
2025 <it>NOTE: This will be described better. We're in the process of
2026 re-evaluating and most likely changing the way that MARC records are
2027 handled by the system.</it>
2028
2029 <sect2>Field Structure and Character Sets
2030 <label id="field structure and character sets">
2031
2032 <p>
2033 In order to provide a flexible approach to national character set
2034 handling, Zebra allows the administrator to configure the set up the
2035 system to handle any 8-bit character set &mdash; including sets that
2036 require multi-octet diacritics or other multi-octet characters. The
2037 definition of a character set includes a specification of the
2038 permissible values, their sort order (this affects the display in the
2039 SCAN function), and relationships between upper- and lowercase
2040 characters. Finally, the definition includes the specification of
2041 space characters for the set.
2042
2043 The operator can define different character sets for different fields,
2044 typical examples being standard text fields, numerical fields, and
2045 special-purpose fields such as WWW-style linkages (URx).
2046
2047 The field types, and hence character sets, are associated with data
2048 elements by the .abs files (see above). The file <tt/default.idx/
2049 provides the association between field type codes (as used in the .abs
2050 files) and the character map files (with the .chr suffix). The format
2051 of the .idx file is as follows
2052
2053 <descrip>
2054 <tag>index <it/field type code/</tag>This directive introduces a new
2055 index code. The argument is a one-character code to be used in the
2056 .abs files to select this particular index type. An index, roughly,
2057 corresponds to a particular structure attribute during search. Refer
2058 to section <ref id="search" name="Search">.
2059
2060 <tag>completeness <it/boolean/</tag>This directive enables or disables
2061 complete field indexing. The value of the <it/boolean/ should be 0
2062 (disable) or 1. If completeness is enabled, the index entry will
2063 contain the complete contents of the field (up to a limit), with words
2064 (non-space characters) separated by single space characters
2065 (normalized to &dquot; &dquot; on display). When completeness is
2066 disabled, each word is indexed as a separate entry. Complete subfield
2067 indexing is most useful for fields which are typically browsed (eg.
2068 titles, authors, or subjects), or instances where a match on a
2069 complete subfield is essential (eg. exact title searching). For fields
2070 where completeness is disabled, the search engine will interpret a
2071 search containing space characters as a word proximity search.
2072
2073 <tag>charmap <it/filename/</tag> This is the filename of the character
2074 map to be used for this index for field type.
2075 </descrip>
2076
2077 The contents of the character map files are structured as follows:
2078
2079 <descrip>
2080 <tag>lowercase <it/value-set/</tag>This directive introduces the basic
2081 value set of the field type. The format is an ordered list (without
2082 spaces) of the characters which may occur in &dquot;words&dquot; of
2083 the given type. The order of the entries in the list determines the
2084 sort order of the index. In addition to single characters, the
2085 following combinations are legal:
2086
2087 <itemize>
2088 <item>Backslashes may be used to introduce three-digit octal, or
2089 two-digit hex representations of single characters (preceded by <tt/x/).
2090 In addition, the combinations
2091 \\, \\r, \\n, \\t, \\s (space &mdash; remember that real space-characters
2092 may ot occur in the value definition), and \\ are recognised,
2093 with their usual interpretation.
2094
2095 <item>Curly braces {} may be used to enclose ranges of single
2096 characters (possibly using the escape convention described in the
2097 preceding point), eg. {a-z} to entroduce the standard range of ASCII
2098 characters. Note that the interpretation of such a range depends on
2099 the concrete representation in your local, physical character set.
2100
2101 <item>Paranthesises () may be used to enclose multi-byte characters -
2102 eg. diacritics or special national combinations (eg. Spanish
2103 &dquot;ll&dquot;). When found in the input stream (or a search term),
2104 these characters are viewed and sorted as a single character, with a
2105 sorting value depending on the position of the group in the value
2106 statement.
2107 </itemize>
2108
2109 <tag>uppercase <it/value-set/</tag>This directive introduces the
2110 upper-case equivalencis to the value set (if any). The number and
2111 order of the entries in the list should be the same as in the
2112 <tt/lowercase/ directive.
2113
2114 <tag>space <it/value-set/</tag>This directive introduces the character
2115 which separate words in the input stream. Depending on the
2116 completeness mode of the field in question, these characters either
2117 terminate an index entry, or delimit individual &dquot;words&dquot; in
2118 the input stream. The order of the elements is not significant &mdash;
2119 otherwise the representation is the same as for the <tt/upercase/ and
2120 <tt/lowercase/ directives.
2121
2122 <tag>map <it/value-set/ <it/target/</tag>This directive introduces a
2123 mapping between each of the members of the value-set on the left to
2124 the character on the right. The character on the right must occur in
2125 the value set (the <tt/lowercase/ directive) of the character set, but
2126 it may be a paranthesis-enclosed multi-octet character. This directive
2127 may be used to map diacritics to their base characters, or to map
2128 HTML-style character-representations to their natural form, etc.
2129 </descrip>
2130
2131 <sect1>Exchange Formats
2132
2133 <p>
2134 Converting records from the internal structure to en exchange format
2135 is largely an automatic process. Currently, the following exchange
2136 formats are supported:
2137
2138 <itemize>
2139 <item>GRS-1. The internal representation is based on GRS-1, so the
2140 conversion here is straightforward. The system will create
2141 applied variant and supported variant lists as required, if a record
2142 contains variant information.
2143
2144 <item>SUTRS. Again, the mapping is fairly straighforward. Indentation
2145 is used to show the hierarchical structure of the record. All
2146 &dquot;GRS&dquot; type records support both the GRS-1 and SUTRS
2147 representations.
2148
2149 <item>ISO2709-based formats (USMARC, etc.). Only records with a
2150 two-level structure (corresponding to fields and subfields) can be
2151 directly mapped to ISO2709. For records with a different structuring
2152 (eg., GILS), the representation in a structure like USMARC involves a
2153 schema-mapping (see section <ref id="schema-mapping" name="Schema
2154 Mapping">), to an &dquot;implied&dquot; USMARC schema (implied,
2155 because there is no formal schema which specifies the use of the
2156 USMARC fields outside of ISO2709). The resultant, two-level record is
2157 then mapped directly from the internal representation to ISO2709. See
2158 the GILS schema definition files for a detailed example of this
2159 approach.
2160
2161 <item>Explain. This representation is only available for records
2162 belonging to the Explain schema.
2163
2164 <item>Summary.  This ASN-1 based structure is only available for records
2165 belonging to the Summary schema - or schema which provide a mapping
2166 to this schema (see the description of the schema mapping facility
2167 above).
2168
2169 <item>SOIF. Support for this syntax is experimental, and is currently
2170 keyed to a private Index Data OID (1.2.840.10003.5.1000.81.2). All
2171 abstract syntaxes can be mapped to the SOIF format, although nested
2172 elements are represented by concatenation of the tag names at each
2173 level.
2174
2175 </itemize>
2176
2177 <sect>License
2178
2179 <p>
2180 Copyright &copy; 1995-1998 Index Data.
2181
2182 All rights reserved.
2183
2184 Use and redistribution in source or binary form, with or without
2185 modification, of any or all of this software and documentation is
2186 permitted, provided that the following conditions are met:
2187
2188 1. This copyright and permission notice appear with all copies of the
2189 software and its documentation. Notices of copyright or attribution
2190 which appear at the beginning of any file must remain unchanged.
2191
2192 2. The names of Index Data or the individual authors may not be used to
2193 endorse or promote products derived from this software without specific
2194 prior written permission.
2195
2196 3. Source code or binary versions of this software and its
2197 documentation may be used freely in not-for-profit applications. For
2198 profit applications - such as providing for-pay database services,
2199 marketing a product based in whole or in part on this software or its
2200 documentation, or generally distributing this software or its
2201 documentation under a different license - requires a commercial
2202 license from Index Data. The software may be installed and used for
2203 evaluation purposes in conjunction with a commercial application for a
2204 trial period of no more than 60 days.
2205
2206 THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
2207 EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
2208 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
2209 IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
2210 INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
2211 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
2212 NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
2213 LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
2214 OF THIS SOFTWARE.
2215
2216 <sect>About Index Data and the Zebra Server
2217
2218 <p>
2219 Index Data is a consulting and software-development enterprise that
2220 specialises in library and information management systems. Our
2221 interests and expertise span a broad range of related fields, and one
2222 of our primary, long-term objectives is the development of a powerful
2223 information management
2224 system with open network interfaces and hypermedia capabilities.
2225
2226 We make this software available free of charge for not-for-profit
2227 purposes, as a service to the networking community, and to further
2228 the development and use of quality software for open network
2229 communication.
2230
2231 If you like this software, and would like to use all or part of it in
2232 a commercial product, or to provide a commercial database service,
2233 please contact us to discuss the details. We'll be happy to answer
2234 questions about the software, and about our services in general. If
2235 you have specific requirements to the software, we'll be glad to offer
2236 our advice - and if you need to adapt the software to a special
2237 purpose, our consulting services and expert knowledge of the software
2238 is available to you at favorable rates.
2239
2240 <tscreen><verb>
2241 Index Data
2242 Ryesgade 3
2243 DK-2200 Copenhagen N
2244 </verb></tscreen>
2245
2246 <p>
2247 <tscreen><verb>
2248 Phone: +45 3536 3672
2249 Fax  : +45 3536 0449
2250 Email: info@indexdata.dk
2251 </verb></tscreen>
2252
2253 The <it>Random House College Dictionary</it>, 1975 edition
2254 offers this definition of the 
2255 word &dquot;Zebra&dquot;:
2256
2257 <it>
2258 Zebra, n., any of several horselike, African mammals of the genus Equus,
2259 having a characteristic pattern of black or dark-brown stripes on
2260 a whitish background.
2261 </it>
2262
2263 </article>