Document rank may be dynamically defined in XSLT
[pazpar2-moved-to-github.git] / doc / pazpar2_conf.xml
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.4//EN"
3  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"
4 [
5      <!ENTITY % local SYSTEM "local.ent">
6      %local;
7      <!ENTITY % entities SYSTEM "entities.ent">
8      %entities;
9      <!ENTITY % idcommon SYSTEM "common/common.ent">
10      %idcommon;
11 ]>
12 <refentry id="pazpar2_conf">
13  <refentryinfo>
14   <productname>Pazpar2</productname>
15   <productnumber>&version;</productnumber>
16   <info><orgname>Index Data</orgname></info>
17  </refentryinfo>
18  
19  <refmeta>
20   <refentrytitle>Pazpar2 conf</refentrytitle>
21   <manvolnum>5</manvolnum>
22   <refmiscinfo class="manual">File formats and conventions</refmiscinfo>
23  </refmeta>
24  
25  <refnamediv>
26   <refname>pazpar2_conf</refname>
27   <refpurpose>Pazpar2 Configuration</refpurpose>
28  </refnamediv>
29  
30  <refsynopsisdiv>
31   <cmdsynopsis>
32    <command>pazpar2.conf</command>
33   </cmdsynopsis>
34  </refsynopsisdiv>
35  
36  <refsect1>
37   <title>DESCRIPTION</title>
38   <para>
39    The Pazpar2 configuration file, together with any referenced XSLT files,
40    govern Pazpar2's behavior as a client, and control the normalization and
41    extraction of data elements from incoming result records, for the
42    purposes of merging, sorting, facet analysis, and display.
43   </para>
44   
45   <para>
46    The file is specified using the option -f on the Pazpar2 command line.
47    There is not presently a way to reload the configuration file without
48    restarting Pazpar2, although this will most likely be added some time
49    in the future.
50   </para>
51  </refsect1>
52  
53  <refsect1>
54   <title>FORMAT</title>
55   <para>
56    The configuration file is XML-structured. It must be well-formed XML. All
57    elements specific to Pazpar2 should belong to the namespace
58    <literal>http://www.indexdata.com/pazpar2/1.0</literal> 
59    (this is assumed in the
60    following examples). The root element is named "<literal>pazpar2</literal>".
61    Under the  root element are a number of elements which group categories of
62    information. The categories are described below.
63   </para>
64   
65   <refsect2 id="config-threads">
66    <title>threads</title>
67    <para>
68     This section is optional and is supported for Pazpar2 version 1.3.1 and
69     later . It is identified by element "<literal>threads</literal>" which
70     may include one attribute "<literal>number</literal>" which specifies
71     the number of worker-threads that the Pazpar2 instance is to use.
72     A value of 0 (zero) disables worker-threads (all work is carried out
73     in main thread).
74    </para>
75   </refsect2>
76   <refsect2 id="config-server">
77    <title>server</title>
78    <para>
79     This section governs overall behavior of a server endpoint. It is identified
80     by the element "server" which takes an optional attribute, "id", which
81     identifies this particular Pazpar2 server. Any string value for "id"
82     may be given.
83    </para>
84    <para>
85     The data
86     elements are described below. From Pazpar2 version 1.2 this is
87     a repeatable element.
88    </para>
89    <variablelist> <!-- level 1 -->
90     <varlistentry>
91      <term>listen</term>
92      <listitem>
93       <para>
94        Configures the webservice -- this controls how you can connect
95        to Pazpar2 from your browser or server-side code. The
96        attributes 'host' and 'port' control the binding of the
97        server. The 'host' attribute can be used to bind the server to
98        a secondary IP address of your system, enabling you to run
99        Pazpar2 on port 80 alongside a conventional web server. You
100        can override this setting on the command line using the option -h.
101       </para>
102      </listitem>
103     </varlistentry>
104     
105     <varlistentry>
106      <term>proxy</term>
107      <listitem>
108       <para>
109        If this item is given, Pazpar2 will forward all incoming HTTP
110        requests that do not contain the filename 'search.pz2' to the
111        host and port specified using the 'host' and 'port'
112        attributes. The 'myurl' attribute is required, and should provide
113        the base URL of the server. Generally, the HTTP URL for the host
114        specified in the 'listen' parameter. This functionality is
115        crucial if you wish to use
116        Pazpar2 in conjunction with browser-based code (JS, Flash,
117        applets, etc.) which operates in a security sandbox. Such code
118        can only connect to the same server from which the enclosing
119        HTML page originated. Pazpar2s proxy functionality enables you
120        to host all of the main pages (plus images, CSS, etc) of your
121        application on a conventional webserver, while efficiently
122        processing webservice requests for metasearch status, results,
123        etc.
124       </para>
125      </listitem>
126     </varlistentry>
127
128     <varlistentry>
129      <term>icu_chain</term>
130      <listitem>
131       <para>
132        Specifies character set normalization for relevancy / sorting /
133        mergekey and facets - for the server. These definitions serves as
134        default for services that don't have these given. For the meaning
135        of these settings refer to the
136        <xref linkend="icuchain"/> element inside service.
137       </para>
138      </listitem>
139     </varlistentry>
140     
141     <varlistentry>
142      <term>relevance / sort / mergekey / facet</term>
143      <listitem>
144       <para>
145        Obsolete. Use element icu_chain instead.
146       </para>
147      </listitem>
148     </varlistentry>
149     
150     <varlistentry>
151      <term>settings</term>
152      <listitem>
153       <para>
154        Specifies target settings for the server.. These settings serves
155        as default for all services which don't have these given.
156        The settings element requires one attribute 'src' which specifies
157        a settings file or a directory . If a directory is given all
158        files with suffix <filename>.xml</filename> is read from this
159        directory. Refer to 
160        <xref linkend="target_settings"/> for more information.
161       </para>
162      </listitem>
163     </varlistentry>
164     
165     <varlistentry>
166      <term>service</term>
167      <listitem>
168       <para>
169        This nested element controls the behavior of Pazpar2 with
170        respect to your data model. In Pazpar2, incoming records are
171        normalized, using XSLT, into an internal representation.
172        The 'service' section controls the further processing and
173        extraction of data from the internal representation, primarily
174        through the 'metadata' sub-element.
175       </para>
176       <para>
177        Pazpar2 version 1.2 and later allows multiple service elements.
178        Multiple services must be given a unique ID by specifying
179        attribute <literal>id</literal>.
180        A single service may be unnamed (service ID omitted). The
181        service ID is referred to in the
182        <link linkend="command-init"><literal>init</literal></link> webservice
183        command's <literal>service</literal> parameter.
184       </para>
185
186       <variablelist> <!-- Level 2 -->
187        <varlistentry>
188         <term>metadata</term>
189         <listitem>
190          <para>
191           One of these elements is required for every data element in
192           the internal representation of the record (see
193           <xref linkend="data_model"/>. It governs
194           subsequent processing as pertains to sorting, relevance
195           ranking, merging, and display of data elements. It supports
196           the following attributes:
197          </para>
198          
199          <variablelist> <!-- level 3 -->
200           <varlistentry>
201            <term>name</term>
202            <listitem>
203             <para>
204              This is the name of the data element. It is matched
205              against the 'type' attribute of the
206              'metadata' element 
207              in the normalized record. A warning is produced if
208              metadata elements with an unknown name are
209              found in the 
210              normalized record. This name is also used to
211              represent 
212              data elements in the records returned by the
213              webservice API, and to name sort lists and browse
214              facets.
215             </para>
216            </listitem>
217           </varlistentry>
218           
219           <varlistentry>
220            <term>type</term>
221            <listitem>
222             <para>
223              The type of data element. This value governs any
224              normalization or special processing that might take
225              place on an element. Possible values are 'generic'
226              (basic string), 'year' (a range is computed if
227              multiple years are found in the record). Note: This
228              list is likely to increase in the future.
229             </para>
230            </listitem>
231           </varlistentry>
232           
233           <varlistentry>
234            <term>brief</term>
235            <listitem>
236             <para>
237              If this is set to 'yes', then the data element is
238              includes in brief records in the webservice API. Note
239              that this only makes sense for metadata elements that
240              are merged (see below). The default value is 'no'.
241             </para>
242            </listitem>
243           </varlistentry>
244           
245           <varlistentry>
246            <term>sortkey</term>
247            <listitem>
248             <para>
249              Specifies that this data element is to be used for
250              sorting. The possible values are 'numeric' (numeric
251              value), 'skiparticle' (string; skip common, leading
252              articles), and 'no' (no sorting). The default value is
253              'no'.
254             </para>
255            </listitem>
256           </varlistentry>
257           
258           <varlistentry>
259            <term>rank</term>
260            <listitem>
261             <para>
262              Specifies that this element is to be used to
263              help rank 
264              records against the user's query (when ranking is
265              requested). The value is an integer, used as a
266              multiplier against the basic TF*IDF score. A value of
267              1 is the base, higher values give additional
268              weight to 
269              elements of this type. The default is '0', which
270              excludes this element from the rank calculation.
271             </para>
272             <para>
273              For Pazpar2 1.6.13 and later, the rank may also defined
274              "per-document", by the normalization stylesheet. 
275             </para>
276            </listitem>
277           </varlistentry>
278           
279           <varlistentry>
280            <term>termlist</term>
281            <listitem>
282             <para>
283              Specifies that this element is to be used as a
284              termlist, or browse facet. Values are tabulated from
285              incoming records, and a highscore of values (with
286              their associated frequency) is made available to the
287              client through the webservice API. 
288              The possible values
289              are 'yes' and 'no' (default).
290             </para>
291            </listitem>
292           </varlistentry>
293           
294           <varlistentry>
295            <term>merge</term>
296            <listitem>
297             <para>
298              This governs whether, and how elements are extracted
299              from individual records and merged into cluster
300              records. The possible values are: 'unique' (include
301              all unique elements), 'longest' (include only the
302              longest element (strlen), 'range' (calculate a range
303              of values across all matching records), 'all' (include
304              all elements), or 'no' (don't merge; this is the
305              default);
306             </para>
307            </listitem>
308           </varlistentry>
309           
310           <varlistentry>
311            <term>mergekey</term>
312            <listitem>
313             <para>
314              If set to '<literal>required</literal>', the value of this
315              metadata element is appended to the resulting mergekey if
316              the metadata is present in a record instance.
317              If the metadata element is not present, the a unique mergekey
318              will be generated instead.
319             </para>
320             <para>
321              If set to '<literal>optional</literal>', the value of this
322              metadata element is appended to the resulting mergekey if the
323              the metadata is present in a record instance. If the metadata
324              is not present, it will be empty.
325             </para>
326             <para>
327              If set to '<literal>no</literal>' or the mergekey attribute is
328              omitted, the metadata will not be used in the creation of a
329              mergekey.
330             </para>
331            </listitem>
332           </varlistentry>
333
334           <varlistentry>
335            <term id="facetrule">facetrule</term>
336            <listitem>
337             <para>
338              Specifies the ICU rule set to be used for normalizing
339              facets. If facetrule is omitted from metadata, the
340              rule set 'facet' is used.
341             </para>
342            </listitem>
343           </varlistentry>
344           
345           <varlistentry>
346            <term>setting</term>
347            <listitem>
348             <para>
349              This attribute allows you to make use of static database
350              settings in the processing of records. Three possible values
351              are allowed. 'no' is the default and doesn't do anything.
352              'postproc' copies the value of a setting with the same name
353              into the output of the normalization stylesheet(s). 'parameter'
354              makes the value of a setting with the same name available 
355              as a parameter to the normalization stylesheet, so you
356              can further process the value inside of the stylesheet, or use
357              the value to decide how to deal with other data values.
358             </para>
359             <para>
360              The purpose of using settings in this way can either be to
361              control the behavior of normalization stylesheet in a database-
362              dependent way, or to easily make database-dependent values
363              available to display-logic in your user interface, without having
364              to implement complicated interactions between the user interface
365              and your configuration system.
366             </para>
367            </listitem>
368           </varlistentry>
369           
370          </variablelist> <!-- attributes to metadata -->
371          
372         </listitem>
373        </varlistentry>
374
375        <varlistentry>
376         <term id="servicexslt" xreflabel="xslt">xslt</term>
377         <listitem>
378          <para>
379           Defines a XSLT stylesheet. The <literal>xslt</literal>
380           element takes exactly one attribute <literal>id</literal>
381           which names the stylesheet. This can be referred to in target
382           settings <xref linkend="pzxslt"/>.
383          </para>
384          <para>
385           The content of the xslt element is the embedded stylesheet XML
386          </para>
387         </listitem>
388        </varlistentry>
389        <varlistentry>
390         <term id="icuchain" xreflabel="icu_chain">icu_chain</term>
391         <listitem>
392          <para>
393           Specifies a named ICU rule set. The icu_chain element must include
394           attribute 'id' which specifies the identifier (name) for the ICU
395           rule set.
396           Pazpar2 uses the particular rule sets for particular purposes.
397           Rule set 'relevance' is used to normalize
398           terms for relevance ranking. Rule set 'sort' is used to 
399           normalize terms for sorting. Rule set 'mergekey' is used to
400           normalize terms for making a mergekey and, finally. Rule set 'facet'
401           is normally used to normalize facet terms, unless
402           <xref linkend="facetrule">facetrule</xref> is given for a
403           metadata field.
404          </para>
405          <para>
406           The icu_chain element must also include a 'locale'
407           attribute which must be set to one of the locale strings
408           defined in ICU. The child elements listed below can be
409           in any order, except the 'index' element which logically
410           belongs to the end of the list. The stated tokenization,
411           transformation and charmapping instructions are performed
412           in order from top to bottom. 
413          </para>
414          <variablelist> <!-- Level 2 -->
415           <varlistentry>
416            <term>casemap</term>
417            <listitem>
418             <para>
419              The attribute 'rule' defines the direction of the
420              per-character casemapping, allowed values are "l"
421              (lower), "u" (upper), "t" (title).  
422             </para>
423            </listitem>
424           </varlistentry>
425           <varlistentry>
426            <term>transform</term>
427            <listitem>
428             <para>
429              Normalization and transformation of tokens follows
430              the rules defined in the 'rule' attribute. For
431              possible values we refer to the extensive ICU
432              documentation found at the 
433              <ulink url="&url.icu.transform;">ICU
434              transformation</ulink> home page. Set filtering
435              principles are explained at the 
436              <ulink url="&url.icu.unicode.set;">ICU set and
437              filtering</ulink> page.
438             </para>
439            </listitem>
440           </varlistentry>
441           <varlistentry>
442            <term>tokenize</term>
443            <listitem>
444             <para>
445              Tokenization is the only rule in the ICU chain
446              which splits one token into multiple tokens. The
447              'rule' attribute may have the following values:
448              "s" (sentence), "l" (line-break), "w" (word), and
449              "c" (character), the later probably not being
450              very useful in a pruning Pazpar2 installation. 
451             </para>
452            </listitem>
453           </varlistentry>
454          </variablelist>
455          <para>
456           From Pazpar2 version 1.1 the ICU wrapper from YAZ is used.
457           Refer to the <ulink url="&url.yaz.yaz-icu;">yaz-icu</ulink>
458           utility for more information.
459          </para>
460         </listitem>
461        </varlistentry>
462        
463        <varlistentry>
464         <term>relevance</term>
465         <listitem>
466          <para>
467           Specifies the ICU rule set used for relevance ranking.
468           The child element of 'relevance' must be 'icu_chain' and the
469           'id' attribute of the icu_chain is ignored. This
470           definition is obsolete and should be replaced by the equivalent
471           construct:
472           <screen>
473            &lt;icu_chain id="relevance" locale="en">..&lt;icu_chain>
474           </screen>
475          </para>
476         </listitem>
477        </varlistentry>
478        
479        <varlistentry>
480         <term>sort</term>
481         <listitem>
482          <para>
483           Specifies the ICU rule set used for sorting.
484           The child element of 'sort' must be 'icu_chain' and the
485           'id' attribute of the icu_chain is ignored. This
486           definition is obsolete and should be replaced by the equivalent
487           construct:
488           <screen>
489            &lt;icu_chain id="sort" locale="en">..&lt;icu_chain>
490           </screen>
491          </para>
492         </listitem>
493        </varlistentry>
494        
495        <varlistentry>
496         <term>mergekey</term>
497         <listitem>
498          <para>
499           Specifies ICU tokenization and transformation rules
500           for tokens that are used in Pazpar2's mergekey. 
501           The child element of 'mergekey' must be 'icu_chain' and the
502           'id' attribute of the icu_chain is ignored. This
503           definition is obsolete and should be replaced by the equivalent
504           construct:
505           <screen>
506            &lt;icu_chain id="mergekey" locale="en">..&lt;icu_chain>
507           </screen>
508          </para>
509         </listitem>
510        </varlistentry>
511
512        <varlistentry>
513         <term>facet</term>
514         <listitem>
515          <para>
516           Specifies ICU tokenization and transformation rules
517           for tokens that are used in Pazpar2's facets.
518           The child element of 'facet' must be 'icu_chain' and the
519           'id' attribute of the icu_chain is ignored. This
520           definition is obsolete and should be replaced by the equivalent
521           construct:
522           <screen>
523            &lt;icu_chain id="facet" locale="en">..&lt;icu_chain>
524           </screen>
525          </para>
526         </listitem>
527        </varlistentry>
528        
529        <varlistentry>
530         <term>settings</term>
531         <listitem>
532          <para>
533           Specifies target settings for this service. Refer to
534           <xref linkend="target_settings"/>.
535          </para>
536         </listitem>
537        </varlistentry>
538
539        <varlistentry>
540         <term>timeout</term>
541         <listitem>
542          <para>
543           Specifies timeout parameters for this service.
544           The <literal>timeout</literal>
545           element supports the following attributes: 
546           <literal>session</literal>, <literal>z3950_operation</literal>,
547           <literal>z3950_session</literal> which specifies
548           'session timeout', 'Z39.50 operation timeout',
549           'Z39.50 session timeout' respectively. The Z39.50 operation
550           timeout is the time Pazpar2 will wait for an active Z39.50/SRU
551           operation before it gives up (times out). The Z39.50 session
552           time out is the time Pazpar2 will keep the session alive for
553           an idle session (no operation).
554          </para>
555          <para>
556           The following is recommended but not required:
557           z3950_operation (30) &lt; session (60) &lt; z3950_session (180) .
558           The default values are given in parantheses.
559          </para>
560         </listitem>
561        </varlistentry>
562       </variablelist>     <!-- Data elements in service directive -->
563      </listitem>
564     </varlistentry>
565    </variablelist>           <!-- Data elements in server directive -->
566   </refsect2>
567  </refsect1>
568
569  <refsect1>
570   <title>EXAMPLE</title>
571   <para>
572    Below is a working example configuration:
573   </para>
574   <screen>
575    <![CDATA[
576 <?xml version="1.0" encoding="UTF-8"?>
577 <pazpar2 xmlns="http://www.indexdata.com/pazpar2/1.0">
578
579  <threads number="10"/>
580  <server>
581   <listen port="9004"/>
582   <service>
583    <metadata name="title" brief="yes" sortkey="skiparticle"
584              merge="longest" rank="6"/>
585    <metadata name="isbn" merge="unique"/>
586    <metadata name="date" brief="yes" sortkey="numeric"
587              type="year" merge="range" termlist="yes"/>
588    <metadata name="author" brief="yes" termlist="yes"
589              merge="longest" rank="2"/>
590    <metadata name="subject" merge="unique" termlist="yes" rank="3"/>
591    <metadata name="url" merge="unique"/>
592    <icu_chain id="relevance" locale="el">
593     <transform rule="[:Control:] Any-Remove"/>
594     <tokenize rule="l"/>
595     <transform rule="[[:WhiteSpace:][:Punctuation:]] Remove"/>
596     <casemap rule="l"/>
597    </icu_chain>
598    <settings src="mysettings"/>
599    <timeout session="60"/>
600   <service>
601  </server>
602 </pazpar2>
603    ]]>
604   </screen>
605  </refsect1> 
606
607  <refsect1 id="config-include">
608   <title>INCLUDE FACILITY</title>
609   <para>
610    The XML configuration may be partitioned into multiple files by using
611    the <literal>include</literal> element which takes a single attribute,
612    <literal>src</literal>. The of the <literal>src</literal> attribute is
613    regular Shell like glob-pattern. For example,
614    <screen><![CDATA[
615    <include src="/etc/pazpar2/conf.d/*.xml"/>
616    ]]></screen>
617   </para>
618   <para>
619    The include facility requires Pazpar2 version 1.2.
620   </para>
621  </refsect1>
622
623  <refsect1 id="target_settings">
624   <title>TARGET SETTINGS</title>
625   <para>
626    Pazpar2 features a cunning scheme by which you can associate various
627    kinds of attributes, or settings with search targets. This can be done
628    through XML files which are read at startup; each file can associate
629    one or more settings with one or more targets. The file format is generic
630    in nature, designed to support a wide range of application requirements. The
631    settings can be purely technical things, like, how to perform a title
632    search against a given target, or it can associate arbitrary name=value
633    pairs with groups of targets -- for instance, if you would like to
634    place all commercial full-text bases in one group for selection
635    purposes, or you would like to control what targets are accessible
636    to users by default. Per-database settings values can even be used
637    to drive sorting, facet/termlist generation, or end-user interface display
638    logic.
639   </para>
640   
641   <para>
642    During startup, Pazpar2 will recursively read a specified directory
643    (can be identified in the pazpar2.cfg file or on the command line), and
644    process any settings files found therein.
645   </para>
646   
647   <para>
648    Clients of the Pazpar2 webservice interface can selectively override
649    settings for individual targets within the scope of one session. This
650    can be used in conjunction with an external authentication system to
651    determine which resources are to be accessible to which users. Pazpar2
652    itself has no notion of end-users, and so can be used in conjunction
653    with any type of authentication system. Similarly, the authentication
654    tokens submitted to access-controlled search targets can similarly be
655    overridden, to allow use of Pazpar2 in a consortial or multi-library
656    environment, where different end-users may need to be represented to
657    some search targets in different ways. This, again, can be managed
658    using an external database or other lookup mechanism. Setting overrides
659    can be performed either using the
660    <link linkend="command-init">init</link> or the 
661    <link linkend="command-settings">settings</link> webservice
662    command.
663   </para>
664   
665   <para>
666    In fact, every setting that applies to a database (except pz:id, which
667    can only be used for filtering targets to use for a search) can be overridden
668    on a per-session basis. This allows the client to override specific CCL fields
669    for searching, etc., to meet the needs of a session or user.
670   </para>
671
672   <para>
673    Finally, as an extreme case of this, the webservice client can
674    introduce entirely new targets, on the fly, as part of the
675    <link linkend="command-init">init</link> or
676    <link linkend="command-settings">settings</link> command.
677    This is useful if you desire to manage information
678    about your search targets in a separate application such as a database.
679    You do not need any static settings file whatsoever to run Pazpar2 -- as
680    long as the webservice client is prepared to supply the necessary
681    information at the beginning of every session.
682   </para>
683
684   <note>
685    <para>
686     The following discussion of practical issues related to session
687     and settings management are cast in terms of a user interface based on
688     Ajax/Javascript technology. It would apply equally well to many other
689     kinds of browser-based logic.
690    </para>
691   </note>
692
693   <para>
694    Typically, a Javascript client is not allowed to directly alter the
695    parameters of a session. There are two reasons for this. One has to do
696    with access to information; typically, information about a user will
697    be stored in a system on the server side, or it will be accessible in
698    some way from the server.  However, since the Javascript client cannot
699    be entirely trusted (some hostile agent might in fact 'pretend' to be
700    a regular ws client), it is more robust to control session settings
701    from scripting that you run as part of your webserver. Typically, this
702    can be handled during the session initialization, as follows:
703   </para>
704
705   <para>
706    Step 1: The Javascript client loads, and asks the webserver for a
707    new Pazpar2 session ID. This can be done using a Javascript call, for
708    instance. Note that it is possible to submit Ajax HTTPXmlRequest calls
709    either to Pazpar2 or to the webserver that Pazpar2 is proxying
710    for. See (XXX Insert link to Pazpar2 protocol).
711   </para>
712
713   <para>
714    Step 2: Code on the webserver authenticates the user, by database lookup,
715    LDAP access, NCIP, etc. Determines which resources the user has access to,
716    and any user-specific parameters that are to be applied during this session.
717   </para>
718
719   <para>
720    Step 3: The webserver initializes a new Pazpar2 settings, and sets
721    user-specific parameters as necessary, using the init webservice
722    command. A new session ID is returned.
723   </para>
724
725   <para>
726    Step 4: The webserver returns this session ID to the Javascript
727    client, which then uses the session ID to submit searches, show
728    results, etc.
729   </para>
730
731   <para>
732    Step 5: When the Javascript client ceases to use the session,
733    Pazpar2 destroys any session-specific information.
734   </para>
735
736   <refsect2>
737    <title>SETTINGS FILE FORMAT</title>
738    <para>
739     Each file contains a root element named &lt;settings&gt;. It may
740     contain one or more &lt;set&gt; elements. The settings and set
741     elements may contain the following attributes. Attributes in the set
742     node overrides those in the setting root element. Each set node must
743     specify (directly, or inherited from the parent node) at least a
744     target, name, and value.
745    </para>
746
747    <variablelist> 
748     <varlistentry>
749      <term>target</term>
750      <listitem>
751       <para>
752        This specifies the search target to which this setting should be
753        applied. Targets are identified by their Z39.50 URL, generally
754        including the host, port, and database name, (e.g.
755        <literal>bagel.indexdata.com:210/marc</literal>).
756        Two wildcard forms are accepted:
757        * (asterisk) matches all known targets;
758        <literal>bagel.indexdata.com:210/*</literal> matches all
759        known databases on the given host.
760       </para>
761       <para>
762        A precedence system determines what happens if there are
763        overlapping values for the same setting name for the same
764        target. A setting for a specific target name overrides a
765        setting which specifies target using a wildcard. This makes it
766        easy to set defaults for all targets, and then override them
767        for specific targets or hosts. If there are
768        multiple overlapping settings with the same name and target
769        value, the 'precedence' attribute determines what happens.
770       </para>
771       <para>
772        For Pazpar2 1.6.4 or later, the target ID may be user-defined, in
773        which case, the actual host, port, etc is given by setting
774        <xref linkend="pzurl"/>.
775       </para>
776      </listitem>
777     </varlistentry>
778     <varlistentry>
779      <term>name</term>
780      <listitem>
781       <para>
782        The name of the setting. This can be anything you like.
783        However, Pazpar2 reserves a number of setting names for
784        specific purposes, all starting with 'pz:', and it is a good
785        idea to avoid that prefix if you make up your own setting
786        names. See below for a list of reserved variables.
787       </para>
788      </listitem>
789     </varlistentry>
790     <varlistentry>
791      <term>value</term>
792      <listitem>
793       <para>
794        The value of the setting. Generally, this can be anything you
795        want -- however, some of the reserved settings may expect
796        specific kinds of values.
797       </para>
798      </listitem>
799     </varlistentry>
800     <varlistentry>
801      <term>precedence</term>
802      <listitem>
803       <para>
804        This should be an integer. If not provided, the default value
805        is 0. If two (or more) settings have the same content for
806        target and name, the precedence value determines the outcome.
807        If both settings have the same precedence value, they are both
808        applied to the target(s). If one has a higher value, then the
809        value of that setting is applied, and the other one is ignored.
810       </para>
811      </listitem>
812     </varlistentry>
813    </variablelist>
814
815    <para>
816     By setting defaults for target, name, or value in the root
817     settings node, you can use the settings files in many different
818     ways. For instance, you can use a single file to set defaults for
819     many different settings, like search fields, retrieval syntaxes,
820     etc. You can have one file per server, which groups settings for
821     that server or target. You could also have one file which associates
822     a number of targets with a given setting, for instance, to associate
823     many databases with a given category or class that makes sense
824     within your application.
825    </para>
826
827    <para>
828     The following examples illustrate uses of the settings system to
829     associate settings with targets to meet different requirements.
830    </para>
831
832    <para>
833     The example below associates a set of default values that can be
834     used across many targets. Note the wildcard for targets.
835     This associates the given settings with all targets for which no
836     other information is provided.
837     <screen><![CDATA[
838     <settings target="*">
839
840     <!-- This file introduces default settings for pazpar2 -->
841
842     <!-- mapping for unqualified search -->
843     <set name="pz:cclmap:term" value="u=1016 t=l,r s=al"/>
844
845     <!-- field-specific mappings -->
846     <set name="pz:cclmap:ti" value="u=4 s=al"/>
847     <set name="pz:cclmap:su" value="u=21 s=al"/>
848     <set name="pz:cclmap:isbn" value="u=7"/>
849     <set name="pz:cclmap:issn" value="u=8"/>
850     <set name="pz:cclmap:date" value="u=30 r=r"/>
851     
852     <set name="pz:limitmap:title" value="rpn:@attr 1=4 @attr 6=3"/>
853     <set name="pz:limitmap:date" value="ccl:date"/>
854
855     <!-- Retrieval settings -->
856
857     <set name="pz:requestsyntax" value="marc21"/>
858     <set name="pz:elements" value="F"/>
859
860     <!-- Query encoding -->
861     <set name="pz:queryencoding" value="iso-8859-1"/>
862
863     <!-- Result normalization settings -->
864
865     <set name="pz:nativesyntax" value="iso2709"/>
866     <set name="pz:xslt" value="../etc/marc21.xsl"/>
867
868     </settings>
869
870     ]]></screen>
871    </para>
872
873    <para>
874     The next example shows certain settings overridden for one target,
875     one which returns XML records containing DublinCore elements, and
876     which furthermore requires a username/password.
877     <screen><![CDATA[
878     <settings target="funkytarget.com:210/db1">
879     <set name="pz:requestsyntax" value="xml"/>
880     <set name="pz:nativesyntax" value="xml"/>
881     <set name="pz:xslt" value="../etc/dublincore.xsl"/>
882
883     <set name="pz:authentication" value="myuser/password"/>
884     </settings>
885     ]]></screen>
886    </para>
887
888    <para>
889     The following example associates a specific name/value combination
890     with a number of targets. The targets below are access-restricted,
891     and can only be used by users with special credentials.
892     <screen><![CDATA[
893     <settings name="pz:allow" value="0">
894     <set target="funkytarget.com:210/*"/>
895     <set target="commercial.com:2100/expensiveDb"/>
896     </settings>
897     ]]></screen>
898    </para>
899
900   </refsect2>
901
902   <refsect2>
903    <title>RESERVED SETTING NAMES</title>
904    <para>
905     The following setting names are reserved by Pazpar2 to control the
906     behavior of the client function.
907    </para>
908    
909    <variablelist>
910     <varlistentry>
911      <term>pz:cclmap:xxx</term>
912      <listitem>
913       <para>
914        This establishes a CCL field definition or other setting, for
915        the purpose of mapping end-user queries. XXX is the field or
916        setting name, and the value of the setting provides parameters
917        (e.g. parameters to send to the server, etc.). Please consult
918        the YAZ manual for a full overview of the many capabilities of
919        the powerful and flexible CCL parser.
920       </para>
921       <para>
922        Note that it is easy to establish a set of default parameters,
923        and then override them individually for a given target.
924       </para>
925      </listitem>
926     </varlistentry>
927     <varlistentry id="requestsyntax">
928      <term>pz:requestsyntax</term>
929      <listitem>
930       <para>
931        This specifies the record syntax to use when requesting
932        records from a given server. The value can be a symbolic name like
933        marc21 or xml, or it can be a Z39.50-style dot-separated OID.
934       </para>
935      </listitem>
936     </varlistentry>
937     <varlistentry>
938      <term>pz:elements</term>
939      <listitem>
940       <para>
941        The element set name to be used when retrieving records from a
942        server.
943       </para>
944      </listitem>
945     </varlistentry>
946     <varlistentry>
947      <term>pz:piggyback</term>
948      <listitem>
949       <para>
950        Piggybacking enables the server to retrieve records from the
951        server as part of the search response in Z39.50. Almost all
952        servers support this (or fail it gracefully), but a few
953        servers will produce undesirable results.
954        Set to '1' to enable piggybacking, '0' to disable it. Default
955        is 1 (piggybacking enabled).
956       </para>
957      </listitem>
958     </varlistentry>
959     <varlistentry>
960      <term>pz:nativesyntax</term>
961      <listitem>
962       <para>
963        Specifies how Pazpar2 shoule map retrieved records to XML. Currently
964        supported values are <literal>xml</literal>,
965        <literal>iso2709</literal> and <literal>txml</literal>.
966       </para>
967       <para>
968        The value <literal>iso2709</literal> makes Pazpar2 convert retrieved
969        MARC records to MARCXML. In order to convert to XML, the exact
970        chacater set of the MARC must be known (if not, the resulting
971        XML is probably not well-formed). The character set may be 
972        specified by adding:
973        <literal>;charset=</literal><replaceable>charset</replaceable> to
974        <literal>iso2709</literal>. If omitted, a charset of
975        MARC-8 is assumed. This is correct for most MARC21/USMARC records.
976       </para>
977       <para>
978        The value <literal>txml</literal> is like <literal>iso2709</literal>
979        except that records are converted to TurboMARC instead of MARCXML.
980       </para>
981       <para>
982        The value <literal>xml</literal> is used if Pazpar2 retrieves
983        records that are already XML (no conversion takes place).
984       </para>
985      </listitem>
986     </varlistentry>
987
988     <varlistentry>
989      <term>pz:queryencoding</term>
990      <listitem>
991       <para>
992        The encoding of the search terms that a target accepts. Most
993        targets do not honor UTF-8 in which case this needs to be specified.
994        Each term in a query will be converted if this setting is given.
995       </para>
996      </listitem>
997     </varlistentry>
998
999     <varlistentry>
1000      <term>pz:negotiation_charset</term>
1001      <listitem>
1002       <para>
1003        Sets character set for Z39.50 negotiation. Most targets do not support
1004        this, and some will even close connection if set (crash on server
1005        side or similar). If set, you probably want to set it to
1006        <literal>UTF-8</literal>.
1007       </para>
1008      </listitem>
1009     </varlistentry>
1010
1011     <varlistentry>
1012      <term id="pzxslt" xreflabel="pz:xslt">pz:xslt</term>
1013      <listitem>
1014       <para>
1015        Is a comma separated list of of stylesheet names that specifies
1016        how to convert incoming records to the internal representation.
1017       </para>
1018       <para>
1019        For each name, the embedded stylesheets (XSL) that comes with the
1020        service definition are consulted first and takes precedence over
1021        external files; see <xref linkend="servicexslt"/>
1022        of service definition).
1023        If the name does not match an embedded stylesheet it is
1024        considered a filename.
1025       </para>
1026       <para>
1027        The suffix of each file specifies the kind of tranformation.
1028        Suffix "<literal>.xsl</literal>" makes an XSL transform. Suffix
1029        "<literal>.mmap</literal>" will use the MMAP transform (described below).
1030       </para>
1031       <para>
1032        The special value "<literal>auto</literal>" will use a file
1033        which is the <link linkend="requestsyntax">pz:requestsyntax's</link>
1034        value followed by
1035        <literal>'.xsl'</literal>.
1036       </para>
1037       <para>
1038        When mapping MARC records, XSLT can be bypassed for increased 
1039        performance with the alternate "MARC map" format.  Provide the
1040        path of a file with extension ".mmap" containing on each line:
1041        <programlisting>
1042        &lt;field&gt; &lt;subfield&gt; &lt;metadata element&gt;</programlisting>
1043        For example:
1044        <programlisting>
1045         245 a title
1046         500 $ description
1047         773 * citation
1048        </programlisting>
1049        To map the field value specify a subfield of '$'.  To store a 
1050        concatenation of all subfields, specify a subfield of '*'.
1051       </para>
1052      </listitem>
1053     </varlistentry>
1054     <varlistentry>
1055      <term>pz:authentication</term>
1056      <listitem>
1057       <para>
1058        Sets an authentication string for a given server. See the section on
1059        authorization and authentication for discussion.
1060       </para>
1061      </listitem>
1062     </varlistentry>
1063     <varlistentry>
1064      <term>pz:allow</term>
1065      <listitem>
1066       <para>
1067        Allows or denies access to the resources it is applied to. Possible
1068        values are '0' and '1'.
1069        The default is '1' (allow access to this resource).
1070        See the manual section on authorization and authentication for
1071        discussion about how to use this setting.
1072       </para>
1073      </listitem>
1074     </varlistentry>
1075     <varlistentry>
1076      <term>pz:maxrecs</term>
1077      <listitem>
1078       <para>
1079        Controls the maximum number of records to be retrieved from a
1080        server. The default is 100.
1081       </para>
1082      </listitem>
1083     </varlistentry>
1084     <varlistentry>
1085      <term>pz:id</term>
1086      <listitem>
1087       <para>
1088        This setting can't be 'set' -- it contains the ID (normally
1089        ZURL) for a given target, and is useful for filtering --
1090        specifically when you want to select one or more specific
1091        targets in the search command.
1092       </para>
1093      </listitem>
1094     </varlistentry>
1095     <varlistentry>
1096      <term>pz:zproxy</term>
1097      <listitem>
1098       <para>
1099        The 'pz:zproxy' setting has the value syntax 
1100        'host.internet.adress:port', it is used to tunnel Z39.50
1101        requests through the named Z39.50 proxy.
1102       </para>
1103      </listitem>
1104     </varlistentry>
1105     
1106     <varlistentry>
1107      <term>pz:apdulog</term>
1108      <listitem>
1109       <para>
1110        If the 'pz:apdulog' setting is defined and has other value than 0,
1111        then Z39.50 APDUs are written to the log.
1112       </para>
1113      </listitem>
1114     </varlistentry>
1115     
1116     <varlistentry>
1117      <term>pz:sru</term>
1118      <listitem>
1119       <para>
1120        This setting enables
1121        <ulink url="&url.sru;">SRU</ulink>/<ulink url="&url.solr;">SOLR</ulink>
1122        support.
1123        It has four possible settings.
1124        'get', enables SRU access through GET requests. 'post' enables SRU/POST
1125        support, less commonly supported, but useful if very large requests are
1126        to be submitted. 'srw' enables the SRW (SRU over SOAP) variation of
1127        the protocol.
1128       </para>
1129       <para>
1130        A value of 'solr' anables SOLR client support. This is supported
1131        for Pazpar version 1.5.0 and later.
1132       </para>
1133      </listitem>
1134     </varlistentry>
1135     
1136     <varlistentry>
1137      <term>pz:sru_version</term>
1138      <listitem>
1139       <para>
1140        This allows SRU version to be specified. If unset Pazpar2
1141        will the default of YAZ (currently 1.2). Should be set
1142        to 1.1 or 1.2. For SOLR, the current supported/tested version is 1.4
1143       </para>
1144      </listitem>
1145     </varlistentry>
1146     
1147     <varlistentry>
1148      <term>pz:pqf_prefix</term>
1149      <listitem>
1150       <para>
1151        Allows you to specify an arbitrary PQF query language substring.
1152        The provided string is prefixed to the user's query after it has been
1153        normalized to PQF internally in pazpar2.
1154        This allows you to attach complex 'filters' to queries for a given
1155        target, sometimes necessary to select sub-catalogs
1156        in union catalog systems, etc.
1157       </para>
1158      </listitem>
1159     </varlistentry>
1160     
1161     <varlistentry>
1162      <term>pz:pqf_strftime</term>
1163      <listitem>
1164       <para>
1165        Allows you to extend a query with dates and operators.
1166        The provided string allows certain substitutions and serves as a
1167        format string.
1168        The special two character sequence '%%' gets converted to the
1169        original query. Other characters leading with the percent sign are
1170        conversions supported by strftime.
1171        All other characters are copied verbatim. For example, the string
1172        <literal>@and @attr 1=30 @attr 2=3 %Y %%</literal>
1173        would search for current year combined with the original PQF (%%).
1174       </para>
1175       <para>
1176        This setting can also be used as more general alternative to
1177        pz:pqf_prefix -- a way of embedding the submitted query
1178        anywhere in the string rather than appending it to prefix.  For
1179        example, if it is desired to omit all records satisfying the
1180        query <literal>@attr 1=pica.bib 0007</literal> then this
1181        subquery can be combined with the submitted query as the second
1182        argument of <literal>@andnot</literal> by using the
1183        pz:pqf_strftime value <literal>@not %% @attr 1=pica.bib
1184        0007</literal>.
1185       </para>
1186      </listitem>
1187     </varlistentry>
1188     
1189     <varlistentry>
1190      <term>pz:sort</term>
1191      <listitem>
1192       <para>
1193        Specifies sort criteria to be applied to the result set.
1194        Only works for targets which support the sort service.
1195       </para>
1196      </listitem>
1197     </varlistentry>
1198
1199     <varlistentry>
1200      <term>pz:recordfilter</term>
1201      <listitem>
1202       <para>
1203        Specifies a filter which allows Pazpar2 to only include
1204        records that meet a certain criteria in a result.
1205        Unmatched records  will be ignored.
1206        The filter takes the form name, name~value, or name=value, which
1207        will include only records with metadata element (name) that has the
1208        substring (~value) given, or matches exactly (=value).
1209        If value is omitted all records with the named metadata element
1210        present will be included.
1211       </para>
1212      </listitem>
1213     </varlistentry>
1214     
1215     <varlistentry>
1216      <term>pz:preferred</term>
1217      <listitem>
1218       <para>
1219        Specifies that a target is preferred, e.g. possible local, faster
1220        target. Using block=pref on show command will wait for all these
1221        targets to return records before releasing the block.
1222        If no target is preferred, the block=pref will identical to block=1,
1223        which release when one target has returned records.     
1224       </para>
1225      </listitem>
1226     </varlistentry>
1227
1228     <varlistentry>
1229      <term>pz:block_timeout</term>
1230      <listitem>
1231       <para>
1232        (Not yet implemented).
1233        Specifies the time for which a block should be released anyway.      
1234       </para>
1235      </listitem>
1236     </varlistentry>
1237
1238     <varlistentry>
1239      <term>pz:facetmap:<replaceable>name</replaceable></term>
1240      <listitem>
1241       <para>
1242        Specifies that for field <replaceable>name</replaceable>, the target
1243        supports (native) facets. The value is the name of the
1244        field on the target.
1245       </para>
1246       <note>
1247        <para>
1248         At this point only SOLR targets have been tested with this
1249         facility.
1250        </para>
1251       </note>
1252      </listitem>
1253     </varlistentry>
1254
1255     <varlistentry id="limitmap">
1256      <term>pz:limitmap:<replaceable>name</replaceable></term>
1257      <listitem>
1258       <para>
1259        Specifies attributes for limiting a search to a field - using
1260        the limit parameter for search. It can be used to filter locally
1261        or remotely (search in a target). In some cases the mapping of 
1262        a field to a value is identical to an existing cclmap field; in
1263        other cases the field must be specified in a different way - for
1264        example to match a complete field (rather than parts of a subfield).
1265       </para>
1266       <para>
1267        The value of limitmap may have one of three forms: referral to
1268        an existing CCL field, a raw PQF string or a local limit. Leading string
1269        determines type; either <literal>ccl:</literal> for CCL field, 
1270        <literal>rpn:</literal> for PQF/RPN, or <literal>local:</literal>
1271        for filtering in Pazpar2. The local filtering may be followed
1272        by a field a metadata field (default is to use the name of the 
1273        limitmap itself).
1274       </para>
1275       <note>
1276        <para>
1277         The limitmap facility is supported for Pazpar2 version 1.6.0.
1278         Local filtering is supported in Pazpar2 1.6.6.
1279        </para>
1280       </note>
1281      </listitem>
1282     </varlistentry>
1283
1284     <varlistentry id="pzurl">
1285      <term>pz:url</term>
1286      <listitem>
1287       <para>
1288        Specifies URL for the target and overrides the target ID.
1289       </para>
1290       <note>
1291        <para>
1292         <literal>pz:url</literal> is only recognized for
1293         Pazpar2 1.6.4 and later.
1294        </para>
1295       </note>
1296      </listitem>
1297     </varlistentry>
1298
1299     <varlistentry id="pzsortmap">
1300      <term>pz:sortmap:<replaceable>field</replaceable></term>
1301      <listitem>
1302       <para>
1303        Specifies native sorting for a target where
1304        <replaceable>field</replaceable> is a sort criteria (see command
1305        show). The value has to components separated by colon: strategy and
1306        native-field. Strategy is one of <literal>z3950</literal>,
1307        <literal>type7</literal>, <literal>cql</literal>,
1308        <literal>sru11</literal>, or <literal>embed</literal>.
1309        The second component, native-field, is the field that is recognized
1310        by the target.
1311       </para>
1312       <note>
1313        <para>
1314         Only supported for Pazpar2 1.6.4 and later.
1315        </para>
1316       </note>
1317      </listitem>
1318     </varlistentry>
1319     
1320    </variablelist>
1321    
1322   </refsect2>
1323
1324  </refsect1>
1325  <refsect1>
1326   <title>SEE ALSO</title>
1327   <para>
1328    <citerefentry>
1329     <refentrytitle>pazpar2</refentrytitle>
1330     <manvolnum>8</manvolnum>
1331    </citerefentry>
1332    <citerefentry>
1333     <refentrytitle>yaz-icu</refentrytitle>
1334     <manvolnum>1</manvolnum>
1335    </citerefentry>
1336    <citerefentry>
1337     <refentrytitle>pazpar2_protocol</refentrytitle>
1338     <manvolnum>7</manvolnum>
1339    </citerefentry>
1340   </para>
1341  </refsect1>
1342 </refentry>
1343 <!-- Keep this comment at the end of the file
1344 Local variables:
1345 mode: nxml
1346 nxml-child-indent: 1
1347 End:
1348 -->