Describe new configuration for zoom WRT ZeeRex.
[metaproxy-moved-to-github.git] / doc / zoom.xml
1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.4//EN" 
2     "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
3  <!ENTITY copyright SYSTEM "copyright.xml">
4  <!ENTITY % idcommon SYSTEM "common/common.ent">
5      %idcommon;
6 ]>
7 <refentry id="ref-zoom">
8  <refentryinfo>
9   <productname>Metaproxy</productname>
10   <info><orgname>Index Data</orgname></info>
11  </refentryinfo>
12  
13  <refmeta>
14   <refentrytitle>zoom</refentrytitle>
15   <manvolnum>3mp</manvolnum>
16   <refmiscinfo class="manual">Metaproxy Module</refmiscinfo>
17  </refmeta>
18  
19  <refnamediv>
20   <refname>zoom</refname>
21   <refpurpose>Metaproxy ZOOM Module</refpurpose>
22  </refnamediv>
23  
24  <refsect1>
25   <title>DESCRIPTION</title>
26   <para>
27    This filter implements a generic client based on
28    <ulink url="&url.yaz.zoom;">ZOOM</ulink> of YAZ.
29    The client implements the protocols that ZOOM C does: Z39.50, SRU
30    (GET, POST, SOAP) and SOLR .
31   </para>
32   
33   <para>
34    This filter only deals with Z39.50 on input. The following services
35    are supported: init, search, present and close. The backend target
36    is selected based on the database as part search and
37    <emphasis>not</emphasis> as part of init.
38   </para>
39
40   <para>
41    This filter is an alternative to the z3950_client filter but also
42    shares properties of the virt_db - in that the target is selected
43    for a specific database
44   </para>
45
46   <para>
47    The ZOOM filter relies on a target profile description, which is
48    XML based. It picks the profile for a given database from a web service
49    or it may be locally given for each unique database (AKA virtual database
50    in virt_db). Target profiles are directly and indrectly given as part
51    of the <literal>torus</literal> element in the configuration.
52   </para>
53
54  </refsect1>
55
56  <refsect1>
57   <title>CONFIGURATION</title>
58   <para>
59    The configuration consists of five parts: <literal>torus</literal>,
60    <literal>fieldmap</literal>, <literal>cclmap</literal>,
61    <literal>contentProxy</literal> and <literal>log</literal>.
62   </para>
63   <refsect2>
64    <title>torus</title>
65    <para>
66     The <literal>torus</literal> element specifies target profiles
67     and takes the following content:
68    </para>
69    <variablelist>
70     <varlistentry>
71      <term>attribute <literal>url</literal></term>
72      <listitem>
73       <para>
74        URL of Web service to be used when fetch target profiles from
75        a remote service (Torus normally).
76       </para>
77       <para>
78        The sequence <literal>%query</literal> is replaced with a CQL
79        query for the Torus search.
80       </para>
81       <para>
82        The special sequence <literal>%realm</literal> is replaced by value
83        of attribute <literal>realm</literal> or by realm DATABASE argument.
84       </para>
85       <para>
86        The special sequence <literal>%db</literal> is replaced with
87        a single database while searching. Note that this sequence
88        is no longer needed, because the <literal>%query</literal> can already
89        query for a single database by using CQL query
90        <literal>udb==...</literal>.
91       </para>
92      </listitem>
93     </varlistentry>
94     <varlistentry>
95      <term>attribute <literal>content_url</literal></term>
96      <listitem>
97       <para>
98        URL of Web service to be used to fetch target profile
99        for a given database (udb) of type content. Semantics otherwise like
100        <literal>url</literal> attribute above.
101       </para>
102      </listitem>
103     </varlistentry>
104     <varlistentry>
105       <term>attribute <literal>realm</literal></term>
106       <listitem>
107         <para>
108          The default realm value. Used for %realm in URL, unless
109          specified in DATABASE argument.
110         </para>
111       </listitem>
112     </varlistentry>
113     <varlistentry>
114      <term>attribute <literal>proxy</literal></term>
115      <listitem>
116       <para>
117        HTTP proxy to bse used for fetching target profiles.
118       </para>
119      </listitem>
120     </varlistentry>
121     <varlistentry>
122      <term>attribute <literal>xsldir</literal></term>
123      <listitem>
124       <para>
125        Directory that is searched for XSL stylesheets. Stylesheets
126        are specified in the target profile by the
127        <literal>transform</literal> element.
128       </para>
129      </listitem>
130     </varlistentry>
131     <varlistentry>
132      <term>attribute <literal>element_transform</literal></term>
133      <listitem>
134       <para>
135        Specifies the element that triggers retrieval and transform using
136        the parameters elementSet, recordEncoding, requestSyntax, transform
137        from the target profile. Default value
138        is "pz2", due to the fact that for historical reasons the
139        common format is that used in Pazpar2.
140       </para>
141      </listitem>
142     </varlistentry>
143     <varlistentry>
144      <term>attribute <literal>element_raw</literal></term>
145      <listitem>
146       <para>
147        Specifies an element that triggers retrieval using the
148        parameters elementSet, recordEncoding, requestSyntax from the
149        target profile. Same actions as for element_transform, but without
150        the XSL transform. Useful for debugging.
151        The default value is "raw".
152       </para>
153      </listitem>
154     </varlistentry>
155     <varlistentry>
156      <term>attribute <literal>explain_xsl</literal></term>
157      <listitem>
158       <para>
159        Specifies a stylesheet that converts one or more Torus records
160        to ZeeExplain records. The content of recordData is assumed to be
161        holding each Explain record.
162       </para>
163      </listitem>
164     </varlistentry>
165     <varlistentry>
166      <term>element <literal>records</literal></term>
167      <listitem>
168       <para>
169        Local target profiles. This element may includes zero or
170        more <literal>record</literal> elements (one per target
171        profile). See section TARGET PROFILE.
172       </para>
173      </listitem>
174     </varlistentry>
175    </variablelist>
176   </refsect2>
177   <refsect2 id="fieldmap">
178    <title>fieldmap</title>
179    <para>
180     The <literal>fieldmap</literal> may be specified zero or more times and
181     specifies the map from CQL fields to CCL fields and takes the
182     following content:
183    </para>
184    <variablelist>
185     <varlistentry>
186      <term>attribute <literal>cql</literal></term>
187      <listitem>
188       <para>
189        CQL field that we are mapping "from".
190       </para>
191      </listitem>
192     </varlistentry>
193     <varlistentry>
194      <term>attribute <literal>ccl</literal></term>
195      <listitem>
196       <para>
197        CCL field that we are mapping "to".
198       </para>
199      </listitem>
200     </varlistentry>
201    </variablelist>
202   </refsect2>
203   <refsect2 id="cclmap_base">
204    <title>cclmap</title>
205    <para>
206     The third part of the configuration consists of zero or more
207     <literal>cclmap</literal> elements that specifies
208     <emphasis>base</emphasis> CCL profile to be used for all targets.
209     This configuration, thus, will be combined with cclmap-definitions
210     from the target profile.
211    </para>
212   </refsect2>
213   <refsect2>
214    <title>contentProxy</title>
215    <para>
216     The <literal>contentProxy</literal> element controls content proxy'in.
217     This section
218     is optional and must only be defined if content proxy'ing is enabled.
219    </para>
220    <variablelist>
221     <varlistentry>
222      <term>attribute <literal>server</literal></term>
223      <listitem>
224       <para>
225        Specifies the content proxy host. The host is of the form
226        host[:port]. That is without a method (such as HTTP) and optional
227        port number.
228       </para>
229      </listitem>
230     </varlistentry>
231     <varlistentry>
232      <term>attribute <literal>tmp_file</literal></term>
233      <listitem>
234       <para>
235        Specifies a filename of a session file for content proxy'ing. The
236        file should be an absolute filename that includes
237        <literal>XXXXXX</literal> which is replaced by a unique filename
238        using the mkstemp(3) system call. The default value of this
239        setting is <literal>/tmp/cf.XXXXXX.p</literal>.
240       </para>
241      </listitem>
242     </varlistentry>
243    </variablelist>
244   </refsect2>
245   <refsect2>
246    <title>log</title>
247    <para>
248     The <literal>log</literal> element controls logging for the
249     ZOOM filter.
250    </para>
251    <variablelist>
252     <varlistentry>
253      <term>attribute <literal>apdu</literal></term>
254      <listitem>
255       <para>
256        If the value of apdu is "true", then protocol packages
257        (APDUs and HTTP packages) from the ZOOM filter will be
258        logged to the yaz_log system. A value of "false" will
259        not perform logging of protocol packages (the default
260        behavior).
261       </para>
262      </listitem>
263     </varlistentry>
264    </variablelist>
265   </refsect2>
266  </refsect1>
267  <refsect1>
268   <title>QUERY HANDLING</title>
269   <para>
270    The ZOOM filter accepts three query types: RPN(Type-1), CCL and
271    CQL.
272   </para>
273   <para>
274    Queries are converted in two separate steps. In the first step
275    the input query is converted to RPN/Type-1. This is always
276    the common internal format between step 1 and step 2.
277    In step 2 the query is converted to the native query type of the target.
278   </para>
279   <para>
280    Step 1: for RPN, the query is passed un-modified to the target.
281   </para>
282   <para>
283    Step 1: for CCL, the query is converted to RPN via
284    <link linkend="cclmap"><literal>cclmap</literal></link> elements part of
285    the target profile as well as 
286    <link linkend="cclmap_base">base CCL maps</link>.
287   </para>
288   <para>
289    Step 1: For CQL, the query is converted to CCL. The mappings of
290    CQL fields to CCL fields are handled by
291    <link linkend="fieldmap"><literal>fieldmap</literal></link>
292    elements as part of the target profile. The resulting query, CCL,
293    is the converted to RPN using the schema mentioned earlier (via
294    <literal>cclmap</literal>).
295   </para>
296   <para>
297    Step 2: If the target is Z39.50-based, it is passed verbatim (RPN).
298    If the target is SRU-based, the RPN will be converted to CQL.
299    If the target is SOLR-based, the RPN will be converted to SOLR's query
300    type.
301   </para>
302  </refsect1>
303  
304  <refsect1>
305   <title>SORTING</title>
306   <para>
307    The ZOOM module actively handle CQL sorting - using the SORTBY parameter
308    which was introduced in SRU version 1.2. The conversion from SORTBY clause
309    to native sort for some target is driven by the two parameters: 
310    <link linkend="sortStrategy"><literal>sortStrategy</literal></link>
311    and <link linkend="sortmap"><literal>sortmap_</literal><replaceable>field</replaceable></link>.
312   </para>
313   <para>
314    If a sort field that does not have an equivalent
315    <literal>sortmap_</literal>-mapping is passed un-modified through the
316    conversion. It doesn't throw a diagnostic.
317   </para>
318  </refsect1>
319  
320  <refsect1>
321   <title>TARGET PROFILE</title>
322   <para>
323    The ZOOM module is driven by a number of settings that specifies how
324    to handle each target.
325    Note that unknown elements are silently <emphasis>ignored</emphasis>.
326   </para>
327   <para>
328    The elements, in alphabetical order, are:
329   </para>
330   <variablelist>
331    <varlistentry>
332     <term id="zoom-torus-authentication">authentication</term><listitem>
333     <para>
334      Authentication parameters to be sent to the target. For
335      Z39.50 targets, this will be sent as part of the
336      Init Request. Authentication consists of two components: username
337      and password, separated by a slash.
338     </para>
339     <para>
340      If this value is omitted or empty no authentication information is sent.
341     </para>
342    </listitem>
343    </varlistentry>
344    
345    <varlistentry id="cclmap">
346     <term>cclmap_<replaceable>field</replaceable></term><listitem>
347     <para>
348      This value specifies CCL field (qualifier) definition for some
349      field. For Z39.50 targets this most likely will specify the
350      mapping to a numeric use attribute + a structure attribute.
351      For SRU targets, the use attribute should be string based, in
352      order to make the RPN to CQL conversion work properly (step 2).
353     </para>
354    </listitem>
355    </varlistentry>
356    
357    <varlistentry>
358     <term>cfAuth</term><listitem>
359     <para>
360      When cfAuth is defined, its value will be used as authentication
361      to backend target and authentication setting will be specified
362      as part of a database. This is like a "proxy" for authentication and
363      is used for Connector Framework based targets.
364     </para>
365    </listitem>
366    </varlistentry>
367
368    <varlistentry>
369     <term id="zoom-torus-cfproxy">cfProxy</term><listitem>
370     <para>
371      Specifies HTTP proxy for the target in the form
372      <replaceable>host</replaceable>:<replaceable>port</replaceable>.
373     </para>
374    </listitem>
375    </varlistentry>
376
377    <varlistentry>
378     <term>cfSubDB</term><listitem>
379     <para>
380      Specifies sub database for a Connector Framework based target.
381     </para>
382    </listitem>
383    </varlistentry>
384
385    <varlistentry id="zoom-torus-contentConnector">
386     <term>contentConnector</term><listitem>
387     <para>
388      Specifies a database for content-based proxy'ing.
389     </para>
390    </listitem>
391    </varlistentry>
392
393    <varlistentry>
394     <term>elementSet</term><listitem>
395     <para>
396      Specifies the elementSet to be sent to the target if record
397      transform is enabled (not to be confused' with the record_transform
398      module). The record transform is enabled only if the client uses
399      record syntax = XML and a element set determined by
400      the <literal>element_transform</literal> /
401      <literal>element_raw</literal> from the configuration.
402      By default that is the element sets <literal>pz2</literal>
403      and <literal>raw</literal>.
404      If record transform is not enabled, this setting is 
405      not used and the element set specified by the client
406      is passed verbatim.
407     </para>
408    </listitem>
409    </varlistentry>
410
411    <varlistentry>
412     <term>literalTransform</term><listitem>
413     <para>
414      Specifies a XSL stylesheet to be used if record
415      transform is anabled; see description of elementSet.
416      The XSL transform is only used if the element set is set to the
417      value of <literal>element_transform</literal> in the configuration.
418     </para>
419     <para>
420      The value of literalTransform is the XSL - string encoded.
421     </para>
422    </listitem>
423    </varlistentry>
424    
425    <varlistentry>
426     <term>piggyback</term><listitem>
427     <para>
428      A value of 1/true is a hint to the ZOOM module that this Z39.50
429      target supports piggyback searches, ie Search Response with
430      records. Any other value (false) will prevent the ZOOM module
431      to make use of piggyback (all records part of Present Response).
432     </para>
433    </listitem>
434    </varlistentry>
435    
436    <varlistentry>
437     <term>queryEncoding</term><listitem>
438     <para>
439      If this value is defined, all queries will be converted
440      to this encoding. This should be used for all Z39.50 targets that
441      do not use UTF-8 for query terms.
442     </para>
443    </listitem>
444    </varlistentry>
445    
446    <varlistentry>
447     <term>recordEncoding</term><listitem>
448     <para>
449      Specifies the character encoding of records that are returned
450      by the target. This is primarily used for targets were records
451      are not UTF-8 encoded already. This setting is only used
452      if the record transform is enabled (see description of elementSet).
453     </para>
454    </listitem>
455    </varlistentry>
456
457    <varlistentry>
458     <term>requestSyntax</term><listitem>
459     <para>
460      Specifies the record syntax to be specified for the target
461      if record transform is enabled; see description of elementSet.
462      If record transform is not enabled, the record syntax of the
463      client is passed verbatim to the target.
464     </para>
465    </listitem>
466    </varlistentry>
467
468    <varlistentry id="sortmap">
469     <term>sortmap_<replaceable>field</replaceable></term><listitem>
470     <para>
471      This value the native field for a target. The form of the value is
472      given by <link linkend="sortStrategy">sortStrategy</link>.
473     </para>
474    </listitem>
475    </varlistentry>
476    
477    <varlistentry id="sortStrategy">
478     <term>sortStrategy</term><listitem>
479     <para>
480      Specifies sort strategy for a target. One of:
481      <literal>z3950</literal>, <literal>type7</literal>,
482      <literal>cql</literal>, <literal>sru11</literal> or
483      <literal>embed</literal>. The <literal>embed</literal> chooses type-7
484      or CQL sortby depending on whether Type-1 or CQL is
485      actually sent to the target.
486     </para>
487    </listitem>
488    </varlistentry>
489    
490    <varlistentry>
491     <term>sru</term><listitem>
492     <para>
493      If this setting is set, it specifies that the target is web service
494      based and must be one of : <literal>get</literal>,
495      <literal>post</literal>, <literal>soap</literal>
496      or <literal>solr</literal>.
497     </para>
498    </listitem>
499    </varlistentry>
500
501    <varlistentry>
502     <term>sruVersion</term><listitem>
503     <para>
504      Specifies the SRU version to use. It unset, version 1.2 will be
505      used. Some servers do not support this version, in which case
506      version 1.1 or even 1.0 could be set it.
507     </para>
508    </listitem>
509    </varlistentry>
510
511    <varlistentry>
512     <term>transform</term><listitem>
513     <para>
514      Specifies a XSL stylesheet filename to be used if record
515      transform is anabled; see description of elementSet.
516      The XSL transform is only used if the element set is set to the
517      value of <literal>element_transform</literal> in the configuration.
518     </para>
519    </listitem>
520    </varlistentry>
521
522    <varlistentry>
523     <term>udb</term><listitem>
524     <para>
525      This value is required and specifies the unique database for
526      this profile . All target profiles should hold a unique database.
527     </para>
528    </listitem>
529    </varlistentry>
530
531    <varlistentry id="urlRecipe">
532     <term>urlRecipe</term><listitem>
533     <para>
534      The value of this field is a string that generates a dynamic link
535      based on record content. If the resulting string is non-zero in length
536      a new field, <literal>metadata</literal> with attribute 
537      <literal>type="generated-url"</literal> is generated.
538      The contents of this field is the result of the URL recipe conversion.
539      The urlRecipe value may refer to an existing metadata element by
540      ${field[pattern/result/flags]}, which will take content
541      of field and perform a regular expression conversion using the pattern
542      given. For example: <literal>${md-title[\s+/+/g]}</literal> takes
543      metadata element <literal>title</literal> and converts one or more
544      spaces to a plus character.
545     </para>
546     <para>
547      If the <link linkend="zoom-torus-contentConnector">contentConnector</link>
548      setting also defined, the resulting value is
549      augmented with a session string as well as host name of the
550      content proxy server.
551     </para>
552    </listitem>
553    </varlistentry>
554    
555    <varlistentry>
556     <term>zurl</term><listitem>
557     <para>
558      This is setting is mandatory and specifies the ZURL of the
559      target in the form of host/database. The HTTP method should
560      not be provided as this is guessed from the "sru" attribute value.
561     </para>
562    </listitem>
563    </varlistentry>
564   </variablelist>
565  </refsect1>
566  <refsect1>
567   <title>DATABASE parameters</title>
568   <para>
569    Extra information may be carried in the Z39.50 Database or SRU path,
570    such as authentication to be passed to backend etc. Some of
571    the parameters override TARGET profile values. The format is
572   </para>
573   <para>
574    udb,parm1=value1&amp;parm2=value2&amp;...
575   </para>
576   <para>
577    Where udb is the unique database recognised by the backend and parm1,
578    value1, .. are parameters to be passed. The following describes the
579    supported parameters. Like form values in HTTP the parameters and
580    values are URL encoded. The separator, though, between udb and parameters
581    is a comma rather than a question mark. What follows question mark are
582    HTTP arguments (in this case SRU arguments).
583   </para>
584   <variablelist>  
585    <varlistentry>
586     <term>user</term>
587     <listitem>
588      <para>
589       Specifies user to be passed to backend. If this parameter is
590       omitted, the user will be taken from TARGET profile setting
591       <link linkend="zoom-torus-authentication">
592        <literal>authentication</literal>
593       </link>
594       .
595      </para>
596     </listitem>
597    </varlistentry>
598    <varlistentry>
599     <term>password</term>
600     <listitem>
601      <para>
602       Specifies password to be passed to backend. If this parameters is
603       omitted, the password will be taken from TARGET profile setting
604       <link linkend="zoom-torus-authentication">
605        <literal>authentication</literal>
606       </link>
607       .
608      </para>
609     </listitem>
610    </varlistentry>
611    <varlistentry>
612     <term>proxy</term>
613     <listitem>
614      <para>
615       Specifies one or more proxies for backend. If this parameter is
616       omitted, the proxy will be taken from TARGET profile setting
617       <link linkend="zoom-torus-cfproxy">
618        <literal>cfProxy</literal></link>.
619        The parameter is a list of  comma-separated  host:port entries.
620        Bost host and port must be given for each proxy.
621      </para>
622     </listitem>
623    </varlistentry>
624    <varlistentry>
625     <term>cproxysession</term>
626     <listitem>
627      <para>
628       Session ID for content proxy. This parameter is, generally,
629       not used by anything but the content proxy itself.
630      </para>
631     </listitem>
632    </varlistentry>
633    <varlistentry>
634     <term>nocproxy</term>
635     <listitem>
636      <para>
637       If this parameter is specified, content-proyxing is disabled
638       for the search.
639      </para>
640     </listitem>
641    </varlistentry>
642    <varlistentry>
643     <term>realm</term>
644     <listitem>
645      <para>
646       Session realm to be used for this target, changed the resulting
647       URL to be used for getting a target profile, by changing the
648       value that gets substituted for the %realm string.
649      </para>
650     </listitem>
651    </varlistentry>
652    <varlistentry>
653     <term>x-parm</term>
654     <listitem>
655      <para>
656       All parameters that has prefix x, dash are passed verbatim
657       to the backend.
658      </para>
659     </listitem>
660    </varlistentry>
661   </variablelist>  
662  </refsect1>
663  <refsect1>
664   <title>SCHEMA</title>
665   <literallayout><xi:include
666   xi:href="../xml/schema/filter_zoom.rnc"
667   xi:parse="text"  
668   xmlns:xi="http://www.w3.org/2001/XInclude" />
669   </literallayout>
670  </refsect1>
671  
672  <refsect1>
673   <title>EXAMPLES</title>
674   <para>
675    The following configuration illustrates most of the
676    facilities:
677    <screen><![CDATA[
678     <filter type="zoom">
679       <torus
680          url="http://torus.indexdata.com/src/records/?query=udb%3D%db"
681          proxy="localhost:3128"
682          />
683       <fieldmap cql="cql.anywhere"/>
684       <fieldmap cql="cql.serverChoice"/>
685       <fieldmap cql="dc.creator" ccl="au"/>
686       <fieldmap cql="dc.title" ccl="ti"/>
687       <fieldmap cql="dc.subject" ccl="su"/>
688       
689       <cclmap>
690         <qual name="ocn">
691           <attr type="u" value="12"/>
692           <attr type="s" value="107"/>
693         </qual>
694       </cclmap>
695       <log apdu="true"/>
696     </filter>
697 ]]>
698    </screen>
699   </para>
700   
701  </refsect1> 
702  
703  <refsect1>
704   <title>SEE ALSO</title>
705   <para>
706    <citerefentry>
707     <refentrytitle>metaproxy</refentrytitle>
708     <manvolnum>1</manvolnum>
709    </citerefentry>
710   </para>
711   <para>
712    <citerefentry>
713     <refentrytitle>virt_db</refentrytitle>
714     <manvolnum>3mp</manvolnum>
715    </citerefentry>
716   </para>
717  </refsect1>
718  
719  &copyright;
720 </refentry>
721
722 <!-- Keep this comment at the end of the file
723 Local variables:
724 mode: nxml
725 nxml-child-indent: 1
726 End:
727 -->