added examples fo phrase and word search
[idzebra-moved-to-github.git] / doc / querymodel.xml
1  <chapter id="querymodel">
2   <!-- $Id: querymodel.xml,v 1.15 2006-06-23 13:45:41 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 syntax and semantics</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> or
169      <emphasis>named result sets</emphasis>, eventually
170      paired by <emphasis>boolean binary operators</emphasis>, and 
171      finally  <emphasis>recursively combined </emphasis> into 
172      complex query trees.   
173     </para>
174     
175     <sect3 id="querymodel-attribute-sets">
176      <title>Attribute sets</title>
177      <para>
178       Attribute sets define the exact meaning and semantics of queries
179       issued. Zebra comes with some predefined attribute set
180       definitions, others can easily be defined and added to the
181       configuration.
182      </para>
183
184      
185      <table id="querymodel-attribute-sets-table"
186       frame="all" rowsep="1" colsep="1" align="center">
187
188       <caption>Attribute sets predefined in Zebra</caption>
189        
190        <thead>
191        <tr>
192          <td>Attribute set</td>
193          <td>Short hand</td>
194          <td>Status</td>
195          <td>Notes</td>
196         </tr>
197       </thead>
198       
199        <tbody>
200         <tr>
201          <td><literal>Explain</literal></td>
202          <td><literal>exp-1</literal></td>
203          <td>Special attribute set used on the special automagic
204           <literal>IR-Explain-1</literal> database to gain information on
205           server capabilities, database names, and database
206           and semantics.</td>
207          <td>predefined</td>
208         </tr>
209         <tr>
210          <td><literal>Bib1</literal></td>
211          <td><literal>bib-1</literal></td>
212          <td>Standard PQF query language attribute set which defines the
213           semantics of Z39.50 searching. In addition, all of the
214           non-use attributes (type 2-9) define the hard-wired 
215           Zebra internal query
216           processing.</td>
217          <td>default</td>
218         </tr>
219         <tr>
220          <td><literal>GILS</literal></td>
221          <td><literal>gils</literal></td>
222          <td>Extention to the <literal>Bib1</literal> attribute set.</td>
223          <td>predefined</td>
224         </tr>
225         <!--
226         <tr>
227          <td><literal>IDXPATH</literal></td>
228          <td><literal>idxpath</literal></td>
229          <td>Hardwired XPATH like attribute set, only available for
230              indexing with the GRS record model</td>
231          <td>depreciated</td>
232         </tr>
233         -->
234        </tbody>
235      </table>
236     </sect3>
237
238     <para>
239      The <literal>use attributes (type 1)</literal> mappings  the
240      predefined attribute sets are found in the
241      attribute set configuration files <filename>tab/*.att</filename>. 
242     </para>
243
244     <note>
245      The Zebra internal query processing is modeled after 
246      the <literal>Bib1</literal> attribute set, and the non-use
247      attributes type 2-6 are hard-wired in. It is therefore essential
248      to be familiar with <xref linkend="querymodel-bib1-nonuse"/>. 
249     </note>
250
251     
252     <sect3 id="querymodel-boolean-operators">
253      <title>Boolean operators</title>
254      <para>
255       A pair of subquery trees, or of atomic queries, is combined
256       using the standard boolean operators into new query trees.
257      </para>
258      
259      <table id="querymodel-boolean-operators-table"
260       frame="all" rowsep="1" colsep="1" align="center">
261
262       <caption>Boolean operators</caption>
263        <thead>
264         <tr>
265          <td>Keyword</td>
266          <td>Operator</td>
267          <td>Description</td>
268         </tr>
269       </thead>
270        <tbody>
271         <tr><td><literal>@and</literal></td>
272          <td>binary <literal>AND</literal> operator</td>
273          <td>Set intersection of two atomic queries hit sets</td>
274         </tr>
275         <tr><td><literal>@or</literal></td>
276          <td>binary <literal>OR</literal> operator</td>
277          <td>Set union of two atomic queries hit sets</td>
278         </tr>
279         <tr><td><literal>@not</literal></td>
280          <td>binary <literal>AND NOT</literal> operator</td>
281          <td>Set complement of two atomic queries hit sets</td>
282         </tr>
283         <tr><td><literal>@prox</literal></td>
284          <td>binary <literal>PROXIMY</literal> operator</td>
285          <td>Set intersection of two atomic queries hit sets. In 
286           addition, the intersection set is purged for all 
287           documents which do not satisfy the requested query 
288           term proximity. Usually a proper subset of the AND 
289           operation.</td>
290         </tr>
291        </tbody>
292      </table>
293      
294      <para>
295       For example, we can combine the terms 
296       <emphasis>information</emphasis> and <emphasis>retrieval</emphasis> 
297       into different searches in the default index of the default
298       attribute set as follows.
299       Querying for the union of all documents containing the
300       terms <emphasis>information</emphasis> OR
301       <emphasis>retrieval</emphasis>: 
302       <screen>
303        Z> find @or information retrieval
304       </screen>
305      </para>
306      <para>
307       Querying for the intersection of all documents containing the
308       terms <emphasis>information</emphasis> AND
309       <emphasis>retrieval</emphasis>: 
310       The hit set is a subset of the coresponding
311       OR query.
312       <screen>
313        Z> find @and information retrieval
314       </screen>
315      </para>
316      <para>
317       Querying for the intersection of all documents containing the
318       terms <emphasis>information</emphasis> AND
319       <emphasis>retrieval</emphasis>, taking proximity into account:
320       The hit set is a subset of the coresponding
321       AND query.
322       <screen>
323        Z> find @prox 0 3 0 2 k 2 information retrieval
324       </screen>
325        See  <ulink url="&url.yaz.pqf;">PQF grammer</ulink> for details.
326      </para>
327      <para>
328       Querying for the intersection of all documents containing the
329       terms <emphasis>information</emphasis> AND
330       <emphasis>retrieval</emphasis>, in the same order and near each
331       other as described in the term list  
332       The hit set is a subset of the coresponding
333       PROXIMY query.
334       <screen>
335        Z> find "information retrieval"
336       </screen>
337      </para>
338     </sect3>
339     
340     
341     <sect3 id="querymodel-atomic-queries">
342      <title>Atomic queries (APT)</title>
343      <para>
344       Atomic queries are the query parts which work on one acess point
345       only. These consist of <literal>an attribute list</literal>
346       followed by a <literal>single term</literal> or a
347       <literal>quoted term list</literal>, and are often called 
348       <emphasis>Attributes-Plus-Terms (APT)</emphasis> queries.
349      </para>
350      <para>
351       Unsupplied non-use attributes type 2-9 are either inherited from
352       higher nodes in the query tree, or are set to Zebra's default values.
353       See <xref linkend="querymodel-bib1"/> for details. 
354      </para>
355      
356      <table id="querymodel-atomic-queries-table"
357       frame="all" rowsep="1" colsep="1" align="center">
358
359       <caption>Atomic queries</caption>
360        <!--
361        <thead>
362        <tr><td>one</td><td>two</td></tr>
363       </thead>
364        -->
365        <tbody>
366         <tr>
367          <td><emphasis>attribute list</emphasis></td>
368          <td>List of <literal>orthogonal</literal> attributes</td>
369          <td>Any of the orthogonal attribute types may be omitted,
370           these are inherited from higher query tree nodes, or if not
371           inherited, are set to the default Zebra configuration values.
372          </td>
373         </tr>
374         <tr>
375          <td><emphasis>term</emphasis></td>
376          <td>single <literal>term</literal> 
377           or <literal>quoted term list</literal>   </td>
378          <td>Here the search terms or list of search terms is added
379           to the query</td>
380         </tr>
381        </tbody>
382      </table>
383      <para>
384       Querying for the term <emphasis>information</emphasis> in the
385       default index using the default attribite set, the server choice
386       of access point/index, and the default non-use attributes.
387       <screen>
388        Z> find information
389       </screen>
390      </para>
391      <para>
392       Equivalent query fully specified including all default values:
393       <screen>
394        Z> find @attrset bib-1 @attr 1=1017 @attr 2=3 @attr 3=3 @attr 4=1 @attr 5=100 @attr 6=1 information
395       </screen>
396      </para>
397      
398      <para>
399       Finding all documents which have the term
400       <emphasis>debussy</emphasis> in the title field.
401       <screen>
402        Z> find @attr 1=4 debussy
403       </screen>
404      </para>
405
406     </sect3>
407     
408     
409     <sect3 id="querymodel-resultset">
410      <title>Named Result Sets</title>
411      <para>
412       Named result sets are supported in Zebra, and result sets can be
413       used as operands without limitations.
414      </para>
415      <para>      
416       After the execution of a search, the result set is available at
417       the server, such that the client can use it for subsequent
418       searches or retrieval requests. The Z30.50 standard actually
419       stresses the fact that result sets are voliatile. It may cease
420       to exist at any time point after search, and the server will
421       send a diagnostic to the effect that the requested
422       result set does not exist any more.
423      </para>
424      
425      <para>
426       Defining a named result set and re-using it in the next query,
427       using <literal>yaz-client</literal>. 
428       <screen>
429        Z> f @attr 1=4 mozart
430        ...
431        Number of hits: 43, setno 1
432        ...
433        Z> f @and @set 1 @attr 1=4 amadeus
434        ...
435        Number of hits: 14, setno 2
436        ...
437        Z> f @attr 1=1016 beethoven
438        ...
439        Number of hits: 26, setno 3
440        ...
441       </screen>
442      </para>
443      
444      <note>
445       Named result sets are only supported by the Z39.50 protocol.
446       The SRU web service is stateless, and therefore the notion of
447       named result sets does not exist when acessing a Zebra server by
448       the SRU protocol.
449      </note>
450     </sect3>
451
452
453     <sect3 id="querymodel-use-string">
454      <title>Zebra's special access point of type 'string'</title>
455      <para>
456       The numeric <literal>use (type 1)</literal> attribute is usually 
457       refered to from a given
458       attribute set. In addition, Zebra let you use 
459       <emphasis>any internal index
460        name defined in your configuration</emphasis> 
461       as use atribute value. This is a great feature for
462       debugging, and when you do
463       not need the complecity of defined use attribute values. It is
464       the preferred way of accessing Zebra indexes directly.  
465      </para>
466      <para>
467       Finding all documents which have the term list "information
468       retrieval" in an Zebra index, using it's internal full string
469       name. Scanning the same index.
470       <screen>
471        Z> find @attr 1=sometext "information retrieval"
472        Z> scan @attr 1=sometext aterm
473       </screen>
474      </para>
475      <para>
476       Searching or scanning
477       the bib-1 use attribute 54 using it's string name:
478       <screen>
479        Z> find @attr 1=Code-language eng
480        Z> scan @attr 1=Code-language ""
481       </screen>
482      </para>
483      <para>
484       It is possible to search
485       in any silly string index - if it's defined in your
486       indexation rules and can be parsed by the PQF parser. 
487       This is definitely not the recommended use of
488       this facility, as it might confuse your users with some very
489       unexpected results.
490       <screen>
491        Z> find @attr 1=silly/xpath/alike[@index]/name "information retrieval"
492       </screen>
493      </para>
494      <para>
495       See also <xref linkend="querymodel-pqf-apt-mapping"/> for details, and 
496       <xref linkend="server-sru"/>
497       for the SRU PQF query extention using string names as a fast
498       debugging facility.
499      </para>
500     </sect3>
501     
502     <sect3 id="querymodel-use-xpath">
503      <title>Zebra's special access point of type 'XPath' 
504       for GRS filters</title>
505      <para>
506       As we have seen above, it is possible (albeit seldom a great
507       idea) to emulate 
508       <ulink url="http://www.w3.org/TR/xpath">XPath 1.0</ulink> based
509       search by defining <literal>use (type 1)</literal> 
510       <emphasis>string</emphasis> attributes which in appearence 
511       <emphasis>resemble XPath queries</emphasis>. There are two
512       problems with this approach: first, the XPath-look-alike has to
513       be defined at indexation time, no new undefined
514       XPath queries can entered at search time, and second, it might
515       confuse users very much that an XPath-alike index name in fact
516       gets populated from a possible entirely different XML element
517       than it pretends to access. 
518      </para>
519      <para>
520       When using the <literal>GRS Record Model</literal> 
521       (see  <xref linkend="record-model-grs"/>), we have the
522       possibility to embed <emphasis>life</emphasis> 
523       XPath expressions
524       in the PQF queries, which are here called
525       <literal>use (type 1)</literal> <emphasis>xpath</emphasis>
526       attributes. You must enable the 
527       <literal>xpath enable</literal> directive in your 
528       <literal>.abs</literal> config files. 
529      </para>
530      <note>
531       Only a <emphasis>very</emphasis> restricted subset of the 
532       <ulink url="http://www.w3.org/TR/xpath">XPath 1.0</ulink> 
533       standard is supported as the GRS record model is simpler than
534       a full XML DOM structure. See the following examples for 
535       possibilities.
536      </note>
537      <para>
538       Finding all documents which have the term "content" 
539       inside a text node found in a specific XML DOM
540       <emphasis>subtree</emphasis>, whose starting element is 
541       adressed by XPath. 
542       <screen>
543        Z> find @attr 1=/root content 
544        Z> find @attr 1=/root/first content
545       </screen>
546       <emphasis>Notice that the
547        XPath must be absolute, i.e., must start with '/', and that the
548        XPath <literal>decendant-or-self</literal> axis followed by a
549        text node selection <literal>text()</literal> is implicitly
550        appended to the stated XPath.
551       </emphasis>
552       It follows that the above searches are interpreted as:
553       <screen>
554        Z> find @attr 1=/root//text() content 
555        Z> find @attr 1=/root/first//text() content
556       </screen>
557      </para>
558      
559      <para>
560       Searching inside attribute strings is possible:
561       <screen>
562        Z> find @attr 1=/link/@creator morten 
563       </screen>
564       </para>
565
566      <para>     
567       Filter the adressing XPath by a predicate working on exact
568       string values in
569       attributes (in the XML sense) can be done: return all those docs which
570       have the term "english" contained in one of all text subnodes of
571       the subtree defined by the XPath
572       <literal>/record/title[@lang='en']</literal>. And similar
573       predicate filtering.
574       <screen>
575        Z> find @attr 1=/record/title[@lang='en'] english
576        Z> find @attr 1=/link[@creator='sisse'] sibelius
577        Z> find @attr 1=/link[@creator='sisse']/description[@xml:lang='da'] sibelius 
578       </screen>
579      </para>
580      
581      <para>     
582       Combining numeric indexes, boolean expressions, 
583       and xpath based searches is possible:
584       <screen>
585        Z> find @attr 1=/record/title @and foo bar
586        Z> find @and @attr 1=/record/title foo @attr 1=4 bar
587       </screen> 
588      </para>
589      <para>
590       Escaping PQF keywords and other non-parseable XPath constructs
591       with <literal>'{ }'</literal> to prevent syntax errors:
592       <screen>
593        Z> find @attr {1=/root/first[@attr='danish']} content
594        Z> find @attr {1=/record/@set} oai
595       </screen>
596      </para>
597      <warning>
598       It is worth mentioning that these dynamic performed XPath
599       queries are a performance bottelneck, as no optimized
600       specialized indexes can be used. Therefore, avoid the use of
601       this facility when speed is essential, and the database content
602       size is medium to large. 
603      </warning>
604
605     </sect3>
606     
607    </sect2>
608    
609    <sect2 id="querymodel-exp1">
610     <title>Explain Attribute Set</title>
611     <para>
612      The Z39.50 standard defines the  
613      <ulink url="&url.z39.50.explain;">Explain</ulink> attribute set
614      <literal>Exp-1</literal>, which is used to discover information 
615      about a server's search semantics and functional capabilities
616      Zebra exposes a  "classic" 
617      Explain database by base name <literal>IR-Explain-1</literal>, which
618      is populated with system internal information.  
619     </para>
620    <para>
621      The attribute-set <literal>exp-1</literal> consists of a single 
622      <literal>use attribute (type 1)</literal>. 
623     </para>
624     <para>
625      In addition, the non-Use
626      <literal>bib-1</literal> attributes, that is, the types 
627      <literal>Relation</literal>, <literal>Position</literal>,
628      <literal>Structure</literal>, <literal>Truncation</literal>, 
629      and <literal>Completeness</literal> are imported from 
630      the <literal>bib-1</literal> attribute set, and may be used
631      within any explain query. 
632     </para>
633     
634     <sect3 id="querymodel-exp1-use">
635     <title>Use Attributes (type = 1)</title>
636      <para>
637       The following Explain search atributes are supported:
638       <literal>ExplainCategory</literal> (@attr 1=1), 
639       <literal>DatabaseName</literal> (@attr 1=3), 
640       <literal>DateAdded</literal> (@attr 1=9), 
641       <literal>DateChanged</literal>(@attr 1=10).
642      </para>
643      <para>
644       A search in the use attribute  <literal>ExplainCategory</literal>
645       supports only these predefined values:
646       <literal>CategoryList</literal>, <literal>TargetInfo</literal>,
647       <literal>DatabaseInfo</literal>, <literal>AttributeDetails</literal>.
648      </para>
649      <para>
650       See <filename>tab/explain.att</filename> and the 
651       <ulink url="&url.z39.50;">Z39.50</ulink> standard
652       for more information.
653      </para>
654     </sect3>
655     
656     <sect3>
657      <title>Explain searches with yaz-client</title>
658      <para>
659       Classic Explain only defines retrieval of Explain information
660       via ASN.1. Pratically no Z39.50 clients supports this. Fortunately
661       they don't have to - Zebra allows retrieval of this information
662       in other formats:
663       <literal>SUTRS</literal>, <literal>XML</literal>, 
664       <literal>GRS-1</literal> and  <literal>ASN.1</literal> Explain.
665      </para>
666      
667      <para>
668       List supported categories to find out which explain commands are
669       supported: 
670       <screen>
671        Z> base IR-Explain-1
672        Z> find @attr exp1 1=1 categorylist
673        Z> form sutrs
674        Z> show 1+2
675       </screen>
676      </para>
677      
678      <para>
679       Get target info, that is, investigate which databases exist at
680       this server endpoint:
681       <screen>
682        Z> base IR-Explain-1
683        Z> find @attr exp1 1=1 targetinfo
684        Z> form xml
685        Z> show 1+1
686        Z> form grs-1
687        Z> show 1+1
688        Z> form sutrs
689        Z> show 1+1
690       </screen>
691      </para>
692      
693      <para>
694       List all supported databases, the number of hits
695       is the number of databases found, which most commonly are the
696       following two:
697       the <literal>Default</literal> and the
698       <literal>IR-Explain-1</literal> databases.
699       <screen>
700        Z> base IR-Explain-1
701        Z> find @attr exp1 1=1 databaseinfo
702        Z> form sutrs
703        Z> show 1+2
704       </screen>
705      </para>
706      
707      <para>
708       Get database info record for database <literal>Default</literal>.
709       <screen>
710        Z> base IR-Explain-1
711        Z> find @and @attr exp1 1=1 databaseinfo @attr exp1 1=3 Default
712       </screen>
713       Identical query with explicitly specified attribute set:
714       <screen>
715        Z> base IR-Explain-1
716        Z> find @attrset exp1 @and @attr 1=1 databaseinfo @attr 1=3 Default
717       </screen>
718      </para>
719      
720      <para>
721       Get attribute details record for database
722       <literal>Default</literal>.
723       This query is very useful to study the internal Zebra indexes.
724       If records have been indexed using the <literal>alvis</literal>
725       XSLT filter, the string representation names of the known indexes can be
726       found.
727       <screen>
728        Z> base IR-Explain-1
729        Z> find @and @attr exp1 1=1 attributedetails @attr exp1 1=3 Default
730       </screen>
731       Identical query with explicitly specified attribute set:
732       <screen>
733        Z> base IR-Explain-1
734        Z> find @attrset exp1 @and @attr 1=1 attributedetails @attr 1=3 Default
735       </screen>
736      </para>
737     </sect3>
738     
739    </sect2>
740    
741    <sect2 id="querymodel-bib1">
742     <title>Bib1 Attribute Set</title>
743     <para>
744      Most of the information contained in this section is an excerpt of
745      the <literal>ATTRIBUTE SET BIB-1 (Z39.50-1995)
746       SEMANTICS</literal>, 
747      found at  <ulink url="&url.z39.50.attset.bib1.1995;">. The BIB-1
748       Attribute Set Semantics</ulink> from 1995, also in an updated 
749      <ulink url="&url.z39.50.attset.bib1;">Bib-1
750       Attribute Set</ulink> 
751      version from 2003. Index Data is not the copyright holder of this
752      information, except for the configuration details, the listing of
753      Zebra's capabilities, and the example queries. 
754     </para>
755     
756     
757    <sect3 id="querymodel-bib1-use">
758      <title>Use Attributes (type 1)</title>
759
760     <para>
761      A use attribute specifies an access point for any atomic query.
762      These acess points are highly dependent on the attribute set used
763      in the query, and are user configurable using the following
764      default configuration files:
765      <filename>tab/bib1.att</filename>,
766      <filename>tab/dan1.att</filename>,
767      <filename>tab/explain.att</filename>, and
768      <filename>tab/gils.att</filename>.
769      New attribute sets can be added by adding new 
770      <filename>tab/*.att</filename> configuration files, which need to
771      be sourced in the main configuration <filename>zebra.cfg</filename>.
772      </para>
773
774     <para>
775      In addition, Zebra allows the acess of 
776      <emphasis>internal index names</emphasis> and <emphasis>dynamic
777      XPath</emphasis> as use attributes; see
778       <xref linkend="querymodel-use-string"/> and 
779      <xref linkend="querymodel-use-xpath"/>.
780     </para> 
781
782     <para>
783      Phrase search for <emphasis>information retrieval</emphasis> in
784      the title-register, scanning the same register afterwards:
785      <screen>
786       Z> find @attr 1=4 "information retrieval"
787       Z> scan @attr 1=4 information
788      </screen>
789     </para>
790     </sect3>
791
792    </sect2>
793
794
795    <sect2 id="querymodel-bib1-nonuse">
796      <title>Zebra general Bib1 Non-Use Attributes (type 2-6)</title>
797     
798     <sect3 id="querymodel-bib1-relation">
799      <title>Relation Attributes (type 2)</title>
800      
801      <para>
802       Relation attributes describe the relationship of the access
803       point (left side 
804       of the relation) to the search term as qualified by the attributes (right
805       side of the relation), e.g., Date-publication &lt;= 1975.
806       </para>
807
808      <table id="querymodel-bib1-relation-table"
809       frame="all" rowsep="1" colsep="1" align="center">
810
811       <caption>Relation Attributes (type 2)</caption>
812       <thead>
813         <tr>
814          <td>Relation</td>
815          <td>Value</td>
816          <td>Notes</td>
817         </tr>
818        </thead>
819        <tbody>
820         <tr>
821          <td> Less than</td>
822          <td>1</td>
823          <td>supported</td>
824         </tr>
825         <tr>
826          <td>Less than or equal</td>
827          <td>2</td>
828          <td>supported</td>
829         </tr>
830         <tr>
831          <td>Equal</td>
832          <td>3</td>
833          <td>default</td>
834         </tr>
835         <tr>
836          <td>Greater or equal</td>
837          <td>4</td>
838          <td>supported</td>
839         </tr>
840         <tr>
841          <td>Greater than</td>
842          <td>5</td>
843          <td>supported</td>
844         </tr>
845         <tr>
846          <td>Not equal</td>
847          <td>6</td>
848          <td>unsupported</td>
849         </tr>
850         <tr>
851          <td>Phonetic</td>
852          <td>100</td>
853          <td>unsupported</td>
854         </tr>
855         <tr>
856          <td>Stem</td>
857          <td>101</td>
858          <td>unsupported</td>
859         </tr>
860         <tr>
861          <td>Relevance</td>
862          <td>102</td>
863          <td>supported</td>
864         </tr>
865         <tr>
866          <td>AlwaysMatches</td>
867          <td>103</td>
868          <td>supported</td>
869         </tr>
870        </tbody>
871      </table>
872
873      <para>
874       The relation attributes 
875       <literal>1-5</literal> are supported and work exactly as
876       expected.
877       All ordering operations are based on a lexicographical ordering, 
878       <emphasis>expect</emphasis> when the 
879       <literal>structure attribute numeric (109)</literal> is used. In
880       this case, ordering is numerical. See 
881       <xref linkend="querymodel-bib1-structure"/>.
882       <screen>
883        Z>  find @attr 1=Title @attr 2=1 music
884        ...
885        Number of hits: 11745, setno 1
886        ...
887        Z>  find @attr 1=Title @attr 2=2 music
888        ...
889        Number of hits: 11771, setno 2
890        ...
891        Z>  find @attr 1=Title @attr 2=3 music
892        ...
893        Number of hits: 532, setno 3
894        ...
895        Z>  find @attr 1=Title @attr 2=4 music
896        ...
897        Number of hits: 11463, setno 4
898        ...
899        Z>  find @attr 1=Title @attr 2=5 music
900        ...
901        Number of hits: 11419, setno 5
902       </screen>
903      </para>
904
905      <para>
906       The relation attribute 
907       <literal>Relevance (102)</literal> is supported, see
908       <xref linkend="administration-ranking"/> for full information.
909      </para>
910      
911      <para>
912       Ranked search for <emphasis>information retrieval</emphasis> in
913       the title-register:
914       <screen>
915        Z> find @attr 1=4 @attr 2=102 "information retrieval"
916       </screen>
917      </para>
918
919      <para>
920       The relation attribute 
921       <literal>AlwaysMatches (103)</literal> is in the default
922       configuration
923       supported in conjecture with structure attribute 
924       <literal>Phrase (1)</literal> (which may be omitted by
925       default). 
926       It can be configured to work with other structure attributes,
927       see the configuration file 
928       <filename>tab/default.idx</filename> and 
929        <xref linkend="querymodel-pqf-apt-mapping"/>. 
930      </para>
931      <para>
932       <literal>AlwaysMatches (103)</literal> is a
933       great way to discover how many documents have been indexed in a
934       given field. The search term is ignored, but needed for correct
935       PQF syntax. An empty search term may be supplied.
936       <screen>
937        Z> find @attr 1=Title  @attr 2=103  ""
938        Z> find @attr 1=Title  @attr 2=103  @attr 4=1 ""
939       </screen>
940      </para>
941
942
943     </sect3>
944
945     <sect3 id="querymodel-bib1-position">
946      <title>Position Attributes (type 3)</title>
947  
948      <para>
949       The position attribute specifies the location of the search term
950       within the field or subfield in which it appears.
951      </para>
952
953      <table id="querymodel-bib1-position-table"
954       frame="all" rowsep="1" colsep="1" align="center">
955
956       <caption>Position Attributes (type 3)</caption>
957       <thead>
958         <tr>
959          <td>Position</td>
960          <td>Value</td>
961          <td>Notes</td>
962         </tr>
963        </thead>
964        <tbody>
965         <tr>
966          <td>First in field </td>
967          <td>1</td>
968          <td>unsupported</td>
969         </tr>
970         <tr>
971          <td>First in subfield</td>
972          <td>2</td>
973          <td>unsupported</td>
974         </tr>
975         <tr>
976          <td>Any position in field</td>
977          <td>3</td>
978          <td>default</td>
979         </tr>
980        </tbody>
981      </table>
982  
983     <para>
984       The position attribute values <literal>first in field (1)</literal>,
985       and <literal>first in subfield(2)</literal> are unsupported.
986       Using them does not trigger an error, but silent defaults to 
987       <literal>any position in field (3)</literal>.
988       <!-- It should -->
989       </para>
990     </sect3>
991     
992     <sect3 id="querymodel-bib1-structure">
993      <title>Structure Attributes (type 4)</title>
994    
995      <para>
996       The structure attribute specifies the type of search
997       term. This causes the search to be mapped on
998       different Zebra internal indexes, which must have been defined
999       at index time. 
1000      </para>
1001
1002      <para> 
1003       The possible values of the  
1004       <literal>structure attribute (type 4)</literal> can be defined
1005       using the configuration file <filename>
1006       tab/default.idx</filename>.
1007       The default configuration is summerized in this table.
1008      </para>
1009
1010      <table id="querymodel-bib1-structure-table"
1011       frame="all" rowsep="1" colsep="1" align="center">
1012
1013       <caption>Structure Attributes (type 4)</caption>
1014       <thead>
1015         <tr>
1016          <td>Structure</td>
1017          <td>Value</td>
1018          <td>Notes</td>
1019         </tr>
1020        </thead>
1021        <tbody>
1022         <tr>
1023          <td>Phrase </td>
1024          <td>1</td>
1025          <td>default</td>
1026         </tr>
1027         <tr>
1028          <td>Word</td>
1029          <td>2</td>
1030          <td>supported</td>
1031         </tr>
1032         <tr>
1033          <td>Key</td>
1034          <td>3</td>
1035          <td>supported</td>
1036         </tr>
1037         <tr>
1038          <td>Year</td>
1039          <td>4</td>
1040          <td>supported</td>
1041         </tr>
1042         <tr>
1043          <td>Date (normalized)</td>
1044          <td>5</td>
1045          <td>supported</td>
1046         </tr>
1047         <tr>
1048          <td>Word list</td>
1049          <td>6</td>
1050          <td>supported</td>
1051         </tr>
1052         <tr>
1053          <td>Date (un-normalized)</td>
1054          <td>100</td>
1055          <td>unsupported</td>
1056         </tr>
1057         <tr>
1058          <td>Name (normalized) </td>
1059          <td>101</td>
1060          <td>unsupported</td>
1061         </tr>
1062         <tr>
1063          <td>Name (un-normalized) </td>
1064          <td>102</td>
1065          <td>unsupported</td>
1066         </tr>
1067         <tr>
1068          <td>Structure</td>
1069          <td>103</td>
1070          <td>unsupported</td>
1071         </tr>
1072         <tr>
1073          <td>Urx</td>
1074          <td>104</td>
1075          <td>supported</td>
1076         </tr>
1077         <tr>
1078          <td>Free-form-text</td>
1079          <td>105</td>
1080          <td>supported</td>
1081         </tr>
1082         <tr>
1083          <td>Document-text</td>
1084          <td>106</td>
1085          <td>supported</td>
1086         </tr>
1087         <tr>
1088          <td>Local-number</td>
1089          <td>107</td>
1090          <td>supported</td>
1091         </tr>
1092         <tr>
1093          <td>String</td>
1094          <td>108</td>
1095          <td>unsupported</td>
1096         </tr>
1097         <tr>
1098          <td>Numeric string</td>
1099          <td>109</td>
1100          <td>supported</td>
1101         </tr>
1102        </tbody>
1103      </table>
1104      
1105
1106     <para>
1107      The structure attribute values 
1108      <literal>Word list (6)</literal>
1109      is supported, and maps to the boolean <literal>AND</literal>
1110      combination of words supplied. The word list is useful when
1111      google-like bag-of-word queries need to be translated from a GUI
1112      query language to PQF.  For example, the following queries
1113      are equivalent:
1114      <screen>
1115       Z> find @attr 1=Title @attr 4=6 "mozart amadeus"
1116       Z> find @attr 1=Title  @and mozart amadeus
1117      </screen>
1118     </para>
1119
1120     <para>
1121      The structure attribute value 
1122      <literal>Free-form-text (105)</literal> and
1123      <literal>Document-text (106)</literal>
1124      are supported, and map both to the boolean <literal>OR</literal>
1125      combination of words supplied. The following queries
1126      are equivalent:
1127      <screen>
1128       Z> find @attr 1=Body-of-text @attr 4=105 "bach salieri teleman"
1129       Z> find @attr 1=Body-of-text @attr 4=106 "bach salieri teleman"
1130       Z> find @attr 1=Body-of-text @or bach @or salieri teleman 
1131      </screen>
1132      This <literal>OR</literal> list of terms is very usefull in
1133      combination with relevance ranking:
1134      <screen>
1135       Z> find @attr 1=Body-of-text @attr 2=102 @attr 4=105 "bach salieri teleman"
1136      </screen>
1137     </para>
1138     
1139     <para>
1140      The structure attribute value 
1141      <literal>Local number (107)</literal>
1142      is supported, and maps always to the Zebra internal document ID,
1143      irrespectively which use attribute is specified. The following queries
1144      have exactly the same unique record in the hit set:
1145      <screen>
1146       Z> find @attr 4=107 10
1147       Z> find @attr 1=4 @attr 4=107 10
1148       Z> find @attr 1=1010 @attr 4=107 10
1149      </screen>
1150     </para>
1151
1152     <para>
1153      In
1154      the GILS schema (<literal>gils.abs</literal>), the
1155      west-bounding-coordinate is indexed as type <literal>n</literal>,
1156      and is therefore searched by specifying
1157      <emphasis>structure</emphasis>=<emphasis>Numeric String</emphasis>.
1158      To match all those records with west-bounding-coordinate greater
1159      than -114 we use the following query:
1160      <screen>
1161       Z> find @attr 4=109 @attr 2=5 @attr gils 1=2038 -114
1162      </screen> 
1163     </para>
1164      <note>
1165       The exact mapping between PQF queries and Zebra internal indexes
1166       and index types is explained in 
1167        <xref linkend="querymodel-pqf-apt-mapping"/>.
1168       </note>
1169
1170    </sect3>
1171
1172     <sect3 id="querymodel-bib1-truncation">
1173      <title>Truncation Attributes (type = 5)</title>
1174
1175      <para>
1176       The truncation attribute specifies whether variations of one or
1177       more characters are allowed between serch term and hit terms, or
1178       not. Using non-default truncation attributes will broaden the
1179       document hit set of a search query.
1180      </para>
1181
1182      <table id="querymodel-bib1-truncation-table"
1183       frame="all" rowsep="1" colsep="1" align="center">
1184
1185       <caption>Truncation Attributes (type 5)</caption>
1186       <thead>
1187         <tr>
1188          <td>Truncation</td>
1189          <td>Value</td>
1190          <td>Notes</td>
1191         </tr>
1192        </thead>
1193        <tbody>
1194         <tr>
1195          <td>Right truncation </td>
1196          <td>1</td>
1197          <td>supported</td>
1198         </tr>
1199         <tr>
1200          <td>Left truncation</td>
1201          <td>2</td>
1202          <td>supported</td>
1203         </tr>
1204         <tr>
1205          <td>Left and right truncation</td>
1206          <td>3</td>
1207          <td>supported</td>
1208         </tr>
1209         <tr>
1210          <td>Do not truncate</td>
1211          <td>100</td>
1212          <td>default</td>
1213         </tr>
1214         <tr>
1215          <td>Process # in search term</td>
1216          <td>101</td>
1217          <td>supported</td>
1218         </tr>
1219         <tr>
1220          <td>RegExpr-1 </td>
1221          <td>102</td>
1222          <td>supported</td>
1223         </tr>
1224         <tr>
1225          <td>RegExpr-2</td>
1226          <td>103</td>
1227          <td>supported</td>
1228         </tr>
1229        </tbody>
1230      </table>
1231
1232      <para>
1233       The truncation attribute values 1-3 perform the obvious way:
1234       <screen>
1235        Z> scan @attr 1=Body-of-text  schnittke
1236        ...
1237        * schnittke (81)
1238        schnittkes (31)
1239        schnittstelle (1)
1240        ...
1241        Z> find @attr 1=Body-of-text  @attr 5=1 schnittke
1242        ...
1243        Number of hits: 95, setno 7
1244        ...
1245        Z> find @attr 1=Body-of-text  @attr 5=2 schnittke
1246        ...
1247        Number of hits: 81, setno 6
1248        ...
1249        Z> find @attr 1=Body-of-text  @attr 5=3 schnittke
1250        ...
1251        Number of hits: 95, setno 8
1252       </screen>
1253       </para>
1254
1255      <para>
1256       The truncation attribute value 
1257       <literal>Process # in search term (101)</literal> is a
1258       poor-man's regular expression search. It maps
1259       each <literal>#</literal> to <literal>.*</literal>, and
1260       performes then a <literal>Regexp-1 (102)</literal> regular
1261       expression search. The following two queries are equivalent:
1262       <screen>
1263        Z> find @attr 1=Body-of-text  @attr 5=101 schnit#ke
1264        Z> find @attr 1=Body-of-text  @attr 5=102 schnit.*ke
1265        ...
1266        Number of hits: 89, setno 10
1267       </screen>
1268      </para>
1269      
1270      <para>
1271       The truncation attribute value 
1272        <literal>Regexp-1 (102)</literal> is a normal regular search,
1273       see <xref linkend="querymodel-regular"/> for details.
1274       <screen>
1275        Z> find @attr 1=Body-of-text  @attr 5=102 schnit+ke
1276        Z> find @attr 1=Body-of-text  @attr 5=102 schni[a-t]+ke
1277       </screen>
1278      </para>
1279
1280      <para>
1281        The truncation attribute value 
1282       <literal>Regexp-2 (103) </literal> is a Zebra specific extention
1283       which allows <emphasis>fuzzy</emphasis> matches. One single
1284       error in spelling of search terms is allowed, i.e., a document
1285       is hit if it includes a term which can be mapped to the used
1286       search term by one character substitution, addition, deletion or
1287       change of posiiton. 
1288       <screen>
1289        Z> find @attr 1=Body-of-text  @attr 5=100 schnittke
1290        ...
1291        Number of hits: 81, setno 14
1292        ...
1293        Z> find @attr 1=Body-of-text  @attr 5=103 schnittke
1294        ...
1295        Number of hits: 103, setno 15
1296        ...
1297       </screen>
1298       </para>  
1299     </sect3>
1300     
1301     <sect3 id="querymodel-bib1-completeness">
1302     <title>Completeness Attributes (type = 6)</title>
1303
1304
1305      <para>
1306       The <literal>Completeness Attributes (type = 6)</literal>
1307       is used to specify that a given search term or term list is  either  
1308       part of the terms of a given index/field 
1309       (<literal>Incomplete subfield (1)</literal>), or is
1310       what literally is found in the entire field's index
1311       (<literal>Complete field (3)</literal>).
1312       </para>
1313
1314      <table id="querymodel-bib1-completeness-table"
1315       frame="all" rowsep="1" colsep="1" align="center">
1316       <caption>Completeness Attributes (type = 6)</caption>
1317       <thead>
1318         <tr>
1319          <td>Completeness</td>
1320          <td>Value</td>
1321          <td>Notes</td>
1322         </tr>
1323        </thead>
1324        <tbody>
1325         <tr>
1326          <td>Incomplete subfield</td>
1327          <td>1</td>
1328          <td>default</td>
1329         </tr>
1330         <tr>
1331          <td>Complete subfield</td>
1332          <td>2</td>
1333          <td>depreciated</td>
1334         </tr>
1335         <tr>
1336          <td>Complete field</td>
1337          <td>3</td>
1338          <td>supported</td>
1339         </tr>
1340        </tbody>
1341      </table>
1342
1343      <para>
1344       The <literal>Completeness Attributes (type = 6)</literal>
1345       is only partially and conditionally
1346       supported in the sense that it is ignored if the hit index is
1347       not of structure <literal>type="w"</literal> or 
1348       <literal>type="p"</literal>.
1349       </para>
1350      <para>
1351       <literal>Incomplete subfield (1)</literal> is the default, and
1352       makes Zebra use 
1353       register <literal>type="w"</literal>, whereas 
1354       <literal>Complete field (3)</literal> triggers
1355       search and scan in index <literal>type="p"</literal>.
1356      </para>
1357      <para>
1358       The <literal>Complete subfield (2)</literal> is a reminiscens
1359       from the  happy <literal>MARC</literal>
1360       binary format days. Zebra does not support it, but maps silently
1361       to <literal>Complete field (3)</literal>.
1362      </para>
1363
1364      <note>
1365       The exact mapping between PQF queries and Zebra internal indexes
1366       and index types is explained in 
1367        <xref linkend="querymodel-pqf-apt-mapping"/>.
1368       </note>
1369     </sect3>
1370    </sect2>
1371   
1372    </sect1>
1373
1374
1375   <sect1 id="querymodel-zebra">
1376    <title>Advanced Zebra PQF Features</title>
1377    <para>
1378     The Zebra internal query engine has been extended to specific needs
1379     not covered by the <literal>bib-1</literal> attribute set query
1380     model. These extentions are <emphasis>non-standard</emphasis>
1381     and <emphasis>non-portable</emphasis>: most functional extentions
1382     are modeled over the <literal>bib-1</literal> attribute set,
1383     defining type 7-9 attributes.
1384     There are also the speciel 
1385     <literal>string</literal> type index names for the
1386     <literal>idxpath</literal> attribute set.  
1387    </para>
1388     
1389    <sect2 id="querymodel-zebra-attr-allrecords">
1390     <title>Zebra specific retrieval of all records</title>
1391     <para>
1392      Zebra defines a hardwired <literal>string</literal> index name
1393      called <literal>_ALLRECORDS</literal>. It matches any record
1394      contained in the database, if used in conjunction with 
1395      the relation attribute 
1396      <literal>AlwaysMatches (103)</literal>.
1397      </para>
1398     <para>
1399      The <literal>_ALLRECORDS</literal> index name is used for total database
1400      export. The search term is ignored, it may be empty.
1401      <screen>
1402       Z> find @attr 1=_ALLRECORDS @attr 2=103 ""
1403      </screen>
1404     </para>
1405     <para>
1406      Combination with other index types can be made. For example, to
1407      find all records which are <emphasis>not</emphasis> indexed in
1408      the <literal>Title</literal> register, issue one of the two
1409      equivalent queries:
1410      <screen>
1411       Z> find @not @attr 1=_ALLRECORDS @attr 2=103 "" @attr 1=Title @attr 2=103 ""
1412       Z> find @not @attr 1=_ALLRECORDS @attr 2=103 "" @attr 1=4 @attr 2=103 ""
1413      </screen>
1414     </para>
1415     <warning>
1416      The special string index <literal>_ALLRECORDS</literal> is
1417      experimental, and the provided functionality and syntax may very
1418      well change in future releases of Zebra.
1419     </warning>
1420     
1421    </sect2>
1422
1423    <sect2 id="querymodel-zebra-attr-search">
1424     <title>Zebra specific Search Extentions to all Attribute Sets</title>
1425     <para>
1426      Zebra extends the Bib1 attribute types, and these extentions are
1427      recognized regardless of attribute 
1428      set used in a <literal>search</literal> operation query.
1429     </para>
1430
1431      <table id="querymodel-zebra-attr-search-table"
1432       frame="all" rowsep="1" colsep="1" align="center">
1433
1434       <caption>Zebra Search Attribute Extentions</caption>
1435        <thead>
1436         <tr>
1437          <td>Name</td>
1438          <td>Value</td>
1439          <td>Operation</td>
1440          <td>Zebra version</td>
1441         </tr>
1442       </thead>
1443        <tbody>
1444         <tr>
1445          <td>Embedded Sort</td>
1446          <td>7</td>
1447          <td>search</td>
1448          <td>1.1</td>
1449         </tr>
1450         <tr>
1451          <td>Term Set</td>
1452          <td>8</td>
1453          <td>search</td>
1454          <td>1.1</td>
1455         </tr>
1456         <tr>
1457          <td>Rank Weight</td>
1458          <td>9</td>
1459          <td>search</td>
1460          <td>1.1</td>
1461         </tr>
1462         <tr>
1463          <td>Approx Limit</td>
1464          <td>9</td>
1465          <td>search</td>
1466          <td>1.4</td>
1467         </tr>
1468         <tr>
1469          <td>Term Reference</td>
1470          <td>10</td>
1471          <td>search</td>
1472          <td>1.4</td>
1473         </tr>
1474        </tbody>
1475       </table>      
1476
1477     <sect3 id="querymodel-zebra-attr-sorting">
1478      <title>Zebra Extention Embedded Sort Attribute (type 7)</title>
1479     </sect3>
1480     <para>
1481      The embedded sort is a way to specify sort within a query - thus
1482      removing the need to send a Sort Request separately. It is both
1483      faster and does not require clients to deal with the Sort
1484      Facility. 
1485     </para>
1486
1487     <para>
1488      All ordering operations are based on a lexicographical ordering, 
1489      <emphasis>expect</emphasis> when the 
1490      <literal>structure attribute numeric (109)</literal> is used. In
1491      this case, ordering is numerical. See 
1492       <xref linkend="querymodel-bib1-structure"/>.
1493     </para>
1494
1495     <para>
1496      The possible values after attribute <literal>type 7</literal> are
1497      <literal>1</literal> ascending and 
1498      <literal>2</literal> descending. 
1499      The attributes+term (APT) node is separate from the
1500      rest and must be <literal>@or</literal>'ed. 
1501      The term associated with APT is the sorting level in integers,
1502      where <literal>0</literal> means primary sort, 
1503      <literal>1</literal> means secondary sort, and so forth.
1504      See also <xref linkend="administration-ranking"/>.
1505     </para>
1506     <para>
1507      For example, searching for water, sort by title (ascending) 
1508      <screen>
1509       Z> find @or @attr 1=1016 water @attr 7=1 @attr 1=4 0
1510      </screen>
1511     </para>
1512     <para>
1513      Or, searching for water, sort by title ascending, then date descending
1514      <screen>
1515       Z> find @or @or @attr 1=1016 water @attr 7=1 @attr 1=4 0 @attr 7=2 @attr 1=30 1
1516      </screen>
1517     </para>
1518     
1519     <sect3 id="querymodel-zebra-attr-estimation">
1520      <title>Zebra Extention Term Set Attribute (type 8)</title>
1521     </sect3>
1522     <para>
1523      The Term Set feature is a facility that allows a search to store
1524      hitting terms in a "pseudo" resultset; thus a search (as usual) +
1525      a scan-like facility. Requires a client that can do named result
1526      sets since the search generates two result sets. The value for
1527      attribute 8 is the name of a result set (string). The terms in
1528      the named term set are returned as SUTRS records. 
1529     </para>
1530     <para>
1531      For example, searching  for u in title, right truncated, and
1532      storing the result in term set named 'aset'
1533      <screen> 
1534       Z> find @attr 5=1 @attr 1=4 @attr 8=aset u
1535      </screen>
1536     </para>
1537     <warning>
1538      The model has one serious flaw: we don't know the size of term
1539      set. Experimental. Do not use in production code.
1540     </warning>
1541
1542     <sect3 id="querymodel-zebra-attr-weight">
1543      <title>Zebra Extention Rank Weight Attribute (type 9)</title>
1544     </sect3>
1545     <para>
1546      Rank weight is a way to pass a value to a ranking algorithm - so
1547      that one APT has one value - while another as a different one. 
1548      See also <xref linkend="administration-ranking"/>.
1549     </para>
1550     <para>
1551      For example, searching  for utah in title with weight 30 as well
1552      as any with weight 20: 
1553      <screen>  
1554       Z> find @attr 2=102 @or @attr 9=30 @attr 1=4 utah @attr 9=20 utah
1555      </screen>
1556     </para>
1557
1558     <sect3 id="querymodel-zebra-attr-limit">
1559      <title>Zebra Extention Approximative Limit Attribute (type 9)</title>
1560     </sect3>
1561     <para>
1562      Newer Zebra versions normally estemiates hit count for every APT
1563      (leaf) in the query tree. These hit counts are returned as part of
1564      the searchResult-1 facility in the binary encoded Z39.50 search
1565      response packages.
1566     </para>
1567     <para>
1568      By setting a limit for the APT we can make Zebra turn into
1569      approximate hit count when a certain hit count limit is
1570      reached. A value of zero means exact hit count.
1571     </para>
1572     <para>
1573      For example, we might be intersted in exact hit count for a, but
1574      for b we allow hit count estimates for 1000 and higher. 
1575      <screen>
1576       Z> find @and a @attr 9=1000 b
1577      </screen>
1578     </para>
1579     <note>
1580      The estimated hit count fascility makes searches faster, as one
1581      only needs to process large hit lists partially.
1582     </note>
1583     <warning>
1584      This facility clashes with rank weight, because there all
1585      documents in the hit lists need to be examined for scoring and
1586      re-sorting.
1587      It is an experimental
1588      extention. Do not use in production code.
1589     </warning>
1590
1591     <sect3 id="querymodel-zebra-attr-termref">
1592      <title>Zebra Extention Term Reference Attribute (type 10)</title>
1593     </sect3>
1594     <para>
1595      Zebra supports the <literal>searchResult-1</literal> facility. 
1596      If the <literal>Term Reference Attribute (type 10)</literal> is
1597      given, that specifies a subqueryId value returned as part of the
1598      search result. It is a way for a client to name an APT part of a
1599      query. 
1600     </para>
1601     <!--
1602     <para>
1603      <screen>
1604      </screen>
1605     </para>
1606     -->
1607     <warning>
1608      Experimental. Do not use in production code.
1609     </warning>
1610
1611
1612    </sect2>
1613     
1614
1615    <sect2 id="querymodel-zebra-attr-scan">
1616     <title>Zebra specific Scan Extentions to all Attribute Sets</title>
1617     <para>
1618      Zebra extends the Bib1 attribute types, and these extentions are
1619      recognized regardless of attribute 
1620      set used in a <literal>scan</literal> operation query.
1621     </para>
1622      <table id="querymodel-zebra-attr-scan-table"
1623       frame="all" rowsep="1" colsep="1" align="center">
1624
1625       <caption>Zebra Scan Attribute Extentions</caption>
1626        <thead>
1627         <tr>
1628          <td>Name</td>
1629          <td>Type</td>
1630          <td>Operation</td>
1631          <td>Zebra version</td>
1632         </tr>
1633       </thead>
1634        <tbody>
1635         <tr>
1636          <td>Result Set Narrow</td>
1637          <td>8</td>
1638          <td>scan</td>
1639          <td>1.3</td>
1640         </tr>
1641         <tr>
1642          <td>Approximative Limit</td>
1643          <td>9</td>
1644          <td>scan</td>
1645          <td>1.4</td>
1646         </tr>
1647        </tbody>
1648       </table>      
1649
1650     <sect3 id="querymodel-zebra-attr-narrow">
1651      <title>Zebra Extention Result Set Narrow (type 8)</title>
1652     </sect3>
1653     <para>
1654      If attribute <literal>Result Set Narrow (type 8)</literal> 
1655      is given for <literal>scan</literal>, the value is the name of a
1656      result set. Each hit count in <literal>scan</literal> is 
1657      <literal>@and</literal>'ed with the result set given. 
1658     </para>
1659     <para>
1660      Consider for example 
1661      the case of scanning all title fields around the
1662      scanterm <emphasis>mozart</emphasis>, then refining the scan by
1663      issuing a filtering query for <emphasis>amadeus</emphasis> to
1664      restric the scan to the result set of the query:  
1665      <screen>
1666       Z> scan @attr 1=4 mozart 
1667       ...
1668       * mozart (43)
1669         mozartforskningen (1)
1670         mozartiana (1)
1671         mozarts (16)
1672       ...
1673       Z> f @attr 1=4 amadeus   
1674       ...
1675       Number of hits: 15, setno 2
1676       ...
1677       Z> scan @attr 1=4 @attr 8=2 mozart
1678       ...
1679       * mozart (14)
1680         mozartforskningen (0)
1681         mozartiana (0)
1682         mozarts (1)
1683       ...
1684      </screen>
1685     </para>
1686    
1687     <warning>
1688      Experimental. Do not use in production code.
1689     </warning>
1690
1691     <sect3 id="querymodel-zebra-attr-approx">
1692      <title>Zebra Extention Approximative Limit (type 9)</title>
1693     </sect3>
1694     <para>
1695      The <literal>Zebra Extention Approximative Limit (type
1696       9)</literal> is a way to enable approx
1697      hit counts for <literal>scan</literal> hit counts, in the same
1698      way as for <literal>search</literal> hit counts. 
1699     </para>
1700     <!--
1701     <para>
1702      <screen>
1703      </screen>
1704     </para>
1705     -->
1706     <warning>
1707      Experimental and buggy. Definitely not to be used in production code.
1708     </warning>
1709
1710
1711    </sect2>
1712    
1713    
1714    <sect2 id="querymodel-idxpath">
1715     <title>Zebra special IDXPATH Attribute Set for GRS indexing</title>
1716     <para>
1717      The attribute-set <literal>idxpath</literal> consists of a single 
1718      <literal>Use (type 1)</literal> attribute. All non-use attributes
1719      behave as normal. 
1720     </para>
1721     <para>
1722      This feature is enabled when defining the
1723      <literal>xpath enable</literal> option in the GRS filter
1724      <filename>*.abs</filename> configuration files. If one wants to use
1725      the special <literal>idxpath</literal> numeric attribute set, the
1726      main Zebra configuraiton file <filename>zebra.cfg</filename>
1727      directive <literal>attset: idxpath.att</literal> must be enabled.
1728     </para>
1729     <warning>The <literal>idxpath</literal> is depreciated, may not be
1730      supported in future Zebra versions, and should definitely
1731      not be used in production code.
1732     </warning>
1733
1734     <sect3 id="querymodel-idxpath-use">
1735     <title>IDXPATH Use Attributes (type = 1)</title>
1736      <para>
1737       This attribute set allows one to search GRS filter indexed
1738       records by XPATH like structured index names. 
1739      </para>
1740
1741      <warning>The <literal>idxpath</literal> option defines hard-coded
1742       index names, which might clash with your own index names.
1743      </warning>
1744      
1745      <table id="querymodel-idxpath-use-table"
1746       frame="all" rowsep="1" colsep="1" align="center">
1747
1748       <caption>Zebra specific IDXPATH Use Attributes (type 1)</caption>
1749       <thead>
1750         <tr>
1751          <td>IDXPATH</td>
1752          <td>Value</td>
1753          <td>String Index</td>
1754          <td>Notes</td>
1755         </tr>
1756        </thead>
1757        <tbody>
1758         <tr>
1759          <td>XPATH Begin</td>
1760          <td>1</td>
1761          <td>_XPATH_BEGIN</td>
1762          <td>depreciated</td>
1763         </tr>
1764         <tr>
1765          <td>XPATH End</td>
1766          <td>2</td>
1767          <td>_XPATH_END</td>
1768          <td>depreciated</td>
1769         </tr>
1770         <tr>
1771          <td>XPATH CData</td>
1772          <td>1016</td>
1773          <td>_XPATH_CDATA</td>
1774          <td>depreciated</td>
1775         </tr>
1776         <tr>
1777          <td>XPATH Attribute Name</td>
1778          <td>3</td>
1779          <td>_XPATH_ATTR_NAME</td>
1780          <td>depreciated</td>
1781         </tr>
1782         <tr>
1783          <td>XPATH Attribute CData</td>
1784          <td>1015</td>
1785          <td>_XPATH_ATTR_CDATA</td>
1786          <td>depreciated</td>
1787         </tr>
1788        </tbody>
1789      </table>
1790
1791
1792      <para>
1793       See <filename>tab/idxpath.att</filename> for more information.
1794      </para>
1795      <para>
1796       Search for all documents starting with root element 
1797       <literal>/root</literal> (either using the numeric or the string
1798       use attributes):
1799       <screen>
1800        Z> find @attrset idxpath @attr 1=1 @attr 4=3 root/ 
1801        Z> find @attr idxpath 1=1 @attr 4=3 root/ 
1802        Z> find @attr 1=_XPATH_BEGIN @attr 4=3 root/ 
1803       </screen>
1804      </para>
1805      <para>
1806       Search for all documents where specific nested XPATH 
1807       <literal>/c1/c2/../cn</literal> exists. Notice the very
1808       counter-intuitive <emphasis>reverse</emphasis> notation!
1809       <screen>
1810        Z> find @attrset idxpath @attr 1=1 @attr 4=3 cn/cn-1/../c1/ 
1811        Z> find @attr 1=_XPATH_BEGIN @attr 4=3 cn/cn-1/../c1/ 
1812       </screen>
1813      </para>
1814      <para>
1815       Search for CDATA string <emphasis>text</emphasis> in any  element
1816       <screen>
1817        Z> find @attrset idxpath @attr 1=1016 text
1818        Z> find @attr 1=_XPATH_CDATA text
1819       </screen>
1820      </para>
1821      <para>
1822        Search for CDATA string <emphasis>anothertext</emphasis> in any
1823        attribute: 
1824       <screen> 
1825        Z> find @attrset idxpath @attr 1=1015 anothertext
1826        Z> find @attr 1=_XPATH_ATTR_CDATA anothertext
1827       </screen>
1828      </para>
1829      <para>
1830        Search for all documents with have an XML element node
1831        including an XML  attribute named <emphasis>creator</emphasis> 
1832       <screen> 
1833        Z> find @attrset idxpath @attr 1=3 @attr 4=3 creator 
1834        Z> find @attr 1=_XPATH_ATTR_NAME @attr 4=3 creator 
1835       </screen>
1836      </para>
1837      <para>
1838       Combining usual <literal>bib-1</literal> attribut set searches
1839       with <literal>idxpath</literal> attribute set searches:
1840       <screen>
1841        Z> find @and @attr idxpath 1=1 @attr 4=3 link/ @attr 1=4 mozart
1842        Z> find @and @attr 1=_XPATH_BEGIN @attr 4=3 link/ @attr 1=_XPATH_CDATA mozart
1843       </screen>
1844      </para>
1845      <para>
1846       Scanning is supportet on all <literal>idxpath</literal>
1847       indexes, both specified as numeric use attributes, or as string
1848       index names. 
1849       <screen>
1850        Z> scan  @attrset idxpath @attr 1=1016 text
1851        Z> scan  @attr 1=_XPATH_ATTR_CDATA anothertext
1852        Z> scan  @attrset idxpath @attr 1=3 @attr 4=3 ''
1853       </screen>
1854      </para>
1855
1856     </sect3>
1857    </sect2>
1858
1859
1860    <sect2 id="querymodel-pqf-apt-mapping">
1861     <title>Mapping from PQF atomic APT queries to Zebra internal 
1862      register indexes</title>
1863     <para>
1864      The rules for PQF APT mapping are rather tricky to grasp in the
1865      first place. We deal first with the rules for deciding which
1866      internal register or string index to use, according to the use
1867      attribute or access point specified in the query. Thereafter we
1868      deal with the rules for determining the correct structure type of
1869      the named register. 
1870     </para>
1871
1872    <sect3 id="querymodel-pqf-apt-mapping-accesspoint">
1873     <title>Mapping of PQF APT access points</title>
1874     <para>
1875       Zebra understands four fundamental different types of access
1876       points, of which only the  
1877       <emphasis>numeric use attribute</emphasis> type access points
1878       are defined by the  <ulink url="&url.z39.50;">Z39.50</ulink>
1879       standard.
1880       All other access point types are Zebra specific, and non-portable.
1881     </para>
1882
1883      <table id="querymodel-zebra-mapping-accesspoint-types"
1884       frame="all" rowsep="1" colsep="1" align="center">
1885
1886       <caption>Acces point name mapping</caption>
1887        <thead>
1888         <tr>
1889          <td>Acess Point</td>
1890          <td>Type</td>
1891          <td>Grammar</td>
1892          <td>Notes</td>
1893         </tr>
1894       </thead>
1895       <tbody>
1896        <tr>
1897         <td>Use attibute</td>
1898         <td>numeric</td>
1899         <td>[1-9][1-9]*</td>
1900         <td>directly mapped to string index name</td>
1901        </tr>
1902        <tr>
1903         <td>String index name</td>
1904         <td>string</td>
1905         <td>[a-zA-Z](\-?[a-zA-Z0-9])*</td>
1906         <td>normalized name is used as internal string index name</td>
1907        </tr>
1908        <tr>
1909         <td>Zebra internal index name</td>
1910         <td>zebra</td>
1911         <td>_[a-zA-Z](_?[a-zA-Z0-9])*</td>
1912         <td>hardwired internal string index name</td>
1913        </tr>
1914        <tr>
1915         <td>XPATH special index</td>
1916         <td>XPath</td>
1917         <td>/.*</td>
1918         <td>special xpath search for GRS indexed records</td>
1919        </tr>
1920       </tbody>
1921     </table>
1922
1923     <para>
1924      <literal>Attribute set names</literal> and 
1925      <literal>string index names</literal> are normalizes
1926      according to the following rules: all <emphasis>single</emphasis>
1927      hyphens <literal>'-'</literal> are stripped, and all upper case
1928      letters are folded to lower case.
1929      </para>
1930
1931      <para>
1932       <emphasis>Numeric use attributes</emphasis> are mapped 
1933       to the Zebra internal
1934       string index according to the attribute set defintion in use.
1935       The default attribute set is <literal>Bib-1</literal>, and may be
1936       omitted in the PQF query.
1937      </para>
1938      
1939      <para>
1940       According to normalization and numeric
1941       use attribute mapping, it follows that the following
1942       PQF queries are considered equivalent (assuming the default
1943       configuration has not been altered):
1944       <screen>
1945       Z> find  @attr 1=Body-of-text serenade
1946       Z> find  @attr 1=bodyoftext serenade
1947       Z> find  @attr 1=BodyOfText serenade
1948       Z> find  @attr 1=bO-d-Y-of-tE-x-t serenade
1949       Z> find  @attr 1=1010 serenade
1950       Z> find  @attrset Bib-1 @attr 1=1010 serenade
1951       Z> find  @attrset bib1 @attr 1=1010 serenade
1952       Z> find  @attrset Bib1 @attr 1=1010 serenade
1953       Z> find  @attrset b-I-b-1 @attr 1=1010 serenade
1954      </screen>
1955     </para>
1956
1957     <para>
1958       The <emphasis>numerical</emphasis>
1959       <literal>use attributes (type 1)</literal>  
1960       are interpreted according to the
1961       attribute sets which have been loaded in the
1962       <literal>zebra.cfg</literal> file, and are matched against specific
1963       fields as specified in the <literal>.abs</literal> file which
1964       describes the profile of the records which have been loaded.
1965       If no use attribute is provided, a default of 
1966       <literal>Bib-1 Use Any (1016)</literal> is
1967       assumed.
1968       The predefined <literal>use attribute sets</literal>
1969       can be reconfigured by  tweaking the configuration files
1970       <filename>tab/*.att</filename>, and 
1971       new attribute sets can be defined by adding similar files in the
1972       configuration path <literal>profilePath</literal> of the server.  
1973     </para>
1974
1975      <para>
1976       <literal>String indexes</literal> can be acessed directly,
1977       independently which attribute set is in use. These are just
1978       ignored. The above mentioned name normalization applies.
1979       <literal>String index names</literal> are defined in the
1980       used indexing  filter configuration files, for example in the
1981       <literal>GRS</literal> 
1982       <filename>*.abs</filename> configuration files, or in the
1983       <literal>alvis</literal> filter XSLT indexing stylesheets.
1984      </para>
1985
1986      <para>
1987       <literal>Zebra internal indexes</literal> can be acessed directly,
1988       according to the same rules as the user defined
1989       <literal>string indexes</literal>. The only difference is that   
1990       <literal>Zebra internal indexe names</literal> are hardwired,
1991       all uppercase and
1992       must start with the character <literal>'_'</literal>. 
1993      </para>
1994
1995      <para>
1996       Finally, <literal>XPATH</literal> access points are only
1997       available using the <literal>GRS</literal> filter for indexing.
1998       These acees point names must start with the character
1999       <literal>'/'</literal>, they are <emphasis>not
2000       normalized</emphasis>, but passed unaltered to the Zebra internal
2001       XPATH engine. See <xref linkend="querymodel-use-xpath"/>.
2002
2003      </para>
2004
2005
2006     </sect3>
2007
2008
2009    <sect3 id="querymodel-pqf-apt-mapping-structuretype">
2010      <title>Mapping of PQF APT structure and completeness to 
2011       register type</title>
2012     <para>
2013       Internally Zebra has in it's default configuration several
2014      different types of registers or indexes, whose tokenization and
2015       character normalization rules differ. This reflects the fact that 
2016       serching fundamental different tokens like dates, numbers,
2017       bitfields and string based text needs different rulesets. 
2018      </para>
2019
2020      <table id="querymodel-zebra-mapping-structure-types"
2021       frame="all" rowsep="1" colsep="1" align="center">
2022
2023       <caption>Structure and completeness mapping to register types</caption>
2024        <thead>
2025         <tr>
2026          <td>Structure</td>
2027          <td>Completeness</td>
2028          <td>Register type</td>
2029          <td>Notes</td>
2030         </tr>
2031       </thead>
2032       <tbody>
2033        <tr>
2034         <td>
2035           phrase (@attr 4=1), word (@attr 4=2), 
2036           word-list (@attr 4=6),
2037           free-form-text  (@attr 4=105), or document-text (@attr 4=106)
2038          </td>
2039         <td>Incomplete field (@attr 6=1)</td>
2040         <td>Word ('w')</td>
2041         <td>Traditional tokenized and character normalized word index</td>
2042        </tr>
2043        <tr>
2044         <td>
2045           phrase (@attr 4=1), word (@attr 4=2), 
2046           word-list (@attr 4=6),
2047           free-form-text  (@attr 4=105), or document-text (@attr 4=106)
2048          </td>
2049         <td>complete field' (@attr 6=3)</td>
2050         <td>Phrase ('p')</td>
2051         <td>Character normalized, but not tokenized index for phrase
2052           matches
2053          </td>
2054        </tr>
2055        <tr>
2056         <td>urx (@attr 4=104)</td>
2057         <td>ignored</td>
2058         <td>URX/URL ('u')</td>
2059         <td>Special index for URL web adresses</td>
2060        </tr>
2061        <tr>
2062         <td>numeric (@attr 4=109)</td>
2063         <td>ignored</td>
2064         <td>Numeric ('u')</td>
2065         <td>Special index for digital numbers</td>
2066        </tr>
2067        <tr>
2068         <td>key (@attr 4=3)</td>
2069         <td>ignored</td>
2070         <td>Null bitmap ('0')</td>
2071         <td>Used for non-tokenizated and non-normalized bit sequences</td>
2072        </tr>
2073        <tr>
2074         <td>year (@attr 4=4)</td>
2075         <td>ignored</td>
2076         <td>Year ('y')</td>
2077         <td>Non-tokenizated and non-normalized 4 digit numbers</td>
2078        </tr>
2079        <tr>
2080         <td>date (@attr 4=5)</td>
2081         <td>ignored</td>
2082         <td>Date ('d')</td>
2083         <td>Non-tokenizated and non-normalized ISO date strings</td>
2084        </tr>
2085        <tr>
2086         <td>ignored</td>
2087         <td>ignored</td>
2088         <td>Sort ('s')</td>
2089         <td>Used with special sort attribute set (@attr 7=1, @attr 7=2)</td>
2090        </tr>
2091        <tr>
2092         <td>overruled</td>
2093         <td>overruled</td>
2094         <td>special</td>
2095         <td>Internal record ID register, used whenever 
2096          Relation Always Matches (@attr 2=103) is specified</td>
2097        </tr>
2098       </tbody>
2099     </table>
2100
2101      <!-- see in util/zebramap.c -->
2102         
2103     <para>
2104      If a <emphasis>Structure</emphasis> attribute of
2105      <emphasis>Phrase</emphasis> is used in conjunction with a
2106      <emphasis>Completeness</emphasis> attribute of
2107      <emphasis>Complete (Sub)field</emphasis>, the term is matched
2108      against the contents of the phrase (long word) register, if one
2109      exists for the given <emphasis>Use</emphasis> attribute.
2110      A phrase register is created for those fields in the
2111      GRS <filename>*.abs</filename> file that contains a
2112      <literal>p</literal>-specifier.
2113       <screen>
2114        Z>  scan @attr 1=Title @attr 4=1 @attr 6=3 beethoven 
2115        ...
2116        bayreuther festspiele (1)
2117        * beethoven bibliography database (1)
2118        benny carter (1)
2119        ...
2120        Z> find @attr 1=Title @attr 4=1 @attr 6=3 "beethoven bibliography" 
2121        ...
2122        Number of hits: 0, setno 5
2123        ...
2124        Z> find @attr 1=Title @attr 4=1 @attr 6=3 "beethoven bibliography database" 
2125        ...
2126        Number of hits: 1, setno 6
2127        </screen>
2128     </para>
2129
2130     <para>
2131      If <emphasis>Structure</emphasis>=<emphasis>Phrase</emphasis> is
2132      used in conjunction with <emphasis>Incomplete Field</emphasis> - the
2133      default value for <emphasis>Completeness</emphasis>, the
2134      search is directed against the normal word registers, but if the term
2135      contains multiple words, the term will only match if all of the words
2136      are found immediately adjacent, and in the given order.
2137      The word search is performed on those fields that are indexed as
2138      type <literal>w</literal> in the GRS <filename>*.abs</filename> file.
2139       <screen>
2140        Z>  scan @attr 1=Title @attr 4=1 @attr 6=1 beethoven 
2141        ...
2142          beefheart (1)
2143        * beethoven (18)
2144          beethovens (7)
2145        ...
2146        Z> find @attr 1=Title @attr 4=1 @attr 6=1 beethoven 
2147        ...
2148        Number of hits: 18, setno 1
2149        ...
2150        Z> find @attr 1=Title @attr 4=1 @attr 6=1 "beethoven  bibliography"
2151        ...
2152        Number of hits: 2, setno 2
2153        ...
2154      </screen>
2155     </para>
2156
2157     <para>
2158      If the <emphasis>Structure</emphasis> attribute is
2159      <emphasis>Word List</emphasis>,
2160      <emphasis>Free-form Text</emphasis>, or
2161      <emphasis>Document Text</emphasis>, the term is treated as a
2162      natural-language, relevance-ranked query.
2163      This search type uses the word register, i.e. those fields
2164      that are indexed as type <literal>w</literal> in the
2165      GRS <filename>*.abs</filename> file.
2166     </para>
2167
2168     <para>
2169      If the <emphasis>Structure</emphasis> attribute is
2170      <emphasis>Numeric String</emphasis> the term is treated as an integer.
2171      The search is performed on those fields that are indexed
2172      as type <literal>n</literal> in the GRS 
2173       <filename>*.abs</filename> file.
2174     </para>
2175
2176     <para>
2177      If the <emphasis>Structure</emphasis> attribute is
2178      <emphasis>URx</emphasis> the term is treated as a URX (URL) entity.
2179      The search is performed on those fields that are indexed as type
2180      <literal>u</literal> in the <filename>*.abs</filename> file.
2181     </para>
2182
2183     <para>
2184      If the <emphasis>Structure</emphasis> attribute is
2185      <emphasis>Local Number</emphasis> the term is treated as
2186      native Zebra Record Identifier.
2187     </para>
2188
2189     <para>
2190      If the <emphasis>Relation</emphasis> attribute is
2191      <emphasis>Equals</emphasis> (default), the term is matched
2192      in a normal fashion (modulo truncation and processing of
2193      individual words, if required).
2194      If <emphasis>Relation</emphasis> is <emphasis>Less Than</emphasis>,
2195      <emphasis>Less Than or Equal</emphasis>,
2196      <emphasis>Greater than</emphasis>, or <emphasis>Greater than or
2197       Equal</emphasis>, the term is assumed to be numerical, and a
2198      standard regular expression is constructed to match the given
2199      expression.
2200      If <emphasis>Relation</emphasis> is <emphasis>Relevance</emphasis>,
2201      the standard natural-language query processor is invoked.
2202     </para>
2203
2204     <para>
2205      For the <emphasis>Truncation</emphasis> attribute,
2206      <emphasis>No Truncation</emphasis> is the default.
2207      <emphasis>Left Truncation</emphasis> is not supported.
2208      <emphasis>Process # in search term</emphasis> is supported, as is
2209      <emphasis>Regxp-1</emphasis>.
2210      <emphasis>Regxp-2</emphasis> enables the fault-tolerant (fuzzy)
2211      search. As a default, a single error (deletion, insertion, 
2212      replacement) is accepted when terms are matched against the register
2213      contents.
2214     </para>
2215
2216      </sect3>
2217    </sect2>
2218
2219    <sect2  id="querymodel-regular">
2220     <title>Zebra Regular Expressions in Truncation Attribute (type = 5)</title>
2221     
2222     <para>
2223      Each term in a query is interpreted as a regular expression if
2224      the truncation value is either <emphasis>Regxp-1 (@attr 5=102)</emphasis>
2225      or <emphasis>Regxp-2 (@attr 5=103)</emphasis>.
2226      Both query types follow the same syntax with the operands:
2227     </para>
2228
2229      <table id="querymodel-regular-operands-table"
2230       frame="all" rowsep="1" colsep="1" align="center">
2231
2232       <caption>Regular Expression Operands</caption>
2233        <!--
2234        <thead>
2235        <tr><td>one</td><td>two</td></tr>
2236       </thead>
2237        -->
2238        <tbody>
2239         <tr>
2240          <td><literal>x</literal></td>
2241          <td>Matches the character <literal>x</literal>.</td>
2242         </tr>
2243         <tr>
2244          <td><literal>.</literal></td>
2245          <td>Matches any character.</td>
2246         </tr>
2247         <tr>
2248          <td><literal>[ .. ]</literal></td>
2249          <td>Matches the set of characters specified;
2250          such as <literal>[abc]</literal> or <literal>[a-c]</literal>.</td>
2251         </tr>
2252        </tbody>
2253       </table>      
2254
2255     <para>
2256      The above operands can be combined with the following operators:
2257     </para>
2258
2259      <table id="querymodel-regular-operators-table"
2260       frame="all" rowsep="1" colsep="1" align="center">
2261       <caption>Regular Expression Operators</caption>
2262        <!--
2263        <thead>
2264        <tr><td>one</td><td>two</td></tr>
2265       </thead>
2266        -->
2267        <tbody>
2268         <tr>
2269          <td><literal>x*</literal></td>
2270          <td>Matches <literal>x</literal> zero or more times. 
2271           Priority: high.</td>
2272         </tr>
2273         <tr>
2274          <td><literal>x+</literal></td>
2275          <td>Matches <literal>x</literal> one or more times. 
2276           Priority: high.</td>
2277         </tr>
2278         <tr>
2279          <td><literal>x?</literal></td>
2280          <td> Matches <literal>x</literal> zero or once. 
2281           Priority: high.</td>
2282         </tr>
2283         <tr>
2284          <td><literal>xy</literal></td>
2285          <td> Matches <literal>x</literal>, then <literal>y</literal>.
2286          Priority: medium.</td>
2287         </tr>
2288         <tr>
2289          <td><literal>x|y</literal></td>
2290          <td> Matches either <literal>x</literal> or <literal>y</literal>.
2291          Priority: low.</td>
2292         </tr>
2293         <tr>
2294          <td><literal>( )</literal></td>
2295          <td>The order of evaluation may be changed by using parentheses.</td>
2296         </tr>
2297        </tbody>
2298       </table>      
2299
2300     <para>
2301      If the first character of the <literal>Regxp-2</literal> query
2302      is a plus character (<literal>+</literal>) it marks the
2303      beginning of a section with non-standard specifiers.
2304      The next plus character marks the end of the section.
2305      Currently Zebra only supports one specifier, the error tolerance,
2306      which consists one digit. 
2307     </para>
2308
2309     <para>
2310      Since the plus operator is normally a suffix operator the addition to
2311      the query syntax doesn't violate the syntax for standard regular
2312      expressions.
2313     </para>
2314
2315     <para>
2316      For example, a phrase search with regular expressions  in
2317      the title-register is performed like this:
2318      <screen>
2319       Z> find @attr 1=4 @attr 5=102 "informat.* retrieval"
2320      </screen>
2321     </para>
2322
2323     <para>
2324      Combinations with other attributes are possible. For example, a
2325      ranked search with a regular expression:
2326      <screen>
2327       Z> find @attr 1=4 @attr 5=102 @attr 2=102 "informat.* retrieval"
2328      </screen>
2329     </para>
2330    </sect2>
2331
2332   
2333    <!--
2334    <para>
2335     The RecordType parameter in the <literal>zebra.cfg</literal> file, or
2336     the <literal>-t</literal> option to the indexer tells Zebra how to
2337     process input records.
2338     Two basic types of processing are available - raw text and structured
2339     data. Raw text is just that, and it is selected by providing the
2340     argument <literal>text</literal> to Zebra. Structured records are
2341     all handled internally using the basic mechanisms described in the
2342     subsequent sections.
2343     Zebra can read structured records in many different formats.
2344    </para>
2345    -->
2346   </sect1>
2347
2348
2349   <sect1 id="querymodel-cql-to-pqf">
2350    <title>Server Side CQL to PQF Query Translation</title>
2351    <para>
2352     Using the
2353     <literal>&lt;cql2rpn&gt;l2rpn.txt&lt;/cql2rpn&gt;</literal>
2354       YAZ Frontend Virtual
2355     Hosts option, one can configure
2356     the YAZ Frontend CQL-to-PQF
2357     converter, specifying the interpretation of various 
2358     <ulink url="&url.cql;">CQL</ulink>
2359     indexes, relations, etc. in terms of Type-1 query attributes.
2360     <!-- The  yaz-client config file -->  
2361    </para>
2362    <para>
2363     For example, using server-side CQL-to-PQF conversion, one might
2364     query a zebra server like this:
2365     <screen>
2366     <![CDATA[
2367      yaz-client localhost:9999
2368      Z> querytype cql
2369      Z> find text=(plant and soil)
2370      ]]>
2371     </screen>
2372      and - if properly configured - even static relevance ranking can
2373      be performed using CQL query syntax:
2374     <screen>
2375     <![CDATA[
2376      Z> find text = /relevant (plant and soil)
2377      ]]>
2378      </screen>
2379    </para>
2380
2381    <para>
2382     By the way, the same configuration can be used to 
2383     search using client-side CQL-to-PQF conversion:
2384     (the only difference is <literal>querytype cql2rpn</literal> 
2385     instead of 
2386     <literal>querytype cql</literal>, and the call specifying a local
2387     conversion file)
2388     <screen>
2389     <![CDATA[
2390      yaz-client -q local/cql2pqf.txt localhost:9999
2391      Z> querytype cql2rpn
2392      Z> find text=(plant and soil)
2393      ]]>
2394      </screen>
2395    </para>
2396
2397    <para>
2398     Exhaustive information can be found in the
2399     Section "Specification of CQL to RPN mappings" in the YAZ manual.
2400     <ulink url="http://www.indexdata.dk/yaz/doc/tools.tkl#tools.cql.map">
2401      http://www.indexdata.dk/yaz/doc/tools.tkl#tools.cql.map</ulink>,
2402    and shall therefore not be repeated here.
2403    </para> 
2404   <!-- 
2405   <para>
2406     See 
2407       <ulink url="http://www.loc.gov/z3950/agency/zing/cql/dc-indexes.html">
2408       http://www.loc.gov/z3950/agency/zing/cql/dc-indexes.html</ulink>
2409     for the Maintenance Agency's work-in-progress mapping of Dublin Core
2410     indexes to Attribute Architecture (util, XD and BIB-2)
2411     attributes.
2412    </para>
2413    -->
2414  </sect1>
2415
2416
2417
2418 </chapter>
2419
2420  <!-- Keep this comment at the end of the file
2421  Local variables:
2422  mode: sgml
2423  sgml-omittag:t
2424  sgml-shorttag:t
2425  sgml-minimize-attributes:nil
2426  sgml-always-quote-attributes:t
2427  sgml-indent-step:1
2428  sgml-indent-data:t
2429  sgml-parent-document: "zebra.xml"
2430  sgml-local-catalogs: nil
2431  sgml-namecase-general:t
2432  End:
2433  -->