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