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