Document new setting icu_chain for service/server
[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="icu_chain">"icu_chain"</xref> 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            </listitem>
273           </varlistentry>
274           
275           <varlistentry>
276            <term>termlist</term>
277            <listitem>
278             <para>
279              Specifies that this element is to be used as a
280              termlist, or browse facet. Values are tabulated from
281              incoming records, and a highscore of values (with
282              their associated frequency) is made available to the
283              client through the webservice API. 
284              The possible values
285              are 'yes' and 'no' (default).
286             </para>
287            </listitem>
288           </varlistentry>
289           
290           <varlistentry>
291            <term>merge</term>
292            <listitem>
293             <para>
294              This governs whether, and how elements are extracted
295              from individual records and merged into cluster
296              records. The possible values are: 'unique' (include
297              all unique elements), 'longest' (include only the
298              longest element (strlen), 'range' (calculate a range
299              of values across all matching records), 'all' (include
300              all elements), or 'no' (don't merge; this is the
301              default);
302             </para>
303            </listitem>
304           </varlistentry>
305           
306           <varlistentry>
307            <term>mergekey</term>
308            <listitem>
309             <para>
310              If set to '<literal>required</literal>', the value of this
311              metadata element is appended to the resulting mergekey if
312              the metadata is present in a record instance.
313              If the metadata element is not present, the a unique mergekey
314              will be generated instead.
315             </para>
316             <para>
317              If set to '<literal>optional</literal>', the value of this
318              metadata element is appended to the resulting mergekey if the
319              the metadata is present in a record instance. If the metadata
320              is not present, it will be empty.
321             </para>
322             <para>
323              If set to '<literal>no</literal>' or the mergekey attribute is
324              omitted, the metadata will not be used in the creation of a
325              mergekey.
326             </para>
327            </listitem>
328           </varlistentry>
329           
330           <varlistentry>
331            <term>setting</term>
332            <listitem>
333             <para>
334              This attribute allows you to make use of static database
335              settings in the processing of records. Three possible values
336              are allowed. 'no' is the default and doesn't do anything.
337              'postproc' copies the value of a setting with the same name
338              into the output of the normalization stylesheet(s). 'parameter'
339              makes the value of a setting with the same name available 
340              as a parameter to the normalization stylesheet, so you
341              can further process the value inside of the stylesheet, or use
342              the value to decide how to deal with other data values.
343             </para>
344             <para>
345              The purpose of using settings in this way can either be to
346              control the behavior of normalization stylesheet in a database-
347              dependent way, or to easily make database-dependent values
348              available to display-logic in your user interface, without having
349              to implement complicated interactions between the user interface
350              and your configuration system.
351             </para>
352            </listitem>
353           </varlistentry>
354           
355          </variablelist> <!-- attributes to metadata -->
356          
357         </listitem>
358        </varlistentry>
359
360        <varlistentry>
361         <term id="icu_chain">icu_chain</term>
362         <listitem>
363          <para>
364           Specifies a named ICU rule set. The icu_chain element must include
365           attribute 'id' which specifies the identifier (name) for the ICU
366           rule set.
367           Pazpar2 uses the particular rule sets for particular purposes.
368           Rule set 'relevance' is used to normalize
369           terms for relevance ranking. Rule set 'sort' is used to 
370           normalize terms for sorting. Rule set 'mergekey' is used to
371           normalize terms for making a mergekey and, finally, 'facet'
372           is used to normalize facet terms (AKA termlists).
373          </para>
374          <para>
375           The icu_chain element must also include a 'locale'
376           attribute which must be set to one of the locale strings
377           defined in ICU. The child elements listed below can be
378           in any order, except the 'index' element which logically
379           belongs to the end of the list. The stated tokenization,
380           transformation and charmapping instructions are performed
381           in order from top to bottom. 
382          </para>
383          <variablelist> <!-- Level 2 -->
384           <varlistentry>
385            <term>casemap</term>
386            <listitem>
387             <para>
388              The attribute 'rule' defines the direction of the
389              per-character casemapping, allowed values are "l"
390              (lower), "u" (upper), "t" (title).  
391             </para>
392            </listitem>
393           </varlistentry>
394           <varlistentry>
395            <term>transform</term>
396            <listitem>
397             <para>
398              Normalization and transformation of tokens follows
399              the rules defined in the 'rule' attribute. For
400              possible values we refer to the extensive ICU
401              documentation found at the 
402              <ulink url="&url.icu.transform;">ICU
403              transformation</ulink> home page. Set filtering
404              principles are explained at the 
405              <ulink url="&url.icu.unicode.set;">ICU set and
406              filtering</ulink> page.
407             </para>
408            </listitem>
409           </varlistentry>
410           <varlistentry>
411            <term>tokenize</term>
412            <listitem>
413             <para>
414              Tokenization is the only rule in the ICU chain
415              which splits one token into multiple tokens. The
416              'rule' attribute may have the following values:
417              "s" (sentence), "l" (line-break), "w" (word), and
418              "c" (character), the later probably not being
419              very useful in a pruning Pazpar2 installation. 
420             </para>
421            </listitem>
422           </varlistentry>
423          </variablelist>
424          <para>
425           From Pazpar2 version 1.1 the ICU wrapper from YAZ is used.
426           Refer to the <ulink url="&url.yaz.yaz-icu;">yaz-icu</ulink>
427           utility for more information.
428          </para>
429         </listitem>
430        </varlistentry>
431        
432        <varlistentry>
433         <term>relevance</term>
434         <listitem>
435          <para>
436           Specifies the ICU rule set used for relevance ranking.
437           The child element of 'relevance' must be 'icu_chain' and the
438           'id' attribute of the icu_chain is ignored. This
439           definition is obsolete and should be replaced by the equivalent
440           construct:
441           <screen>
442            &lt;icu_chain id="relevance" locale="en">..&lt;icu_chain>
443           </screen>
444          </para>
445         </listitem>
446        </varlistentry>
447        
448        <varlistentry>
449         <term>sort</term>
450         <listitem>
451          <para>
452           Specifies the ICU rule set used for sorting.
453           The child element of 'sort' must be 'icu_chain' and the
454           'id' attribute of the icu_chain is ignored. This
455           definition is obsolete and should be replaced by the equivalent
456           construct:
457           <screen>
458            &lt;icu_chain id="sort" locale="en">..&lt;icu_chain>
459           </screen>
460          </para>
461         </listitem>
462        </varlistentry>
463        
464        <varlistentry>
465         <term>mergekey</term>
466         <listitem>
467          <para>
468           Specifies ICU tokenization and transformation rules
469           for tokens that are used in Pazpar2's mergekey. 
470           The child element of 'mergekey' must be 'icu_chain' and the
471           'id' attribute of the icu_chain is ignored. This
472           definition is obsolete and should be replaced by the equivalent
473           construct:
474           <screen>
475            &lt;icu_chain id="mergekey" locale="en">..&lt;icu_chain>
476           </screen>
477          </para>
478         </listitem>
479        </varlistentry>
480
481        <varlistentry>
482         <term>facet</term>
483         <listitem>
484          <para>
485           Specifies ICU tokenization and transformation rules
486           for tokens that are used in Pazpar2's facets.
487           The child element of 'facet' must be 'icu_chain' and the
488           'id' attribute of the icu_chain is ignored. This
489           definition is obsolete and should be replaced by the equivalent
490           construct:
491           <screen>
492            &lt;icu_chain id="facet" locale="en">..&lt;icu_chain>
493           </screen>
494          </para>
495         </listitem>
496        </varlistentry>
497        
498        <varlistentry>
499         <term>settings</term>
500         <listitem>
501          <para>
502           Specifies target settings for this service. Refer to
503           <xref linkend="target_settings"/>.
504          </para>
505         </listitem>
506        </varlistentry>
507
508        <varlistentry>
509         <term>timeout</term>
510         <listitem>
511          <para>
512           Specifies timeout parameters for this service.
513           The <literal>timeout</literal>
514           element supports the following attributes: 
515           <literal>session</literal>, <literal>z3950_operation</literal>,
516           <literal>z3950_session</literal> which specifies
517           'session timeout', 'Z39.50 operation timeout',
518           'Z39.50 session timeout' respectively. The Z39.50 operation
519           timeout is the time Pazpar2 will wait for an active Z39.50/SRU
520           operation before it gives up (times out). The Z39.50 session
521           time out is the time Pazpar2 will keep the session alive for
522           an idle session (no operation).
523          </para>
524          <para>
525           The following is recommended but not required:
526           z3950_operation (30) &lt; session (60) &lt; z3950_session (180) .
527           The default values are given in parantheses.
528          </para>
529         </listitem>
530        </varlistentry>
531       </variablelist>     <!-- Data elements in service directive -->
532      </listitem>
533     </varlistentry>
534    </variablelist>           <!-- Data elements in server directive -->
535   </refsect2>
536  </refsect1>
537
538  <refsect1>
539   <title>EXAMPLE</title>
540   <para>
541    Below is a working example configuration:
542   </para>
543   <screen>
544    <![CDATA[
545 <?xml version="1.0" encoding="UTF-8"?>
546 <pazpar2 xmlns="http://www.indexdata.com/pazpar2/1.0">
547
548  <threads number="10"/>
549  <server>
550   <listen port="9004"/>
551   <service>
552    <metadata name="title" brief="yes" sortkey="skiparticle"
553              merge="longest" rank="6"/>
554    <metadata name="isbn" merge="unique"/>
555    <metadata name="date" brief="yes" sortkey="numeric"
556              type="year" merge="range" termlist="yes"/>
557    <metadata name="author" brief="yes" termlist="yes"
558              merge="longest" rank="2"/>
559    <metadata name="subject" merge="unique" termlist="yes" rank="3"/>
560    <metadata name="url" merge="unique"/>
561    <icu_chain id="relevance" locale="el">
562     <transform rule="[:Control:] Any-Remove"/>
563     <tokenize rule="l"/>
564     <transform rule="[[:WhiteSpace:][:Punctuation:]] Remove"/>
565     <casemap rule="l"/>
566    </icu_chain>
567    <settings src="mysettings"/>
568    <timeout session="60"/>
569   <service>
570  </server>
571 </pazpar2>
572    ]]>
573   </screen>
574  </refsect1> 
575
576  <refsect1 id="config-include">
577   <title>INCLUDE FACILITY</title>
578   <para>
579    The XML configuration may be partitioned into multiple files by using
580    the <literal>include</literal> element which takes a single attribute,
581    <literal>src</literal>. The of the <literal>src</literal> attribute is
582    regular Shell like glob-pattern. For example,
583    <screen><![CDATA[
584    <include src="/etc/pazpar2/conf.d/*.xml"/>
585    ]]></screen>
586   </para>
587   <para>
588    The include facility requires Pazpar2 version 1.2.
589   </para>
590  </refsect1>
591
592  <refsect1 id="target_settings">
593   <title>TARGET SETTINGS</title>
594   <para>
595    Pazpar2 features a cunning scheme by which you can associate various
596    kinds of attributes, or settings with search targets. This can be done
597    through XML files which are read at startup; each file can associate
598    one or more settings with one or more targets. The file format is generic
599    in nature, designed to support a wide range of application requirements. The
600    settings can be purely technical things, like, how to perform a title
601    search against a given target, or it can associate arbitrary name=value
602    pairs with groups of targets -- for instance, if you would like to
603    place all commercial full-text bases in one group for selection
604    purposes, or you would like to control what targets are accessible
605    to users by default. Per-database settings values can even be used
606    to drive sorting, facet/termlist generation, or end-user interface display
607    logic.
608   </para>
609   
610   <para>
611    During startup, Pazpar2 will recursively read a specified directory
612    (can be identified in the pazpar2.cfg file or on the command line), and
613    process any settings files found therein.
614   </para>
615   
616   <para>
617    Clients of the Pazpar2 webservice interface can selectively override
618    settings for individual targets within the scope of one session. This
619    can be used in conjunction with an external authentication system to
620    determine which resources are to be accessible to which users. Pazpar2
621    itself has no notion of end-users, and so can be used in conjunction
622    with any type of authentication system. Similarly, the authentication
623    tokens submitted to access-controlled search targets can similarly be
624    overridden, to allow use of Pazpar2 in a consortial or multi-library
625    environment, where different end-users may need to be represented to
626    some search targets in different ways. This, again, can be managed
627    using an external database or other lookup mechanism. Setting overrides
628    can be performed either using the
629    <link linkend="command-init">init</link> or the 
630    <link linkend="command-settings">settings</link> webservice
631    command.
632   </para>
633   
634   <para>
635    In fact, every setting that applies to a database (except pz:id, which
636    can only be used for filtering targets to use for a search) can be overridden
637    on a per-session basis. This allows the client to override specific CCL fields
638    for searching, etc., to meet the needs of a session or user.
639   </para>
640
641   <para>
642    Finally, as an extreme case of this, the webservice client can
643    introduce entirely new targets, on the fly, as part of the
644    <link linkend="command-init">init</link> or
645    <link linkend="command-settings">settings</link> command.
646    This is useful if you desire to manage information
647    about your search targets in a separate application such as a database.
648    You do not need any static settings file whatsoever to run Pazpar2 -- as
649    long as the webservice client is prepared to supply the necessary
650    information at the beginning of every session.
651   </para>
652
653   <note>
654    <para>
655     The following discussion of practical issues related to session and settings
656     management are cast in terms of a user interface based on Ajax/Javascript
657     technology. It would apply equally well to many other kinds of browser-based logic.
658    </para>
659   </note>
660
661   <para>
662    Typically, a Javascript client is not allowed to  directly alter the parameters
663    of a session. There are two reasons for this. One has to do with access
664    to information; typically, information about a user will be stored in a
665    system on the server side, or it will be accessible in some way from the server.
666    However, since the Javascript client cannot be entirely trusted (some hostile
667    agent might in fact 'pretend' to be a regular ws client), it is more robust
668    to control session settings from scripting that you run as part of your
669    webserver. Typically, this can be handled during the session initialization,
670    as follows:
671   </para>
672
673   <para>
674    Step 1: The Javascript client loads, and asks the webserver for a new Pazpar2
675    session ID. This can be done using a Javascript call, for instance. Note that
676    it is possible to submit Ajax HTTPXmlRequest calls either to Pazpar2 or to the
677    webserver that Pazpar2 is proxying for. See (XXX Insert link to Pazpar2 protocol).
678   </para>
679
680   <para>
681    Step 2: Code on the webserver authenticates the user, by database lookup,
682    LDAP access, NCIP, etc. Determines which resources the user has access to,
683    and any user-specific parameters that are to be applied during this session.
684   </para>
685
686   <para>
687    Step 3: The webserver initializes a new Pazpar2 settings, and sets user-specific
688    parameters as necessary, using the init webservice command. A new session ID is
689    returned.
690   </para>
691
692   <para>
693    Step 4: The webserver returns this session ID to the Javascript client, which then
694    uses the session ID to submit searches, show results, etc.
695   </para>
696
697   <para>
698    Step 5: When the Javascript client ceases to use the session, Pazpar2 destroys
699    any session-specific information.
700   </para>
701
702   <refsect2>
703    <title>SETTINGS FILE FORMAT</title>
704    <para>
705     Each file contains a root element named &lt;settings&gt;. It may
706     contain one or more &lt;set&gt; elements. The settings and set
707     elements may contain the following attributes. Attributes in the set node
708     overrides those in the setting root element. Each set node must
709     specify (directly, or inherited from the parent node) at least a
710     target, name, and value.
711    </para>
712
713    <variablelist> 
714     <varlistentry>
715      <term>target</term>
716      <listitem>
717       <para>
718        This specifies the search target to which this setting should be
719        applied. Targets are identified by their Z39.50 URL, generally
720        including the host, port, and database name, (e.g.
721        <literal>bagel.indexdata.com:210/marc</literal>).
722        Two wildcard forms are accepted:
723        * (asterisk) matches all known targets;
724        <literal>bagel.indexdata.com:210/*</literal> matches all
725        known databases on the given host.
726       </para>
727       <para>
728        A precedence system determines what happens if there are
729        overlapping values for the same setting name for the same
730        target. A setting for a specific target name overrides a
731        setting which specifies target using a wildcard. This makes it
732        easy to set defaults for all targets, and then override them
733        for specific targets or hosts. If there are
734        multiple overlapping settings with the same name and target
735        value, the 'precedence' attribute determines what happens.
736       </para>
737      </listitem>
738     </varlistentry>
739     <varlistentry>
740      <term>name</term>
741      <listitem>
742       <para>
743        The name of the setting. This can be anything you like.
744        However, Pazpar2 reserves a number of setting names for
745        specific purposes, all starting with 'pz:', and it is a good
746        idea to avoid that prefix if you make up your own setting
747        names. See below for a list of reserved variables.
748       </para>
749      </listitem>
750     </varlistentry>
751     <varlistentry>
752      <term>value</term>
753      <listitem>
754       <para>
755        The value of the setting. Generally, this can be anything you
756        want -- however, some of the reserved settings may expect
757        specific kinds of values.
758       </para>
759      </listitem>
760     </varlistentry>
761     <varlistentry>
762      <term>precedence</term>
763      <listitem>
764       <para>
765        This should be an integer. If not provided, the default value
766        is 0. If two (or more) settings have the same content for
767        target and name, the precedence value determines the outcome.
768        If both settings have the same precedence value, they are both
769        applied to the target(s). If one has a higher value, then the
770        value of that setting is applied, and the other one is ignored.
771       </para>
772      </listitem>
773     </varlistentry>
774    </variablelist>
775
776    <para>
777     By setting defaults for target, name, or value in the root
778     settings node, you can use the settings files in many different
779     ways. For instance, you can use a single file to set defaults for
780     many different settings, like search fields, retrieval syntaxes,
781     etc. You can have one file per server, which groups settings for
782     that server or target. You could also have one file which associates
783     a number of targets with a given setting, for instance, to associate
784     many databases with a given category or class that makes sense
785     within your application.
786    </para>
787
788    <para>
789     The following examples illustrate uses of the settings system to
790     associate settings with targets to meet different requirements.
791    </para>
792
793    <para>
794     The example below associates a set of default values that can be
795     used across many targets. Note the wildcard for targets.
796     This associates the given settings with all targets for which no
797     other information is provided.
798     <screen><![CDATA[
799     <settings target="*">
800
801     <!-- This file introduces default settings for pazpar2 -->
802
803     <!-- mapping for unqualified search -->
804     <set name="pz:cclmap:term" value="u=1016 t=l,r s=al"/>
805
806     <!-- field-specific mappings -->
807     <set name="pz:cclmap:ti" value="u=4 s=al"/>
808     <set name="pz:cclmap:su" value="u=21 s=al"/>
809     <set name="pz:cclmap:isbn" value="u=7"/>
810     <set name="pz:cclmap:issn" value="u=8"/>
811     <set name="pz:cclmap:date" value="u=30 r=r"/>
812     
813     <set name="pz:limitmap:title" value="rpn:@attr 1=4 @attr 6=3"/>
814     <set name="pz:limitmap:date" value="ccl:date"/>
815
816     <!-- Retrieval settings -->
817
818     <set name="pz:requestsyntax" value="marc21"/>
819     <set name="pz:elements" value="F"/>
820
821     <!-- Query encoding -->
822     <set name="pz:queryencoding" value="iso-8859-1"/>
823
824     <!-- Result normalization settings -->
825
826     <set name="pz:nativesyntax" value="iso2709"/>
827     <set name="pz:xslt" value="../etc/marc21.xsl"/>
828
829     </settings>
830
831     ]]></screen>
832    </para>
833
834    <para>
835     The next example shows certain settings overridden for one target,
836     one which returns XML records containing DublinCore elements, and
837     which furthermore requires a username/password.
838     <screen><![CDATA[
839     <settings target="funkytarget.com:210/db1">
840     <set name="pz:requestsyntax" value="xml"/>
841     <set name="pz:nativesyntax" value="xml"/>
842     <set name="pz:xslt" value="../etc/dublincore.xsl"/>
843
844     <set name="pz:authentication" value="myuser/password"/>
845     </settings>
846     ]]></screen>
847    </para>
848
849    <para>
850     The following example associates a specific name/value combination
851     with a number of targets. The targets below are access-restricted,
852     and can only be used by users with special credentials.
853     <screen><![CDATA[
854     <settings name="pz:allow" value="0">
855     <set target="funkytarget.com:210/*"/>
856     <set target="commercial.com:2100/expensiveDb"/>
857     </settings>
858     ]]></screen>
859    </para>
860
861   </refsect2>
862
863   <refsect2>
864    <title>RESERVED SETTING NAMES</title>
865    <para>
866     The following setting names are reserved by Pazpar2 to control the
867     behavior of the client function.
868    </para>
869    
870    <variablelist>
871     <varlistentry>
872      <term>pz:cclmap:xxx</term>
873      <listitem>
874       <para>
875        This establishes a CCL field definition or other setting, for
876        the purpose of mapping end-user queries. XXX is the field or
877        setting name, and the value of the setting provides parameters
878        (e.g. parameters to send to the server, etc.). Please consult
879        the YAZ manual for a full overview of the many capabilities of
880        the powerful and flexible CCL parser.
881       </para>
882       <para>
883        Note that it is easy to establish a set of default parameters,
884        and then override them individually for a given target.
885       </para>
886      </listitem>
887     </varlistentry>
888     <varlistentry id="requestsyntax">
889      <term>pz:requestsyntax</term>
890      <listitem>
891       <para>
892        This specifies the record syntax to use when requesting
893        records from a given server. The value can be a symbolic name like
894        marc21 or xml, or it can be a Z39.50-style dot-separated OID.
895       </para>
896      </listitem>
897     </varlistentry>
898     <varlistentry>
899      <term>pz:elements</term>
900      <listitem>
901       <para>
902        The element set name to be used when retrieving records from a
903        server.
904       </para>
905      </listitem>
906     </varlistentry>
907     <varlistentry>
908      <term>pz:piggyback</term>
909      <listitem>
910       <para>
911        Piggybacking enables the server to retrieve records from the
912        server as part of the search response in Z39.50. Almost all
913        servers support this (or fail it gracefully), but a few
914        servers will produce undesirable results.
915        Set to '1' to enable piggybacking, '0' to disable it. Default
916        is 1 (piggybacking enabled).
917       </para>
918      </listitem>
919     </varlistentry>
920     <varlistentry>
921      <term>pz:nativesyntax</term>
922      <listitem>
923       <para>
924        Specifies how Pazpar2 shoule map retrieved records to XML. Currently
925        supported values are <literal>xml</literal>,
926        <literal>iso2709</literal> and <literal>txml</literal>.
927       </para>
928       <para>
929        The value <literal>iso2709</literal> makes Pazpar2 convert retrieved
930        MARC records to MARCXML. In order to convert to XML, the exact
931        chacater set of the MARC must be known (if not, the resulting
932        XML is probably not well-formed). The character set may be 
933        specified by adding:
934        <literal>;charset=</literal><replaceable>charset</replaceable> to
935        <literal>iso2709</literal>. If omitted, a charset of
936        MARC-8 is assumed. This is correct for most MARC21/USMARC records.
937       </para>
938       <para>
939        The value <literal>txml</literal> is like <literal>iso2709</literal>
940        except that records are converted to TurboMARC instead of MARCXML.
941       </para>
942       <para>
943        The value <literal>xml</literal> is used if Pazpar2 retrieves
944        records that are already XML (no conversion takes place).
945       </para>
946      </listitem>
947     </varlistentry>
948
949     <varlistentry>
950      <term>pz:queryencoding</term>
951      <listitem>
952       <para>
953        The encoding of the search terms that a target accepts. Most
954        targets do not honor UTF-8 in which case this needs to be specified.
955        Each term in a query will be converted if this setting is given.
956       </para>
957      </listitem>
958     </varlistentry>
959
960     <varlistentry>
961      <term>pz:negotiation_charset</term>
962      <listitem>
963       <para>
964        Sets character set for Z39.50 negotiation. Most targets do not support
965        this, and some will even close connection if set (crash on server
966        side or similar). If set, you probably want to set it to
967        <literal>UTF-8</literal>.
968       </para>
969      </listitem>
970     </varlistentry>
971
972     <varlistentry>
973      <term>pz:xslt</term>
974      <listitem>
975       <para>
976        Is a comma separated list of of files that specifies
977        how to convert incoming records to the internal representation.
978       </para>
979       <para>
980        The suffix of each file specifies the kind of tranformation.
981        Suffix "<literal>.xsl</literal>" makes an XSL transform. Suffix
982        "<literal>.mmap</literal>" will use the MMAP transform (described below).
983       </para>
984       <para>
985        The special value "<literal>auto</literal>" will use a file
986        which is the <link linkend="requestsyntax">pz:requestsyntax's</link>
987        value followed by
988        <literal>'.xsl'</literal>.
989       </para>
990       <para>
991        When mapping MARC records, XSLT can be bypassed for increased 
992        performance with the alternate "MARC map" format.  Provide the
993        path of a file with extension ".mmap" containing on each line:
994        <programlisting>
995        &lt;field&gt; &lt;subfield&gt; &lt;metadata element&gt;</programlisting>
996        For example:
997        <programlisting>
998         245 a title
999         500 $ description
1000         773 * citation
1001        </programlisting>
1002        To map the field value specify a subfield of '$'.  To store a 
1003        concatenation of all subfields, specify a subfield of '*'.
1004       </para>
1005      </listitem>
1006     </varlistentry>
1007     <varlistentry>
1008      <term>pz:authentication</term>
1009      <listitem>
1010       <para>
1011        Sets an authentication string for a given server. See the section on
1012        authorization and authentication for discussion.
1013       </para>
1014      </listitem>
1015     </varlistentry>
1016     <varlistentry>
1017      <term>pz:allow</term>
1018      <listitem>
1019       <para>
1020        Allows or denies access to the resources it is applied to. Possible
1021        values are '0' and '1'.
1022        The default is '1' (allow access to this resource).
1023        See the manual section on authorization and authentication for
1024        discussion about how to use this setting.
1025       </para>
1026      </listitem>
1027     </varlistentry>
1028     <varlistentry>
1029      <term>pz:maxrecs</term>
1030      <listitem>
1031       <para>
1032        Controls the maximum number of records to be retrieved from a
1033        server. The default is 100.
1034       </para>
1035      </listitem>
1036     </varlistentry>
1037     <varlistentry>
1038      <term>pz:id</term>
1039      <listitem>
1040       <para>
1041        This setting can't be 'set' -- it contains the ID (normally
1042        ZURL) for a given target, and is useful for filtering --
1043        specifically when you want to select one or more specific
1044        targets in the search command.
1045       </para>
1046      </listitem>
1047     </varlistentry>
1048     <varlistentry>
1049      <term>pz:zproxy</term>
1050      <listitem>
1051       <para>
1052        The 'pz:zproxy' setting has the value syntax 
1053        'host.internet.adress:port', it is used to tunnel Z39.50
1054        requests through the named Z39.50 proxy.
1055       </para>
1056      </listitem>
1057     </varlistentry>
1058     
1059     <varlistentry>
1060      <term>pz:apdulog</term>
1061      <listitem>
1062       <para>
1063        If the 'pz:apdulog' setting is defined and has other value than 0,
1064        then Z39.50 APDUs are written to the log.
1065       </para>
1066      </listitem>
1067     </varlistentry>
1068     
1069     <varlistentry>
1070      <term>pz:sru</term>
1071      <listitem>
1072       <para>
1073        This setting enables
1074        <ulink url="&url.sru;">SRU</ulink>/<ulink url="&url.solr;">SOLR</ulink>
1075        support.
1076        It has four possible settings.
1077        'get', enables SRU access through GET requests. 'post' enables SRU/POST
1078        support, less commonly supported, but useful if very large requests are
1079        to be submitted. 'srw' enables the SRW (SRU over SOAP) variation of
1080        the protocol.
1081       </para>
1082       <para>
1083        A value of 'solr' anables SOLR client support. This is supported
1084        for Pazpar version 1.5.0 and later.
1085       </para>
1086      </listitem>
1087     </varlistentry>
1088     
1089     <varlistentry>
1090      <term>pz:sru_version</term>
1091      <listitem>
1092       <para>
1093        This allows SRU version to be specified. If unset Pazpar2
1094        will the default of YAZ (currently 1.2). Should be set
1095        to 1.1 or 1.2. For SOLR, the current supported/tested version is 1.4
1096       </para>
1097      </listitem>
1098     </varlistentry>
1099     
1100     <varlistentry>
1101      <term>pz:pqf_prefix</term>
1102      <listitem>
1103       <para>
1104        Allows you to specify an arbitrary PQF query language substring.
1105        The provided string is prefixed the user's query after it has been
1106        normalized to PQF internally in pazpar2.
1107        This allows you to attach complex 'filters' to queries for a given
1108        target, sometimes necessary to select sub-catalogs
1109        in union catalog systems, etc.
1110       </para>
1111      </listitem>
1112     </varlistentry>
1113     
1114     <varlistentry>
1115      <term>pz:pqf_strftime</term>
1116      <listitem>
1117       <para>
1118        Allows you to extend a query with dates and operators.
1119        The provided string allows certain substitutions and serves as a
1120        format string.
1121        The special two character sequence '%%' gets converted to the
1122        original query. Other characters leading with the percent sign are
1123        conversions supported by strftime.
1124        All other characters are copied verbatim. For example, the string
1125        <literal>@and @attr 1=30 @attr 2=3 %Y %%</literal>
1126        would search for current year combined with the original PQF (%%).
1127       </para>
1128      </listitem>
1129     </varlistentry>
1130     
1131     <varlistentry>
1132      <term>pz:sort</term>
1133      <listitem>
1134       <para>
1135        Specifies sort criteria to be applied to the result set.
1136        Only works for targets which support the sort service.
1137       </para>
1138      </listitem>
1139     </varlistentry>
1140
1141     <varlistentry>
1142      <term>pz:recordfilter</term>
1143      <listitem>
1144       <para>
1145        Specifies a filter which allows Pazpar2 to only include
1146        records that meet a certain criteria in a result. Unmatched records
1147        will be ignored. The filter takes the form name, name~value, or name=value, which
1148        will include only records with metadata element (name) that has the
1149        substring (~value) given, or matches exactly (=value). If value is omitted all records
1150        with the named
1151        metadata element present will be included.
1152       </para>
1153      </listitem>
1154     </varlistentry>
1155     
1156     <varlistentry>
1157      <term>pz:preferred</term>
1158      <listitem>
1159       <para>
1160        Specifies that a target is preferred, e.g. possible local, faster target. Using block=pref on show command  
1161        will wait for all these targets to return records before releasing the block. If no target is preferred, 
1162        the block=pref will identical to block=1, which release when one target has returned records.     
1163       </para>
1164      </listitem>
1165     </varlistentry>
1166
1167     <varlistentry>
1168      <term>pz:block_timeout</term>
1169      <listitem>
1170       <para>
1171        (Not yet implemented). Specifies the time for which a block should be released anyway.      
1172       </para>
1173      </listitem>
1174     </varlistentry>
1175
1176     <varlistentry>
1177      <term>pz:facetmap:<replaceable>name</replaceable></term>
1178      <listitem>
1179       <para>
1180        Specifies that for field <replaceable>name</replaceable>, the target
1181        supports (native) facets. The value is the name of the
1182        field on the target.
1183       </para>
1184       <note>
1185        <para>
1186         At this point only SOLR targets have been tested with this
1187         facility.
1188        </para>
1189       </note>
1190      </listitem>
1191     </varlistentry>
1192
1193     <varlistentry>
1194      <term>pz:limitmap:<replaceable>name</replaceable></term>
1195      <listitem>
1196       <para>
1197        Specifies attributes for limiting a search to a field - using
1198        the limit parameter for search. In some cases the mapping of 
1199        a field to a value is identical to an existing cclmap field; in
1200        other cases the field must be specified in a different way - for
1201        example to match a complete field (rather than parts of a subfield).
1202       </para>
1203       <para>
1204        The value of limitmap may have one of two forms: referral to
1205        an exisiting CCL field or a raw PQF string. Leading string
1206        determines type; either <literal>ccl:</literal> for CCL field or
1207        <literal>rpn:</literal> for PQF/RPN.
1208       </para>
1209       <note>
1210        <para>
1211         The limitmap facility is supported for Pazpar2 version 1.6.0.
1212        </para>
1213       </note>
1214      </listitem>
1215     </varlistentry>
1216     
1217    </variablelist>
1218
1219   </refsect2>
1220
1221  </refsect1>
1222  <refsect1>
1223   <title>SEE ALSO</title>
1224   <para>
1225    <citerefentry>
1226     <refentrytitle>pazpar2</refentrytitle>
1227     <manvolnum>8</manvolnum>
1228    </citerefentry>
1229    <citerefentry>
1230     <refentrytitle>yaz-icu</refentrytitle>
1231     <manvolnum>1</manvolnum>
1232    </citerefentry>
1233    <citerefentry>
1234     <refentrytitle>pazpar2_protocol</refentrytitle>
1235     <manvolnum>7</manvolnum>
1236    </citerefentry>
1237   </para>
1238  </refsect1>
1239 </refentry>
1240 <!-- Keep this comment at the end of the file
1241 Local variables:
1242 mode: nxml
1243 nxml-child-indent: 1
1244 End:
1245 -->