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