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