added section on explain, search, scan and on PQN
[idzebra-moved-to-github.git] / doc / querymodel.xml
1  <chapter id="querymodel">
2   <!-- $Id: querymodel.xml,v 1.8 2006-06-16 12:54:55 marc Exp $ -->
3   <title>Query Model</title>
4   
5   <sect1 id="querymodel-overview">
6    <title>Query Model Overview</title>
7    
8
9    <sect2 id="querymodel-query-languages">
10     <title>Query Languages</title>
11  
12     <para>
13      Zebra is born as a networking Information Retrieval engine adhering
14      to the international standards 
15      <ulink url="&url.z39.50;">Z39.50</ulink> and
16      <ulink url="&url.sru;">SRU</ulink>,
17      and implement the 
18      <literal>type-1 Reverse Polish Notation (RPN)</literal> query
19      model defined there.
20      Unfortunately, this model has only defined a binary
21      encoded representation, which is used as transport packaging in
22      the Z39.50 protocol layer. This representation is not human
23      readable, nor defines any convenient way to specify queries. 
24     </para>
25     <para>
26      Since the <literal>type-1 (RPN)</literal> 
27      query structure has no direct, useful string
28      representation, every origin application needs to provide some
29      form of mapping from a local query notation or representation to it.
30      </para>
31
32
33    <sect3 id="querymodel-query-languages-pqf">
34     <title>Prefix Query Format (PQF)</title>
35
36    <para>
37      Index Data has defined a textual representaion in the 
38      <literal>Prefix Query Format</literal>, short
39      <literal>PQF</literal>, which mappes 
40       <literal>one-to-one</literal> to binary encoded  
41       <literal>type-1 RPN</literal> query packages.
42       It has been adopted by other
43       parties developing Z39.50 software, and is often referred to as
44      <literal>Prefix Query Notation</literal>, or in short 
45      <literal>PQN</literal>. See       
46      <xref linkend="querymodel-pqf"/> for further explanaitions and
47      descriptions of Zebra's capabilities.  
48     </para>
49    </sect3>    
50
51    <sect3 id="querymodel-query-languages-cql">
52     <title>Common Query Language (CQL)</title>
53      <para>
54       The query model of the   <literal>type-1 RPN</literal>,
55       expressed in <literal>PQF/PQN</literal> is natively supported. 
56       On the other hand, the default <literal>SRU</literal>
57       webservices <literal>Common Query Language</literal>
58      <ulink url="&url.cql;">CQL</ulink> is not natively supported.
59      </para>
60      <para>
61      Zebra can be configured to understand and map CQL to PQF. See
62      <xref linkend="querymodel-cql-to-pqf"/>.
63     </para>
64    </sect3>    
65  
66    </sect2>
67
68    <sect2 id="querymodel-operation-types">
69     <title>Operation types</title>
70     <para>
71      Zebra supports all of the three different
72      <literal>Z39.50/SRU</literal> operations defined in the
73      standards: <literal>explain</literal>, <literal>search</literal>, 
74      and <literal>scan</literal>. A short description of the
75      functionality and purpose of each is quite in order here. 
76     </para>
77
78     <sect3 id="querymodel-operation-type-explain">
79      <title>Explain Operation</title>
80      <para>
81       The <emphasis>syntax</emphasis> of Z39.50/SRU queries is
82       well known to any client, but the specific
83       <emphasis>semantics</emphasis> - taking into account a
84       particular servers functionalities and abilities - must be
85       discovered from case to case. Enters the 
86       <literal>explain</literal> operation, which provides the means
87       for learning which  
88       <emphasis>fields</emphasis> (also called
89       <emphasis>indexes</emphasis> or <emphasis>access points</emphasis>
90       are provided, which default parameter the server uses, which
91       retrieve document formats are defined, and which specific parts
92       of the general query model are supported.      
93      </para>
94      <para>
95       The Z39.50 embeddes the <literal>explain</literal> operation
96       by perfoming a 
97       <literal>search</literal> in the magic 
98       <literal>IR-Explain-1</literal> database;
99       see <xref linkend="querymodel-exp1"/>. 
100      </para>
101      <para>
102       In SRU, <literal>explain</literal> is an entirely  seperate
103       operation, which returns an  <literal>Zeerex
104       XML</literal> record according to the 
105       structure defined by the protocol.
106      </para>
107      <para>
108       In both cases, the information gathered through
109       <literal>explain</literal> operations can be used to
110       auto-configure a client user interface to the servers
111       capabilities.  
112      </para>
113     </sect3>
114
115     <sect3 id="querymodel-operation-type-search">
116      <title>Search Operation</title>
117      <para>
118       Search and retrieve interactions are the raison d'ĂȘtre. 
119       They are used to query the remote database and
120       return search result documents.  Search queries span from
121       simple free text searches to nested complex boolean queries,
122       targeting specific indexes, and possibly enhanced with many
123       query semantic specifications. Search interactions are the heart
124       and soul of Z39.50/SRU servers.
125      </para>
126     </sect3>
127
128     <sect3 id="querymodel-operation-type-scan">
129      <title>Scan Operation</title>
130      <para>
131       The <literal>scan</literal> operation is a helper functionality,
132        which operates on one index or access point a time. 
133      </para>
134      <para>
135       It provides
136       the means to investigate the content of specific indexes.
137       Scanning an index returns a handfull of terms actually fond in
138       the indexes, and in addition the <literal>scan</literal>
139       operation returns th enumber of documents indexed by each term.
140       A search client can use this information to propose proper
141       spelling of search terms, to auto-fill search boxes, or to 
142       display  controlled vocabularies.
143      </para>
144     </sect3>
145
146    </sect2>
147
148  </sect1>
149
150   
151   <sect1 id="querymodel-pqf">
152    <title>Prefix Query Format structure and syntax</title>
153    <para>
154     The <ulink url="&url.yaz.pqf;">PQF grammer</ulink>
155     is documented in the YAZ manual, and shall not be
156     repeated here. This textual PQF representation
157     is always during search mapped to the equivalent Zebra internal
158     query parse tree. 
159    </para>
160    
161    <sect2 id="querymodel-pqf-tree">
162     <title>PQF tree structure</title>
163     <para>
164      The PQF parse tree - or the equivalent textual representation -
165      may start with one specification of the 
166      <emphasis>attribute set</emphasis> used. Following is a query
167      tree, which 
168      consists of <emphasis>atomic query parts (APT)</emphasis>, eventually
169      paired by <emphasis>boolean binary operators</emphasis>, and 
170      finally  <emphasis>recursively combined </emphasis> into 
171      complex query trees.   
172     </para>
173     
174     <sect3 id="querymodel-attribute-sets">
175      <title>Attribute sets</title>
176      <para>
177       Attribute sets define the exact meaning and semantics of queries
178       issued. Zebra comes with some predefined attribute set
179       definitions, others can easily be defined and added to the
180       configuration.
181       <note>
182        The Zebra internal query procesing is modeled after 
183        the <literal>Bib1</literal> attribute set, and the non-use
184        attributes type 2-6 are hard-wired in. It is therefore essential
185        to be familiar with <xref linkend="querymodel-bib1"/>. 
186       </note>
187      </para>
188      
189      <table id="querymodel-attribute-sets-table"
190       frame="all" rowsep="1" colsep="1" align="center">
191
192       <caption>Attribute sets predefined in Zebra</caption>
193        <!--
194        <thead>
195        <tr><td>one</td><td>two</td></tr>
196       </thead>
197        -->
198        <tbody>
199         <tr>
200          <td><literal>exp-1</literal></td>
201          <td><literal>Explain</literal> attribute set</td>
202          <td>Special attribute set used on the special automagic
203           <literal>IR-Explain-1</literal> database to gain information on
204           server capabilities, database names, and database
205           and semantics.</td>
206         </tr>
207         <tr>
208          <td><literal>bib-1</literal></td>
209          <td><literal>Bib1</literal> attribute set</td>
210          <td>Standard PQF query language attribute set which defines the
211           semantics of Z39.50 searching. In addition, all of the
212           non-use attributes (type 2-9) define the Zebra internal query
213           processing</td>
214         </tr>
215         <tr>
216          <td><literal>gils</literal></td>
217          <td><literal>GILS</literal> attribute set</td>
218          <td>Extention to the <literal>Bib1</literal> attribute set.</td>
219         </tr>
220        </tbody>
221      </table>
222     </sect3>
223     
224     <sect3 id="querymodel-boolean-operators">
225      <title>Boolean operators</title>
226      <para>
227       A pair of subquery trees, or of atomic queries, is combined
228       using the standard boolean operators into new query trees.
229      </para>
230      
231      <table id="querymodel-boolean-operators-table"
232       frame="all" rowsep="1" colsep="1" align="center">
233
234       <caption>Boolean operators</caption>
235        <!--
236        <thead>
237        <tr><td>one</td><td>two</td></tr>
238       </thead>
239        -->
240        <tbody>
241         <tr><td><literal>@and</literal></td>
242          <td>binary <literal>AND</literal> operator</td>
243          <td>Set intersection of two atomic queries hit sets</td>
244         </tr>
245         <tr><td><literal>@or</literal></td>
246          <td>binary <literal>OR</literal> operator</td>
247          <td>Set union of two atomic queries hit sets</td>
248         </tr>
249         <tr><td><literal>@not</literal></td>
250          <td>binary <literal>AND NOT</literal> operator</td>
251          <td>Set complement of two atomic queries hit sets</td>
252         </tr>
253         <tr><td><literal>@prox</literal></td>
254          <td>binary <literal>PROXIMY</literal> operator</td>
255          <td>Set intersection of two atomic queries hit sets. In 
256           addition, the intersection set is purged for all 
257           documents which do not satisfy the requested query 
258           term proximity. Usually a proper subset of the AND 
259           operation.</td>
260         </tr>
261        </tbody>
262      </table>
263      
264      <para>
265       For example, we can combine the terms 
266       <emphasis>information</emphasis> and <emphasis>retrieval</emphasis> 
267       into different searches in the default index of the default
268       attribute set as follows.
269       Querying for the union of all documents containing the
270       terms <emphasis>information</emphasis> OR
271       <emphasis>retrieval</emphasis>: 
272       <screen>
273        Z> find @or information retrieval
274       </screen>
275      </para>
276      <para>
277       Querying for the intersection of all documents containing the
278       terms <emphasis>information</emphasis> AND
279       <emphasis>retrieval</emphasis>: 
280       The hit set is a subset of the coresponding
281       OR query.
282       <screen>
283        Z> find @and information retrieval
284       </screen>
285      </para>
286      <para>
287       Querying for the intersection of all documents containing the
288       terms <emphasis>information</emphasis> AND
289       <emphasis>retrieval</emphasis>, taking proximity into account:
290       The hit set is a subset of the coresponding
291       AND query.
292       <screen>
293        Z> find @prox information retrieval
294       </screen>
295      </para>
296      <para>
297       Querying for the intersection of all documents containing the
298       terms <emphasis>information</emphasis> AND
299       <emphasis>retrieval</emphasis>, in the same order and near each
300       other as described in the term list  
301       The hit set is a subset of the coresponding
302       PROXIMY query.
303       <screen>
304        Z> find "information retrieval"
305       </screen>
306      </para>
307     </sect3>
308     
309     
310     <sect3 id="querymodel-atomic-queries">
311      <title>Atomic queries (APT)</title>
312      <para>
313       Atomic queries are the query parts which work on one acess point
314       only. These consist of <literal>an attribute list</literal>
315       followed by a <literal>single term</literal> or a
316       <literal>quoted term list</literal>, and are often called 
317       <emphasis>Attributes-Plus-Terms (APT)</emphasis> queries.
318      </para>
319      <para>
320       Unsupplied non-use attributes type 2-9 are either inherited from
321       higher nodes in the query tree, or are set to Zebra's default values.
322       See <xref linkend="querymodel-bib1"/> for details. 
323      </para>
324      
325      <table id="querymodel-atomic-queries-table"
326       frame="all" rowsep="1" colsep="1" align="center">
327
328       <caption>Atomic queries</caption>
329        <!--
330        <thead>
331        <tr><td>one</td><td>two</td></tr>
332       </thead>
333        -->
334        <tbody>
335         <tr><td><emphasis>attribute list</emphasis></td>
336          <td>List of <literal>orthogonal</literal> attributes</td>
337          <td>Any of the orthogonal attribute types may be omitted,
338           these are inherited from higher query tree nodes, or if not
339           inherited, are set to the default Zebra configuration values.
340          </td>
341         </tr>
342         <tr><td><emphasis>term</emphasis></td>
343          <td>single <literal>term</literal> 
344           or <literal>quoted term list</literal>   </td>
345          <td>Here the search terms or list of search terms is added
346           to the query</td>
347         </tr>
348        </tbody>
349      </table>
350      <para>
351       Querying for the term <emphasis>information</emphasis> in the
352       default index using the default attribite set, the server choice
353       of access point/index, and the default non-use attributes.
354       <screen>
355        Z> find "information"
356       </screen>
357      </para>
358      <para>
359       Equivalent query fully specified including all default values:
360       <screen>
361        Z> find @attrset bib-1 @attr 1=1017 @attr 2=3 @attr 3=3 @attr 4=1 @attr 5=100 @attr 6=1 "information"
362       </screen>
363      </para>
364      
365      <para>
366       Finding all documents which have empty titles. Notice that the
367       empty term must be quoted, but is otherwise legal.
368       <screen>
369        Z> find @attr 1=4 ""
370       </screen>
371      </para>
372
373     </sect3>
374     
375     <sect3 id="querymodel-use-string">
376      <title>Zebra's special use attribute type 1 of form 'string'</title>
377      <para>
378       The numeric <literal>use (type 1)</literal> attribute is usually 
379       refered to from a given
380       attribute set. In addition, Zebra let you use 
381       <emphasis>any internal index
382        name defined in your configuration</emphasis> 
383       as use atribute value. This is a great feature for
384       debugging, and when you do
385       not need the complecity of defined use attribute values. It is
386       the preferred way of accessing Zebra indexes directly.  
387      </para>
388      <para>
389       Finding all documents which have the term list "information
390       retrieval" in an Zebra index, using it's internal full string name.
391       <screen>
392        Z> find @attr 1=sometext "information retrieval"
393       </screen>
394      </para>
395      <para>
396       Searching the bib-1 use attribute 54 using it's string name:
397       <screen>
398        Z> find @attr 1=Code-language eng
399       </screen>
400      </para>
401      <para>
402       Searching in any silly string index - if it's defined in your
403       indexation rules and can be parsed by the PQF parser. 
404       This is definitely not the recommended use of
405       this facility, as it might confuse your users with some very
406       unexpected results.
407       <screen>
408        Z> find @attr 1=silly/xpath/alike[@index]/name "information retrieval"
409       </screen>
410      </para>
411      <para>
412       See <xref linkend="querymodel-bib1-mapping"/> for details, and 
413       <xref linkend="server-sru"/>
414       for the SRU PQF query extention using string names as a fast
415       debugging facility.
416      </para>
417     </sect3>
418     
419     <sect3 id="querymodel-use-xpath">
420      <title>Zebra's special use attribute type 1 of form 'XPath' 
421       for GRS filters</title>
422      <para>
423       As we have seen above, it is possible (albeit seldom a great
424       idea) to emulate 
425       <ulink url="http://www.w3.org/TR/xpath">XPath 1.0</ulink> based
426       search by defining <literal>use (type 1)</literal> 
427       <emphasis>string</emphasis> attributes which in appearence 
428       <emphasis>resemble XPath queries</emphasis>. There are two
429       problems with this approach: first, the XPath-look-alike has to
430       be defined at indexation time, no new undefined
431       XPath queries can entered at search time, and second, it might
432       confuse users very much that an XPath-alike index name in fact
433       gets populated from a possible entirely different XML element
434       than it pretends to acess. 
435      </para>
436      <para>
437       When using the <literal>GRS Record Model</literal> 
438       (see  <xref linkend="record-model-grs"/>), we have the
439       possibility to embed <emphasis>life</emphasis> 
440       XPath expressions
441       in the PQF queries, which are here called
442       <literal>use (type 1)</literal> <emphasis>xpath</emphasis>
443       attributes. You must enable the 
444       <literal>xpath enable</literal> directive in your 
445       <literal>.abs</literal> config files. 
446      </para>
447      <note>
448       Only a <emphasis>very</emphasis> restricted subset of the 
449       <ulink url="http://www.w3.org/TR/xpath">XPath 1.0</ulink> 
450       standard is supported as the GRS record model is simpler than
451       a full XML DOM structure. See the following examples for 
452       possibilities.
453      </note>
454      <para>
455       Finding all documents which have the term "content" 
456       inside a text node found in a specific XML DOM
457       <emphasis>subtree</emphasis>, whose starting element is 
458       adressed by XPath. 
459       <screen>
460        Z> find @attr 1=/root content 
461        Z> find @attr 1=/root/first content
462       </screen>
463       <emphasis>Notice that the
464        XPath must be absolute, i.e., must start with '/', and that the
465        XPath <literal>decendant-or-self</literal> axis followed by a
466        text node selection <literal>text()</literal> is implicitly
467        appended to the stated XPath.
468       </emphasis>
469       It follows that the above searches are interpreted as:
470       <screen>
471        Z> find @attr 1=/root//text() content 
472        Z> find @attr 1=/root/first//text() content
473       </screen>
474      </para>
475      
476      <para>     
477       Filter the adressing XPath by a predicate working on exact
478       string values in
479       attributes (in the XML sense) can be done: return all those docs which
480       have the term "english" contained in one of all text subnodes of
481       the subtree defined by the XPath
482       <literal>/record/title[@lang='en']</literal> 
483       <screen>
484        Z> find @attr 1=/record/title[@lang='en'] english
485       </screen>
486      </para>
487      
488      <para>     
489       Combining numeric indexes, boolean expressions, 
490       and xpath based searches is possible:
491       <screen>
492        Z> find @attr 1=/record/title @and foo bar
493        Z> find @and @attr 1=/record/title foo @attr 1=4 bar
494       </screen> 
495      </para>
496      <para>
497       Escaping PQF keywords and other non-parseable XPath constructs
498       with <literal>'{ }'</literal> to prevent syntax errors:
499       <screen>
500        Z> find @attr {1=/root/first[@attr='danish']} content
501        Z> find @attr {1=/root/second[@attr='danish lake']} 
502        Z> find @attr {1=/root/third[@attr='dansk s\xc3\xb8']} 
503       </screen>
504      </para>
505      <warning>
506       It is worth mentioning that these dynamic performed XPath
507       queries are a performance bottelneck, as no optimized
508       specialized indexes can be used. Therefore, avoid the use of
509       this facility when speed is essential, and the database content
510       size is medium to large. 
511      </warning>
512     </sect3>
513     
514    </sect2>
515    
516    <sect2 id="querymodel-exp1">
517     <title>Explain Attribute Set</title>
518     <para>
519      The Z39.50 standard defines the  
520      <ulink url="&url.z39.50.explain;">Explain</ulink>attribute set
521      <literal>exp-1</literal>, which is used to discover information 
522      about a server's search semantics and functional capabilities
523      Zebra exposes a  "classic" 
524      Explain database by base name <literal>IR-Explain-1</literal>, which
525      is populated with system internal information.  
526     </para>
527    <para>
528      The attribute-set <literal>exp-1</literal> consists of a single 
529      <literal>Use (type 1)</literal> attribute. 
530     </para>
531     <para>
532      In addition, the non-Use
533      <literal>bib-1</literal> attributes, that is, the types 
534      <literal>Relation</literal>, <literal>Position</literal>,
535      <literal>Structure</literal>, <literal>Truncation</literal>, 
536      and <literal>Completeness</literal> are imported from 
537      the <literal>bib-1</literal> attribute set, and may be used
538      within any explain query. 
539     </para>
540     
541     <sect3 id="querymodel-exp1-use">
542     <title>Use Attributes (type = 1)</title>
543      <para>
544       The following Explain search atributes are supported:
545       <literal>ExplainCategory</literal> (@attr 1=1), 
546       <literal>DatabaseName</literal> (@attr 1=3), 
547       <literal>DateAdded</literal> (@attr 1=9), 
548       <literal>DateChanged</literal>(@attr 1=10).
549      </para>
550      <para>
551       A search in the use attribute  <literal>ExplainCategory</literal>
552       supports only these predefined values:
553       <literal>CategoryList</literal>, <literal>TargetInfo</literal>,
554       <literal>DatabaseInfo</literal>, <literal>AttributeDetails</literal>.
555      </para>
556      <para>
557       See <filename>tab/explain.att</filename> and the 
558       <ulink url="&url.z39.50;">Z39.50</ulink> standard
559       for more information.
560      </para>
561     </sect3>
562     
563     <sect3>
564      <title>Explain searches with yaz-client</title>
565      <para>
566       Classic Explain only defines retrieval of Explain information
567       via ASN.1. Pratically no Z39.50 clients supports this. Fortunately
568       they don't have to - Zebra allows retrieval of this information
569       in other formats:
570       <literal>SUTRS</literal>, <literal>XML</literal>, 
571       <literal>GRS-1</literal> and  <literal>ASN.1</literal> Explain.
572      </para>
573      
574      <para>
575       List supported categories to find out which explain commands are
576       supported: 
577       <screen>
578        Z> base IR-Explain-1
579        Z> find @attr exp1 1=1 categorylist
580        Z> form sutrs
581        Z> show 1+2
582       </screen>
583      </para>
584      
585      <para>
586       Get target info, that is, investigate which databases exist at
587       this server endpoint:
588       <screen>
589        Z> base IR-Explain-1
590        Z> find @attr exp1 1=1 targetinfo
591        Z> form xml
592        Z> show 1+1
593        Z> form grs-1
594        Z> show 1+1
595        Z> form sutrs
596        Z> show 1+1
597       </screen>
598      </para>
599      
600      <para>
601       List all supported databases, the number of hits
602       is the number of databases found, which most commonly are the
603       following two:
604       the <literal>Default</literal> and the
605       <literal>IR-Explain-1</literal> databases.
606       <screen>
607        Z> base IR-Explain-1
608        Z> find @attr exp1 1=1 databaseinfo
609        Z> form sutrs
610        Z> show 1+2
611       </screen>
612      </para>
613      
614      <para>
615       Get database info record for database <literal>Default</literal>.
616       <screen>
617        Z> base IR-Explain-1
618        Z> find @and @attr exp1 1=1 databaseinfo @attr exp1 1=3 Default
619       </screen>
620       Identical query with explicitly specified attribute set:
621       <screen>
622        Z> base IR-Explain-1
623        Z> find @attrset exp1 @and @attr 1=1 databaseinfo @attr 1=3 Default
624       </screen>
625      </para>
626      
627      <para>
628       Get attribute details record for database
629       <literal>Default</literal>.
630       This query is very useful to study the internal Zebra indexes.
631       If records have been indexed using the <literal>alvis</literal>
632       XSLT filter, the string representation names of the known indexes can be
633       found.
634       <screen>
635        Z> base IR-Explain-1
636        Z> find @and @attr exp1 1=1 attributedetails @attr exp1 1=3 Default
637       </screen>
638       Identical query with explicitly specified attribute set:
639       <screen>
640        Z> base IR-Explain-1
641        Z> find @attrset exp1 @and @attr 1=1 attributedetails @attr 1=3 Default
642       </screen>
643      </para>
644     </sect3>
645     
646    </sect2>
647    
648    <sect2 id="querymodel-bib1">
649     <title>Bib1 Attribute Set</title>
650     <para>
651      Something about querying to be written ..
652     </para>
653     <para>
654      Most of the information contained in this section is an excerpt of
655      the <literal>ATTRIBUTE SET BIB-1 (Z39.50-1995)
656       SEMANTICS</literal>, 
657      found at  <ulink url="&url.z39.50.attset.bib1.1995;">. The BIB-1
658       Attribute Set Semantics</ulink> from 1995, also in an updated 
659      <ulink url="&url.z39.50.attset.bib1;">Bib-1
660       Attribute Set</ulink> 
661      version from 2003. Index Data is not the copyright holder of this
662      information. 
663     </para>
664     
665     
666    <sect3 id="querymodel-bib1-use">
667      <title>Use Attributes (type 1)</title>
668     </sect3>
669
670     <para>
671      A use attribute specifies an access point for any atomic query.
672      These acess points are highly dependent on the attribute set used
673      in the query, and are user configurable using the following
674      default configuration files:
675      <filename>tab/bib1.att</filename>,
676      <filename>tab/dan1.att</filename>,
677      <filename>tab/explain.att</filename>, and
678      <filename>tab/gils.att</filename>.
679      New attribute sets can be added by adding new 
680      <filename>tab/*.att</filename> configuration files, which need to
681      be sourced in the main configuration <filename>zebra.cfg</filename>.
682      </para>
683
684     <para>
685      In addition, Zebra allows the acess of 
686      <emphasis>internal index names</emphasis> and <emphasis>dynamic
687      XPath</emphasis> as use attributes. 
688      See  <xref linkend="querymodel-use-string"/> and 
689      <xref linkend="querymodel-use-xpath"/> for
690      alternative acess to the Zebra internal index names and XPath queries.
691     </para> 
692
693     <para>
694      Phrase search for <emphasis>information retrieval</emphasis> in
695      the title-register:
696      <screen>
697       Z> find @attr 1=4 "information retrieval"
698      </screen>
699     </para>
700
701     
702     <sect3 id="querymodel-bib1-relation">
703      <title>Relation Attributes (type 2)</title>
704      
705      <para>
706       Relation attributes describe the relationship of the access
707       point (left side 
708       of the relation) to the search term as qualified by the attributes (right
709       side of the relation), e.g., Date-publication &lt;= 1975.
710       </para>
711
712      <table id="querymodel-bib1-relation-table"
713       frame="all" rowsep="1" colsep="1" align="center">
714
715       <caption>Relation Attributes (type 2)</caption>
716       <thead>
717         <tr>
718          <td>Relation</td>
719          <td>Value</td>
720          <td>Notes</td>
721         </tr>
722        </thead>
723        <tbody>
724         <tr>
725          <td> Less than</td>
726          <td>1</td>
727          <td>supported</td>
728         </tr>
729         <tr>
730          <td>Less than or equal</td>
731          <td>2</td>
732          <td>supported</td>
733         </tr>
734         <tr>
735          <td>Equal</td>
736          <td>3</td>
737          <td>default</td>
738         </tr>
739         <tr>
740          <td>Greater or equal</td>
741          <td>4</td>
742          <td>supported</td>
743         </tr>
744         <tr>
745          <td>Greater than</td>
746          <td>5</td>
747          <td>supported</td>
748         </tr>
749         <tr>
750          <td>Not equal</td>
751          <td>6</td>
752          <td>unsupported</td>
753         </tr>
754         <tr>
755          <td>Phonetic</td>
756          <td>100</td>
757          <td>unsupported</td>
758         </tr>
759         <tr>
760          <td>Stem</td>
761          <td>101</td>
762          <td>unsupported</td>
763         </tr>
764         <tr>
765          <td>Relevance</td>
766          <td>102</td>
767          <td>supported</td>
768         </tr>
769         <tr>
770          <td>AlwaysMatches</td>
771          <td>103</td>
772          <td>unsupported</td>
773         </tr>
774        </tbody>
775      </table>
776
777      <para>
778       The relation attribute 
779       <literal>relevance (102)</literal> is supported, see
780       <xref linkend="administration-ranking"/> for full information.
781       <!-- always-matches (103) not supported for all indexes -->
782      </para>
783      
784     <para>
785      All ordering operations are based on a lexicographical ordering, 
786      <emphasis>expect</emphasis> when the 
787      <literal>structure attribute numeric (109)</literal> is used. In
788      this case, ordering is numerical. See 
789       <xref linkend="querymodel-bib1-structure"/>.
790     </para>
791
792      <para>
793      Ranked search for <emphasis>information retrieval</emphasis> in
794      the title-register:
795      <screen>
796       Z> find @attr 1=4 @attr 2=102 "information retrieval"
797      </screen>
798     </para>
799     </sect3>
800
801     <sect3 id="querymodel-bib1-position">
802      <title>Position Attributes (type 3)</title>
803  
804      <para>
805       The position attribute specifies the location of the search term
806       within the field or subfield in which it appears.
807      </para>
808
809      <table id="querymodel-bib1-position-table"
810       frame="all" rowsep="1" colsep="1" align="center">
811
812       <caption>Position Attributes (type 3)</caption>
813       <thead>
814         <tr>
815          <td>Position</td>
816          <td>Value</td>
817          <td>Notes</td>
818         </tr>
819        </thead>
820        <tbody>
821         <tr>
822          <td>First in field </td>
823          <td>1</td>
824          <td>unsupported</td>
825         </tr>
826         <tr>
827          <td>First in subfield</td>
828          <td>2</td>
829          <td>unsupported</td>
830         </tr>
831         <tr>
832          <td>Any position in field</td>
833          <td>3</td>
834          <td>default</td>
835         </tr>
836        </tbody>
837      </table>
838  
839     <para>
840       The position attribute values <literal>first in field (1)</literal>,
841       and <literal>first in subfield(2)</literal> are unsupported.
842       Using them does not trigger an error, but silent defaults to 
843       <literal>any position in field (3)</literal>.
844       <!-- It should -->
845       </para>
846     </sect3>
847     
848     <sect3 id="querymodel-bib1-structure">
849      <title>Structure Attributes (type 4)</title>
850    
851      <para>
852       The structure attribute specifies the type of search
853       term. This causes the search to be mapped on
854       different Zebra internal indexes, which must have been defined
855       at index time. 
856      </para>
857
858      <para> 
859       The possible values of the  
860       <literal>structure attribute (type 4)</literal> can be defined
861       using the configuraiton file <filename>
862       tab/default.idx</filename>.
863       The default configuration is summerized in this table.
864      </para>
865
866      <table id="querymodel-bib1-structure-table"
867       frame="all" rowsep="1" colsep="1" align="center">
868
869       <caption>Structure Attributes (type 4)</caption>
870       <thead>
871         <tr>
872          <td>Structure</td>
873          <td>Value</td>
874          <td>Notes</td>
875         </tr>
876        </thead>
877        <tbody>
878         <tr>
879          <td>Phrase </td>
880          <td>1</td>
881          <td>default</td>
882         </tr>
883         <tr>
884          <td>Word</td>
885          <td>2</td>
886          <td>supported</td>
887         </tr>
888         <tr>
889          <td>Key</td>
890          <td>3</td>
891          <td>supported</td>
892         </tr>
893         <tr>
894          <td>Year</td>
895          <td>4</td>
896          <td>supported</td>
897         </tr>
898         <tr>
899          <td>Date (normalized)</td>
900          <td>5</td>
901          <td>supported</td>
902         </tr>
903         <tr>
904          <td>Word list</td>
905          <td>6</td>
906          <td>supported</td>
907         </tr>
908         <tr>
909          <td>Date (un-normalized)</td>
910          <td>100</td>
911          <td>unsupported</td>
912         </tr>
913         <tr>
914          <td>Name (normalized) </td>
915          <td>101</td>
916          <td>unsupported</td>
917         </tr>
918         <tr>
919          <td>Name (un-normalized) </td>
920          <td>102</td>
921          <td>unsupported</td>
922         </tr>
923         <tr>
924          <td>Structure</td>
925          <td>103</td>
926          <td>unsupported</td>
927         </tr>
928         <tr>
929          <td>Urx</td>
930          <td>104</td>
931          <td>supported</td>
932         </tr>
933         <tr>
934          <td>Free-form-text</td>
935          <td>105</td>
936          <td>supported</td>
937         </tr>
938         <tr>
939          <td>Document-text</td>
940          <td>106</td>
941          <td>supported</td>
942         </tr>
943         <tr>
944          <td>Local-number</td>
945          <td>107</td>
946          <td>supported</td>
947         </tr>
948         <tr>
949          <td>String</td>
950          <td>108</td>
951          <td>unsupported</td>
952         </tr>
953         <tr>
954          <td>Numeric string</td>
955          <td>109</td>
956          <td>supported</td>
957         </tr>
958        </tbody>
959      </table>
960     </sect3>
961     
962     <para>
963      The structure attribute value <literal>local-number
964       (107)</literal>
965      is supported, and maps always to the Zebra internal document ID.
966      </para>
967
968     <para>
969      For example, in
970      the GILS schema (<literal>gils.abs</literal>), the
971      west-bounding-coordinate is indexed as type <literal>n</literal>,
972      and is therefore searched by specifying
973      <emphasis>structure</emphasis>=<emphasis>Numeric String</emphasis>.
974      To match all those records with west-bounding-coordinate greater
975      than -114 we use the following query:
976      <screen>
977       Z> find @attr 4=109 @attr 2=5 @attr gils 1=2038 -114
978      </screen> 
979     </para>
980
981     <sect3 id="querymodel-bib1-truncation">
982      <title>Truncation Attributes (type = 5)</title>
983
984      <para>
985       The truncation attribute specifies whether variations of one or
986       more characters are allowed between serch term and hit terms, or
987       not. Using non-default truncation attributes will broaden the
988       document hit set of a search query.
989      </para>
990
991      <table id="querymodel-bib1-truncation-table"
992       frame="all" rowsep="1" colsep="1" align="center">
993
994       <caption>Truncation Attributes (type 5)</caption>
995       <thead>
996         <tr>
997          <td>Truncation</td>
998          <td>Value</td>
999          <td>Notes</td>
1000         </tr>
1001        </thead>
1002        <tbody>
1003         <tr>
1004          <td>Right truncation </td>
1005          <td>1</td>
1006          <td>supported</td>
1007         </tr>
1008         <tr>
1009          <td>Left truncation</td>
1010          <td>2</td>
1011          <td>supported</td>
1012         </tr>
1013         <tr>
1014          <td>Left and right truncation</td>
1015          <td>3</td>
1016          <td>supported</td>
1017         </tr>
1018         <tr>
1019          <td>Do not truncate</td>
1020          <td>100</td>
1021          <td>default</td>
1022         </tr>
1023         <tr>
1024          <td>Process # in search term</td>
1025          <td>101</td>
1026          <td>supported</td>
1027         </tr>
1028         <tr>
1029          <td>RegExpr-1 </td>
1030          <td>102</td>
1031          <td>supported</td>
1032         </tr>
1033         <tr>
1034          <td>RegExpr-2</td>
1035          <td>103</td>
1036          <td>supported</td>
1037         </tr>
1038        </tbody>
1039      </table>
1040
1041      <para>
1042       Truncation attribute value 
1043       <literal>Process # in search term (100)</literal> is a
1044       poor-man's regular expression search. It maps
1045       each <literal>#</literal> to <literal>.*</literal>, and
1046       performes then a <literal>Regexp-1 (102)</literal> regular
1047       expression search.
1048      </para>
1049      <para>
1050       Truncation attribute value 
1051        <literal>Regexp-1 (102)</literal> is a normal regular search,
1052       see.
1053      </para>
1054      <para>
1055        Truncation attribute value 
1056       <literal>Regexp-2 (103) </literal> is a Zebra specific extention
1057       which allows <emphasis>fuzzy</emphasis> matches. One single
1058       error in spelling of search terms is allowed, i.e., a document
1059       is hit if it includes a term which can be mapped to the used
1060       search term by one character substitution, addition, deletion or
1061       change of posiiton. 
1062       </para>  
1063       <!--
1064       Special 104, 105, 106 are deprecated and will be removed! -->
1065     </sect3>
1066     
1067     <sect3 id="querymodel-bib1-completeness">
1068     <title>Completeness Attributes (type = 6)</title>
1069      <para>
1070       This attribute is ONLY used if structure w, p is to be
1071       chosen. completeness is ignorned if not w, p is to be
1072       used..
1073       Incomplete field(1) is the default and makes Zebra use
1074       register type w.
1075       complete subfield(2) and complete field(3) both triggers
1076       search field type p.
1077      </para>
1078     </sect3>
1079    </sect2>
1080     
1081
1082    <sect2 id="querymodel-zebra-attr-search">
1083     <title>Zebra specific Search Extentions to all Attribute Sets</title>
1084     <para>
1085      Zebra extends the Bib1 attribute types, and these extentions are
1086      recognized regardless of attribute 
1087      set used in a <literal>search</literal> operation query.
1088     </para>
1089
1090      <table id="querymodel-zebra-attr-search-table"
1091       frame="all" rowsep="1" colsep="1" align="center">
1092
1093       <caption>Zebra Search Attribute Extentions</caption>
1094        <thead>
1095         <tr>
1096          <td>Name</td>
1097          <td>Value</td>
1098          <td>Operation</td>
1099          <td>Zebra version</td>
1100         </tr>
1101       </thead>
1102        <tbody>
1103         <tr>
1104          <td>Embedded Sort</td>
1105          <td>7</td>
1106          <td>search</td>
1107          <td>1.1</td>
1108         </tr>
1109         <tr>
1110          <td>Term Set</td>
1111          <td>8</td>
1112          <td>search</td>
1113          <td>1.1</td>
1114         </tr>
1115         <tr>
1116          <td>Rank Weight</td>
1117          <td>9</td>
1118          <td>search</td>
1119          <td>1.1</td>
1120         </tr>
1121         <tr>
1122          <td>Approx Limit</td>
1123          <td>9</td>
1124          <td>search</td>
1125          <td>1.4</td>
1126         </tr>
1127         <tr>
1128          <td>Term Reference</td>
1129          <td>10</td>
1130          <td>search</td>
1131          <td>1.4</td>
1132         </tr>
1133        </tbody>
1134       </table>      
1135
1136     <sect3 id="querymodel-zebra-attr-sorting">
1137      <title>Zebra Extention Embedded Sort Attribute (type 7)</title>
1138     </sect3>
1139     <para>
1140      The embedded sort is a way to specify sort within a query - thus
1141      removing the need to send a Sort Request separately. It is both
1142      faster and does not require clients to deal with the Sort
1143      Facility. 
1144     </para>
1145     <para>
1146      The possible values after attribute <literal>type 7</literal> are
1147      <literal>1</literal> ascending and 
1148      <literal>2</literal> descending. 
1149      The attributes+term (APT) node is separate from the
1150      rest and must be <literal>@or</literal>'ed. 
1151      The term associated with APT is the sorting level in integers,
1152      where <literal>0</literal> means primary sort, 
1153      <literal>1</literal> means secondary sort, and so forth.
1154      See also <xref linkend="administration-ranking"/>.
1155     </para>
1156     <para>
1157      For example, searching for water, sort by title (ascending) 
1158      <screen>
1159       Z> find @or @attr 1=1016 water @attr 7=1 @attr 1=4 0
1160      </screen>
1161     </para>
1162     <para>
1163      Or, searching for water, sort by title ascending, then date descending
1164      <screen>
1165       Z> find @or @or @attr 1=1016 water @attr 7=1 @attr 1=4 0 @attr 7=2 @attr 1=30 1
1166      </screen>
1167     </para>
1168     
1169     <sect3 id="querymodel-zebra-attr-estimation">
1170      <title>Zebra Extention Term Set Attribute (type 8)</title>
1171     </sect3>
1172     <para>
1173      The Term Set feature is a facility that allows a search to store
1174      hitting terms in a "pseudo" resultset; thus a search (as usual) +
1175      a scan-like facility. Requires a client that can do named result
1176      sets since the search generates two result sets. The value for
1177      attribute 8 is the name of a result set (string). The terms in
1178      the named term set are returned as SUTRS records. 
1179     </para>
1180     <para>
1181      For example, searching  for u in title, right truncated, and
1182      storing the result in term set named 'aset'
1183      <screen> 
1184       Z> find @attr 5=1 @attr 1=4 @attr 8=aset u
1185      </screen>
1186     </para>
1187     <warning>
1188      The model has one serious flaw: we don't know the size of term
1189      set. Experimental. Do not use in production code.
1190     </warning>
1191
1192     <sect3 id="querymodel-zebra-attr-weight">
1193      <title>Zebra Extention Rank Weight Attribute (type 9)</title>
1194     </sect3>
1195     <para>
1196      Rank weight is a way to pass a value to a ranking algorithm - so
1197      that one APT has one value - while another as a different one. 
1198      See also <xref linkend="administration-ranking"/>.
1199     </para>
1200     <para>
1201      For example, searching  for utah in title with weight 30 as well
1202      as any with weight 20: 
1203      <screen>  
1204       Z> find @attr 2=102 @or @attr 9=30 @attr 1=4 utah @attr 9=20 utah
1205      </screen>
1206     </para>
1207
1208     <sect3 id="querymodel-zebra-attr-limit">
1209      <title>Zebra Extention Approximative Limit Attribute (type 9)</title>
1210     </sect3>
1211     <para>
1212      Newer Zebra versions normally estemiates hit count for every APT
1213      (leaf) in the query tree. These hit counts are returned as part of
1214      the searchResult-1 facility in the binary encoded Z39.50 search
1215      response packages.
1216     </para>
1217     <para>
1218      By setting a limit for the APT we can make Zebra turn into
1219      approximate hit count when a certain hit count limit is
1220      reached. A value of zero means exact hit count.
1221     </para>
1222     <para>
1223      For example, we might be intersted in exact hit count for a, but
1224      for b we allow hit count estimates for 1000 and higher. 
1225      <screen>
1226       Z> find @and a @attr 9=1000 b
1227      </screen>
1228     </para>
1229     <note>
1230      The estimated hit count fascility makes searches faster, as one
1231      only needs to process large hit lists partially.
1232     </note>
1233     <warning>
1234      This facility clashes with rank weight, because there all
1235      documents in the hit lists need to be examined for scoring and
1236      re-sorting.
1237      It is an experimental
1238      extention. Do not use in production code.
1239     </warning>
1240
1241     <sect3 id="querymodel-zebra-attr-termref">
1242      <title>Zebra Extention Term Reference Attribute (type 10)</title>
1243     </sect3>
1244     <para>
1245      Zebra supports the <literal>searchResult-1</literal> facility. 
1246      If the <literal>Term Reference Attribute (type 10)</literal> is
1247      given, that specifies a subqueryId value returned as part of the
1248      search result. It is a way for a client to name an APT part of a
1249      query. 
1250     </para>
1251     <!--
1252     <para>
1253      <screen>
1254      </screen>
1255     </para>
1256     -->
1257     <warning>
1258      Experimental. Do not use in production code.
1259     </warning>
1260
1261
1262    </sect2>
1263     
1264
1265    <sect2 id="querymodel-zebra-attr-scan">
1266     <title>Zebra specific Scan Extentions to all Attribute Sets</title>
1267     <para>
1268      Zebra extends the Bib1 attribute types, and these extentions are
1269      recognized regardless of attribute 
1270      set used in a <literal>scan</literal> operation query.
1271     </para>
1272      <table id="querymodel-zebra-attr-scan-table"
1273       frame="all" rowsep="1" colsep="1" align="center">
1274
1275       <caption>Zebra Scan Attribute Extentions</caption>
1276        <thead>
1277         <tr>
1278          <td>Name</td>
1279          <td>Type</td>
1280          <td>Operation</td>
1281          <td>Zebra version</td>
1282         </tr>
1283       </thead>
1284        <tbody>
1285         <tr>
1286          <td>Result Set Narrow</td>
1287          <td>8</td>
1288          <td>scan</td>
1289          <td>1.3</td>
1290         </tr>
1291         <tr>
1292          <td>Approximative Limit</td>
1293          <td>9</td>
1294          <td>scan</td>
1295          <td>1.4</td>
1296         </tr>
1297        </tbody>
1298       </table>      
1299
1300     <sect3 id="querymodel-zebra-attr-narrow">
1301      <title>Zebra Extention Result Set Narrow (type 8)</title>
1302     </sect3>
1303     <para>
1304      If attribute <literal>Result Set Narrow (type 8)</literal> 
1305      is given for <literal>scan</literal>, the value is the name of a
1306      result set. Each hit count in <literal>scan</literal> is 
1307      <literal>@and</literal>'ed with the result set given. 
1308     </para>
1309     <!--
1310     <para>
1311      <screen>
1312      </screen>
1313     </para>
1314     -->
1315     <warning>
1316      Experimental and buggy. Definitely not to be used in production code.
1317     </warning>
1318
1319     <sect3 id="querymodel-zebra-attr-approx">
1320      <title>Zebra Extention Approximative Limit (type 9)</title>
1321     </sect3>
1322     <para>
1323      The <literal>Zebra Extention Approximative Limit (type
1324       9)</literal> is a way to enable approx
1325      hit counts for <literal>scan</literal> hit counts, in the same
1326      way as for <literal>search</literal> hit counts. 
1327     </para>
1328     <!--
1329     <para>
1330      <screen>
1331      </screen>
1332     </para>
1333     -->
1334     <warning>
1335      Experimental. Do not use in production code.
1336     </warning>
1337
1338
1339    </sect2>
1340     
1341
1342    <sect2 id="querymodel-bib1-mapping">
1343     <title>Mapping from Bib1 Attributes to Zebra internal 
1344      register indexes</title>
1345     <para>
1346      TO-DO
1347      </para>
1348
1349
1350      <!-- see in util/zebramap.c
1351       int zebra_maps_attr
1352
1353   if (completeness_value == 2 || completeness_value == 3)
1354         *complete_flag = 1;
1355     else
1356         *complete_flag = 0;
1357     *reg_id = 0;
1358
1359     *sort_flag =(sort_relation_value > 0) ? 1 : 0;
1360     *search_type = "phrase";
1361     strcpy(rank_type, "void");
1362     if (relation_value == 102)
1363     {
1364         if (weight_value == -1)
1365             weight_value = 34;
1366         sprintf(rank_type, "rank,w=%d,u=%d", weight_value, use_value);
1367     }
1368     if (relation_value == 103)
1369     {
1370         *search_type = "always";
1371         *reg_id = 'w';
1372         return 0;
1373     }
1374     if (*complete_flag)
1375         *reg_id = 'p';
1376     else
1377         *reg_id = 'w';
1378     switch (structure_value)
1379     {
1380     case 6:   /* word list */
1381         *search_type = "and-list";
1382         break;
1383     case 105: /* free-form-text */
1384         *search_type = "or-list";
1385         break;
1386     case 106: /* document-text */
1387         *search_type = "or-list";
1388         break;  
1389     case -1:
1390     case 1:   /* phrase */
1391     case 2:   /* word */
1392     case 108: /* string */ 
1393         *search_type = "phrase";
1394         break;
1395    case 107: /* local-number */
1396         *search_type = "local";
1397         *reg_id = 0;
1398         break;
1399     case 109: /* numeric string */
1400         *reg_id = 'n';
1401         *search_type = "numeric";
1402         break;
1403     case 104: /* urx */
1404         *reg_id = 'u';
1405         *search_type = "phrase";
1406         break;
1407     case 3:   /* key */
1408         *reg_id = '0';
1409         *search_type = "phrase";
1410         break;
1411     case 4:  /* year */
1412         *reg_id = 'y';
1413         *search_type = "phrase";
1414         break;
1415     case 5:  /* date */
1416         *reg_id = 'd';
1417         *search_type = "phrase";
1418         break;
1419     default:
1420         return -1;
1421     }
1422     return 0;
1423
1424      -->
1425
1426     
1427     <para>
1428      <emphasis>Use</emphasis> attributes are interpreted according to the
1429      attribute sets which have been loaded in the
1430     <literal>zebra.cfg</literal> file, and are matched against specific
1431      fields as specified in the <literal>.abs</literal> file which
1432      describes the profile of the records which have been loaded.
1433      If no Use attribute is provided, a default of Bib-1 Any is assumed.
1434     </para>
1435     
1436     <para>
1437      If a <emphasis>Structure</emphasis> attribute of
1438      <emphasis>Phrase</emphasis> is used in conjunction with a
1439      <emphasis>Completeness</emphasis> attribute of
1440      <emphasis>Complete (Sub)field</emphasis>, the term is matched
1441      against the contents of the phrase (long word) register, if one
1442      exists for the given <emphasis>Use</emphasis> attribute.
1443      A phrase register is created for those fields in the
1444      <literal>.abs</literal> file that contains a
1445      <literal>p</literal>-specifier.
1446      <!-- ### whatever the hell _that_ is -->
1447     </para>
1448
1449     <para>
1450      If <emphasis>Structure</emphasis>=<emphasis>Phrase</emphasis> is
1451      used in conjunction with <emphasis>Incomplete Field</emphasis> - the
1452      default value for <emphasis>Completeness</emphasis>, the
1453      search is directed against the normal word registers, but if the term
1454      contains multiple words, the term will only match if all of the words
1455      are found immediately adjacent, and in the given order.
1456      The word search is performed on those fields that are indexed as
1457      type <literal>w</literal> in the <literal>.abs</literal> file.
1458     </para>
1459
1460     <para>
1461      If the <emphasis>Structure</emphasis> attribute is
1462      <emphasis>Word List</emphasis>,
1463      <emphasis>Free-form Text</emphasis>, or
1464      <emphasis>Document Text</emphasis>, the term is treated as a
1465      natural-language, relevance-ranked query.
1466      This search type uses the word register, i.e. those fields
1467      that are indexed as type <literal>w</literal> in the
1468      <literal>.abs</literal> file.
1469     </para>
1470
1471     <para>
1472      If the <emphasis>Structure</emphasis> attribute is
1473      <emphasis>Numeric String</emphasis> the term is treated as an integer.
1474      The search is performed on those fields that are indexed
1475      as type <literal>n</literal> in the <literal>.abs</literal> file.
1476     </para>
1477
1478     <para>
1479      If the <emphasis>Structure</emphasis> attribute is
1480      <emphasis>URx</emphasis> the term is treated as a URX (URL) entity.
1481      The search is performed on those fields that are indexed as type
1482      <literal>u</literal> in the <literal>.abs</literal> file.
1483     </para>
1484
1485     <para>
1486      If the <emphasis>Structure</emphasis> attribute is
1487      <emphasis>Local Number</emphasis> the term is treated as
1488      native Zebra Record Identifier.
1489     </para>
1490
1491     <para>
1492      If the <emphasis>Relation</emphasis> attribute is
1493      <emphasis>Equals</emphasis> (default), the term is matched
1494      in a normal fashion (modulo truncation and processing of
1495      individual words, if required).
1496      If <emphasis>Relation</emphasis> is <emphasis>Less Than</emphasis>,
1497      <emphasis>Less Than or Equal</emphasis>,
1498      <emphasis>Greater than</emphasis>, or <emphasis>Greater than or
1499       Equal</emphasis>, the term is assumed to be numerical, and a
1500      standard regular expression is constructed to match the given
1501      expression.
1502      If <emphasis>Relation</emphasis> is <emphasis>Relevance</emphasis>,
1503      the standard natural-language query processor is invoked.
1504     </para>
1505
1506     <para>
1507      For the <emphasis>Truncation</emphasis> attribute,
1508      <emphasis>No Truncation</emphasis> is the default.
1509      <emphasis>Left Truncation</emphasis> is not supported.
1510      <emphasis>Process # in search term</emphasis> is supported, as is
1511      <emphasis>Regxp-1</emphasis>.
1512      <emphasis>Regxp-2</emphasis> enables the fault-tolerant (fuzzy)
1513      search. As a default, a single error (deletion, insertion, 
1514      replacement) is accepted when terms are matched against the register
1515      contents.
1516     </para>
1517    </sect2>
1518
1519    <sect2  id="querymodel-regular">
1520     <title>Zebra Regular Expressions in Truncation Attribute (type = 5)</title>
1521     
1522     <para>
1523      Each term in a query is interpreted as a regular expression if
1524      the truncation value is either <emphasis>Regxp-1 (@attr 5=102)</emphasis>
1525      or <emphasis>Regxp-2 (@attr 5=103)</emphasis>.
1526      Both query types follow the same syntax with the operands:
1527     </para>
1528
1529      <table id="querymodel-regular-operands-table"
1530       frame="all" rowsep="1" colsep="1" align="center">
1531
1532       <caption>Regular Expression Operands</caption>
1533        <!--
1534        <thead>
1535        <tr><td>one</td><td>two</td></tr>
1536       </thead>
1537        -->
1538        <tbody>
1539         <tr>
1540          <td><literal>x</literal></td>
1541          <td>Matches the character <literal>x</literal>.</td>
1542         </tr>
1543         <tr>
1544          <td><literal>.</literal></td>
1545          <td>Matches any character.</td>
1546         </tr>
1547         <tr>
1548          <td><literal>[ .. ]</literal></td>
1549          <td>Matches the set of characters specified;
1550          such as <literal>[abc]</literal> or <literal>[a-c]</literal>.</td>
1551         </tr>
1552        </tbody>
1553       </table>      
1554
1555     <para>
1556      The above operands can be combined with the following operators:
1557     </para>
1558
1559      <table id="querymodel-regular-operators-table"
1560       frame="all" rowsep="1" colsep="1" align="center">
1561       <caption>Regular Expression Operators</caption>
1562        <!--
1563        <thead>
1564        <tr><td>one</td><td>two</td></tr>
1565       </thead>
1566        -->
1567        <tbody>
1568         <tr>
1569          <td><literal>x*</literal></td>
1570          <td>Matches <literal>x</literal> zero or more times. 
1571           Priority: high.</td>
1572         </tr>
1573         <tr>
1574          <td><literal>x+</literal></td>
1575          <td>Matches <literal>x</literal> one or more times. 
1576           Priority: high.</td>
1577         </tr>
1578         <tr>
1579          <td><literal>x?</literal></td>
1580          <td> Matches <literal>x</literal> zero or once. 
1581           Priority: high.</td>
1582         </tr>
1583         <tr>
1584          <td><literal>xy</literal></td>
1585          <td> Matches <literal>x</literal>, then <literal>y</literal>.
1586          Priority: medium.</td>
1587         </tr>
1588         <tr>
1589          <td><literal>x|y</literal></td>
1590          <td> Matches either <literal>x</literal> or <literal>y</literal>.
1591          Priority: low.</td>
1592         </tr>
1593         <tr>
1594          <td><literal>( )</literal></td>
1595          <td>The order of evaluation may be changed by using parentheses.</td>
1596         </tr>
1597        </tbody>
1598       </table>      
1599
1600     <para>
1601      If the first character of the <literal>Regxp-2</literal> query
1602      is a plus character (<literal>+</literal>) it marks the
1603      beginning of a section with non-standard specifiers.
1604      The next plus character marks the end of the section.
1605      Currently Zebra only supports one specifier, the error tolerance,
1606      which consists one digit. 
1607     </para>
1608
1609     <para>
1610      Since the plus operator is normally a suffix operator the addition to
1611      the query syntax doesn't violate the syntax for standard regular
1612      expressions.
1613     </para>
1614
1615     <para>
1616      For example, a phrase search with regular expressions  in
1617      the title-register is performed like this:
1618      <screen>
1619       Z> find @attr 1=4 @attr 5=102 "informat.* retrieval"
1620      </screen>
1621     </para>
1622
1623     <para>
1624      Combinations with other attributes are possible. For example, a
1625      ranked search with a regular expression:
1626      <screen>
1627       Z> find @attr 1=4 @attr 5=102 @attr 2=102 "informat.* retrieval"
1628      </screen>
1629     </para>
1630    </sect2>
1631
1632   
1633    <!--
1634    <para>
1635     The RecordType parameter in the <literal>zebra.cfg</literal> file, or
1636     the <literal>-t</literal> option to the indexer tells Zebra how to
1637     process input records.
1638     Two basic types of processing are available - raw text and structured
1639     data. Raw text is just that, and it is selected by providing the
1640     argument <literal>text</literal> to Zebra. Structured records are
1641     all handled internally using the basic mechanisms described in the
1642     subsequent sections.
1643     Zebra can read structured records in many different formats.
1644    </para>
1645    -->
1646   </sect1>
1647
1648
1649   <sect1 id="querymodel-cql-to-pqf">
1650    <title>Server Side CQL to PQF Query Translation</title>
1651    <para>
1652     Using the
1653     <literal>&lt;cql2rpn&gt;l2rpn.txt&lt;/cql2rpn&gt;</literal>
1654       YAZ Frontend Virtual
1655     Hosts option, one can configure
1656     the YAZ Frontend CQL-to-PQF
1657     converter, specifying the interpretation of various 
1658     <ulink url="&url.cql;">CQL</ulink>
1659     indexes, relations, etc. in terms of Type-1 query attributes.
1660     <!-- The  yaz-client config file -->  
1661    </para>
1662    <para>
1663     For example, using server-side CQL-to-PQF conversion, one might
1664     query a zebra server like this:
1665     <screen>
1666     <![CDATA[
1667      yaz-client localhost:9999
1668      Z> querytype cql
1669      Z> find text=(plant and soil)
1670      ]]>
1671     </screen>
1672      and - if properly configured - even static relevance ranking can
1673      be performed using CQL query syntax:
1674     <screen>
1675     <![CDATA[
1676      Z> find text = /relevant (plant and soil)
1677      ]]>
1678      </screen>
1679    </para>
1680
1681    <para>
1682     By the way, the same configuration can be used to 
1683     search using client-side CQL-to-PQF conversion:
1684     (the only difference is <literal>querytype cql2rpn</literal> 
1685     instead of 
1686     <literal>querytype cql</literal>, and the call specifying a local
1687     conversion file)
1688     <screen>
1689     <![CDATA[
1690      yaz-client -q local/cql2pqf.txt localhost:9999
1691      Z> querytype cql2rpn
1692      Z> find text=(plant and soil)
1693      ]]>
1694      </screen>
1695    </para>
1696
1697    <para>
1698     Exhaustive information can be found in the
1699     Section "Specification of CQL to RPN mappings" in the YAZ manual.
1700     <ulink url="http://www.indexdata.dk/yaz/doc/tools.tkl#tools.cql.map">
1701      http://www.indexdata.dk/yaz/doc/tools.tkl#tools.cql.map</ulink>,
1702    and shall therefore not be repeated here.
1703    </para> 
1704   <!-- 
1705   <para>
1706     See 
1707       <ulink url="http://www.loc.gov/z3950/agency/zing/cql/dc-indexes.html">
1708       http://www.loc.gov/z3950/agency/zing/cql/dc-indexes.html</ulink>
1709     for the Maintenance Agency's work-in-progress mapping of Dublin Core
1710     indexes to Attribute Architecture (util, XD and BIB-2)
1711     attributes.
1712    </para>
1713    -->
1714  </sect1>
1715
1716
1717
1718 </chapter>
1719
1720  <!-- Keep this comment at the end of the file
1721  Local variables:
1722  mode: sgml
1723  sgml-omittag:t
1724  sgml-shorttag:t
1725  sgml-minimize-attributes:nil
1726  sgml-always-quote-attributes:t
1727  sgml-indent-step:1
1728  sgml-indent-data:t
1729  sgml-parent-document: "zebra.xml"
1730  sgml-local-catalogs: nil
1731  sgml-namecase-general:t
1732  End:
1733  -->