Added descriptive text about dynamic settings. Todo, create links from
[pazpar2-moved-to-github.git] / doc / pazpar2_conf.xml
1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
2  "http://www.oasis-open.org/docbook/xml/4.1/docbookx.dtd"
3 [
4      <!ENTITY % local SYSTEM "local.ent">
5      %local;
6      <!ENTITY % entities SYSTEM "entities.ent">
7      %entities;
8      <!ENTITY % common SYSTEM "common/common.ent">
9      %common;
10 ]>
11 <!-- $Id: pazpar2_conf.xml,v 1.23 2007-04-24 04:37:58 quinn Exp $ -->
12 <refentry id="pazpar2_conf">
13  <refentryinfo>
14   <productname>Pazpar2</productname>
15   <productnumber>&version;</productnumber>
16  </refentryinfo>
17  <refmeta>
18   <refentrytitle>Pazpar2 conf</refentrytitle>
19   <manvolnum>5</manvolnum>
20  </refmeta>
21  
22  <refnamediv>
23   <refname>pazpar2_conf</refname>
24   <refpurpose>Pazpar2 Configuration</refpurpose>
25  </refnamediv>
26  
27  <refsynopsisdiv>
28   <cmdsynopsis>
29    <command>pazpar2.conf</command>
30   </cmdsynopsis>
31  </refsynopsisdiv>
32  
33  <refsect1><title>DESCRIPTION</title>
34    <para>
35      The pazpar2 configuration file, together with any referenced XSLT files,
36      govern pazpar2's behavior as a client, and control the normalization and
37      extraction of data elements from incoming result records, for the
38      purposes of merging, sorting, facet analysis, and display.
39     </para>
40
41     <para>
42       The file is specified using the option -f on the pazpar2 command line.
43       There is not presently a way to reload the configuration file without
44       restarting pazpar2, although this will most likely be added some time
45       in the future.
46     </para>
47  </refsect1>
48
49  <refsect1><title>FORMAT</title>
50    <para>
51      The configuration file is XML-structured. It must be valid XML. All
52      elements specific to pazpar2 should belong to the namespace
53      "http://www.indexdata.com/pazpar2/1.0" (this is assumed in the
54      following examples). The root element is named 'pazpar2'. Under the
55      root element are a number of elements which group categories of
56      information. The categories are described below.
57     </para>
58
59     <refsect2 id="config-server"><title>server</title>
60       <para>
61         This section governs overall behavior of the client. The data
62         elements are described below.
63       </para>
64       <variablelist> <!-- level 1 -->
65         <varlistentry>
66           <term>listen</term>
67           <listitem>
68             <para>
69               Configures the webservice -- this controls how you can connect
70               to pazpar2 from your browser or server-side code. The
71               attributes 'host' and 'port' control the binding of the
72               server. The 'host' attribute can be used to bind the server to
73               a secondary IP address of your system, enabling you to run
74               pazpar2 on port 80 alongside a conventional web server. You
75               can override this setting on the command lineusing the option -h.
76             </para>
77           </listitem>
78         </varlistentry>
79
80         <varlistentry>
81           <term>proxy</term>
82           <listitem>
83             <para>
84               If this item is given, pazpar2 will forward all incoming HTTP
85               requests that do not contain the filename 'search.pz2' to the
86               host and port specified using the 'host' and 'port'
87               attributes. The 'myurl' attribute is required, and should provide
88               the base URL of the server. Generally, the HTTP URL for the host
89               specified in the 'listen' parameter. This functionality is
90               crucial if you wish to use
91               pazpar2 in conjunction with browser-based code (JS, Flash,
92               applets, etc.) which operates in a security sandbox. Such code
93               can only connect to the same server from which the enclosing
94               HTML page originated. Pazpar2s proxy functionality enables you
95               to host all of the main pages (plus images, CSS, etc) of your
96               application on a conventional webserver, while efficiently
97               processing webservice requests for metasearch status, results,
98               etc.
99             </para>
100           </listitem>
101         </varlistentry>
102
103         <varlistentry>
104           <term>zproxy</term>
105           <listitem>
106             <para>
107               If this item is given, pazpar2 will send all Z39.50
108               packages through this Z39.50 proxy server.
109               At least one of the 'host' and 'post' attributes is required.
110               The 'host' attribute may contain both host name and port
111               number, seperated by a colon ':', or only the host name.
112               An empty 'host' attribute sets the Z39.50 host address
113               to 'localhost'.  
114             </para>
115           </listitem>
116         </varlistentry>
117
118         <varlistentry>
119           <term>service</term>
120           <listitem>
121             <para>
122               This nested element controls the behavior of pazpar2 with
123               respect to your data model. In pazpar2, incoming records are
124               normalized, using XSLT, into an internal representation.
125               The 'service' section controls the further processing and
126               extraction of data from the internal representation, primarily
127               through the 'metdata' sub-element.
128             </para>
129
130             <variablelist> <!-- Level 2 -->
131               <varlistentry><term>metadata</term>
132                 <listitem>
133                   <para>
134                     One of these elements is required for every data element in
135                     the internal representation of the record (see
136                     <xref linkend="data_model"/>. It governs
137                     subsequent processing as pertains to sorting, relevance
138                     ranking, merging, and display of data elements. It supports
139                     the following attributes:
140                   </para>
141
142                   <variablelist> <!-- level 3 -->
143                     <varlistentry><term>name</term>
144                       <listitem>
145                         <para>
146                           This is the name of the data element. It is matched
147                           against the 'type' attribute of the 'metadata' element
148                           in the normalized record. A warning is produced if
149                           metdata elements with an unknown name are found in the
150                           normalized record. This name is also used to represent
151                           data elements in the records returned by the
152                           webservice API, and to name sort lists and browse
153                           facets.
154                         </para>
155                       </listitem>
156                     </varlistentry>
157
158                     <varlistentry><term>type</term>
159                      <listitem>
160                         <para>
161                           The type of data element. This value governs any
162                           normalization or special processing that might take
163                           place on an element. Possible values are 'generic'
164                           (basic string), 'year' (a range is computed if
165                           multiple years are found in the record). Note: This
166                           list is likely to increase in the future.
167                         </para>
168                       </listitem>
169                     </varlistentry>
170
171                     <varlistentry><term>brief</term>
172                       <listitem>
173                         <para>
174                           If this is set to 'yes', then the data element is
175                           includes in brief records in the webservice API. Note
176                           that this only makes sense for metadata elements that
177                           are merged (see below). The default value is 'no'.
178                         </para>
179                       </listitem>
180                     </varlistentry>
181
182                     <varlistentry><term>sortkey</term>
183                       <listitem>
184                         <para>
185                           Specifies that this data element is to be used for
186                           sorting. The possible values are 'numeric' (numeric
187                           value), 'skiparticle' (string; skip common, leading
188                           articles), and 'no' (no sorting). The default value is
189                           'no'.
190                         </para>
191                       </listitem>
192                     </varlistentry>
193
194                     <varlistentry><term>rank</term>
195                       <listitem>
196                         <para>
197                           Specifies that this element is to be used to help rank
198                           records against the user's query (when ranking is
199                           requested). The value is an integer, used as a
200                           multiplier against the basic TF*IDF score. A value of
201                           1 is the base, higher values give additional weight to
202                           elements of this type. The default is '0', which
203                           excludes this element from the rank calculation.
204                         </para>
205                       </listitem>
206                     </varlistentry>
207
208                     <varlistentry><term>termlist</term>
209                       <listitem>
210                         <para>
211                           Specifies that this element is to be used as a
212                           termlist, or browse facet. Values are tabulated from
213                           incoming records, and a highscore of values (with
214                           their associated frequency) is made available to the
215                           client through the webservice API. The possible values
216                           are 'yes' and 'no' (default).
217                         </para>
218                       </listitem>
219                     </varlistentry>
220
221                     <varlistentry><term>merge</term>
222                       <listitem>
223                         <para>
224                           This governs whether, and how elements are extracted
225                           from individual records and merged into cluster
226                           records. The possible values are: 'unique' (include
227                           all unique elements), 'longest' (include only the
228                           longest element (strlen), 'range' (calculate a range
229                           of values across al matching records), 'all' (include
230                           all elements), or 'no' (don't merge; this is the
231                           default);
232                         </para>
233                       </listitem>
234                     </varlistentry>
235                   </variablelist> <!-- attributes to metadata -->
236
237                 </listitem>
238               </varlistentry>
239             </variablelist>     <!-- Data elements in service directive -->
240           </listitem>
241         </varlistentry>
242       </variablelist>           <!-- Data elements in server directive -->
243     </refsect2>
244
245   </refsect1>
246  
247  <refsect1><title>EXAMPLE</title>
248   <para>Below is a working example configuration:
249   <screen><![CDATA[
250 <?xml version="1.0" encoding="UTF-8"?>
251 <pazpar2 xmlns="http://www.indexdata.com/pazpar2/1.0">
252
253 <server>
254   <listen port="9004"/>
255   <proxy host="us1.indexdata.com" myurl="us1.indexdata.com"/>
256
257   <!-- <zproxy host="localhost" port="9000"/> -->
258   <!-- <zproxy host="localhost:9000"/> -->
259   <!-- <zproxy port="9000"/> -->
260
261   <service>
262     <metadata name="title" brief="yes" sortkey="skiparticle" merge="longest" rank="6"/>
263     <metadata name="isbn" merge="unique"/>
264     <metadata name="date" brief="yes" sortkey="numeric" type="year" merge="range"
265             termlist="yes"/>
266     <metadata name="author" brief="yes" termlist="yes" merge="longest" rank="2"/>
267     <metadata name="subject" merge="unique" termlist="yes" rank="3"/>
268     <metadata name="url" merge="unique"/>
269   </service>
270 </server>
271
272 </pazpar2>
273 ]]></screen>
274    </para>
275  </refsect1> 
276
277  <refsect1 id="target_settings"><title>TARGET SETTINGS</title>
278    <para>
279      Pazpar2 features a cunning scheme by which you can associate various
280      kinds of attributes, or settings with search targets. This can be done
281      through XML files which are read at startup; each file can associate
282      one or more settings with one or more targets. The file format is generic
283      in nature, designed to support a wide range of application requirements. The
284      settings can be purely technical things, like, how to perform a title
285      search against a given target, or it can associate arbitrary name=value
286      pairs with groups of targets -- for instance, if you would like to
287      place all commercial full-text bases in one group for selection
288      purposes, or you would like to control what targets are accessible
289      to users by default.
290    </para>
291
292    <para>
293      During startup, pazpar2 will recursively read a specified directory
294      (can be identified in the pazpar2.cfg file or on the command line), and
295      process any settings files found therein.
296    </para>
297
298    <para>
299      Clients of the pazpar2 webservice interface can selectively override
300      settings for individual targets within the scope of one session. This
301      can be used in conjunction with an external authentication system to
302      determine which resources are to be accessible to which users. Pazpar2
303      itself has no notion of end-users, and so can be used in conjunction
304      with any type of authentication system. Similarly, the authentication
305      tokens submitted to access-controlled search targets can similarly be
306      overriden, to allow use of pazpar2 in a consortial or multi-library
307      environment, where different end-users may need to be represented to
308      some search targets in different ways. This, again, can be managed
309      using an external database or other lookup mechanism. Setting overrides
310      can be performed either using the 'init' or the 'settings' webservice
311      command (see XXX ref to pazpar2 protocol).
312     </para>
313
314     <para>
315       In fact, every setting that applies to a database (except pz:id, which
316       can only be used for filtering targets to use for a search) can be overriden
317       on a per-session basis. This allows the client to override specific CCL fields
318       for searching, etc., to meet the needs of a session or user.
319     </para>
320
321     <para>
322       Finally, as an extreme case of this, the webservice client can
323       introduce entirely new targets, on the fly, as part of the init or
324       settings command. This is useful if you desire to manage information
325       about your search targets in a separate application such as a database.
326       You do not need any static settings file whatsoever to run pazpar2 -- as
327       long as the webservice client is prepared to supply the necessary
328       information at the beginning of every session.
329     </para>
330
331     <para>
332       NOTE: The following discussion of practical issues related to session and settings
333       management are cast in terms of a user interface based on Ajax/Javascript
334       technology. It would apply equally well to many other kinds of browser-based logic.
335     </para>
336
337     <para>
338       Typically, a Javascript client is not allowed to  directly alter the parameters
339       of a session. There are two reasons for this. One has to do with access
340       to information; typically, information about a user will be stored in a
341       system on the server side, or it will be accessible in some way from the server.
342       However, since the Javascript client cannot be entirely trusted (some hostile
343       agent might in fact 'pretend' to be a regular ws client), it is more robust
344       to control session sesttings from scripting that you run as part of your
345       webserver. Typically, this can be handled during the session initialization,
346       as follows:
347     </para>
348
349     <para>
350       Step 1: The Javascript client loads, and asks the webserver for a new pazpar2
351       session ID. This can be done using a Javascript call, for instance. Note that
352       it is possible to submit Ajax HTTPXmlRequest calls either to pazpar2 or to the
353       webserver that pazpar2 is proxying for. See (XXX Insert link to pazpar2 protocol).
354     </para>
355
356     <para>
357       Step 2: Code on the webserver authenticates the user, by database lookup,
358       LDAP access, NCIP, etc. Determines which resources the user has access to,
359       and any user-specific parameters that are to be applied during this session.
360     </para>
361
362     <para>
363       Step 3: The webserver initializes a new pazpar2 settings, and sets user-specific
364       parameters as necessary, using the init webservice command. A new session ID is
365       returned.
366     </para>
367
368     <para>
369       Step 4: The webserver returns this session ID to the Javascript client, which then
370       uses the session ID to submit searches, show results, etc.
371     </para>
372
373     <para>
374       Step 5: When the Javascript client ceases to use the session, pazpar2 destroys
375       any session-specific information.
376     </para>
377
378    <refsect2><title>SETTINGS FILE FORMAT</title>
379      <para>
380        Each file contains a root element named &lt;settings&gt;. It may
381        contain one or more &lt;set&gt; elements. The settings and set
382        elements may contain the following attributes. Attributes in the set node
383        overrides those in the setting root element. Each set node must
384        specify (directly, or inherited from the parent node) at least a
385        target, name, and value.
386      </para>
387
388      <variablelist> 
389        <varlistentry>
390          <term>target</term>
391          <listitem>
392            <para>
393              This specifies the search target to which this setting should be
394              applied. Targets are identified by their Z39.50 URL, generally
395              including the host, port, and database name, (e.g.
396              bagel.indexdata.com:210/marc). Two wildcard forms are accepted:
397              * (asterisk) matches all known targets;
398              bagel.indexdata.com:210/* matches all known databases on the given
399              host.
400            </para>
401            <para>
402              A precedence system determines what happens if there are
403              overlapping values for the same setting name for the same
404              target. A setting for a specific target name overrides a
405              setting whch specifies target using a wildcard. This makes it
406              easy to set defaults for all targets, and then override them
407              for specific targets or hosts. If there are
408              multiple overlapping settings with the same name and target
409              value, the 'precedence' attribute determines what happens.
410             </para>
411          </listitem>
412        </varlistentry>
413         <varlistentry>
414           <term>name</term>
415           <listitem>
416             <para>
417               The name of the setting. This can be anything you like.
418               However, pazpar2 reserves a number of setting names for
419               specific purposes, all starting with 'pz:', and it is a good
420               idea to avoid that prefix if you make up your own setting
421               names. See below for a list of reserved variables.
422             </para>
423           </listitem>
424         </varlistentry>
425         <varlistentry>
426           <term>value</term>
427           <listitem>
428             <para>
429               The value of the setting. Generally, this can be anything you
430               want -- however, some of the reserved settings may expect
431               specific kinds of values.
432             </para>
433           </listitem>
434         </varlistentry>
435         <varlistentry>
436           <term>precedence</term>
437           <listitem>
438             <para>
439               This should be an integer. If not provided, the default value
440               is 0. If two (or more) settings have the same content for
441               target and name, the precedence value determines the outcome.
442               If both settings have the same precedence value, they are both
443               applied to the target(s). If one has a higher value, then the
444               value of that setting is applied, and the other one is ignored.
445             </para>
446           </listitem>
447         </varlistentry>
448       </variablelist>
449
450       <para>
451         By setting defaults for target, name, or value in the root
452         settings node, you can use the settings files in many different
453         ways. For instance, you can use a single file to set defaults for
454         many different settings, like search fields, retrieval syntaxes,
455         etc. You can have one file per server, which groups settings for
456         that server or target. You could also have one file which associates
457         a number of targets with a given setting, for instance, to associate
458         many databases with a given category or class that makes sense
459         within your application.
460       </para>
461
462       <para>
463         The following examples illustrate uses of the settings system to
464         associate settings with targets to meet different requirements.
465       </para>
466
467       <para>
468         The example below associates a set of default values that can be
469         used across many targets. Note the wildcard for targets.
470         This associates the given settings with all targets for which no
471         other information is provided.
472         <screen><![CDATA[
473 <settings target="*">
474
475   <!-- This file introduces default settings for pazpar2 -->
476   <!-- $Id: pazpar2_conf.xml,v 1.23 2007-04-24 04:37:58 quinn Exp $ -->
477
478   <!-- mapping for unqualified search -->
479   <set name="pz:cclmap:term" value="u=1016 t=l,r s=al"/>
480
481   <!-- field-specific mappings -->
482   <set name="pz:cclmap:ti" value="u=4 s=al"/>
483   <set name="pz:cclmap:su" value="u=21 s=al"/>
484   <set name="pz:cclmap:isbn" value="u=7"/>
485   <set name="pz:cclmap:issn" value="u=8"/>
486   <set name="pz:cclmap:date" value="u=30 r=r"/>
487
488   <!-- Retrieval settings -->
489
490   <set name="pz:requestsyntax" value="marc21"/>
491   <!-- <set name="pz:elements" value="F"/> NOT YET IMPLEMENTED -->
492
493   <!-- Result normalization settings -->
494
495   <set name="pz:nativesyntax" value="iso2709"/>
496   <set name="pz:xslt" value="../etc/marc21.xsl"/>
497
498 </settings>
499
500         ]]></screen>
501       </para>
502
503       <para>
504         The next example shows certain settings overriden for one target,
505         one which returns XML records containing DublinCore elements, and
506         which furthermore requires a username/password.
507         <screen><![CDATA[
508 <settings target="funkytarget.com:210/db1">
509   <set name="pz:requestsyntax" value="xml"/>
510   <set name="pz:nativesyntax" value="xml"/>
511   <set name="pz:xslt" value="../etc/dublincore.xsl"/>
512
513   <set name="pz:authentication" value="myuser/password"/>
514 </settings>
515         ]]></screen>
516       </para>
517
518       <para>
519         The following example associates a specific name/value combination
520         with a number of targets. The targets below are access-restricted,
521         and can only be used by users with special credentials.
522         <screen><![CDATA[
523 <settings name="pz:allow" value="0">
524   <set target="funkytarget.com:210/*"/>
525   <set target="commercial.com:2100/expensiveDb"/>
526 </settings>
527         ]]></screen>
528       </para>
529
530     </refsect2>
531
532     <refsect2><title>RESERVED SETTING NAMES</title>
533       <para>
534         The following setting names are reserved by pazpar2 to control the
535         behavior of the client function.
536       </para>
537
538       <variablelist>
539         <varlistentry>
540           <term>pz:cclmap:xxx</term>
541           <listitem>
542             <para>
543               This establishes a CCL field definition or other setting, for
544               the purpose of mapping end-user queries. XXX is the field or
545               setting name, and the value of the setting provides parameters
546               (e.g. parameters to send to the server, etc.). Please consult
547               the YAZ manual for a full overview of the many capabilities of
548               the powerful and flexible CCL parser.
549             </para>
550             <para>
551               Note that it is easy to etablish a set of default parameters,
552               and then override them individually for a given target.
553             </para>
554           </listitem>
555         </varlistentry>
556         <varlistentry>
557           <term>pz:requestsyntax</term>
558           <listitem>
559             <para>
560               This specifies the record syntax to use when requesting
561               records from a given server. The value can be a symbolic name like
562               marc21 or xml, or it can be a Z39.50-style dot-separated OID.
563             </para>
564           </listitem>
565         </varlistentry>
566         <varlistentry>
567           <term>pz:elements</term>
568           <listitem>
569             <para>
570               The element set name to be used when retrieving records from a
571               server (not yet implemented).
572             </para>
573           </listitem>
574         </varlistentry>
575         <varlistentry>
576           <term>pz:piggyback</term>
577           <listitem>
578             <para>
579               Piggybacking enables the server to retrieve records from the
580               server as part of the search response in Z39.50. Almost all
581               servers support this (or fail it gracefully), but a few
582               servers will produce undesirable results.
583               Set to '1' to enable piggybacking, '0' to disable it. Default
584               is 1 (piggybacking enabled).
585             </para>
586           </listitem>
587         </varlistentry>
588         <varlistentry>
589           <term>pz:nativesyntax</term>
590           <listitem>
591             <para>
592               The representation (syntax) of the retrieval records. Currently
593               recognized values are iso2709 and xml.
594             </para>
595             <para>
596               For iso2709, can also specify a native character set, e.g. "iso2709;latin-1".
597               If no character set is provided, MARC-8 is assumed.
598             </para>
599           </listitem>
600         </varlistentry>
601         <varlistentry>
602           <term>pz:xslt</term>
603           <listitem>
604             <para>
605               Provides the path of an XSLT stylesheet which will be used to
606               map incoming records to the internal representation.
607             </para>
608           </listitem>
609         </varlistentry>
610         <varlistentry>
611           <term>pz:authentication</term>
612           <listitem>
613             <para>
614               Sets an authentication string for a given server. See the section on
615               authorization and authentication for discussion.
616             </para>
617           </listitem>
618         </varlistentry>
619         <varlistentry>
620           <term>pz:allow</term>
621           <listitem>
622             <para>
623               Allows or denies access to the resources it is applied to. Possible
624               values are '0' and '1'. The default is '1' (allow access to this resource).
625               See the manual section on authorization and authentication for discussion
626               about how to use this setting.
627             </para>
628           </listitem>
629         </varlistentry>
630         <varlistentry>
631           <term>pz:maxrecs</term>
632           <listitem>
633             <para>
634               Controls the maximum number of records to be retrieved from a
635               server. The default is 100 (not yet implemented).
636             </para>
637           </listitem>
638         </varlistentry>
639         <varlistentry>
640           <term>pz:id</term>
641           <listitem>
642             <para>
643               This setting can't be 'set' -- it contains the ID (normally
644               ZURL) for a given target, and is useful for filtering --
645               specifically when you want to select one or more specific
646               targets in the search command.
647             </para>
648           </listitem>
649         </varlistentry>
650       </variablelist>
651     </refsect2>
652
653  </refsect1>
654 </refentry>
655 <!-- Keep this comment at the end of the file
656 Local variables:
657 mode: sgml
658 sgml-omittag:t
659 sgml-shorttag:t
660 sgml-minimize-attributes:nil
661 sgml-always-quote-attributes:t
662 sgml-indent-step:1
663 sgml-indent-data:t
664 sgml-parent-document:nil
665 sgml-local-catalogs: nil
666 sgml-namecase-general:t
667 End:
668 -->