Add enclosing section for bulk of Introduction.
[pazpar2-moved-to-github.git] / doc / book.xml
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1//EN"
3     "http://www.oasis-open.org/docbook/xml/4.1/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 <book id="book">
13  <bookinfo>
14   <title>Pazpar2 - User's Guide and Reference</title>
15   <author>
16    <firstname>Sebastian</firstname><surname>Hammer</surname>
17   </author>
18   <author>
19    <firstname>Adam</firstname><surname>Dickmeiss</surname>
20   </author>
21   <author>
22    <firstname>Marc</firstname><surname>Cromme</surname>
23   </author>
24   <author>
25    <firstname>Jakub</firstname><surname>Skoczen</surname>
26   </author>
27   <author>
28    <firstname>Mike</firstname><surname>Taylor</surname>
29   </author>
30   <releaseinfo>&version;</releaseinfo>
31   <copyright>
32    <year>&copyright-year;</year>
33    <holder>Index Data</holder>
34   </copyright>
35   <abstract>
36    <simpara>
37     Pazpar2 is a high-performance metasearch engine featuring
38     merging, relevance ranking, record sorting,
39     and faceted results.
40     It is middleware: it has no user interface of its own, but can be
41     configured and controlled by an XML-over-HTTP web-service to provide
42     metasearching functionality behind any user interface.
43    </simpara>
44    <simpara>
45     This document is a guide and reference to Pazpar2 version &version;.
46    </simpara>
47    <simpara>
48     <inlinemediaobject>
49      <imageobject>
50       <imagedata fileref="common/id.png" format="PNG"/>
51    </imageobject>
52     <imageobject>
53      <imagedata fileref="common/id.eps" format="EPS"/>
54    </imageobject>
55    </inlinemediaobject>
56    </simpara>
57   </abstract>
58  </bookinfo>
59  
60  <chapter id="introduction">
61   <title>Introduction</title>
62
63   <section id="what.pazpar2.is">
64   <title>What Pazpar2 is</title>
65   <para>
66    Pazpar2 is a stand-alone metasearch engine with a web-service API, designed
67    to be used either from a browser-based client (JavaScript, Flash,
68    Java applet,
69    etc.), from server-side code, or any combination of the two.
70    Pazpar2 is a highly optimized client designed to
71    search many resources in parallel. It implements record merging,
72    relevance-ranking and sorting by arbitrary data content, and facet
73    analysis for browsing purposes. It is designed to be data-model
74    independent, and is capable of working with MARC, DublinCore, or any
75    other <ulink url="&url.xml;">XML</ulink>-structured response format
76    -- <ulink url="&url.xslt;">XSLT</ulink> is used to normalize and extract
77    data from retrieval records for display and analysis. It can be used
78    against any server which supports the 
79    <ulink url="&url.z39.50;">Z39.50</ulink> or <ulink url="&url.sru;">SRU/SRW</ulink>
80    protocol. Proprietary
81    backend modules can function as connectors between these standard
82    protocols and any non-standard API, including web-site scraping, to
83    support a large number of other protocols.
84   </para>
85   <para>
86    Additional functionality such as
87    user management and attractive displays are expected to be implemented by
88    applications that use Pazpar2. Pazpar2 itself is user-interface independent.
89    Its functionality is exposed through a simple XML-based web-service API,
90    designed to be easy to use from an Ajax-enabled browser, Flash
91    animation, Java applet, etc., or from a higher-level server-side language
92    like PHP, Perl or Java. Because session information can be shared between
93    browser-based logic and server-side scripting, there is tremendous
94    flexibility in how you implement application-specific logic on top
95    of Pazpar2.
96   </para>
97   <para>
98    Once you launch a search in Pazpar2, the operation continues behind the
99    scenes. Pazpar2 connects to servers, carries out searches, and
100    retrieves, deduplicates, and stores results internally. Your application
101    code may periodically inquire about the status of an ongoing operation,
102    and ask to see records or result set facets. Results become
103    available immediately, and it is easy to build end-user interfaces than
104    feel extremely responsive, even when searching more than 100 servers
105    concurrently.
106   </para>
107   <para>
108    Pazpar2 is designed to be highly configurable. Incoming records are
109    normalized to XML/UTF-8, and then further normalized using XSLT to a
110    simple internal representation that is suitable for analysis. By
111    providing XSLT stylesheets for different kinds of result records, you
112    can configure Pazpar2 to work against different kinds of information
113    retrieval servers. Finally, metadata is extracted in a configurable
114    way from this internal record, to support display, merging, ranking,
115    result set facets, and sorting. Pazpar2 is not bound to a specific model
116    of metadata, such as DublinCore or MARC: by providing the right
117    configuration, it can work with any combination of different kinds of data in
118    support of many different applications.
119   </para>
120   <para>
121    Pazpar2 is designed to be efficient and scalable. You can set it up to
122    search several hundred targets in parallel, or you can use it to support
123    hundreds of concurrent users. It is implemented with the same attention
124    to performance and economy that we use in our indexing engines, so that
125    you can focus on building your application without worrying about the
126    details of metasearch logic. You can devote all of your attention to
127    usability and let Pazpar2 do what it does best -- metasearch.
128   </para>
129   <para>
130    If you wish to connect to commercial or other databases which do not
131    support open standards, please contact Index Data on
132    <email>info@indexdata.com</email>. We have a
133    proprietary framework for building connectors that enable Pazpar2
134    to access
135    thousands of online databases, in addition to the vast number of catalogs
136    and online services that support the Z39.50/SRU/SRW protocols.
137   </para>
138   <para>
139    Pazpar2 is our attempt to re-think the traditional paradigms for
140    implementing and deploying metasearch logic, with an uncompromising
141    approach to performance, and attempting to make maximum use of the
142    capabilities of modern browsers. The demo user interface that
143    accompanies the distribution is but one example. If you think of new
144    ways of using Pazpar2, we hope you'll share them with us, and if we
145    can provide assistance with regards to training, design, programming,
146    integration with different backends, hosting, or support, please don't
147    hesitate to contact us. If you'd like to see functionality in Pazpar2
148    that is not there today, please don't hesitate to contact us. It may
149    already be in our development pipeline, or there might be a
150    possibility for you to help out by sponsoring development time or
151    code. Either way, get in touch and we will give you straight answers.
152   </para>
153   <para>
154    Enjoy!
155   </para>
156   <para>
157    Pazpar2 is covered by the GNU General Public License (GPL) version 2.
158    See <xref linkend="license"/> for further information.
159   </para>
160   </section>
161
162   <section id="name">
163    <title>A note on the name Pazpar2</title>
164    <para>
165     The name Pazpar2 derives from three sources.  One one hand, it is
166     Index Data's second major piece of software that does parallel
167     searching of Z39.50 targets.  On the other, it is a near-homophone
168     of Passpartout, the ever-helpful servant in Jules Verne's novel
169     Around the World in Eighty Days (who helpfully uses the language
170     of his master).  Finally, "passe par tout" means something like
171     "passes through anything" in French -- on other words, a universal
172     solution, or if you like a MasterKey.
173    </para>
174   </section>
175  </chapter>
176
177  <chapter id="installation">
178   <title>Installation</title>
179   <para>
180    The Pazpar2 package is very small. It includes documentation as well
181    as the Pazpar2 server. The package also includes a simple user
182    interface test1 which consists of a single HTML page and a single
183    JavaScript file to illustrate the use of Pazpar2.
184   </para>
185   <para>
186    Pazpar2 depends on the following tools/libraries:
187    <variablelist>
188     <varlistentry><term><ulink url="&url.yaz;">YAZ</ulink></term>
189      <listitem>
190       <para>
191        The popular Z39.50 toolkit for the C language.
192        YAZ <emphasis>must</emphasis> be compiled with Libxml2/Libxslt support.
193       </para>
194      </listitem>
195     </varlistentry>
196     <varlistentry><term><ulink url="&url.icu;">International
197        Components for Unicode (ICU)</ulink></term>
198      <listitem>
199       <para>
200        ICU provides Unicode support for non-English languages with
201        character sets outside the range of 7bit ASCII, like
202        Greek, Russian, German and French. Pazpar2 uses the ICU
203        Unicode character conversions, Unicode normalization, case
204        folding and other fundamental operations needed in
205        tokenization, normalization and ranking of records. 
206       </para>
207       <para>
208        Compiling, linking, and usage of the ICU libraries is optional,
209        but strongly recommended for usage in an international
210        environment.  
211       </para>
212      </listitem>
213     </varlistentry>
214    </variablelist>
215   </para>
216   <para>
217    In order to compile Pazpar2, a C compiler which supports C99 or later
218    is required.
219   </para>
220
221   <section id="installation.unix">
222    <title>Installation on Unix (from Source)</title>
223    <para>
224     The latest source code for Pazpar2 is available from
225     <ulink url="&url.pazpar2.download;"/>.
226      Only few systems have none of the required
227      tools binary packages.
228      If, for example, Libxml2/libXSLT libraries
229     are already installed as development packages use these.
230    </para>
231    
232    <para>
233     Ensure that the development libraries + header files are
234     available on your system before compiling Pazpar2. For installation
235     of YAZ, refer to the YAZ installation chapter.
236    </para>
237    <screen>
238     gunzip -c pazpar2-version.tar.gz|tar xf -
239     cd pazpar2-version
240     ./configure
241     make
242     su
243     make install
244    </screen>
245    <para>
246     The <literal>make install</literal> will install manpages as well as the
247     Pazpar2 server, <literal>pazpar2</literal>, 
248     in PREFIX<literal>/sbin</literal>.
249     By default, PREFIX is <literal>/usr/local/</literal> . This can be
250     changed with configure option <option>--prefix</option>.
251    </para>
252   </section>
253
254   <section id="installation.win32">
255     <title>Installation on Windows (from Source)</title>
256     <para>
257       Pazpar2 can be built for Windows using
258       <ulink url="&url.vstudio;">Microsoft Visual Studio</ulink>.
259       The support files for building YAZ on Windows are located in the
260       <filename>win</filename> directory. The compilation is performed
261       using the <filename>win/makefile</filename> which is to be
262       processed by the NMAKE utility part of Visual Studio.
263     </para>
264     <para>
265       Ensure that the development libraries + header files are
266       available on your system before compiling Pazpar2. For installation
267       of YAZ, refer to the YAZ installation chapter.
268       It is easiest if YAZ and Pazpar2 are unpacked in the same
269       directory (side-by-side).
270     </para>
271     <para>
272       The compilation is tuned by editing the makefile of Pazpar2.
273       The process is similar to YAZ. Adjust the various directories
274       <literal>YAZ_DIR</literal>, <literal>ZLIB_DIR</literal>, ..
275     </para>
276     <para>
277       Compile Pazpar2 by invoking <application>nmake</application> in
278       the <filename>win</filename> directory.
279       The resulting binaries of the build process are located in the
280       <filename>bin</filename> of the Pazpar2 source
281       tree - including the <filename>pazpar2.exe</filename> and necessary DLLs.
282     </para>
283     <para>
284       The Windows version of Pazpar2 is a console application. It may
285       be installed as a Windows Service by adding option 
286       <literal>-install</literal> for the pazpar2 program. This will
287       register Pazpar2 as a service and use the other options provided
288       in the same invocation. For example:
289       <screen>
290         cd \MyPazpar2\etc
291         ..\bin\pazpar2 -install -f pazpar2.cfg -l pazpar2.log
292       </screen>
293       The Pazpar2 service may now be controlled via the Service Control
294       Panel. It may be unregistered by passing the <literal>-remove</literal>
295       option. Example:
296       <screen>
297         cd \MyPazpar2\etc
298         ..\bin\pazpar2 -remove
299       </screen>
300     </para>
301   </section>
302
303   <section id="installation.test1">
304    <title>Installation of test1 interface</title>
305    <para>
306     In this section we outline how to install a simple interface that
307     is part of the Pazpar2 source package. Note that Debian users can
308     save time by just installing package <literal>pazpar2-test1</literal>.
309    </para>
310    <para>
311     A web server must be installed and running on the system, such as Apache.
312    </para>
313
314    <para>
315     Start the Pazpar2 daemon using the 'in-source' binary of the Pazpar2
316     daemon. On Unix the process is:
317     <screen>
318      cd etc
319      cp pazpar2.cfg.dist pazpar2.cfg
320      ../src/pazpar2 -f pazpar2.cfg
321     </screen>
322     And on Windows:
323     <screen>
324      cd etc
325      copy pazpar2.cfg.dist pazpar2.cfg
326      ..\bin\pazpar2 -f pazpar2.cfg
327     </screen>
328     This will start a Pazpar2 listener on port 9004. It will proxy 
329     HTTP requests to localhost - port 80, which we assume will be the regular
330     HTTP server on the system. Inspect and modify pazpar2.cfg as needed
331     if this is to be changed. The pazpar2.cfg includes settings from the
332     file <filename>settings/edu.xml</filename>
333     to use for searches.
334    </para>
335    <para>
336     Make a new console and move to the other stuff.
337     For more information about pazpar2 options refer to the manpage.
338    </para>
339
340    <para>
341     The test1 UI is located in <literal>www/test1</literal>. Ensure this
342     directory is available to the web server by either copying 
343     <literal>test1</literal> to the document root, create a symlink or
344     use Apache's <literal>Alias</literal> directive.
345    </para>
346
347    <para>
348     The interface test1 interface should now be available on port 8004.
349    </para>
350    <para>
351     If you don't see the test1 interface. See if test1 is really available
352     on the same URL but on port 80. If it's not, the Apache configuration
353     (or other) is not correct. 
354    </para>
355    <para>
356     In order to use Apache as frontend for the interface on port 80
357     for public access etc., refer to 
358     <xref linkend="installation.apache2proxy"/>.
359    </para>
360   </section>
361
362   <section id="installation.debian">
363    <title>Installation on Debian GNU/Linux</title>
364    <para>
365     Index Data provides Debian packages for Pazpar2. These are prepared
366     for Debian versions Etch and Lenny (as of 2007).
367     These packages are available at
368     <ulink url="&url.pazpar2.download.debian;"/>.
369    </para>
370   </section>
371
372   <section id="installation.apache2proxy">
373    <title>Apache 2 Proxy</title>
374    <para>
375     Apache 2 has a 
376     <ulink url="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html">
377      proxy module
378     </ulink> which allows Pazpar2 to become a backend to an Apache 2
379     based web service. The Apache 2 proxy must operate in the
380     <emphasis>Reverse</emphasis> Proxy mode.
381    </para>
382    
383    <para>
384     On a Debian based Apache 2 system, the relevant modules can
385     be enabled with:
386     <screen>
387      sudo a2enmod proxy_http
388     </screen>
389    </para>
390
391    <para>
392     Traditionally Pazpar2 interprets URL paths with suffix 
393     <literal>/search.pz2</literal>.
394     The 
395     <ulink 
396      url="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass"
397      >ProxyPass</ulink> directive of Apache must be used to map a URL path
398     the the Pazpar2 server (listening port).
399    </para>
400
401    <note>
402     <para>
403      The ProxyPass directive takes a prefix rather than
404      a suffix as URL path. It is important that the Java Script code
405      uses the prefix given for it.
406     </para>
407    </note>
408
409    <example id="installation.apache2proxy.example">
410     <title>Apache 2 proxy configuration</title>
411     <para>
412      If Pazpar2 is running on port 8004 and the portal is using
413      <filename>search.pz2</filename> inside portal in directory
414      <filename>/myportal/</filename> we could use the following
415      Apache 2 configuration:
416
417      <screen><![CDATA[
418       <IfModule mod_proxy.c>
419        ProxyRequests Off
420       
421        <Proxy *>
422         AddDefaultCharset off
423         Order deny,allow
424         Allow from all
425        </Proxy>
426       
427        ProxyPass /myportal/search.pz2 http://localhost:8004/search.pz2
428        ProxyVia Off
429       </IfModule>
430       ]]></screen>
431     </para>
432    </example>
433   </section>
434
435  </chapter>
436
437  <chapter id="using">
438   <title>Using Pazpar2</title>
439   <para>
440    This chapter provides a general introduction to the use and
441    deployment of Pazpar2. 
442   </para>
443
444   <section id="architecture">
445    <title>Pazpar2 and your systems architecture</title>
446    <para>
447     Pazpar2 is designed to provide asynchronous, behind-the-scenes
448     metasearching functionality to your application, exposing this
449     functionality using a simple webservice API that can be accessed
450     from any number of development environments. In particular, it is
451     possible to combine Pazpar2 either with your server-side dynamic
452     website scripting, with scripting or code running in the browser, or
453     with any combination of the two. Pazpar2 is an excellent tool for
454     building advanced, Ajax-based user interfaces for metasearch
455     functionality, but it isn't a requirement -- you can choose to use
456     Pazpar2 entirely as a backend to your regular server-side scripting.
457     When you do use Pazpar2 in conjunction
458     with browser scripting (JavaScript/Ajax, Flash, applets,
459     etc.), there are    special considerations.
460    </para>
461
462    <para>
463     Pazpar2 implements a simple but efficient HTTP server, and it is
464     designed to interact directly with scripting running in the browser
465     for the best possible performance, and to limit overhead when
466     several browser clients generate numerous webservice requests.
467     However, it is still desirable to use a conventional webserver,
468     such as Apache, to serve up graphics, HTML documents, and
469     server-side scripting. Because the security sandbox environment of
470     most browser-side programming environments only allows communication
471     with the server from which the enclosing HTML page or object
472     originated, Pazpar2 is designed so that it can act as a transparent
473     proxy in front of an existing webserver (see <xref
474      linkend="pazpar2_conf"/> for details). 
475     In this mode, all regular
476     HTTP requests are transparently passed through to your webserver,
477     while Pazpar2 only intercepts search-related webservice requests.
478    </para>
479
480    <para>
481     If you want to expose your combined service on port 80, you can
482     either run your regular webserver on a different port, a different
483     server, or a different IP address associated with the same server.
484    </para>
485
486    <para>
487     Pazpar2 can also work behind
488     a reverse Proxy. Refer to <xref linkend="installation.apache2proxy"/>)
489     for more information.
490     This allows your existing HTTP server to operate on port 80 as usual.
491     Pazpar2 can be started on another (internal) port.
492    </para>
493
494    <para>
495     Sometimes, it may be necessary to implement functionality on your
496     regular webserver that makes use of search results, for example to
497     implement data import functionality, emailing results, history
498     lists, personal citation lists, interlibrary loan functionality,
499     etc. Fortunately, it is simple to exchange information between
500     Pazpar2, your browser scripting, and backend server-side scripting.
501     You can send a session ID and possibly a record ID from your browser
502     code to your server code, and from there use Pazpar2s webservice API
503     to access result sets or individual records. You could even 'hide'
504     all of Pazpar2s functionality between your own API implemented on
505     the server-side, and access that from the browser or elsewhere. The
506     possibilities are just about endless.
507    </para>
508   </section>
509
510   <section id="data_model">
511    <title>Your data model</title>
512    <para>
513     Pazpar2 does not have a preconceived model of what makes up a data
514     model. There are no assumptions that records have specific fields or
515     that they are organized in any particular way. The only assumption
516     is that data comes packaged in a form that the software can work
517     with (presently, that means XML or MARC), and that you can provide
518     the necessary information to massage it into Pazpar2's internal
519     record abstraction.
520    </para>
521
522    <para>
523     Handling retrieval records in Pazpar2 is a two-step process. First,
524     you decide which data elements of the source record you are
525     interested in, and you specify any desired massaging or combining of
526     elements using an XSLT stylesheet (MARC records are automatically
527     normalized to <ulink url="&url.marcxml;">MARCXML</ulink> before this step).
528     If desired, you can run multiple XSLT stylesheets in series to accomplish
529     this, but the output of the last one should be a representation of the
530     record in a schema that Pazpar2 understands.
531    </para>
532
533    <para>
534     The intermediate, internal representation of the record looks like
535     this:
536     <screen><![CDATA[
537      <record   xmlns="http://www.indexdata.com/pazpar2/1.0"
538      mergekey="title The Shining author King, Stephen">
539
540      <metadata type="title">The Shining</metadata>
541
542      <metadata type="author">King, Stephen</metadata>
543
544      <metadata type="kind">ebook</metadata>
545
546      <!-- ... and so on -->
547     </record>
548      ]]></screen>
549
550     As you can see, there isn't much to it. There are really only a few
551     important elements to this file.
552    </para>
553
554    <para>
555     Elements should belong to the namespace
556     <literal>http://www.indexdata.com/pazpar2/1.0</literal>.
557     If the root node contains the
558     attribute 'mergekey', then every record that generates the same
559     merge key (normalized for case differences, white space, and
560     truncation) will be joined into a cluster. In other words, you
561     decide how records are merged. If you don't include a merge key,
562     records are never merged. The 'metadata' elements provide the meat
563     of the elements -- the content. the 'type' attribute is used to
564     match each element against processing rules that determine what
565     happens to the data element next.
566    </para>
567
568    <para>
569     The next processing step is the extraction of metadata from the
570     intermediate representation of the record. This is governed by the
571     'metadata' elements in the 'service' section of the configuration
572     file. See <xref linkend="config-server"/> for details. The metadata
573     in the retrieval record ultimately drives merging, sorting, ranking,
574     the extraction of browse facets, and display, all configurable.
575    </para>
576   </section>
577
578   <section id="client">
579    <title>Client development overview</title>
580    <para>
581     You can use Pazpar2 from any environment that allows you to use
582     webservices. The initial goal of the software was to support
583     Ajax-based applications, but there literally are no limits to what
584     you can do. You can use Pazpar2 from Javascript, Flash, Java, etc.,
585     on the browser side, and from any development environment on the
586     server side, and you can pass session tokens and record IDs freely
587     around between these environments to build sophisticated applications.
588     Use your imagination.
589    </para>
590
591    <para>
592     The webservice API of Pazpar2 is described in detail in <xref
593      linkend="pazpar2_protocol"/>.
594    </para>
595
596    <para>
597     In brief, you use the 'init' command to create a session, a
598     temporary workspace which carries information about the current
599     search. You start a new search using the 'search' command. Once the
600     search has been started, you can follow its progress using the
601     'stat', 'bytarget', 'termlist', or 'show' commands. Detailed records
602     can be fetched using the 'record' command.
603    </para>
604   </section>
605
606   &sect-ajaxdev;
607
608   <section id="nonstandard">
609    <title>Connecting to non-standard resources</title>
610    <para>
611     Pazpar2 uses Z39.50 as its switchboard language -- i.e. as far as it
612     is concerned, all resources speak Z39.50, or its webservices derivatives,
613     SRU/SRW. It is, however, equipped
614     to handle a broad range of different server behavior, through
615     configurable query mapping and record normalization. If you develop
616     configuration, stylesheets, etc., for a new type of resources, we
617     encourage you to share your work. But you can also use Pazpar2 to
618     connect to hundreds of resources that do not support standard
619     protocols.
620    </para>
621
622    <para>
623     For a growing number of resources, Z39.50 is all you need. Over the
624     last few years, a number of commercial, full-text resources have
625     implemented Z39.50. These can be used through Pazpar2 with little or
626     no effort. Resources that use non-standard record formats will
627     require a bit of XSLT work, but that's all.
628    </para>
629
630    <para>
631     But what about resources that don't support Z39.50 at all? Some resources might
632     support OpenSearch, private, XML/HTTP-based protocols, or something
633     else entirely. Some databases exist only as web user interfaces and
634     will require screen-scraping. Still others exist only as static
635     files, or perhaps as databases supporting the OAI-PMH protocol.
636     There is hope! Read on.
637    </para>
638
639    <para>
640     Index Data continues to advocate the support of open standards. We
641     work with database vendors to support standards, so you don't have
642     to worry about programming against non-standard services. We also
643     provide tools (see <ulink
644      url="http://www.indexdata.com/simpleserver">SimpleServer</ulink>)
645     which make it comparatively easy to build gateways against servers
646     with non-standard behavior. Again, we encourage you to share any
647     work you do in this direction.
648    </para>
649
650    <para>
651     But the bottom line is that working with non-standard resources in
652     metasearching is really, really hard. If you want to build a
653     project with Pazpar2, and you need access to resources with
654     non-standard interfaces, we can help. We run gateways to more than
655     2,000 popular, commercial databases and other resources,
656     making it simple 
657     to plug them directly into Pazpar2. For a small annual fee per
658     database, we can help you establish connections to your licensed
659     resources. Meanwhile, you can help! If you build your own
660     standards-compliant gateways, host them for others, or share the
661     code! And tell your vendors that they can save everybody money and
662     increase the appeal of their resources by supporting standards.
663    </para>
664
665    <para>
666     There are those who will ask us why we are using Z39.50 as our
667     switchboard language rather than a different protocol. Basically,
668     we believe that Z39.50 is presently the most widely implemented 
669     information retrieval protocol that has the level of functionality
670     required to support a good metasearching experience (structured
671     searching, structured, well-defined results). It is also compact and
672     efficient, and there is a very broad range of tools available to
673     implement it.
674    </para>
675   </section>
676
677   <section id="unicode">
678    <title>Unicode Compliance</title>
679    <para>
680     Pazpar2 is Unicode compliant and language and locale aware but relies
681     on character encoding for the targets to be specified correctly if
682     the targets themselves are not UTF-8 based (most aren't).
683     Just a few bad behaving targets can spoil the search experience
684     considerably if for example Greek, Russian or otherwise non 7-bit ASCII
685     search terms are entered. In these cases some targets return
686     records irrelevant to the query, and the result screens will be
687     cluttered with noise.
688    </para>
689    <para>
690     While noise from misbehaving targets can not be removed, it can
691     be reduced using truly Unicode based ranking. This is an
692     option which is available to the system administrator if ICU
693     support is compiled into Pazpar2, see
694     <xref linkend="installation"/> for details.
695    </para>
696    <para>
697     In addition, the ICU tokenization and normalization rules must
698     be defined in the master configuration file described in 
699     <xref linkend="config-server"/>.
700    </para>
701   </section>
702
703   <section id="load_balancing">
704    <title>Load balancing</title>
705    <para>
706      Just like any web server, Pazpar2, can be load balanced by a standard hardware or software load balancer as long as the session stickiness is ensured. If you are already running the Apache2 web server in front of Pazpar2 and use the apache mod_proxy module to 'relay' client requests to Pazpar2, this set up can be easily extended to include load balancing capabilites. To do so you need to enable the <ulink url="http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html">
707      mod_proxy_balancer
708     </ulink> module in your Apache2 installation.
709    </para>
710    
711    <para>
712     On a Debian based Apache 2 system, the relevant modules can
713     be enabled with:
714     <screen>
715      sudo a2enmod proxy_http
716     </screen>
717    </para>
718
719    <para>
720      The mod_proxy_balancer can pass all 'sessionsticky' requests to the same backend worker as long as the requests are marked with the originating worker's ID (called 'route'). If the Pazpar2 serverID is configured (by setting an 'id' attribute on the 'server' element in the Pazpar2 configuration file) Pazpar2 will append it to the 'session' element returned during the 'init' in a mod_proxy_balancer compatible manner. Since the 'session' is then re-sent by the client (for all pazpar2 request besides 'init'), the balancer can use the marker to pass the request to the right route. To do so the balancer needs to be configured to inspect the 'session' parameter.
721    </para>
722
723    <example id="load_balancing.example">
724     <title>Apache 2 load balancing configuration</title>
725     <para>
726      Having 4 Pazpar2 instances running on the same host, port range of 8004-8007 and serverIDs of: pz1, pz2, pz3 and pz4 respectively we could use the following Apache 2 configuration to expose a single pazpar2 'endpoint' on a standard (<filename>/pazpar2/search.pz2</filename>) location:
727
728      <screen><![CDATA[
729        <Proxy *>
730          AddDefaultCharset off
731          Order deny,allow
732          Allow from all
733        </Proxy>
734        ProxyVia Off
735
736        # 'route' has to match the configured pazpar2 server ID
737        <Proxy balancer://pz2cluster>
738          BalancerMember http://localhost:8004 route=pz1
739          BalancerMember http://localhost:8005 route=pz2
740          BalancerMember http://localhost:8006 route=pz3
741          BalancerMember http://localhost:8007 route=pz4
742        </Proxy>
743
744        # route is resent in the 'session' param which has the form: 
745        # 'sessid.serverid', understandable by the mod_proxy_load_balancer
746        # this is not going to work if the client tampers with the 'session' param
747        ProxyPass /pazpar2/search.pz2 balancer://pz2cluster lbmethod=byrequests stickysession=session nofailover=On]]></screen>
748
749      The 'ProxyPass' line sets up a reverse proxy for request ‘/pazpar2/search.pz2’ and delegates all requests to the load balancer (virtual worker) with name ‘pz2cluster’. Sticky sessions are enabled and implemented using the ‘session’ parameter. The ‘Proxy’ section lists all the servers (real workers) which the load balancer can use.
750    </para>
751
752   </example>
753
754   </section>
755
756
757  </chapter> <!-- Using Pazpar2 -->
758
759  <reference id="reference">
760   <title>Reference</title>
761   <partintro id="reference-introduction">
762    <para>
763     The material in this chapter is drawn directly from the individual
764     manual entries.
765    </para>
766   </partintro>
767   &manref;
768  </reference>
769
770  <appendix id="license"><title>License</title>
771   
772    <para>
773     Pazpar2,
774     Copyright &copy; &copyright-year; Index Data.
775    </para>
776    
777    <para>
778     Pazpar2 is free software; you can redistribute it and/or modify it under
779     the terms of the GNU General Public License as published by the Free
780     Software Foundation; either version 2, or (at your option) any later
781     version.
782    </para>
783    
784    <para>
785     Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
786     WARRANTY; without even the implied warranty of MERCHANTABILITY or
787     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
788     for more details.
789    </para>
790    
791    <para>
792     You should have received a copy of the GNU General Public License
793     along with Pazpar2; see the file LICENSE.  If not, write to the
794     Free Software Foundation, 
795     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
796    </para>
797
798  </appendix>
799
800  &gpl2;
801  
802 </book>
803
804  <!-- Keep this comment at the end of the file
805  Local variables:
806  mode: sgml
807  sgml-omittag:t
808  sgml-shorttag:t
809  sgml-minimize-attributes:nil
810  sgml-always-quote-attributes:t
811  sgml-indent-step:1
812  sgml-indent-data:t
813  sgml-parent-document: nil
814  sgml-local-catalogs: nil
815  sgml-namecase-general:t
816  End:
817  -->