Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/pazpar2
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 14 Jun 2013 09:28:58 +0000 (11:28 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 14 Jun 2013 09:28:58 +0000 (11:28 +0200)
22 files changed:
IDMETA
NEWS
configure.ac
debian/changelog
debian/control
doc/book.xml
doc/pazpar2_conf.xml
doc/pazpar2_protocol.xml
pazpar2.spec
src/charsets.c
src/charsets.h
src/http_command.c
src/record.h
src/relevance.c
src/relevance.h
src/session.c
test/test_http.urls
test/test_http_5.res
test/test_http_6.res
test/test_icu.urls
test/test_icu_4.res
win/makefile

diff --git a/IDMETA b/IDMETA
index f06a87b..921908f 100644 (file)
--- a/IDMETA
+++ b/IDMETA
@@ -1,4 +1,4 @@
 DEBIAN_DIST="wheezy squeeze"
 UBUNTU_DIST="quantal precise oneiric lucid"
 CENTOS_DIST="centos5 centos6"
-VERSION=1.6.31
+VERSION=1.6.32
diff --git a/NEWS b/NEWS
index a58a78c..cd6f0cf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+--- 1.6.32 2013/06/14
+
+Experimental support for snippets. If argument snippets=1 is given
+for command record or show, the text will include <match>-tags for
+those area that matches.
+
 Fix memory leak WRT client structures (incorrect inc ref count).
 
 Log when a HTTP response is serialized and the time elapsed.
index f37b77c..ae8cf20 100644 (file)
@@ -24,7 +24,7 @@ AC_LANG(C)
 
 AC_C_INLINE
 
-YAZ_INIT([static icu],[4.2.40])
+YAZ_INIT([static icu],[4.2.58])
 if test -z "$YAZLIB"; then
        AC_MSG_ERROR([YAZ development libraries missing])
 fi
index 5791f98..b6fec63 100644 (file)
@@ -1,3 +1,9 @@
+pazpar2 (1.6.32-1indexdata) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Fri, 14 Jun 2013 10:50:14 +0200
+
 pazpar2 (1.6.31-1indexdata) unstable; urgency=low
 
   * Upstream.
index c03642a..f87fee0 100644 (file)
@@ -4,7 +4,7 @@ Priority: extra
 Maintainer: Adam Dickmeiss <adam@indexdata.dk>
 Build-Depends: debhelper (>= 5),
        autotools-dev,
-       libyaz4-dev (>= 4.2.40),
+       libyaz4-dev (>= 4.2.58),
        docbook-xsl,
        libgnutls-dev
 Standards-Version: 3.7.2
index e223d7e..e71bc69 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" standalone="no"?>
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
-    "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" 
+    "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"
 [
      <!ENTITY % local SYSTEM "local.ent">
      %local;
    </simpara>
   </abstract>
  </bookinfo>
+
  <chapter id="introduction">
   <title>Introduction</title>
-  
+
   <section id="what.pazpar2.is">
    <title>What Pazpar2 is</title>
    <para>
@@ -78,8 +78,8 @@
     other <ulink url="&url.xml;">XML</ulink>-structured response format
     -- <ulink url="&url.xslt;">XSLT</ulink> is used to normalize and extract
     data from retrieval records for display and analysis. It can be used
-    against any server which supports the 
-    <ulink url="&url.z39.50;">Z39.50</ulink>, <ulink url="&url.sru;">SRU/SRW</ulink> 
+    against any server which supports the
+    <ulink url="&url.z39.50;">Z39.50</ulink>, <ulink url="&url.sru;">SRU/SRW</ulink>
     or <ulink url="&url.solr;">SOLR</ulink> protocol. Proprietary
     backend modules can function as connectors between these standard
     protocols and any non-standard API, including web-site scraping, to
       Greek, Russian, German and French. Pazpar2 uses the ICU
       Unicode character conversions, Unicode normalization, case
       folding and other fundamental operations needed in
-      tokenization, normalization and ranking of records. 
+      tokenization, normalization and ranking of records.
      </para>
      <para>
       Compiling, linking, and usage of the ICU libraries is optional,
       but strongly recommended for usage in an international
-      environment.  
+      environment.
      </para>
     </listitem>
     </varlistentry>
     For example, if Libxml2/libXSLT libraries
     are already installed as development packages, use these.
    </para>
-   
+
    <para>
     Ensure that the development libraries and header files are
     available on your system before compiling Pazpar2. For installation
    </screen>
    <para>
     The <literal>make install</literal> will install manpages as well as the
-    Pazpar2 server, <literal>pazpar2</literal>, 
+    Pazpar2 server, <literal>pazpar2</literal>,
     in PREFIX<literal>/sbin</literal>.
     By default, PREFIX is <literal>/usr/local/</literal> . This can be
     changed with configure option <option>--prefix</option>.
    </para>
   </section>
-  
+
   <section id="installation.win32">
    <title>Installation from source on Windows</title>
    <para>
    </para>
    <para>
     The Windows version of Pazpar2 is a console application. It may
-    be installed as a Windows Service by adding option 
+    be installed as a Windows Service by adding option
     <literal>-install</literal> for the pazpar2 program. This will
     register Pazpar2 as a service and use the other options provided
     in the same invocation. For example:
     </screen>
    </para>
   </section>
-  
+
   <section id="installation.test1">
    <title>Installation of test interfaces</title>
    <para>
     In this section we show how to make available the set of simple
     interfaces that are part of the Pazpar2 source package, and which
-    demonstrate some ways to use Pazpar2.  (Note that Debian users can 
+    demonstrate some ways to use Pazpar2.  (Note that Debian users can
     save time by just installing the package <literal>pazpar2-test1</literal>.)
    </para>
    <para>
      copy pazpar2.cfg.dist pazpar2.cfg
      ..\bin\pazpar2 -f pazpar2.cfg
     </screen>
-    This will start a Pazpar2 listener on port 9004. It will proxy 
+    This will start a Pazpar2 listener on port 9004. It will proxy
     HTTP requests to port 80 on localhost, which we assume will be the regular
     HTTP server on the system. Inspect and modify pazpar2.cfg as needed
     if this is to be changed. The pazpar2.cfg file includes settings from the
    <para>
     The test UIs are located in <literal>www</literal>. Ensure that this
     directory is available to the web server by copying
-    <literal>www</literal> to the document root, 
+    <literal>www</literal> to the document root,
     using Apache's <literal>Alias</literal> directive, or
     creating a symbolic link: for example, on a Debian or Ubuntu
     system with Apache2 installed from the standard package, you might
      sudo ln -s `pwd`/www /var/www/pazpar2-demo
     </screen>
    </para>
-   
+
    <para>
     This makes the test applications visible at
     <ulink url="http://localhost/pazpar2-demo/"/>
     accessed: <literal>test1</literal>, <literal>test2</literal> and
     <literal>jsdemo</literal>
     are pure HTML+JavaScript setups, needing no server-side
-    intelligence; 
+    intelligence;
     <literal>demo</literal>
     requires PHP on the server.
    </para>
    </para>
    <para>
     In order to use Apache as frontend for the interface on port 80
-    for public access etc., refer to 
+    for public access etc., refer to
     <xref linkend="installation.apache2proxy"/>.
    </para>
   </section>
     <ulink url="&url.pazpar2.download.ubuntu;"/>.
    </para>
   </section>
-  
+
   <section id="installation.apache2proxy">
    <title>Apache 2 Proxy</title>
    <para>
-    Apache 2 has a 
+    Apache 2 has a
     <ulink
        url="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html">
      proxy module
     based web service. The Apache 2 proxy must operate in the
     <emphasis>Reverse</emphasis> Proxy mode.
    </para>
-   
+
    <para>
     On a Debian based Apache 2 system, the relevant modules can
     be enabled with:
      sudo a2enmod proxy_http proxy_balancer
     </screen>
    </para>
-   
+
    <para>
-    Traditionally Pazpar2 interprets URL paths with suffix 
+    Traditionally Pazpar2 interprets URL paths with suffix
     <literal>/search.pz2</literal>.
-    The 
+    The
     <ulink
        url="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass">
     ProxyPass
      <screen><![CDATA[
       <IfModule mod_proxy.c>
        ProxyRequests Off
-      
+
        <Proxy *>
         AddDefaultCharset off
         Order deny,allow
         Allow from all
        </Proxy>
-      
+
        ProxyPass /myportal/search.pz2 http://localhost:8004/search.pz2
        ProxyVia Off
       </IfModule>
     </para>
    </example>
   </section>
-  
+
  </chapter>
+
  <chapter id="using">
   <title>Using Pazpar2</title>
   <para>
    This chapter provides a general introduction to the use and
-   deployment of Pazpar2. 
+   deployment of Pazpar2.
   </para>
-  
+
   <section id="architecture">
    <title>Pazpar2 and your systems architecture</title>
    <para>
     with the server from which the enclosing HTML page or object
     originated, Pazpar2 is designed so that it can act as a transparent
     proxy in front of an existing webserver (see <xref
-    linkend="pazpar2_conf"/> for details). 
+    linkend="pazpar2_conf"/> for details).
     In this mode, all regular
     HTTP requests are transparently passed through to your webserver,
     while Pazpar2 only intercepts search-related webservice requests.
      <!-- ... and so on -->
     </record>
      ]]></screen>
-    
+
     As you can see, there isn't much to it. There are really only a few
     important elements to this file.
    </para>
-   
+
    <para>
     Elements should belong to the namespace
     <literal>http://www.indexdata.com/pazpar2/1.0</literal>.
     The webservice API of Pazpar2 is described in detail in <xref
      linkend="pazpar2_protocol"/>.
    </para>
-   
+
    <para>
     In brief, you use the 'init' command to create a session, a
     temporary workspace which carries information about the current
    </para>
    <para>
     In addition, the ICU tokenization and normalization rules must
-    be defined in the master configuration file described in 
+    be defined in the master configuration file described in
     <xref linkend="config-server"/>.
    </para>
   </section>
      </ulink>
      module in your Apache2 installation.
    </para>
-   
+
    <para>
     On a Debian based Apache 2 system, the relevant modules can
     be enabled with:
      could use the following Apache 2 configuration to expose a single
      pazpar2 'endpoint' on a standard
      (<filename>/pazpar2/search.pz2</filename>) location:
-     
+
      <screen><![CDATA[
        <Proxy *>
          AddDefaultCharset off
          BalancerMember http://localhost:8007 route=pz4
        </Proxy>
 
-       # route is resent in the 'session' param which has the form: 
+       # route is resent in the 'session' param which has the form:
        # 'sessid.serverid', understandable by the mod_proxy_load_balancer
        # this is not going to work if the client tampers with the 'session' param
        ProxyPass /pazpar2/search.pz2 balancer://pz2cluster lbmethod=byrequests stickysession=session nofailover=On
      ]]></screen>
-     
+
      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’.
      The â€˜Proxy’ section lists all the servers (real workers) which the
      load balancer can use.
     </para>
-    
+
    </example>
-   
+
   </section>
-  
+
   <section id="relevance_ranking">
    <title>Relevance ranking</title>
    <para>
     fetched form the database. In this case, the rank weigth
     <literal>w</literal>, the and rank tweaks <literal>lead</literal>,
     <literal>follow</literal> and <literal>length</literal>.
-    
+
    </para>
    <screen><![CDATA[
     tf[1,2,..N] = 0;
 
  <appendix id="license">
   <title>License</title>
+
  <para>
   Pazpar2,
   Copyright &#xa9; &copyright-year; Index Data.
  </para>
+
  <para>
   Pazpar2 is free software; you can redistribute it and/or modify it under
   the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 2, or (at your option) any later
   version.
  </para>
+
  <para>
   Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   for more details.
  </para>
+
  <para>
   You should have received a copy of the GNU General Public License
   along with Pazpar2; see the file LICENSE.  If not, write to the
-  Free Software Foundation, 
+  Free Software Foundation,
   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  </para>
+
  </appendix>
 
  &gpl2;
+
 </book>
 
 <!-- Keep this comment at the end of the file
index a11061d..c61a73e 100644 (file)
   <productnumber>&version;</productnumber>
   <info><orgname>Index Data</orgname></info>
  </refentryinfo>
+
  <refmeta>
   <refentrytitle>Pazpar2 conf</refentrytitle>
   <manvolnum>5</manvolnum>
   <refmiscinfo class="manual">File formats and conventions</refmiscinfo>
  </refmeta>
+
  <refnamediv>
   <refname>pazpar2_conf</refname>
   <refpurpose>Pazpar2 Configuration</refpurpose>
  </refnamediv>
+
  <refsynopsisdiv>
   <cmdsynopsis>
    <command>pazpar2.conf</command>
   </cmdsynopsis>
  </refsynopsisdiv>
+
  <refsect1>
   <title>DESCRIPTION</title>
   <para>
@@ -41,7 +41,7 @@
    extraction of data elements from incoming result records, for the
    purposes of merging, sorting, facet analysis, and display.
   </para>
-  
+
   <para>
    The file is specified using the option -f on the Pazpar2 command line.
    There is not presently a way to reload the configuration file without
    in the future.
   </para>
  </refsect1>
+
  <refsect1>
   <title>FORMAT</title>
   <para>
    The configuration file is XML-structured. It must be well-formed XML. All
    elements specific to Pazpar2 should belong to the namespace
-   <literal>http://www.indexdata.com/pazpar2/1.0</literal> 
+   <literal>http://www.indexdata.com/pazpar2/1.0</literal>
    (this is assumed in the
    following examples). The root element is named "<literal>pazpar2</literal>".
    Under the  root element are a number of elements which group categories of
    information. The categories are described below.
   </para>
-  
+
   <refsect2 id="config-threads">
    <title>threads</title>
    <para>
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>proxy</term>
      <listitem>
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>relevance / sort / mergekey / facet</term>
      <listitem>
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>settings</term>
      <listitem>
        The settings element requires one attribute 'src' which specifies
        a settings file or a directory . If a directory is given all
        files with suffix <filename>.xml</filename> is read from this
-       directory. Refer to 
+       directory. Refer to
        <xref linkend="target_settings"/> for more information.
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term id="service_conf">service</term>
      <listitem>
          ranking, merging, and display of data elements. It supports
          the following attributes:
         </para>
-        
+
         <variablelist> <!-- level 3 -->
          <varlistentry>
           <term>name</term>
            <para>
             This is the name of the data element. It is matched
             against the 'type' attribute of the
-            'metadata' element 
+            'metadata' element
             in the normalized record. A warning is produced if
             metadata elements with an unknown name are
-            found in the 
+            found in the
             normalized record. This name is also used to
-            represent 
+            represent
             data elements in the records returned by the
             webservice API, and to name sort lists and browse
             facets.
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term>type</term>
           <listitem>
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term>brief</term>
           <listitem>
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term>sortkey</term>
           <listitem>
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term id="metadata-rank">rank</term>
           <listitem>
            <para>
             Specifies that this element is to be used to
-            help rank 
+            help rank
             records against the user's query (when ranking is
-            requested). 
-            The valus is of the form 
+            requested).
+            The valus is of the form
             <literallayout>
              M [F N]
             </literallayout>
            </para>
            <para>
             For Pazpar2 1.6.13 and later, the rank may also defined
-            "per-document", by the normalization stylesheet. 
+            "per-document", by the normalization stylesheet.
            </para>
            <para>
             The per field rank was introduced in Pazpar2 1.6.15. Earlier
            about ranking.
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term>termlist</term>
           <listitem>
             termlist, or browse facet. Values are tabulated from
             incoming records, and a highscore of values (with
             their associated frequency) is made available to the
-            client through the webservice API. 
+            client through the webservice API.
             The possible values
             are 'yes' and 'no' (default).
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term>merge</term>
           <listitem>
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term>mergekey</term>
           <listitem>
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term id="limitcluster">limitcluster</term>
           <listitem>
            </note>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term id="metadata_limitmap">limitmap</term>
           <listitem>
            <para>
-            Specifies a default limitmap for this field. This is to avoid mass 
-            configuring of targets. However it is important to review/do this on a per
-            target since it is usually target-specific. See limitmap for format. 
+            Specifies a default limitmap for this field. This is to avoid mass
+            configuring of targets. However it is important to review/do
+            this on a per target since it is usually target-specific.
+            See limitmap for format.
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term id="metadata_facetmap">facetmap</term>
           <listitem>
            <para>
-            Specifies a default facetmap for this field. This is to avoid mass 
-            configuring of targets. However it is important to review/do this on a per
-            target since it is usually target-specific. See facetmap for format. 
+            Specifies a default facetmap for this field. This is to avoid mass
+            configuring of targets. However it is important to review/do
+            this on a per target since it is usually target-specific.
+            See facetmap for format.
            </para>
           </listitem>
          </varlistentry>
-         
+
          <varlistentry>
           <term>setting</term>
           <listitem>
             are allowed. 'no' is the default and doesn't do anything.
             'postproc' copies the value of a setting with the same name
             into the output of the normalization stylesheet(s). 'parameter'
-            makes the value of a setting with the same name available 
+            makes the value of a setting with the same name available
             as a parameter to the normalization stylesheet, so you
             can further process the value inside of the stylesheet, or use
             the value to decide how to deal with other data values.
            </para>
           </listitem>
          </varlistentry>
-         
+
         </variablelist> <!-- attributes to metadata -->
-        
+
        </listitem>
        </varlistentry>
 
          rule set.
          Pazpar2 uses the particular rule sets for particular purposes.
          Rule set 'relevance' is used to normalize
-         terms for relevance ranking. Rule set 'sort' is used to 
+         terms for relevance ranking. Rule set 'sort' is used to
          normalize terms for sorting. Rule set 'mergekey' is used to
          normalize terms for making a mergekey and, finally. Rule set 'facet'
          is normally used to normalize facet terms, unless
          in any order, except the 'index' element which logically
          belongs to the end of the list. The stated tokenization,
          transformation and charmapping instructions are performed
-         in order from top to bottom. 
+         in order from top to bottom.
         </para>
         <variablelist> <!-- Level 2 -->
          <varlistentry>
            <para>
             The attribute 'rule' defines the direction of the
             per-character casemapping, allowed values are "l"
-            (lower), "u" (upper), "t" (title).  
+            (lower), "u" (upper), "t" (title).
            </para>
           </listitem>
          </varlistentry>
             Normalization and transformation of tokens follows
             the rules defined in the 'rule' attribute. For
             possible values we refer to the extensive ICU
-            documentation found at the 
+            documentation found at the
             <ulink url="&url.icu.transform;">ICU
             transformation</ulink> home page. Set filtering
-            principles are explained at the 
+            principles are explained at the
             <ulink url="&url.icu.unicode.set;">ICU set and
             filtering</ulink> page.
            </para>
             'rule' attribute may have the following values:
             "s" (sentence), "l" (line-break), "w" (word), and
             "c" (character), the later probably not being
-            very useful in a pruning Pazpar2 installation. 
+            very useful in a pruning Pazpar2 installation.
            </para>
           </listitem>
          </varlistentry>
         </para>
        </listitem>
        </varlistentry>
-       
+
        <varlistentry>
        <term>relevance</term>
        <listitem>
         </para>
        </listitem>
        </varlistentry>
-       
+
        <varlistentry>
        <term>sort</term>
        <listitem>
         </para>
        </listitem>
        </varlistentry>
-       
+
        <varlistentry>
        <term>mergekey</term>
        <listitem>
         <para>
          Specifies ICU tokenization and transformation rules
-         for tokens that are used in Pazpar2's mergekey. 
+         for tokens that are used in Pazpar2's mergekey.
          The child element of 'mergekey' must be 'icu_chain' and the
          'id' attribute of the icu_chain is ignored. This
          definition is obsolete and should be replaced by the equivalent
          The name and value of the CCL directive is gigen by attributes
          'name' and 'value' respectively. Refer to possible list of names
          in the
-         <ulink 
+         <ulink
              url="http://www.indexdata.com/yaz/doc/tools.html#ccl.directives.table">
           YAZ manual
           </ulink>.
         </para>
        </listitem>
        </varlistentry>
-       
+
        <varlistentry id="sort-default">
        <term>sort-default</term>
        <listitem>
         <para>
          Specifies the default sort criteria (default 'relevance'),
-         which previous was hard-coded as default criteria in search. 
-         This is a fix/work-around to avoid re-searching when using 
-         target-based sorting. In order for this to work efficient, 
-         the search must also have the sort critera parameter; otherwise 
+         which previous was hard-coded as default criteria in search.
+         This is a fix/work-around to avoid re-searching when using
+         target-based sorting. In order for this to work efficient,
+         the search must also have the sort critera parameter; otherwise
          pazpar2 will do re-searching on search criteria changes, if
          changed between search and show command.
         </para>
        </listitem>
        </varlistentry>
 
-<!--       
+<!--
        <varlistentry>
        <term>set</term>
        <listitem>
         </para>
        </listitem>
        </varlistentry>
--->   
+-->
        <varlistentry>
        <term>settings</term>
        <listitem>
         <para>
          Specifies timeout parameters for this service.
          The <literal>timeout</literal>
-         element supports the following attributes: 
+         element supports the following attributes:
          <literal>session</literal>, <literal>z3950_operation</literal>,
          <literal>z3950_session</literal> which specifies
          'session timeout', 'Z39.50 operation timeout',
 </pazpar2>
    ]]>
   </screen>
- </refsect1> 
+ </refsect1>
 
  <refsect1 id="config-include">
   <title>INCLUDE FACILITY</title>
    kinds of attributes, or settings with search targets. This can be done
    through XML files which are read at startup; each file can associate
    one or more settings with one or more targets. The file format is generic
-   in nature, designed to support a wide range of application requirements. The
-   settings can be purely technical things, like, how to perform a title
+   in nature, designed to support a wide range of application requirements.
+   The settings can be purely technical things, like, how to perform a title
    search against a given target, or it can associate arbitrary name=value
    pairs with groups of targets -- for instance, if you would like to
    place all commercial full-text bases in one group for selection
    to drive sorting, facet/termlist generation, or end-user interface display
    logic.
   </para>
-  
+
   <para>
    During startup, Pazpar2 will recursively read a specified directory
    (can be identified in the pazpar2.cfg file or on the command line), and
    process any settings files found therein.
   </para>
-  
+
   <para>
    Clients of the Pazpar2 webservice interface can selectively override
    settings for individual targets within the scope of one session. This
    some search targets in different ways. This, again, can be managed
    using an external database or other lookup mechanism. Setting overrides
    can be performed either using the
-   <link linkend="command-init">init</link> or the 
+   <link linkend="command-init">init</link> or the
    <link linkend="command-settings">settings</link> webservice
    command.
   </para>
-  
+
   <para>
    In fact, every setting that applies to a database (except pz:id, which
    can only be used for filtering targets to use for a search) can be overridden
-   on a per-session basis. This allows the client to override specific CCL fields
-   for searching, etc., to meet the needs of a session or user.
+   on a per-session basis.
+   This allows the client to override specific CCL fields for
+   searching, etc., to meet the needs of a session or user.
   </para>
 
   <para>
     target, name, and value.
    </para>
 
-   <variablelist> 
+   <variablelist>
     <varlistentry>
      <term>target</term>
      <listitem>
     <set name="pz:cclmap:isbn" value="u=7"/>
     <set name="pz:cclmap:issn" value="u=8"/>
     <set name="pz:cclmap:date" value="u=30 r=r"/>
-    
+
     <set name="pz:limitmap:title" value="rpn:@attr 1=4 @attr 6=3"/>
     <set name="pz:limitmap:date" value="ccl:date"/>
 
     The following setting names are reserved by Pazpar2 to control the
     behavior of the client function.
    </para>
-   
+
    <variablelist>
     <varlistentry>
      <term>pz:cclmap:xxx</term>
        The value <literal>iso2709</literal> makes Pazpar2 convert retrieved
        MARC records to MARCXML. In order to convert to XML, the exact
        chacater set of the MARC must be known (if not, the resulting
-       XML is probably not well-formed). The character set may be 
+       XML is probably not well-formed). The character set may be
        specified by adding:
        <literal>;charset=</literal><replaceable>charset</replaceable> to
        <literal>iso2709</literal>. If omitted, a charset of
        <literal>'.xsl'</literal>.
       </para>
       <para>
-       When mapping MARC records, XSLT can be bypassed for increased 
+       When mapping MARC records, XSLT can be bypassed for increased
        performance with the alternate "MARC map" format.  Provide the
        path of a file with extension ".mmap" containing on each line:
        <programlisting>
        500 $ description
         773 * citation
        </programlisting>
-       To map the field value specify a subfield of '$'.  To store a 
+       To map the field value specify a subfield of '$'.  To store a
        concatenation of all subfields, specify a subfield of '*'.
       </para>
      </listitem>
      <term>pz:presentchunk</term>
      <listitem>
       <para>
-       Controls the chunk size in present requests. Pazpar2 will 
+       Controls the chunk size in present requests. Pazpar2 will
        make (maxrecs / chunk) request(s). The default is 20.
       </para>
      </listitem>
      <term>pz:zproxy</term>
      <listitem>
       <para>
-       The 'pz:zproxy' setting has the value syntax 
+       The 'pz:zproxy' setting has the value syntax
        'host.internet.adress:port', it is used to tunnel Z39.50
        requests through the named Z39.50 proxy.
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>pz:apdulog</term>
      <listitem>
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>pz:sru</term>
      <listitem>
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>pz:sru_version</term>
      <listitem>
       <para>
        This allows SRU version to be specified. If unset Pazpar2
        will the default of YAZ (currently 1.2). Should be set
-       to 1.1 or 1.2. For Solr, the current supported/tested version is 1.4 and 3.x.
+       to 1.1 or 1.2. For Solr, the current supported/tested version
+       is 1.4 and 3.x.
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>pz:pqf_prefix</term>
      <listitem>
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>pz:pqf_strftime</term>
      <listitem>
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>pz:sort</term>
      <listitem>
       </para>
      </listitem>
     </varlistentry>
-    
+
     <varlistentry>
      <term>pz:preferred</term>
      <listitem>
        target. Using block=pref on show command will wait for all these
        targets to return records before releasing the block.
        If no target is preferred, the block=pref will identical to block=1,
-       which release when one target has returned records.     
+       which release when one target has returned records.
       </para>
      </listitem>
     </varlistentry>
      <listitem>
       <para>
        (Not yet implemented).
-       Specifies the time for which a block should be released anyway.      
+       Specifies the time for which a block should be released anyway.
       </para>
      </listitem>
     </varlistentry>
      <term>pz:termlist_term_count</term>
      <listitem>
       <para>
-       Specifies number of facet terms to be requested from the target. 
+       Specifies number of facet terms to be requested from the target.
        The default is unspecified e.g. server-decided. Also see pz:facetmap.
       </para>
      </listitem>
      <term>pz:termlist_term_factor</term>
      <listitem>
       <para>
-       Specifies whether to use a factor for pazpar2 generated facets (1) or not (0). 
-       When mixing locallly generated (by the downloaded (pz:maxrecs) samples) 
-       facet with native (target-generated) facets, the later will dominated the dominate the facet list
-       since they are generated based on the complete result set. 
-       By scaling up the facet count using the ratio between total hit count and the sample size, 
-       the total facet count can be approximated and thus better compared with native facets. 
-       This is not enabled by default.
+       Specifies whether to use a factor for pazpar2 generated facets (1)
+       or not (0).
+       When mixing locally generated (by the downloaded (pz:maxrecs) samples)
+       facet with native (target-generated) facets, the later will
+       dominated the dominate the facet list since they are generated
+       based on the complete result set.
+       By scaling up the facet count using the ratio between total hit
+       count and the sample size,
+       the total facet count can be approximated and thus better compared
+       with native facets. This is not enabled by default.
       </para>
      </listitem>
     </varlistentry>
       <para>
        Specifies attributes for limiting a search to a field - using
        the limit parameter for search. It can be used to filter locally
-       or remotely (search in a target). In some cases the mapping of 
+       or remotely (search in a target). In some cases the mapping of
        a field to a value is identical to an existing cclmap field; in
        other cases the field must be specified in a different way - for
        example to match a complete field (rather than parts of a subfield).
       <para>
        The value of limitmap may have one of three forms: referral to
        an existing CCL field, a raw PQF string or a local limit. Leading string
-       determines type; either <literal>ccl:</literal> for CCL field, 
+       determines type; either <literal>ccl:</literal> for CCL field,
        <literal>rpn:</literal> for PQF/RPN, or <literal>local:</literal>
        for filtering in Pazpar2. The local filtering may be followed
-       by a field a metadata field (default is to use the name of the 
+       by a field a metadata field (default is to use the name of the
        limitmap itself).
       </para>
       <para>
       </note>
      </listitem>
     </varlistentry>
-    
+
    </variablelist>
-   
+
   </refsect2>
 
  </refsect1>
index 7bb308e..2d6f050 100644 (file)
     </variablelist>
    </para>
   </refsect2>
-  
+
   <refsect2 id="command-ping">
    <title>ping</title>
    <para>
     or possibly a wildcard, and value is the desired value for the
     setting.
    </para>
-   
+
    <para>
     Because the settings command manipulates potentially sensitive
     information, it is possible to configure Pazpar2 to only allow access
     scripting, which in turn is responsible for authenticating the user,
     and possibly determining which resources he has access to, etc.
    </para>
-   
+
    <note>
     <para>
      As a shortcut, it is also possible to override settings directly in
@@ -181,7 +181,7 @@ search.pz?command=settings&session=2044502273&pz:allow[search.com:210/db1]=1
 </settings>
 ]]></screen>
    </para>
-   
+
   </refsect2>
   <refsect2 id="command-search">
    <title>search</title>
@@ -277,13 +277,15 @@ search.pz?command=settings&session=2044502273&pz:allow[search.com:210/db1]=1
        'position'.
        </para>
        <para>
-       If not specified here or as <link linkend="sort-default">sort-default"</link>
-       in pazpar2.cfg, Pazpar2 will default to the built-in 'relevance' ranking. 
+       If not specified here or as
+       <link linkend="sort-default">sort-default"</link>
+       in pazpar2.cfg, Pazpar2 will default to the built-in
+       'relevance' ranking.
        </para>
        <para>
-       Having sort criteria at search is important for targets that 
-       supports native sorting in order to get best results. Pazpar2 
-       will trigger a new search if search criteria changes from Pazpar2 
+       Having sort criteria at search is important for targets that
+       supports native sorting in order to get best results. Pazpar2
+       will trigger a new search if search criteria changes from Pazpar2
        to target-based sorting or visa-versa.
        </para>
       </listitem>
@@ -346,7 +348,7 @@ search.pz2?session=2044502273&command=search&query=computer+science
      ]]></screen>
    </para>
   </refsect2>
+
   <refsect2 id="command-stat">
    <title>stat</title>
    <para>
@@ -388,7 +390,7 @@ search.pz2?session=2044502273&command=stat
      ]]></screen>
   </para>
   </refsect2>
-  
+
   <refsect2 id="command-show">
    <title>show</title>
    <para>
@@ -402,14 +404,14 @@ search.pz2?session=2044502273&command=stat
        </para>
       </listitem>
      </varlistentry>
-     
+
      <varlistentry>
       <term>start</term>
       <listitem>
        <para>First record to show - 0-indexed.</para>
       </listitem>
      </varlistentry>
-     
+
      <varlistentry>
       <term>num</term>
       <listitem>
@@ -442,15 +444,18 @@ search.pz2?session=2044502273&command=stat
        Sort field names can be any field name designated as a sort field
         in the pazpar2.cfg file, or the special names 'relevance' and
        'position'.
-
-       If not specified here or as <link linkend="sort-default">sort-default"</link> 
-       in pazpar2.cfg, pazpar2 will default to the built-in 'relevance' ranking. 
-
-       Having sort criteria at search is important for targets that 
-       supports native sorting in order to get best results. pazpar2 
-       will trigger a new search if search criteria changes from pazpar2 
+       </para>
+       <para>
+       If not specified here or as
+       <link linkend="sort-default">sort-default"</link>
+       in pazpar2.cfg, pazpar2 will default to the built-in
+       'relevance' ranking.
+       </para>
+       <para>
+       Having sort criteria at search is important for targets that
+       supports native sorting in order to get best results. pazpar2
+       will trigger a new search if search criteria changes from pazpar2
        to target-based sorting.
-
        </para>
        <para>
        For targets where If <link linkend="pzsortmap">pz:sortmap</link>
@@ -500,6 +505,20 @@ search.pz2?session=2044502273&command=stat
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term>snippets</term>
+      <listitem>
+       <para>
+       If specified and set to 1 data will include snippets marked
+       with &lt;match&gt; tags. Otherwise snippets will not be included.
+       </para>
+       <para>
+       This facility, "snippets", appeared in Pazpar2 version
+       1.6.32.
+       </para>
+      </listitem>
+     </varlistentry>
+
     </variablelist>
    </para>
    <para>
@@ -518,7 +537,7 @@ search.pz2?session=2044502273&command=show&start=0&num=2&sort=title:1
   <num>2</num>                         -- Number of records retrieved
   <hit>
     <md-title>How to program a computer, by Jack Collins</md-title>
-    <count>2</count>                   -- Number of merged records 
+    <count>2</count>                   -- Number of merged records
     <recid>6</recid>                   -- Record ID for this record
   </hit>
   <hit>
@@ -536,10 +555,10 @@ search.pz2?session=2044502273&command=show&start=0&num=2&sort=title:1
   <refsect2 id="command-record">
    <title>record</title>
    <para>
-    Retrieves a detailed record. Unlike the 
-    <link linkend="command-show">show</link> command, this command 
+    Retrieves a detailed record. Unlike the
+    <link linkend="command-show">show</link> command, this command
     returns metadata records before merging takes place. Parameters:
-    
+
     <variablelist>
      <varlistentry>
       <term>session</term>
@@ -619,7 +638,7 @@ search.pz2?session=2044502273&command=show&start=0&num=2&sort=title:1
       <term>syntax</term>
       <listitem>
        <para>
-       This optional parameter is the record syntax used for raw 
+       This optional parameter is the record syntax used for raw
        transfer (i.e. when offset is specified). If syntax is not given,
        but offset is used, the value of pz:requestsyntax is used.
        </para>
@@ -650,16 +669,30 @@ search.pz2?session=2044502273&command=show&start=0&num=2&sort=title:1
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term>snippets</term>
+      <listitem>
+       <para>
+       If specified and set to 1 data will include snippets marked
+       with &lt;match&gt; tags. Otherwise snippets will not be included.
+       </para>
+       <para>
+       This facility, "snippets", appeared in Pazpar2 version
+       1.6.32.
+       </para>
+      </listitem>
+     </varlistentry>
+
     </variablelist>
    </para>
-   <para> 
+   <para>
     Example:
     <screen><![CDATA[
 search.pz2?session=605047297&command=record&id=3
 ]]></screen>
 
     Example output:
-    
+
     <screen><![CDATA[
 <record>
   <md-title>
@@ -677,7 +710,7 @@ search.pz2?session=605047297&command=record&id=3
    <title>termlist</title>
    <para>
     Retrieves term list(s). Parameters:
-    
+
     <variablelist>
      <varlistentry>
       <term>session</term>
@@ -734,7 +767,7 @@ search.pz2?session=2044502273&command=termlist&name=author,subject
 </termlist>
 ]]></screen>
    </para>
-   
+
    <para>
     For the special termlist name "xtargets", results
     are returned about the targets which have returned the most hits.
@@ -755,7 +788,7 @@ search.pz2?session=2044502273&command=termlist&name=author,subject
 ]]></screen>
    </para>
   </refsect2>
-  
+
 
   <refsect2 id="command-bytarget">
    <title>bytarget</title>
@@ -773,14 +806,14 @@ search.pz2?session=2044502273&command=termlist&name=author,subject
      </varlistentry>
     </variablelist>
    </para>
-   <para> 
+   <para>
     Example:
     <screen><![CDATA[
 search.pz2?session=605047297&command=bytarget&id=3
 ]]></screen>
-    
+
     Example output:
-    
+
     <screen><![CDATA[
 <bytarget>
   <status>OK</status>
@@ -794,7 +827,7 @@ search.pz2?session=605047297&command=bytarget&id=3
   <!-- ... more target nodes below as necessary -->
 </bytarget>
 ]]></screen>
-    
+
     The following client states are defined: Client_Connecting,
     Client_Connected, Client_Idle, Client_Initializing, Client_Searching,
     Client_Searching, Client_Presenting, Client_Error, Client_Failed,
index 13b578f..689e27f 100644 (file)
@@ -8,11 +8,11 @@ Group: Applications/Internet
 Vendor: Index Data ApS <info@indexdata.dk>
 Source: pazpar2-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-root
-BuildRequires: libyaz4-devel >= 4.2.40
+BuildRequires: libyaz4-devel >= 4.2.58
 Packager: Adam Dickmeiss <adam@indexdata.dk>
 URL: http://www.indexdata.com/pazpar2
 Summary: pazpar2 daemon
-Requires: libyaz4 >= 4.2.40
+Requires: libyaz4 >= 4.2.58
 
 %description
 Pazpar2 is a high-performance, user interface-independent, data
index f931445..9688628 100644 (file)
@@ -53,6 +53,8 @@ struct pp2_charset_s {
     const char *(*token_next_handler)(pp2_charset_token_t prt);
     const char *(*get_sort_handler)(pp2_charset_token_t prt);
     const char *(*get_display_handler)(pp2_charset_token_t prt);
+    void (*get_org_handler)(pp2_charset_token_t ptr,
+                            size_t *start, size_t *len);
 #if YAZ_HAVE_ICU
     struct icu_chain * icu_chn;
     UErrorCode icu_sts;
@@ -63,11 +65,15 @@ static const char *pp2_charset_token_null(pp2_charset_token_t prt);
 static const char *pp2_charset_token_a_to_z(pp2_charset_token_t prt);
 static const char *pp2_get_sort_ascii(pp2_charset_token_t prt);
 static const char *pp2_get_display_ascii(pp2_charset_token_t prt);
+static void pp2_get_org_ascii(pp2_charset_token_t prt,
+                              size_t *start, size_t *len);
 
 #if YAZ_HAVE_ICU
 static const char *pp2_charset_token_icu(pp2_charset_token_t prt);
 static const char *pp2_get_sort_icu(pp2_charset_token_t prt);
 static const char *pp2_get_display_icu(pp2_charset_token_t prt);
+static void pp2_get_org_icu(pp2_charset_token_t prt,
+                            size_t *start, size_t *len);
 #endif
 
 /* tokenzier handle */
@@ -80,6 +86,9 @@ struct pp2_charset_token_s {
 #if YAZ_HAVE_ICU
     yaz_icu_iter_t iter;
 #endif
+    const char *cp0;
+    size_t start;
+    size_t len;
 };
 
 struct pp2_charset_fact_s {
@@ -226,6 +235,7 @@ pp2_charset_t pp2_charset_create(void)
     pct->token_next_handler = pp2_charset_token_null;
     pct->get_sort_handler  = pp2_get_sort_ascii;
     pct->get_display_handler  = pp2_get_display_ascii;
+    pct->get_org_handler = pp2_get_org_ascii;
 #if YAZ_HAVE_ICU
     pct->icu_chn = 0;
 #endif // YAZ_HAVE_ICU
@@ -250,6 +260,7 @@ pp2_charset_t pp2_charset_create_icu(struct icu_chain *icu_chn)
         pct->token_next_handler = pp2_charset_token_icu;
         pct->get_sort_handler = pp2_get_sort_icu;
         pct->get_display_handler = pp2_get_display_icu;
+        pct->get_org_handler = pp2_get_org_icu;
     }
     return pct;
 }
@@ -290,6 +301,8 @@ pp2_charset_token_t pp2_charset_tokenize(pp2_charset_t pct)
     if (pct->icu_chn)
         prt->iter = icu_iter_create(pct->icu_chn);
 #endif
+    prt->start = 0;
+    prt->len = 0;
     return prt;
 }
 
@@ -313,6 +326,7 @@ void pp2_charset_token_first(pp2_charset_token_t prt,
 
     wrbuf_rewind(prt->norm_str);
     wrbuf_rewind(prt->sort_str);
+    prt->cp0 = buf;
     prt->cp = buf;
     prt->last_cp = 0;
 
@@ -354,6 +368,12 @@ const char *pp2_get_display(pp2_charset_token_t prt)
     return prt->pct->get_display_handler(prt);
 }
 
+void pp2_get_org(pp2_charset_token_t prt, size_t *start, size_t *len)
+{
+    prt->pct->get_org_handler(prt, start, len);
+}
+
+
 #define raw_char(c) (((c) >= 'a' && (c) <= 'z') ? (c) : -1)
 /* original tokenizer with our tokenize interface, but we
    add +1 to ensure no '\0' are in our string (except for EOF)
@@ -363,6 +383,7 @@ static const char *pp2_charset_token_a_to_z(pp2_charset_token_t prt)
     const char *cp = prt->cp;
     int c;
 
+    prt->start = cp - prt->cp0;
     /* skip white space */
     while (*cp && (c = raw_char(tolower(*(const unsigned char *)cp))) < 0)
         cp++;
@@ -381,6 +402,7 @@ static const char *pp2_charset_token_a_to_z(pp2_charset_token_t prt)
         wrbuf_putc(prt->norm_str, c);
         cp++;
     }
+    prt->len = (cp - prt->cp0) - prt->start;
     prt->cp = cp;
     return wrbuf_cstr(prt->norm_str);
 }
@@ -412,6 +434,13 @@ static const char *pp2_get_display_ascii(pp2_charset_token_t prt)
     }
 }
 
+static void pp2_get_org_ascii(pp2_charset_token_t prt,
+                              size_t *start, size_t *len)
+{
+    *start = prt->start;
+    *len = prt->len;
+}
+
 static const char *pp2_charset_token_null(pp2_charset_token_t prt)
 {
     const char *cp = prt->cp;
@@ -420,6 +449,7 @@ static const char *pp2_charset_token_null(pp2_charset_token_t prt)
     while (*cp)
         cp++;
     prt->cp = cp;
+    prt->len = cp - prt->cp0;
     return prt->last_cp;
 }
 
@@ -443,6 +473,11 @@ static const char *pp2_get_display_icu(pp2_charset_token_t prt)
     return icu_iter_get_display(prt->iter);
 }
 
+static void pp2_get_org_icu(pp2_charset_token_t prt, size_t *start, size_t *len)
+{
+    icu_iter_get_org_info(prt->iter, start, len);
+}
+
 #endif // YAZ_HAVE_ICU
 
 
index b203ce4..3b8325b 100644 (file)
@@ -45,6 +45,7 @@ void pp2_charset_token_destroy(pp2_charset_token_t prt);
 const char *pp2_charset_token_next(pp2_charset_token_t prt);
 const char *pp2_get_sort(pp2_charset_token_t prt);
 const char *pp2_get_display(pp2_charset_token_t prt);
+void pp2_get_org(pp2_charset_token_t prt, size_t *start, size_t *len);
 
 #endif
 
index 56e1f63..30de3d8 100644 (file)
@@ -872,7 +872,8 @@ static void cmd_bytarget(struct http_channel *c)
 }
 
 static void write_metadata(WRBUF w, struct conf_service *service,
-                           struct record_metadata **ml, int full, int indent)
+                           struct record_metadata **ml, unsigned flags,
+                           int indent)
 {
     int imeta;
 
@@ -880,7 +881,7 @@ static void write_metadata(WRBUF w, struct conf_service *service,
     {
         struct conf_metadata *cmd = &service->metadata[imeta];
         struct record_metadata *md;
-        if (!cmd->brief && !full)
+        if (!cmd->brief && !(flags & 1))
             continue;
         for (md = ml[imeta]; md; md = md->next)
         {
@@ -900,7 +901,10 @@ static void write_metadata(WRBUF w, struct conf_service *service,
             switch (cmd->type)
             {
                 case Metadata_type_generic:
-                    wrbuf_xmlputs(w, md->data.text.disp);
+                    if (md->data.text.snippet && (flags & 2))
+                        wrbuf_puts(w, md->data.text.snippet);
+                    else
+                        wrbuf_xmlputs(w, md->data.text.disp);
                     break;
                 case Metadata_type_year:
                     wrbuf_printf(w, "%d", md->data.number.min);
@@ -917,7 +921,8 @@ static void write_metadata(WRBUF w, struct conf_service *service,
 }
 
 static void write_subrecord(struct record *r, WRBUF w,
-        struct conf_service *service, int show_details)
+                            struct conf_service *service, unsigned flags,
+                            int indent)
 {
     const char *name = session_setting_oneval(
         client_get_database(r->client), PZ_NAME);
@@ -934,7 +939,7 @@ static void write_subrecord(struct record *r, WRBUF w,
     wrbuf_printf(w,  "%u", r->checksum);
     wrbuf_puts(w, "\">\n");
 
-    write_metadata(w, service, r->metadata, show_details, 2);
+    write_metadata(w, service, r->metadata, flags, indent);
     wrbuf_puts(w, " </location>\n");
 }
 
@@ -997,6 +1002,8 @@ static void show_record(struct http_channel *c, struct http_session *s)
     const char *offsetstr = http_argbyname(rq, "offset");
     const char *binarystr = http_argbyname(rq, "binary");
     const char *checksumstr = http_argbyname(rq, "checksum");
+    const char *snippets = http_argbyname(rq, "snippets");
+    unsigned flags = (snippets && *snippets == '1') ? 3 : 1;
 
     if (!s)
         return;
@@ -1090,9 +1097,9 @@ static void show_record(struct http_channel *c, struct http_session *s)
         }
         wrbuf_printf(c->wrbuf, " <activeclients>%d</activeclients>\n",
                      session_active_clients(s->psession));
-        write_metadata(c->wrbuf, service, rec->metadata, 1, 1);
+        write_metadata(c->wrbuf, service, rec->metadata, flags, 1);
         for (r = rec->records; r; r = r->next)
-            write_subrecord(r, c->wrbuf, service, 2);
+            write_subrecord(r, c->wrbuf, service, flags, 2);
         response_close(c, "record");
     }
     show_single_stop(s->psession, rec);
@@ -1133,6 +1140,8 @@ static void show_records(struct http_channel *c, struct http_session *s,
     const char *num = http_argbyname(rq, "num");
     const char *sort = http_argbyname(rq, "sort");
     int version = get_version(rq);
+    const char *snippets = http_argbyname(rq, "snippets");
+    unsigned flags = (snippets && *snippets == '1') ? 2 : 0;
 
     int startn = 0;
     int numn = 20;
@@ -1187,9 +1196,9 @@ static void show_records(struct http_channel *c, struct http_session *s,
         struct conf_service *service = s->psession->service;
 
         wrbuf_puts(c->wrbuf, "<hit>\n");
-        write_metadata(c->wrbuf, service, rec->metadata, 0, 1);
+        write_metadata(c->wrbuf, service, rec->metadata, flags, 1);
         for (ccount = 0, p = rl[i]->records; p;  p = p->next, ccount++)
-            write_subrecord(p, c->wrbuf, service, 0); // subrecs w/o details
+            write_subrecord(p, c->wrbuf, service, flags, 2);
         wrbuf_printf(c->wrbuf, " <count>%d</count>\n", ccount);
        if (strstr(sort, "relevance"))
         {
index 99a9e63..f2761f5 100644 (file)
@@ -28,6 +28,7 @@ union data_types {
     struct {
         const char *disp;
         const char *sort;
+        const char *snippet;
     } text;
     struct {
         int min;
index 0551980..54bebb5 100644 (file)
@@ -83,6 +83,63 @@ static struct word_entry *word_entry_match(struct relevance *r,
     return 0;
 }
 
+int relevance_snippet(struct relevance *r,
+                      const char *words, const char *name,
+                      WRBUF w_snippet)
+{
+    int no = 0;
+    const char *norm_str;
+    int highlight = 0;
+
+    pp2_charset_token_first(r->prt, words, 0);
+    while ((norm_str = pp2_charset_token_next(r->prt)))
+    {
+        size_t org_start, org_len;
+        struct word_entry *entries = r->entries;
+        int i;
+
+        pp2_get_org(r->prt, &org_start, &org_len);
+        for (; entries; entries = entries->next, i++)
+        {
+            if (*norm_str && !strcmp(norm_str, entries->norm_str))
+            {
+                break;
+                if (!highlight)
+                {
+                    highlight = 1;
+                    wrbuf_puts(w_snippet, "<match>");
+                }
+                break;
+            }
+        }
+        if (entries)
+        {
+            if (!highlight)
+            {
+                highlight = 1;
+                wrbuf_puts(w_snippet, "<match>");
+                no++;
+            }
+        }
+        else
+        {
+            if (highlight)
+            {
+                highlight = 0;
+                wrbuf_puts(w_snippet, "</match>");
+            }
+        }
+        wrbuf_xmlputs_n(w_snippet, words + org_start, org_len);
+    }
+    if (highlight)
+        wrbuf_puts(w_snippet, "</match>");
+    if (no)
+    {
+        yaz_log(YLOG_DEBUG, "SNIPPET match: %s", wrbuf_cstr(w_snippet));
+    }
+    return no;
+}
+
 void relevance_countwords(struct relevance *r, struct record_cluster *cluster,
                           const char *words, const char *rank,
                           const char *name)
index 5a095eb..76bbc22 100644 (file)
@@ -38,6 +38,10 @@ void relevance_newrec(struct relevance *r, struct record_cluster *cluster);
 void relevance_countwords(struct relevance *r, struct record_cluster *cluster,
                           const char *words, const char *multiplier,
                           const char *name);
+int relevance_snippet(struct relevance *r,
+                      const char *words, const char *name,
+                      WRBUF w_snippet);
+
 void relevance_donerecord(struct relevance *r, struct record_cluster *cluster);
 
 void relevance_prepare_read(struct relevance *rel, struct reclist *rec);
index 880fc0c..e3e0a0d 100644 (file)
@@ -1467,6 +1467,7 @@ static struct record_metadata *record_metadata_init(
 
         rec_md->data.text.disp = p;
         rec_md->data.text.sort = 0;
+        rec_md->data.text.snippet = 0;
     }
     else if (type == Metadata_type_year || type == Metadata_type_date)
     {
@@ -1956,6 +1957,18 @@ static int ingest_to_cluster(struct client *cl,
                             "for element '%s'", value, type);
                 continue;
             }
+
+            if (ser_md->type == Metadata_type_generic)
+            {
+                WRBUF w = wrbuf_alloc();
+                if (relevance_snippet(se->relevance,
+                                      (char*) value, ser_md->name, w))
+                    rec_md->data.text.snippet = nmem_strdup(se->nmem,
+                                                            wrbuf_cstr(w));
+                wrbuf_destroy(w);
+            }
+
+
             wheretoput = &record->metadata[md_field_id];
             while (*wheretoput)
                 wheretoput = &(*wheretoput)->next;
@@ -2183,7 +2196,6 @@ static int ingest_to_cluster(struct client *cl,
                 relevance_countwords(se->relevance, cluster,
                                      (char *) value, rank, ser_md->name);
             }
-
             // construct facets ... unless the client already has reported them
             if (ser_md->termlist && !client_has_facet(cl, (char *) type))
             {
index 0f8ecf5..3b4f7e9 100644 (file)
@@ -2,8 +2,8 @@ http://localhost:9763/search.pz2?command=init&pz:elements%5Bz3950.indexdata.com%
 http://localhost:9763/search.pz2?session=1&command=stat
 http://localhost:9763/search.pz2?session=1&command=ping
 http://localhost:9763/search.pz2?session=1&command=search&query=computer
-2 http://localhost:9763/search.pz2?session=1&command=show&block=1
-http://localhost:9763/search.pz2?session=1&command=record&id=content%3A+title+how+to+program+a+computer+author+jack+collins+medium+book
+2 http://localhost:9763/search.pz2?session=1&command=show&block=1&snippets=1
+http://localhost:9763/search.pz2?session=1&command=record&id=content%3A+title+how+to+program+a+computer+author+jack+collins+medium+book&snippets=1
 http://localhost:9763/search.pz2?session=1&command=record&id=content%3A+title+how+to+program+a+computer+author+jack+collins+medium+book&offset=0
 http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=title:0
 http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=title:1
index 837a9ff..d8a21e3 100644 (file)
@@ -10,7 +10,7 @@
  <md-author>Jack Collins</md-author>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="2788512872">
-  <md-title>How to program a computer</md-title>
+  <md-title>How to program a<match> computer</match></md-title>
   <md-author>Jack Collins</md-author>
   <md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
   <md-test-usersetting-2>test-usersetting-2 data: 
@@ -18,7 +18,7 @@
  </location>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="2614320583">
-  <md-title>How to program a computer</md-title>
+  <md-title>How to program a<match> computer</match></md-title>
   <md-author>Jack Collins</md-author>
   <md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
   <md-test-usersetting-2>test-usersetting-2 data: 
@@ -47,7 +47,7 @@ score = relevance(48160);
  <md-subject>Optical pattern recognition</md-subject>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="3659474317">
-  <md-title>Computer science &amp; technology</md-title>
+  <md-title><match>Computer</match> science &amp; technology</md-title>
   <md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
   <md-date>1977</md-date>
   <md-subject>Optical pattern recognition</md-subject>
@@ -79,7 +79,7 @@ score = relevance(40134);
  <md-description>Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates</md-description>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="3136897450">
-  <md-title>The Computer Bible</md-title>
+  <md-title>The<match> Computer</match> Bible</md-title>
   <md-date>1973-1980</md-date>
   <md-subject>Bible. O.T</md-subject>
   <md-subject>Bible</md-subject>
@@ -110,7 +110,7 @@ score = relevance(40134);
  <md-description>Cover title</md-description>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="4182051184">
-  <md-title>A plan for community college computer development</md-title>
+  <md-title>A plan for community college<match> computer</match> development</md-title>
   <md-date>1971</md-date>
   <md-subject>Universities and colleges</md-subject>
   <md-subject>Community colleges</md-subject>
@@ -147,7 +147,7 @@ score = relevance(17200);
  <md-description>&quot;Contract DOT-UT-10003.&quot;</md-description>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="4007858895">
-  <md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+  <md-title>Washington metropolitan area rail<match> computer</match> feasibility study</md-title>
   <md-title-remainder>final report</md-title-remainder>
   <md-date>1971</md-date>
   <md-author>Englund, Carl R</md-author>
@@ -184,7 +184,7 @@ score = relevance(17200);
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="3311089739">
   <md-title>The Puget Sound Region</md-title>
-  <md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+  <md-title-remainder>a portfolio of thematic<match> computer</match> maps</md-title-remainder>
   <md-date>1974</md-date>
   <md-author>Mairs, John W</md-author>
   <md-subject>Cartography</md-subject>
@@ -221,7 +221,7 @@ score = relevance(16722);
  <md-description>Includes bibliographical references and index</md-description>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="2962705161">
-  <md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+  <md-title><match>Computer</match> processing of dynamic images from an Anger scintillation camera</md-title>
   <md-title-remainder>the proceedings of a workshop</md-title-remainder>
   <md-date>1974</md-date>
   <md-subject>Radioisotope scanning</md-subject>
@@ -261,7 +261,7 @@ score = relevance(12040);
  <md-subject>Computers</md-subject>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="3833666606">
-  <md-title>The use of passwords for controlled access to computer resources</md-title>
+  <md-title>The use of passwords for controlled access to<match> computer</match> resources</md-title>
   <md-date>1977</md-date>
   <md-author>Wood, Helen M</md-author>
   <md-subject>Computers</md-subject>
index 66ad286..a7b731f 100644 (file)
@@ -9,7 +9,7 @@
  <md-lccn>11224467</md-lccn>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="2788512872">
-  <md-title>How to program a computer</md-title>
+  <md-title>How to program a<match> computer</match></md-title>
   <md-author>Jack Collins</md-author>
   <md-id>11224467</md-id>
   <md-lccn>11224467</md-lccn>
@@ -19,7 +19,7 @@
  </location>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="2614320583">
-  <md-title>How to program a computer</md-title>
+  <md-title>How to program a<match> computer</match></md-title>
   <md-author>Jack Collins</md-author>
   <md-id>11224466</md-id>
   <md-lccn>11224466</md-lccn>
index 2c6a4b5..be4e983 100644 (file)
@@ -1,7 +1,7 @@
 http://localhost:9763/search.pz2?command=init
 http://localhost:9763/search.pz2?session=1&command=stat
 http://localhost:9763/search.pz2?session=1&command=search&query=computer
-2 http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=title:0
+2 http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=title:0&snippets=1
 http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=title:1
 http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=date:0
 http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=date:1
index 89bbf2d..b2abe57 100644 (file)
@@ -13,7 +13,7 @@
  <md-description>&quot;Contract DOT-UT-10003.&quot;</md-description>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="4007858895">
-  <md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+  <md-title>Washington metropolitan area rail <match>computer </match>feasibility study;</md-title>
   <md-title-remainder>final report</md-title-remainder>
   <md-date>1971</md-date>
   <md-author>Englund, Carl R</md-author>
@@ -31,7 +31,7 @@
  <md-author>Wood, Helen M</md-author>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="3833666606">
-  <md-title>The use of passwords for controlled access to computer resources</md-title>
+  <md-title>The use of passwords for controlled access to <match>computer </match>resources /</md-title>
   <md-date>1977</md-date>
   <md-author>Wood, Helen M</md-author>
   <md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
@@ -68,7 +68,7 @@
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="3311089739">
   <md-title>The Puget Sound Region</md-title>
-  <md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+  <md-title-remainder>a portfolio of thematic <match>computer </match>maps /</md-title-remainder>
   <md-date>1974</md-date>
   <md-author>Mairs, John W</md-author>
   <md-description tag="500">Scale of maps ca. 1:1,000,000</md-description>
@@ -86,7 +86,7 @@
  <md-description>Cover title</md-description>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="4182051184">
-  <md-title>A plan for community college computer development</md-title>
+  <md-title>A plan for community college <match>computer </match>development.</md-title>
   <md-date>1971</md-date>
   <md-description tag="500">Cover title</md-description>
   <md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
  <md-author>Jack Collins</md-author>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="2788512872">
-  <md-title>How to program a computer</md-title>
+  <md-title>How to program a <match>computer</match></md-title>
   <md-author>Jack Collins</md-author>
   <md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
   <md-test-usersetting-2>test-usersetting-2 data: 
  </location>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="2614320583">
-  <md-title>How to program a computer</md-title>
+  <md-title>How to program a <match>computer</match></md-title>
   <md-author>Jack Collins</md-author>
   <md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
   <md-test-usersetting-2>test-usersetting-2 data: 
  <md-date>1977</md-date>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="3659474317">
-  <md-title>Computer science &amp; technology</md-title>
+  <md-title><match>Computer </match>science &amp; technology :</md-title>
   <md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
   <md-date>1977</md-date>
   <md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
  <md-description>Includes bibliographical references and index</md-description>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="2962705161">
-  <md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+  <md-title><match>Computer </match>processing of dynamic images from an Anger scintillation camera :</md-title>
   <md-title-remainder>the proceedings of a workshop</md-title-remainder>
   <md-date>1974</md-date>
   <md-description tag="504">Includes bibliographical references and index</md-description>
  <md-description>Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates</md-description>
  <location id="z3950.indexdata.com/marc"
     name="Index Data MARC test server" checksum="3136897450">
-  <md-title>The Computer Bible</md-title>
+  <md-title>The <match>Computer </match>Bible /</md-title>
   <md-date>1973-1980</md-date>
   <md-description tag="500">Hebrew and Greek; introductions in English</md-description>
   <md-description tag="500">Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates</md-description>
index 5d7ac6d..ab3392a 100644 (file)
@@ -4,7 +4,7 @@
 DEBUG=0   # 0 for release, 1 for debug
 USE_MANIFEST = 1 # Can be enabled Visual Studio 2005/2008
 PACKAGE_NAME=pazpar2
-PACKAGE_VERSION=1.6.31
+PACKAGE_VERSION=1.6.32
 
 # YAZ
 YAZ_DIR=..\..\yaz