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