02729663b6e53deeeba3dc08ba7c9bc14023ad84
[idzebra-moved-to-github.git] / doc / querymodel.xml
1  <chapter id="querymodel">
2   <!-- $Id: querymodel.xml,v 1.32 2007-05-24 13:44:09 adam Exp $ -->
3   <title>Query Model</title>
4   
5   <section id="querymodel-overview">
6    <title>Query Model Overview</title>  
7    
8    <section 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;">&acro.z3950;</ulink> and
15      <ulink url="&url.sru;">&acro.sru;</ulink>,
16      and implement the 
17      type-1 Reverse Polish Notation (&acro.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 &acro.z3950; 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 (&acro.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     <section id="querymodel-query-languages-pqf">
33      <title>Prefix Query Format (&acro.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>&acro.pqf;</emphasis>, which maps 
38       one-to-one to binary encoded  
39       <emphasis>type-1 &acro.rpn;</emphasis> queries.
40       &acro.pqf; has been adopted by other
41       parties developing &acro.z3950; software, and is often referred to as
42       <emphasis>Prefix Query Notation</emphasis>, or in short 
43       &acro.pqn;. See       
44       <xref linkend="querymodel-rpn"/> for further explanations and
45       descriptions of &zebra;'s capabilities.  
46      </para>
47     </section>    
48     
49     <section id="querymodel-query-languages-cql">
50      <title>Common Query Language (&acro.cql;)</title>
51      <para>
52       The query model of the type-1 &acro.rpn;,
53       expressed in &acro.pqf;/&acro.pqn; is natively supported. 
54       On the other hand, the default &acro.sru;
55       web services <emphasis>Common Query Language</emphasis>
56       <ulink url="&url.cql;">&acro.cql;</ulink> is not natively supported.
57      </para>
58      <para>
59       &zebra; can be configured to understand and map &acro.cql; to &acro.pqf;. See
60       <xref linkend="querymodel-cql-to-pqf"/>.
61      </para>
62     </section>    
63  
64    </section>
65
66    <section id="querymodel-operation-types">
67     <title>Operation types</title>
68     <para>
69      &zebra; supports all of the three different
70      &acro.z3950;/&acro.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     <section id="querymodel-operation-type-explain">
77      <title>Explain Operation</title>
78      <para>
79       The <emphasis>syntax</emphasis> of &acro.z3950;/&acro.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 &acro.z3950; 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 &acro.sru;, explain is an entirely  separate
100       operation, which returns an ZeeRex &acro.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     </section>
110
111     <section 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 &acro.z3950;/&acro.sru; servers.
121      </para>
122     </section>
123
124     <section 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     </section>
141
142    </section>
143
144  </section>
145
146   
147   <section id="querymodel-rpn">
148    <title>&acro.rpn; queries and semantics</title>
149    <para>
150     The <ulink url="&url.yaz.pqf;">&acro.pqf; grammar</ulink>
151     is documented in the &yaz; manual, and shall not be
152     repeated here. This textual &acro.pqf; representation
153     is not transmistted to &zebra; during search, but it is in the
154     client mapped to the equivalent &acro.z3950; binary 
155     query parse tree. 
156    </para>
157    
158    <section id="querymodel-rpn-tree">
159     <title>&acro.rpn; tree structure</title>
160     <para>
161      The &acro.rpn; parse tree - or the equivalent textual representation in &acro.pqf; -
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 (&acro.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     <section 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>&acro.pqf; notation (Short hand)</entry>
188          <entry>Status</entry>
189          <entry>Notes</entry>
190         </row>
191        </thead>
192        
193        <tbody>
194         <row>
195          <entry>Explain</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>&acro.bib1;</entry>
205          <entry><literal>bib-1</literal></entry>
206          <entry>Standard &acro.pqf; query language attribute set which defines the
207           semantics of &acro.z3950; searching. In addition, all of the
208           non-use attributes (types 2-12) define the hard-wired 
209           &zebra; internal query
210           processing.</entry>
211          <entry>default</entry>
212         </row>
213         <row>
214          <entry>GILS</entry>
215          <entry><literal>gils</literal></entry>
216          <entry>Extension to the &acro.bib1; attribute set.</entry>
217          <entry>predefined</entry>
218         </row>
219         <!--
220         <row>
221         <entry>&acro.idxpath;</entry>
222         <entry><literal>idxpath</literal></entry>
223         <entry>Hardwired &acro.xpath; like attribute set, only available for
224         indexing with the &acro.grs1; 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 &acro.bib1; 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     </section>
248     
249     <section 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 AND 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 OR 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 AND NOT 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 PROXIMITY 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;">&acro.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     </section>
338     
339     
340     <section id="querymodel-atomic-queries">
341      <title>Atomic queries (&acro.apt;)</title>
342      <para>
343       Atomic queries are the query parts which work on one access point
344       only. These consist of <emphasis>an attribute list</emphasis>
345       followed by a <emphasis>single term</emphasis> or a
346       <emphasis>quoted term list</emphasis>, and are often called 
347       <emphasis>Attributes-Plus-Terms (&acro.apt;)</emphasis> queries.
348      </para>
349      <para>
350       Atomic (&acro.apt;) queries are always leaf nodes in the &acro.pqf; query tree. 
351       UN-supplied non-use attributes types 2-12 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 (&acro.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 <emphasis>orthogonal</emphasis> 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 <emphasis>term</emphasis> 
378           or <emphasis>quoted term list</emphasis>   </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 <emphasis>scan</emphasis> operation is only supported with 
410       atomic &acro.apt; queries, as it is bound to one access point at a
411       time. Boolean query trees are not allowed during
412       <emphasis>scan</emphasis>.
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     </section>
425     
426     
427     <section 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 &acro.pqf; query tree, exactly as
433       atomic &acro.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 <application>yaz-client</application>. Notice that the client, not
448       the server, assigns the string '1' 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 &acro.z3950; protocol.
464        The &acro.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 &acro.sru; protocol.
467       </para>
468      </note>
469     </section>
470     
471     <section id="querymodel-use-string">
472      <title>&zebra;'s special access point of type 'string'</title>
473      <para>
474       The numeric <emphasis>use (type 1)</emphasis> 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 its 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 its 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 &acro.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="zebrasrv-sru"/>
515       for the &acro.sru; &acro.pqf; query extension using string names as a fast
516       debugging facility.
517      </para>
518     </section>
519     
520     <section id="querymodel-use-xpath">
521      <title>&zebra;'s special access point of type 'XPath' 
522       for &acro.grs1; 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 <emphasis>use (type 1)</emphasis>
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 &acro.xml; element
535       than it pretends to access. 
536      </para>
537      <para>
538       When using the &acro.grs1; Record Model
539       (see  <xref linkend="grs"/>), we have the
540       possibility to embed <emphasis>life</emphasis> 
541       XPath expressions
542       in the &acro.pqf; queries, which are here called
543       <emphasis>use (type 1)</emphasis> <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 &acro.grs1; record model is simpler than
553        a full &acro.xml; &acro.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 &acro.xml; &acro.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 &acro.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 &acro.pqf; keywords and other non-parseable XPath constructs
611       with <literal>'{ }'</literal> to prevent client-side &acro.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     </section>
628    </section>
629    
630    <section id="querymodel-exp1">
631     <title>Explain Attribute Set</title>
632     <para>
633      The &acro.z3950; standard defines the  
634      <ulink url="&url.z39.50.explain;">Explain</ulink> attribute set
635      Exp-1, 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      use attribute (type 1). 
644     </para>
645     <para>
646      In addition, the non-Use
647      &acro.bib1; attributes, that is, the types 
648      <emphasis>Relation</emphasis>, <emphasis>Position</emphasis>,
649      <emphasis>Structure</emphasis>, <emphasis>Truncation</emphasis>, 
650      and <emphasis>Completeness</emphasis> are imported from 
651      the &acro.bib1; attribute set, and may be used
652      within any explain query. 
653     </para>
654     
655     <section 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;">&acro.z3950;</ulink> standard
673       for more information.
674      </para>
675     </section>
676     
677     <section id="querymodel-examples">
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 &acro.z3950; clients supports this. Fortunately
682       they don't have to - &zebra; allows retrieval of this information
683       in other formats:
684       <literal>&acro.sutrs;</literal>, <literal>&acro.xml;</literal>, 
685       <literal>&acro.grs1;</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       &acro.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     </section>
759     
760    </section>
761    
762    <section id="querymodel-bib1">
763     <title>&acro.bib1; Attribute Set</title>
764     <para>
765      Most of the information contained in this section is an excerpt of
766      the ATTRIBUTE SET &acro.bib1; (&acro.z3950;-1995) SEMANTICS
767      found at <ulink url="&url.z39.50.attset.bib1.1995;">. The &acro.bib1;
768       Attribute Set Semantics</ulink> from 1995, also in an updated 
769      <ulink url="&url.z39.50.attset.bib1;">&acro.bib1;
770       Attribute Set</ulink> 
771      version from 2003. Index Data is not the copyright holder of this
772      information, except for the configuration details, the listing of
773      &zebra;'s capabilities, and the example queries. 
774     </para>
775     
776     
777    <section id="querymodel-bib1-use">
778      <title>Use Attributes (type 1)</title>
779
780     <para>
781      A use attribute specifies an access point for any atomic query.
782      These access points are highly dependent on the attribute set used
783      in the query, and are user configurable using the following
784      default configuration files:
785      <filename>tab/bib1.att</filename>,
786      <filename>tab/dan1.att</filename>,
787      <filename>tab/explain.att</filename>, and
788      <filename>tab/gils.att</filename>.
789      </para>
790     <para>
791       For example, some few &acro.bib1; use
792       attributes from the  <filename>tab/bib1.att</filename> are:
793       <screen>
794        att 1               Personal-name
795        att 2               Corporate-name
796        att 3               Conference-name
797        att 4               Title
798        ...
799        att 1009            Subject-name-personal
800        att 1010            Body-of-text
801        att 1011            Date/time-added-to-db
802        ...
803        att 1016            Any
804        att 1017            Server-choice
805        att 1018            Publisher
806        ...
807        att 1035            Anywhere
808        att 1036            Author-Title-Subject
809       </screen>
810      </para>
811     <para>
812      New attribute sets can be added by adding new 
813      <filename>tab/*.att</filename> configuration files, which need to
814      be sourced in the main configuration <filename>zebra.cfg</filename>. 
815      </para>
816     <para>
817       In addition, &zebra; allows the access of 
818      <emphasis>internal index names</emphasis> and <emphasis>dynamic
819      XPath</emphasis> as use attributes; see
820       <xref linkend="querymodel-use-string"/> and 
821      <xref linkend="querymodel-use-xpath"/>.
822     </para> 
823
824     <para>
825      Phrase search for <emphasis>information retrieval</emphasis> in
826      the title-register, scanning the same register afterwards:
827      <screen>
828       Z> find @attr 1=4 "information retrieval"
829       Z> scan @attr 1=4 information
830      </screen>
831     </para>
832     </section>
833
834    </section>
835
836
837    <section id="querymodel-bib1-nonuse">
838      <title>&zebra; general Bib1 Non-Use Attributes (type 2-6)</title>
839     
840     <section id="querymodel-bib1-relation">
841      <title>Relation Attributes (type 2)</title>
842      
843      <para>
844       Relation attributes describe the relationship of the access
845       point (left side 
846       of the relation) to the search term as qualified by the attributes (right
847       side of the relation), e.g., Date-publication &lt;= 1975.
848       </para>
849
850      <table id="querymodel-bib1-relation-table" frame="top">
851       <title>Relation Attributes (type 2)</title>
852       <tgroup cols="3">
853        <thead>
854         <row>
855          <entry>Relation</entry>
856          <entry>Value</entry>
857          <entry>Notes</entry>
858         </row>
859        </thead>
860        <tbody>
861         <row>
862          <entry>Less than</entry>
863          <entry>1</entry>
864          <entry>supported</entry>
865         </row>
866         <row>
867          <entry>Less than or equal</entry>
868          <entry>2</entry>
869          <entry>supported</entry>
870         </row>
871         <row>
872          <entry>Equal</entry>
873          <entry>3</entry>
874          <entry>default</entry>
875         </row>
876         <row>
877          <entry>Greater or equal</entry>
878          <entry>4</entry>
879          <entry>supported</entry>
880         </row>
881         <row>
882          <entry>Greater than</entry>
883          <entry>5</entry>
884          <entry>supported</entry>
885         </row>
886         <row>
887          <entry>Not equal</entry>
888          <entry>6</entry>
889          <entry>unsupported</entry>
890         </row>
891         <row>
892          <entry>Phonetic</entry>
893          <entry>100</entry>
894          <entry>unsupported</entry>
895         </row>
896         <row>
897          <entry>Stem</entry>
898          <entry>101</entry>
899          <entry>unsupported</entry>
900         </row>
901         <row>
902          <entry>Relevance</entry>
903          <entry>102</entry>
904          <entry>supported</entry>
905         </row>
906         <row>
907          <entry>AlwaysMatches</entry>
908          <entry>103</entry>
909          <entry>supported *</entry>
910         </row>
911        </tbody>
912       </tgroup>
913      </table>
914      <note>
915       <para>
916        AlwaysMatches searches are only supported if alwaysmatches indexing
917        has been enabled. See <xref linkend="default-idx-file"/>
918       </para>
919       </note>
920      
921      <para>
922       The relation attributes 1-5 are supported and work exactly as
923       expected.
924       All ordering operations are based on a lexicographical ordering, 
925       <emphasis>expect</emphasis> when the 
926       structure attribute numeric (109) is used. In
927       this case, ordering is numerical. See 
928       <xref linkend="querymodel-bib1-structure"/>.
929       <screen>
930        Z> find @attr 1=Title @attr 2=1 music
931        ...
932        Number of hits: 11745, setno 1
933        ...
934        Z> find @attr 1=Title @attr 2=2 music
935        ...
936        Number of hits: 11771, setno 2
937        ...
938        Z> find @attr 1=Title @attr 2=3 music
939        ...
940        Number of hits: 532, setno 3
941        ...
942        Z> find @attr 1=Title @attr 2=4 music
943        ...
944        Number of hits: 11463, setno 4
945        ...
946        Z> find @attr 1=Title @attr 2=5 music
947        ...
948        Number of hits: 11419, setno 5
949       </screen>
950      </para>
951
952      <para>
953       The relation attribute 
954       <emphasis>Relevance (102)</emphasis> is supported, see
955       <xref linkend="administration-ranking"/> for full information.
956      </para>
957      
958      <para>
959       Ranked search for <emphasis>information retrieval</emphasis> in
960       the title-register:
961       <screen>
962        Z> find @attr 1=4 @attr 2=102 "information retrieval"
963       </screen>
964      </para>
965
966      <para>
967       The relation attribute 
968       <emphasis>AlwaysMatches (103)</emphasis> is in the default
969       configuration
970       supported in conjecture with structure attribute 
971       <emphasis>Phrase (1)</emphasis> (which may be omitted by
972       default). 
973       It can be configured to work with other structure attributes,
974       see the configuration file 
975       <filename>tab/default.idx</filename> and 
976        <xref linkend="querymodel-pqf-apt-mapping"/>. 
977      </para>
978      <para>
979       <emphasis>AlwaysMatches (103)</emphasis> is a
980       great way to discover how many documents have been indexed in a
981       given field. The search term is ignored, but needed for correct
982       &acro.pqf; syntax. An empty search term may be supplied.
983       <screen>
984        Z> find @attr 1=Title  @attr 2=103  ""
985        Z> find @attr 1=Title  @attr 2=103  @attr 4=1 ""
986       </screen>
987      </para>
988
989
990     </section>
991
992     <section id="querymodel-bib1-position">
993      <title>Position Attributes (type 3)</title>
994  
995      <para>
996       The position attribute specifies the location of the search term
997       within the field or subfield in which it appears.
998      </para>
999
1000      <table id="querymodel-bib1-position-table" frame="top">
1001       <title>Position Attributes (type 3)</title>
1002       <tgroup cols="3">
1003        <thead>
1004         <row>
1005          <entry>Position</entry>
1006          <entry>Value</entry>
1007          <entry>Notes</entry>
1008         </row>
1009        </thead>
1010        <tbody>
1011         <row>
1012          <entry>First in field </entry>
1013          <entry>1</entry>
1014          <entry>supported *</entry>
1015         </row>
1016         <row>
1017          <entry>First in subfield</entry>
1018          <entry>2</entry>
1019          <entry>supported *</entry>
1020         </row>
1021         <row>
1022          <entry>Any position in field</entry>
1023          <entry>3</entry>
1024          <entry>default</entry>
1025         </row>
1026        </tbody>
1027       </tgroup>
1028      </table>
1029
1030      <note>
1031       <para>
1032        &zebra; only supports first-in-field seaches if the
1033        <literal>firstinfield</literal> is enabled for the index
1034        Refer to <xref linkend="default-idx-file"/>.
1035        &zebra; does not distinguish between first in field and
1036        first in subfield. They result in the same hit count.
1037        Searching for first position in (sub)field in only supported in &zebra;
1038        2.0.2 and later.
1039       </para>
1040      </note>
1041     </section>
1042     
1043     <section id="querymodel-bib1-structure">
1044      <title>Structure Attributes (type 4)</title>
1045    
1046      <para>
1047       The structure attribute specifies the type of search
1048       term. This causes the search to be mapped on
1049       different &zebra; internal indexes, which must have been defined
1050       at index time. 
1051      </para>
1052
1053      <para> 
1054       The possible values of the  
1055       <literal>structure attribute (type 4)</literal> can be defined
1056       using the configuration file <filename>
1057       tab/default.idx</filename>.
1058       The default configuration is summarized in this table.
1059      </para>
1060
1061      <table id="querymodel-bib1-structure-table" frame="top">
1062       <title>Structure Attributes (type 4)</title>
1063       <tgroup cols="3">
1064        <thead>
1065         <row>
1066          <entry>Structure</entry>
1067          <entry>Value</entry>
1068          <entry>Notes</entry>
1069         </row>
1070        </thead>
1071        <tbody>
1072         <row>
1073          <entry>Phrase </entry>
1074          <entry>1</entry>
1075          <entry>default</entry>
1076         </row>
1077         <row>
1078          <entry>Word</entry>
1079          <entry>2</entry>
1080          <entry>supported</entry>
1081         </row>
1082         <row>
1083          <entry>Key</entry>
1084          <entry>3</entry>
1085          <entry>supported</entry>
1086         </row>
1087         <row>
1088          <entry>Year</entry>
1089          <entry>4</entry>
1090          <entry>supported</entry>
1091         </row>
1092         <row>
1093          <entry>Date (normalized)</entry>
1094          <entry>5</entry>
1095          <entry>supported</entry>
1096         </row>
1097         <row>
1098          <entry>Word list</entry>
1099          <entry>6</entry>
1100          <entry>supported</entry>
1101         </row>
1102         <row>
1103          <entry>Date (un-normalized)</entry>
1104          <entry>100</entry>
1105          <entry>unsupported</entry>
1106         </row>
1107         <row>
1108          <entry>Name (normalized) </entry>
1109          <entry>101</entry>
1110          <entry>unsupported</entry>
1111         </row>
1112         <row>
1113          <entry>Name (un-normalized) </entry>
1114          <entry>102</entry>
1115          <entry>unsupported</entry>
1116         </row>
1117         <row>
1118          <entry>Structure</entry>
1119          <entry>103</entry>
1120          <entry>unsupported</entry>
1121         </row>
1122         <row>
1123          <entry>Urx</entry>
1124          <entry>104</entry>
1125          <entry>supported</entry>
1126         </row>
1127         <row>
1128          <entry>Free-form-text</entry>
1129          <entry>105</entry>
1130          <entry>supported</entry>
1131         </row>
1132         <row>
1133          <entry>Document-text</entry>
1134          <entry>106</entry>
1135          <entry>supported</entry>
1136         </row>
1137         <row>
1138          <entry>Local-number</entry>
1139          <entry>107</entry>
1140          <entry>supported</entry>
1141         </row>
1142         <row>
1143          <entry>String</entry>
1144          <entry>108</entry>
1145          <entry>unsupported</entry>
1146         </row>
1147         <row>
1148          <entry>Numeric string</entry>
1149          <entry>109</entry>
1150          <entry>supported</entry>
1151         </row>
1152        </tbody>
1153       </tgroup>
1154      </table>
1155      
1156     <para>
1157      The structure attribute values 
1158      <literal>Word list (6)</literal>
1159      is supported, and maps to the boolean <literal>AND</literal>
1160      combination of words supplied. The word list is useful when
1161      google-like bag-of-word queries need to be translated from a GUI
1162      query language to &acro.pqf;.  For example, the following queries
1163      are equivalent:
1164      <screen>
1165       Z> find @attr 1=Title @attr 4=6 "mozart amadeus"
1166       Z> find @attr 1=Title  @and mozart amadeus
1167      </screen>
1168     </para>
1169
1170     <para>
1171      The structure attribute value 
1172      <literal>Free-form-text (105)</literal> and
1173      <literal>Document-text (106)</literal>
1174      are supported, and map both to the boolean <literal>OR</literal>
1175      combination of words supplied. The following queries
1176      are equivalent:
1177      <screen>
1178       Z> find @attr 1=Body-of-text @attr 4=105 "bach salieri teleman"
1179       Z> find @attr 1=Body-of-text @attr 4=106 "bach salieri teleman"
1180       Z> find @attr 1=Body-of-text @or bach @or salieri teleman 
1181      </screen>
1182      This <literal>OR</literal> list of terms is very useful in
1183      combination with relevance ranking:
1184      <screen>
1185       Z> find @attr 1=Body-of-text @attr 2=102 @attr 4=105 "bach salieri teleman"
1186      </screen>
1187     </para>
1188     
1189     <para>
1190      The structure attribute value 
1191      <literal>Local number (107)</literal>
1192      is supported, and maps always to the &zebra; internal document ID,
1193      irrespectively which use attribute is specified. The following queries
1194      have exactly the same unique record in the hit set:
1195      <screen>
1196       Z> find @attr 4=107 10
1197       Z> find @attr 1=4 @attr 4=107 10
1198       Z> find @attr 1=1010 @attr 4=107 10
1199      </screen>
1200     </para>
1201
1202     <para>
1203      In
1204      the GILS schema (<literal>gils.abs</literal>), the
1205      west-bounding-coordinate is indexed as type <literal>n</literal>,
1206      and is therefore searched by specifying
1207      <emphasis>structure</emphasis>=<emphasis>Numeric String</emphasis>.
1208      To match all those records with west-bounding-coordinate greater
1209      than -114 we use the following query:
1210      <screen>
1211       Z> find @attr 4=109 @attr 2=5 @attr gils 1=2038 -114
1212      </screen> 
1213      </para>
1214      <note>
1215       <para>
1216        The exact mapping between &acro.pqf; queries and &zebra; internal indexes
1217        and index types is explained in 
1218        <xref linkend="querymodel-pqf-apt-mapping"/>.
1219       </para>
1220      </note>
1221     </section>
1222     
1223     <section id="querymodel-bib1-truncation">
1224      <title>Truncation Attributes (type = 5)</title>
1225
1226      <para>
1227       The truncation attribute specifies whether variations of one or
1228       more characters are allowed between search term and hit terms, or
1229       not. Using non-default truncation attributes will broaden the
1230       document hit set of a search query.
1231      </para>
1232
1233      <table id="querymodel-bib1-truncation-table" frame="top">
1234       <title>Truncation Attributes (type 5)</title>
1235       <tgroup cols="3">
1236        <thead>
1237         <row>
1238          <entry>Truncation</entry>
1239          <entry>Value</entry>
1240          <entry>Notes</entry>
1241         </row>
1242        </thead>
1243        <tbody>
1244         <row>
1245          <entry>Right truncation </entry>
1246          <entry>1</entry>
1247          <entry>supported</entry>
1248         </row>
1249         <row>
1250          <entry>Left truncation</entry>
1251          <entry>2</entry>
1252          <entry>supported</entry>
1253         </row>
1254         <row>
1255          <entry>Left and right truncation</entry>
1256          <entry>3</entry>
1257          <entry>supported</entry>
1258         </row>
1259         <row>
1260          <entry>Do not truncate</entry>
1261          <entry>100</entry>
1262          <entry>default</entry>
1263         </row>
1264         <row>
1265          <entry>Process # in search term</entry>
1266          <entry>101</entry>
1267          <entry>supported</entry>
1268         </row>
1269         <row>
1270          <entry>RegExpr-1 </entry>
1271          <entry>102</entry>
1272          <entry>supported</entry>
1273         </row>
1274         <row>
1275          <entry>RegExpr-2</entry>
1276          <entry>103</entry>
1277          <entry>supported</entry>
1278         </row>
1279        </tbody>
1280       </tgroup>
1281      </table>
1282
1283      <para>
1284       The truncation attribute values 1-3 perform the obvious way:
1285       <screen>
1286        Z> scan @attr 1=Body-of-text  schnittke
1287        ...
1288        * schnittke (81)
1289        schnittkes (31)
1290        schnittstelle (1)
1291        ...
1292        Z> find @attr 1=Body-of-text  @attr 5=1 schnittke
1293        ...
1294        Number of hits: 95, setno 7
1295        ...
1296        Z> find @attr 1=Body-of-text  @attr 5=2 schnittke
1297        ...
1298        Number of hits: 81, setno 6
1299        ...
1300        Z> find @attr 1=Body-of-text  @attr 5=3 schnittke
1301        ...
1302        Number of hits: 95, setno 8
1303       </screen>
1304       </para>
1305
1306      <para>
1307       The truncation attribute value 
1308       <literal>Process # in search term (101)</literal> is a
1309       poor-man's regular expression search. It maps
1310       each <literal>#</literal> to <literal>.*</literal>, and
1311       performs then a <literal>Regexp-1 (102)</literal> regular
1312       expression search. The following two queries are equivalent:
1313       <screen>
1314        Z> find @attr 1=Body-of-text  @attr 5=101 schnit#ke
1315        Z> find @attr 1=Body-of-text  @attr 5=102 schnit.*ke
1316        ...
1317        Number of hits: 89, setno 10
1318       </screen>
1319      </para>
1320      
1321      <para>
1322       The truncation attribute value 
1323        <literal>Regexp-1 (102)</literal> is a normal regular search,
1324       see <xref linkend="querymodel-regular"/> for details.
1325       <screen>
1326        Z> find @attr 1=Body-of-text  @attr 5=102 schnit+ke
1327        Z> find @attr 1=Body-of-text  @attr 5=102 schni[a-t]+ke
1328       </screen>
1329      </para>
1330
1331      <para>
1332        The truncation attribute value 
1333       <literal>Regexp-2 (103) </literal> is a &zebra; specific extension
1334       which allows <emphasis>fuzzy</emphasis> matches. One single
1335       error in spelling of search terms is allowed, i.e., a document
1336       is hit if it includes a term which can be mapped to the used
1337       search term by one character substitution, addition, deletion or
1338       change of position. 
1339       <screen>
1340        Z> find @attr 1=Body-of-text  @attr 5=100 schnittke
1341        ...
1342        Number of hits: 81, setno 14
1343        ...
1344        Z> find @attr 1=Body-of-text  @attr 5=103 schnittke
1345        ...
1346        Number of hits: 103, setno 15
1347        ...
1348       </screen>
1349       </para>  
1350     </section>
1351     
1352     <section id="querymodel-bib1-completeness">
1353     <title>Completeness Attributes (type = 6)</title>
1354
1355
1356      <para>
1357       The <literal>Completeness Attributes (type = 6)</literal>
1358       is used to specify that a given search term or term list is  either  
1359       part of the terms of a given index/field 
1360       (<literal>Incomplete subfield (1)</literal>), or is
1361       what literally is found in the entire field's index
1362       (<literal>Complete field (3)</literal>).
1363       </para>
1364
1365      <table id="querymodel-bib1-completeness-table" frame="top">
1366       <title>Completeness Attributes (type = 6)</title>
1367       <tgroup cols="3">
1368        <thead>
1369         <row>
1370          <entry>Completeness</entry>
1371          <entry>Value</entry>
1372          <entry>Notes</entry>
1373         </row>
1374        </thead>
1375        <tbody>
1376         <row>
1377          <entry>Incomplete subfield</entry>
1378          <entry>1</entry>
1379          <entry>default</entry>
1380         </row>
1381         <row>
1382          <entry>Complete subfield</entry>
1383          <entry>2</entry>
1384          <entry>deprecated</entry>
1385         </row>
1386         <row>
1387          <entry>Complete field</entry>
1388          <entry>3</entry>
1389          <entry>supported</entry>
1390         </row>
1391        </tbody>
1392       </tgroup>
1393      </table>
1394
1395      <para>
1396       The <literal>Completeness Attributes (type = 6)</literal>
1397       is only partially and conditionally
1398       supported in the sense that it is ignored if the hit index is
1399       not of structure <literal>type="w"</literal> or 
1400       <literal>type="p"</literal>.
1401       </para>
1402      <para>
1403       <literal>Incomplete subfield (1)</literal> is the default, and
1404       makes &zebra; use 
1405       register <literal>type="w"</literal>, whereas 
1406       <literal>Complete field (3)</literal> triggers
1407       search and scan in index <literal>type="p"</literal>.
1408      </para>
1409      <para>
1410       The <literal>Complete subfield (2)</literal> is a reminiscens
1411       from the  happy <literal>&acro.marc;</literal>
1412       binary format days. &zebra; does not support it, but maps silently
1413       to <literal>Complete field (3)</literal>.
1414      </para>
1415
1416      <note>
1417       <para>
1418        The exact mapping between &acro.pqf; queries and &zebra; internal indexes
1419        and index types is explained in 
1420        <xref linkend="querymodel-pqf-apt-mapping"/>.
1421       </para>
1422      </note>
1423     </section>
1424    </section>
1425   
1426    </section>
1427
1428
1429   <section id="querymodel-zebra">
1430    <title>Extended &zebra; &acro.rpn; Features</title>
1431    <para>
1432     The &zebra; internal query engine has been extended to specific needs
1433     not covered by the <literal>bib-1</literal> attribute set query
1434     model. These extensions are <emphasis>non-standard</emphasis>
1435     and <emphasis>non-portable</emphasis>: most functional extensions
1436     are modeled over the <literal>bib-1</literal> attribute set,
1437     defining type 7 and higher values.
1438     There are also the special 
1439     <literal>string</literal> type index names for the
1440     <literal>idxpath</literal> attribute set.  
1441    </para>
1442     
1443    <section id="querymodel-zebra-attr-allrecords">
1444     <title>&zebra; specific retrieval of all records</title>
1445     <para>
1446      &zebra; defines a hardwired <literal>string</literal> index name
1447      called <literal>_ALLRECORDS</literal>. It matches any record
1448      contained in the database, if used in conjunction with 
1449      the relation attribute 
1450      <literal>AlwaysMatches (103)</literal>.
1451      </para>
1452     <para>
1453      The <literal>_ALLRECORDS</literal> index name is used for total database
1454      export. The search term is ignored, it may be empty.
1455      <screen>
1456       Z> find @attr 1=_ALLRECORDS @attr 2=103 ""
1457      </screen>
1458     </para>
1459     <para>
1460      Combination with other index types can be made. For example, to
1461      find all records which are <emphasis>not</emphasis> indexed in
1462      the <literal>Title</literal> register, issue one of the two
1463      equivalent queries:
1464      <screen>
1465       Z> find @not @attr 1=_ALLRECORDS @attr 2=103 "" @attr 1=Title @attr 2=103 ""
1466       Z> find @not @attr 1=_ALLRECORDS @attr 2=103 "" @attr 1=4 @attr 2=103 ""
1467      </screen>
1468     </para>
1469     <warning>
1470      <para>
1471       The special string index <literal>_ALLRECORDS</literal> is
1472       experimental, and the provided functionality and syntax may very
1473       well change in future releases of &zebra;.
1474      </para>
1475     </warning>
1476    </section>
1477
1478    <section id="querymodel-zebra-attr-search">
1479     <title>&zebra; specific Search Extensions to all Attribute Sets</title>
1480     <para>
1481      &zebra; extends the &acro.bib1; attribute types, and these extensions are
1482      recognized regardless of attribute 
1483      set used in a <literal>search</literal> operation query.
1484     </para>
1485     
1486     <table id="querymodel-zebra-attr-search-table" frame="top">
1487      <title>&zebra; Search Attribute Extensions</title>
1488      <tgroup cols="4">
1489       <thead>
1490        <row>
1491          <entry>Name</entry>
1492         <entry>Value</entry>
1493         <entry>Operation</entry>
1494         <entry>&zebra; version</entry>
1495        </row>
1496       </thead>
1497       <tbody>
1498        <row>
1499         <entry>Embedded Sort</entry>
1500         <entry>7</entry>
1501         <entry>search</entry>
1502         <entry>1.1</entry>
1503        </row>
1504        <row>
1505         <entry>Term Set</entry>
1506         <entry>8</entry>
1507         <entry>search</entry>
1508         <entry>1.1</entry>
1509        </row>
1510        <row>
1511         <entry>Rank Weight</entry>
1512         <entry>9</entry>
1513         <entry>search</entry>
1514         <entry>1.1</entry>
1515        </row>
1516        <row>
1517         <entry>Term Reference</entry>
1518         <entry>10</entry>
1519         <entry>search</entry>
1520         <entry>1.4</entry>
1521        </row>
1522        <row>
1523         <entry>Local Approx Limit</entry>
1524         <entry>11</entry>
1525         <entry>search</entry>
1526         <entry>1.4</entry>
1527        </row>
1528        <row>
1529         <entry>Global Approx Limit</entry>
1530         <entry>12</entry>
1531         <entry>search</entry>
1532         <entry>2.0.8</entry>
1533        </row>
1534       </tbody>
1535        <row>
1536         <entry>Maximum number of truncated terms (truncmax)</entry>
1537         <entry>13</entry>
1538         <entry>search</entry>
1539         <entry>2.0.10</entry>
1540        </row>
1541      </tgroup>
1542     </table>      
1543     
1544     <section id="querymodel-zebra-attr-sorting">
1545      <title>&zebra; Extension Embedded Sort Attribute (type 7)</title>
1546      <para>
1547       The embedded sort is a way to specify sort within a query - thus
1548       removing the need to send a Sort Request separately. It is both
1549       faster and does not require clients to deal with the Sort
1550       Facility. 
1551      </para>
1552      
1553      <para>
1554       All ordering operations are based on a lexicographical ordering, 
1555       <emphasis>expect</emphasis> when the 
1556       <literal>structure attribute numeric (109)</literal> is used. In
1557       this case, ordering is numerical. See 
1558       <xref linkend="querymodel-bib1-structure"/>.
1559      </para>
1560      
1561      <para>
1562       The possible values after attribute <literal>type 7</literal> are
1563       <literal>1</literal> ascending and 
1564       <literal>2</literal> descending. 
1565       The attributes+term (&acro.apt;) node is separate from the
1566       rest and must be <literal>@or</literal>'ed. 
1567       The term associated with &acro.apt; is the sorting level in integers,
1568       where <literal>0</literal> means primary sort, 
1569       <literal>1</literal> means secondary sort, and so forth.
1570       See also <xref linkend="administration-ranking"/>.
1571      </para>
1572      <para>
1573       For example, searching for water, sort by title (ascending) 
1574       <screen>
1575        Z> find @or @attr 1=1016 water @attr 7=1 @attr 1=4 0
1576       </screen>
1577      </para>
1578      <para>
1579       Or, searching for water, sort by title ascending, then date descending
1580       <screen>
1581        Z> find @or @or @attr 1=1016 water @attr 7=1 @attr 1=4 0 @attr 7=2 @attr 1=30 1
1582       </screen>
1583      </para>
1584     </section>
1585
1586      <!--
1587     &zebra; Extension Term Set Attribute
1588     From the manual text, I can not see what is the point with this feature.
1589     I think it makes more sense when there are multiple terms in a query, or
1590     something...
1591     
1592     We decided 2006-06-03 to disable this feature, as it is covered by
1593     scan within a resultset. Better use ressources to upgrade this
1594     feature for good performance.
1595     -->
1596
1597      <!--
1598     <section id="querymodel-zebra-attr-estimation">
1599      <title>&zebra; Extension Term Set Attribute (type 8)</title>
1600     <para>
1601      The Term Set feature is a facility that allows a search to store
1602      hitting terms in a "pseudo" resultset; thus a search (as usual) +
1603      a scan-like facility. Requires a client that can do named result
1604      sets since the search generates two result sets. The value for
1605      attribute 8 is the name of a result set (string). The terms in
1606      the named term set are returned as &acro.sutrs; records. 
1607     </para>
1608     <para>
1609      For example, searching  for u in title, right truncated, and
1610      storing the result in term set named 'aset'
1611      <screen> 
1612       Z> find @attr 5=1 @attr 1=4 @attr 8=aset u
1613      </screen>
1614     </para>
1615     <warning>
1616      The model has one serious flaw: we don't know the size of term
1617      set. Experimental. Do not use in production code.
1618     </warning>
1619     </section>
1620     -->
1621
1622
1623     <section id="querymodel-zebra-attr-weight">
1624      <title>&zebra; Extension Rank Weight Attribute (type 9)</title>
1625      <para>
1626       Rank weight is a way to pass a value to a ranking algorithm - so
1627       that one &acro.apt; has one value - while another as a different one. 
1628       See also <xref linkend="administration-ranking"/>.
1629      </para>
1630      <para>
1631       For example, searching  for utah in title with weight 30 as well
1632       as any with weight 20: 
1633       <screen>  
1634        Z> find @attr 2=102 @or @attr 9=30 @attr 1=4 utah @attr 9=20 utah
1635       </screen>
1636      </para>
1637     </section>
1638
1639     <section id="querymodel-zebra-attr-termref">
1640      <title>&zebra; Extension Term Reference Attribute (type 10)</title>
1641      <para>
1642       &zebra; supports the searchResult-1 facility. 
1643       If the Term Reference Attribute (type 10) is
1644       given, that specifies a subqueryId value returned as part of the
1645       search result. It is a way for a client to name an &acro.apt; part of a
1646       query. 
1647      </para>
1648      <!--
1649      <para>
1650      <screen>
1651     </screen>
1652     </para>
1653      -->
1654      <warning>
1655       <para>
1656        Experimental. Do not use in production code.
1657        </para>
1658      </warning>
1659      
1660     </section>
1661    
1662    
1663      
1664     <section id="querymodel-zebra-local-attr-limit">
1665      <title>Local Approximative Limit Attribute (type 11)</title>
1666      <para>
1667       &zebra; computes - unless otherwise configured -
1668       the exact hit count for every &acro.apt;
1669       (leaf) in the query tree. These hit counts are returned as part of
1670       the searchResult-1 facility in the binary encoded &acro.z3950; search
1671       response packages.
1672      </para>
1673      <para>
1674       By setting an estimation limit size of the resultset of the &acro.apt;
1675       leaves, &zebra; stoppes processing the result set when the limit
1676       length is reached.
1677       Hit counts under this limit are still precise, but hit counts over it
1678       are estimated using the statistics gathered from the chopped
1679       result set.
1680      </para>
1681      <para>
1682       Specifying a limit of <literal>0</literal> resuts in exact hit counts.
1683      </para>
1684      <para>
1685       For example, we might be interested in exact hit count for a, but
1686       for b we allow hit count estimates for 1000 and higher. 
1687       <screen>
1688        Z> find @and a @attr 11=1000 b
1689       </screen>
1690      </para>
1691      <note>
1692       <para>
1693        The estimated hit count facility makes searches faster, as one
1694        only needs to process large hit lists partially.
1695        It is mostly used in huge databases, where you you want trade
1696        exactness of hit counts against speed of execution. 
1697       </para>
1698      </note>
1699      <warning>
1700       <para>
1701        Do not use approximative hit count limits
1702        in conjunction with relevance ranking, as re-sorting of the
1703        result set only works when the entire result set has
1704        been processed. 
1705       </para>
1706      </warning>
1707     </section>
1708
1709     <section id="querymodel-zebra-global-attr-limit">
1710      <title>Global Approximative Limit Attribute (type 12)</title>
1711      <para>
1712       By default &zebra; computes precise hit counts for a query as
1713       a whole. Setting attribute 12 makes it perform approximative
1714       hit counts instead. It has the same semantics as 
1715       <literal>estimatehits</literal> for the <xref linkend="zebra-cfg"/>.
1716      </para>
1717      <para>
1718       The attribute (12) can occur anywhere in the query tree.
1719       Unlike regular attributes it does not relate to the leaf (&acro.apt;)
1720       - but to the whole query.
1721      </para>
1722      <warning>
1723       <para>
1724        Do not use approximative hit count limits
1725        in conjunction with relevance ranking, as re-sorting of the
1726        result set only works when the entire result set has
1727        been processed. 
1728       </para>
1729      </warning>
1730     </section>
1731
1732    </section>
1733
1734    <section id="querymodel-zebra-attr-scan">
1735     <title>&zebra; specific Scan Extensions to all Attribute Sets</title>
1736     <para>
1737      &zebra; extends the Bib1 attribute types, and these extensions are
1738      recognized regardless of attribute 
1739      set used in a scan operation query.
1740     </para>
1741     <table id="querymodel-zebra-attr-scan-table" frame="top">
1742      <title>&zebra; Scan Attribute Extensions</title>
1743      <tgroup cols="4">
1744       <thead>
1745        <row>
1746         <entry>Name</entry>
1747         <entry>Type</entry>
1748         <entry>Operation</entry>
1749         <entry>&zebra; version</entry>
1750        </row>
1751       </thead>
1752       <tbody>
1753        <row>
1754         <entry>Result Set Narrow</entry>
1755         <entry>8</entry>
1756         <entry>scan</entry>
1757         <entry>1.3</entry>
1758        </row>
1759        <row>
1760         <entry>Approximative Limit</entry>
1761         <entry>9</entry>
1762         <entry>scan</entry>
1763         <entry>1.4</entry>
1764        </row>
1765       </tbody>
1766      </tgroup>
1767     </table>      
1768     
1769     <section id="querymodel-zebra-attr-narrow">
1770      <title>&zebra; Extension Result Set Narrow (type 8)</title>
1771      <para>
1772       If attribute Result Set Narrow (type 8)
1773       is given for scan, the value is the name of a
1774       result set. Each hit count in scan is 
1775       <literal>@and</literal>'ed with the result set given. 
1776      </para>
1777      <para>
1778       Consider for example 
1779       the case of scanning all title fields around the
1780       scanterm <emphasis>mozart</emphasis>, then refining the scan by
1781       issuing a filtering query for <emphasis>amadeus</emphasis> to
1782       restrict the scan to the result set of the query:  
1783       <screen>
1784       Z> scan @attr 1=4 mozart 
1785       ...
1786       * mozart (43)
1787         mozartforskningen (1)
1788         mozartiana (1)
1789         mozarts (16)
1790       ...
1791       Z> f @attr 1=4 amadeus   
1792       ...
1793       Number of hits: 15, setno 2
1794       ...
1795       Z> scan @attr 1=4 @attr 8=2 mozart
1796       ...
1797       * mozart (14)
1798         mozartforskningen (0)
1799         mozartiana (0)
1800         mozarts (1)
1801       ...
1802       </screen>
1803      </para>
1804      
1805      <para>
1806       &zebra; 2.0.2 and later is able to skip 0 hit counts. This, however,
1807       is known not to scale if the number of terms to skip is high.
1808       This most likely will happen if the result set is small (and
1809       result in many 0 hits).
1810      </para>
1811     </section>
1812
1813     <section id="querymodel-zebra-attr-approx">
1814      <title>&zebra; Extension Approximative Limit (type 11)</title>
1815      <para>
1816       The &zebra; Extension Approximative Limit (type 11) is a way to
1817       enable approximate hit counts for scan hit counts, in the same
1818       way as for search hit counts. 
1819      </para>
1820     </section>
1821    </section>
1822    
1823    <section id="querymodel-idxpath">
1824     <title>&zebra; special &acro.idxpath; Attribute Set for &acro.grs1; indexing</title>
1825     <para>
1826      The attribute-set <literal>idxpath</literal> consists of a single 
1827      Use (type 1) attribute. All non-use attributes behave as normal. 
1828     </para>
1829     <para>
1830      This feature is enabled when defining the
1831      <literal>xpath enable</literal> option in the &acro.grs1; filter
1832      <filename>*.abs</filename> configuration files. If one wants to use
1833      the special <literal>idxpath</literal> numeric attribute set, the
1834      main &zebra; configuration file <filename>zebra.cfg</filename>
1835      directive <literal>attset: idxpath.att</literal> must be enabled.
1836     </para>
1837     <warning>
1838      <para>
1839       The <literal>idxpath</literal> is deprecated, may not be
1840       supported in future &zebra; versions, and should definitely
1841       not be used in production code.
1842      </para>
1843     </warning>
1844
1845     <section id="querymodel-idxpath-use">
1846     <title>&acro.idxpath; Use Attributes (type = 1)</title>
1847      <para>
1848       This attribute set allows one to search &acro.grs1; filter indexed
1849       records by &acro.xpath; like structured index names. 
1850      </para>
1851
1852      <warning>
1853       <para>
1854        The <literal>idxpath</literal> option defines hard-coded
1855        index names, which might clash with your own index names.
1856       </para>
1857      </warning>
1858      
1859      <table id="querymodel-idxpath-use-table" frame="top">
1860       <title>&zebra; specific &acro.idxpath; Use Attributes (type 1)</title>
1861       <tgroup cols="4">
1862        <thead>
1863         <row>
1864          <entry>&acro.idxpath;</entry>
1865          <entry>Value</entry>
1866          <entry>String Index</entry>
1867          <entry>Notes</entry>
1868         </row>
1869        </thead>
1870        <tbody>
1871         <row>
1872          <entry>&acro.xpath; Begin</entry>
1873          <entry>1</entry>
1874          <entry>_XPATH_BEGIN</entry>
1875          <entry>deprecated</entry>
1876         </row>
1877         <row>
1878          <entry>&acro.xpath; End</entry>
1879          <entry>2</entry>
1880          <entry>_XPATH_END</entry>
1881          <entry>deprecated</entry>
1882         </row>
1883         <row>
1884          <entry>&acro.xpath; CData</entry>
1885          <entry>1016</entry>
1886          <entry>_XPATH_CDATA</entry>
1887          <entry>deprecated</entry>
1888         </row>
1889         <row>
1890          <entry>&acro.xpath; Attribute Name</entry>
1891          <entry>3</entry>
1892          <entry>_XPATH_ATTR_NAME</entry>
1893          <entry>deprecated</entry>
1894         </row>
1895         <row>
1896          <entry>&acro.xpath; Attribute CData</entry>
1897          <entry>1015</entry>
1898          <entry>_XPATH_ATTR_CDATA</entry>
1899          <entry>deprecated</entry>
1900         </row>
1901        </tbody>
1902       </tgroup>
1903      </table>
1904
1905      <para>
1906       See <filename>tab/idxpath.att</filename> for more information.
1907      </para>
1908      <para>
1909       Search for all documents starting with root element 
1910       <literal>/root</literal> (either using the numeric or the string
1911       use attributes):
1912       <screen>
1913        Z> find @attrset idxpath @attr 1=1 @attr 4=3 root/ 
1914        Z> find @attr idxpath 1=1 @attr 4=3 root/ 
1915        Z> find @attr 1=_XPATH_BEGIN @attr 4=3 root/ 
1916       </screen>
1917      </para>
1918      <para>
1919       Search for all documents where specific nested &acro.xpath; 
1920       <literal>/c1/c2/../cn</literal> exists. Notice the very
1921       counter-intuitive <emphasis>reverse</emphasis> notation!
1922       <screen>
1923        Z> find @attrset idxpath @attr 1=1 @attr 4=3 cn/cn-1/../c1/ 
1924        Z> find @attr 1=_XPATH_BEGIN @attr 4=3 cn/cn-1/../c1/ 
1925       </screen>
1926      </para>
1927      <para>
1928       Search for CDATA string <emphasis>text</emphasis> in any  element
1929       <screen>
1930        Z> find @attrset idxpath @attr 1=1016 text
1931        Z> find @attr 1=_XPATH_CDATA text
1932       </screen>
1933      </para>
1934      <para>
1935        Search for CDATA string <emphasis>anothertext</emphasis> in any
1936        attribute: 
1937       <screen> 
1938        Z> find @attrset idxpath @attr 1=1015 anothertext
1939        Z> find @attr 1=_XPATH_ATTR_CDATA anothertext
1940       </screen>
1941      </para>
1942      <para>
1943        Search for all documents with have an &acro.xml; element node
1944        including an &acro.xml;  attribute named <emphasis>creator</emphasis> 
1945       <screen> 
1946        Z> find @attrset idxpath @attr 1=3 @attr 4=3 creator 
1947        Z> find @attr 1=_XPATH_ATTR_NAME @attr 4=3 creator 
1948       </screen>
1949      </para>
1950      <para>
1951       Combining usual <literal>bib-1</literal> attribute set searches
1952       with <literal>idxpath</literal> attribute set searches:
1953       <screen>
1954        Z> find @and @attr idxpath 1=1 @attr 4=3 link/ @attr 1=4 mozart
1955        Z> find @and @attr 1=_XPATH_BEGIN @attr 4=3 link/ @attr 1=_XPATH_CDATA mozart
1956       </screen>
1957      </para>
1958      <para>
1959       Scanning is supported on all <literal>idxpath</literal>
1960       indexes, both specified as numeric use attributes, or as string
1961       index names. 
1962       <screen>
1963        Z> scan  @attrset idxpath @attr 1=1016 text
1964        Z> scan  @attr 1=_XPATH_ATTR_CDATA anothertext
1965        Z> scan  @attrset idxpath @attr 1=3 @attr 4=3 ''
1966       </screen>
1967      </para>
1968
1969     </section>
1970    </section>
1971
1972
1973    <section id="querymodel-pqf-apt-mapping">
1974     <title>Mapping from &acro.pqf; atomic &acro.apt; queries to &zebra; internal 
1975      register indexes</title>
1976     <para>
1977      The rules for &acro.pqf; &acro.apt; mapping are rather tricky to grasp in the
1978      first place. We deal first with the rules for deciding which
1979      internal register or string index to use, according to the use
1980      attribute or access point specified in the query. Thereafter we
1981      deal with the rules for determining the correct structure type of
1982      the named register. 
1983     </para>
1984
1985    <section id="querymodel-pqf-apt-mapping-accesspoint">
1986     <title>Mapping of &acro.pqf; &acro.apt; access points</title>
1987     <para>
1988       &zebra; understands four fundamental different types of access
1989       points, of which only the  
1990       <emphasis>numeric use attribute</emphasis> type access points
1991       are defined by the  <ulink url="&url.z39.50;">&acro.z3950;</ulink>
1992       standard.
1993       All other access point types are &zebra; specific, and non-portable.
1994     </para>
1995
1996      <table id="querymodel-zebra-mapping-accesspoint-types" frame="top">
1997       <title>Access point name mapping</title>
1998       <tgroup cols="4">
1999        <thead>
2000         <row>
2001          <entry>Access Point</entry>
2002          <entry>Type</entry>
2003          <entry>Grammar</entry>
2004          <entry>Notes</entry>
2005         </row>
2006       </thead>
2007       <tbody>
2008        <row>
2009         <entry>Use attribute</entry>
2010         <entry>numeric</entry>
2011         <entry>[1-9][1-9]*</entry>
2012         <entry>directly mapped to string index name</entry>
2013        </row>
2014        <row>
2015         <entry>String index name</entry>
2016         <entry>string</entry>
2017         <entry>[a-zA-Z](\-?[a-zA-Z0-9])*</entry>
2018         <entry>normalized name is used as internal string index name</entry>
2019        </row>
2020        <row>
2021         <entry>&zebra; internal index name</entry>
2022         <entry>zebra</entry>
2023         <entry>_[a-zA-Z](_?[a-zA-Z0-9])*</entry>
2024         <entry>hardwired internal string index name</entry>
2025        </row>
2026        <row>
2027         <entry>&acro.xpath; special index</entry>
2028         <entry>XPath</entry>
2029         <entry>/.*</entry>
2030         <entry>special xpath search for &acro.grs1; indexed records</entry>
2031        </row>
2032        </tbody>
2033       </tgroup>
2034      </table>
2035      
2036      <para>
2037       <literal>Attribute set names</literal> and 
2038       <literal>string index names</literal> are normalizes
2039       according to the following rules: all <emphasis>single</emphasis>
2040       hyphens <literal>'-'</literal> are stripped, and all upper case
2041       letters are folded to lower case.
2042      </para>
2043      
2044      <para>
2045       <emphasis>Numeric use attributes</emphasis> are mapped 
2046       to the &zebra; internal
2047       string index according to the attribute set definition in use.
2048       The default attribute set is <literal>&acro.bib1;</literal>, and may be
2049       omitted in the &acro.pqf; query.
2050      </para>
2051      
2052      <para>
2053       According to normalization and numeric
2054       use attribute mapping, it follows that the following
2055       &acro.pqf; queries are considered equivalent (assuming the default
2056       configuration has not been altered):
2057       <screen>
2058       Z> find  @attr 1=Body-of-text serenade
2059       Z> find  @attr 1=bodyoftext serenade
2060       Z> find  @attr 1=BodyOfText serenade
2061       Z> find  @attr 1=bO-d-Y-of-tE-x-t serenade
2062       Z> find  @attr 1=1010 serenade
2063       Z> find  @attrset &acro.bib1; @attr 1=1010 serenade
2064       Z> find  @attrset bib1 @attr 1=1010 serenade
2065       Z> find  @attrset Bib1 @attr 1=1010 serenade
2066       Z> find  @attrset b-I-b-1 @attr 1=1010 serenade
2067      </screen>
2068     </para>
2069
2070     <para>
2071       The <emphasis>numerical</emphasis>
2072       <literal>use attributes (type 1)</literal>  
2073       are interpreted according to the
2074       attribute sets which have been loaded in the
2075       <literal>zebra.cfg</literal> file, and are matched against specific
2076       fields as specified in the <literal>.abs</literal> file which
2077       describes the profile of the records which have been loaded.
2078       If no use attribute is provided, a default of 
2079       &acro.bib1; Use Any (1016) is assumed.
2080       The predefined use attribute sets
2081       can be reconfigured by  tweaking the configuration files
2082       <filename>tab/*.att</filename>, and 
2083       new attribute sets can be defined by adding similar files in the
2084       configuration path <literal>profilePath</literal> of the server.  
2085     </para>
2086
2087      <para>
2088       String indexes can be accessed directly,
2089       independently which attribute set is in use. These are just
2090       ignored. The above mentioned name normalization applies.
2091       String index names are defined in the
2092       used indexing  filter configuration files, for example in the
2093       <literal>&acro.grs1;</literal> 
2094       <filename>*.abs</filename> configuration files, or in the
2095       <literal>alvis</literal> filter &acro.xslt; indexing stylesheets.
2096      </para>
2097
2098      <para>
2099       &zebra; internal indexes can be accessed directly,
2100       according to the same rules as the user defined
2101       string indexes. The only difference is that   
2102       &zebra; internal index names are hardwired,
2103       all uppercase and
2104       must start with the character <literal>'_'</literal>. 
2105      </para>
2106
2107      <para>
2108       Finally, <literal>&acro.xpath;</literal> access points are only
2109       available using the <literal>&acro.grs1;</literal> filter for indexing.
2110       These access point names must start with the character
2111       <literal>'/'</literal>, they are <emphasis>not
2112       normalized</emphasis>, but passed unaltered to the &zebra; internal
2113       &acro.xpath; engine. See <xref linkend="querymodel-use-xpath"/>.
2114
2115      </para>
2116
2117
2118     </section>
2119
2120
2121    <section id="querymodel-pqf-apt-mapping-structuretype">
2122      <title>Mapping of &acro.pqf; &acro.apt; structure and completeness to 
2123       register type</title>
2124     <para>
2125       Internally &zebra; has in its default configuration several
2126      different types of registers or indexes, whose tokenization and
2127       character normalization rules differ. This reflects the fact that 
2128       searching fundamental different tokens like dates, numbers,
2129       bitfields and string based text needs different rule sets. 
2130      </para>
2131
2132      <table id="querymodel-zebra-mapping-structure-types" frame="top">
2133       <title>Structure and completeness mapping to register types</title>
2134       <tgroup cols="4">
2135        <thead>
2136         <row>
2137          <entry>Structure</entry>
2138          <entry>Completeness</entry>
2139          <entry>Register type</entry>
2140          <entry>Notes</entry>
2141         </row>
2142        </thead>
2143        <tbody>
2144         <row>
2145          <entry>
2146           phrase (@attr 4=1), word (@attr 4=2), 
2147           word-list (@attr 4=6),
2148           free-form-text  (@attr 4=105), or document-text (@attr 4=106)
2149          </entry>
2150          <entry>Incomplete field (@attr 6=1)</entry>
2151          <entry>Word ('w')</entry>
2152          <entry>Traditional tokenized and character normalized word index</entry>
2153         </row>
2154         <row>
2155          <entry>
2156           phrase (@attr 4=1), word (@attr 4=2), 
2157           word-list (@attr 4=6),
2158           free-form-text  (@attr 4=105), or document-text (@attr 4=106)
2159          </entry>
2160          <entry>complete field' (@attr 6=3)</entry>
2161          <entry>Phrase ('p')</entry>
2162          <entry>Character normalized, but not tokenized index for phrase
2163           matches
2164          </entry>
2165         </row>
2166         <row>
2167          <entry>urx (@attr 4=104)</entry>
2168          <entry>ignored</entry>
2169          <entry>URX/URL ('u')</entry>
2170          <entry>Special index for URL web addresses</entry>
2171         </row>
2172         <row>
2173          <entry>numeric (@attr 4=109)</entry>
2174          <entry>ignored</entry>
2175          <entry>Numeric ('u')</entry>
2176          <entry>Special index for digital numbers</entry>
2177         </row>
2178         <row>
2179          <entry>key (@attr 4=3)</entry>
2180          <entry>ignored</entry>
2181          <entry>Null bitmap ('0')</entry>
2182          <entry>Used for non-tokenizated and non-normalized bit sequences</entry>
2183         </row>
2184         <row>
2185          <entry>year (@attr 4=4)</entry>
2186          <entry>ignored</entry>
2187          <entry>Year ('y')</entry>
2188          <entry>Non-tokenizated and non-normalized 4 digit numbers</entry>
2189         </row>
2190         <row>
2191          <entry>date (@attr 4=5)</entry>
2192          <entry>ignored</entry>
2193          <entry>Date ('d')</entry>
2194          <entry>Non-tokenizated and non-normalized ISO date strings</entry>
2195         </row>
2196         <row>
2197          <entry>ignored</entry>
2198          <entry>ignored</entry>
2199          <entry>Sort ('s')</entry>
2200          <entry>Used with special sort attribute set (@attr 7=1, @attr 7=2)</entry>
2201         </row>
2202         <row>
2203          <entry>overruled</entry>
2204          <entry>overruled</entry>
2205          <entry>special</entry>
2206          <entry>Internal record ID register, used whenever 
2207           Relation Always Matches (@attr 2=103) is specified</entry>
2208         </row>
2209        </tbody>
2210       </tgroup>
2211      </table>
2212      
2213      <!-- see in util/zebramap.c -->
2214         
2215     <para>
2216      If a <emphasis>Structure</emphasis> attribute of
2217      <emphasis>Phrase</emphasis> is used in conjunction with a
2218      <emphasis>Completeness</emphasis> attribute of
2219      <emphasis>Complete (Sub)field</emphasis>, the term is matched
2220      against the contents of the phrase (long word) register, if one
2221      exists for the given <emphasis>Use</emphasis> attribute.
2222      A phrase register is created for those fields in the
2223      &acro.grs1; <filename>*.abs</filename> file that contains a
2224      <literal>p</literal>-specifier.
2225       <screen>
2226        Z> scan @attr 1=Title @attr 4=1 @attr 6=3 beethoven 
2227        ...
2228        bayreuther festspiele (1)
2229        * beethoven bibliography database (1)
2230        benny carter (1)
2231        ...
2232        Z> find @attr 1=Title @attr 4=1 @attr 6=3 "beethoven bibliography" 
2233        ...
2234        Number of hits: 0, setno 5
2235        ...
2236        Z> find @attr 1=Title @attr 4=1 @attr 6=3 "beethoven bibliography database" 
2237        ...
2238        Number of hits: 1, setno 6
2239        </screen>
2240     </para>
2241
2242     <para>
2243      If <emphasis>Structure</emphasis>=<emphasis>Phrase</emphasis> is
2244      used in conjunction with <emphasis>Incomplete Field</emphasis> - the
2245      default value for <emphasis>Completeness</emphasis>, the
2246      search is directed against the normal word registers, but if the term
2247      contains multiple words, the term will only match if all of the words
2248      are found immediately adjacent, and in the given order.
2249      The word search is performed on those fields that are indexed as
2250      type <literal>w</literal> in the &acro.grs1; <filename>*.abs</filename> file.
2251       <screen>
2252        Z> scan @attr 1=Title @attr 4=1 @attr 6=1 beethoven 
2253        ...
2254          beefheart (1)
2255        * beethoven (18)
2256          beethovens (7)
2257        ...
2258        Z> find @attr 1=Title @attr 4=1 @attr 6=1 beethoven 
2259        ...
2260        Number of hits: 18, setno 1
2261        ...
2262        Z> find @attr 1=Title @attr 4=1 @attr 6=1 "beethoven  bibliography"
2263        ...
2264        Number of hits: 2, setno 2
2265        ...
2266      </screen>
2267     </para>
2268
2269     <para>
2270      If the <emphasis>Structure</emphasis> attribute is
2271      <emphasis>Word List</emphasis>,
2272      <emphasis>Free-form Text</emphasis>, or
2273      <emphasis>Document Text</emphasis>, the term is treated as a
2274      natural-language, relevance-ranked query.
2275      This search type uses the word register, i.e. those fields
2276      that are indexed as type <literal>w</literal> in the
2277      &acro.grs1; <filename>*.abs</filename> file.
2278     </para>
2279
2280     <para>
2281      If the <emphasis>Structure</emphasis> attribute is
2282      <emphasis>Numeric String</emphasis> the term is treated as an integer.
2283      The search is performed on those fields that are indexed
2284      as type <literal>n</literal> in the &acro.grs1; 
2285       <filename>*.abs</filename> file.
2286     </para>
2287
2288     <para>
2289      If the <emphasis>Structure</emphasis> attribute is
2290      <emphasis>URX</emphasis> the term is treated as a URX (URL) entity.
2291      The search is performed on those fields that are indexed as type
2292      <literal>u</literal> in the <filename>*.abs</filename> file.
2293     </para>
2294
2295     <para>
2296      If the <emphasis>Structure</emphasis> attribute is
2297      <emphasis>Local Number</emphasis> the term is treated as
2298      native &zebra; Record Identifier.
2299     </para>
2300
2301     <para>
2302      If the <emphasis>Relation</emphasis> attribute is
2303      <emphasis>Equals</emphasis> (default), the term is matched
2304      in a normal fashion (modulo truncation and processing of
2305      individual words, if required).
2306      If <emphasis>Relation</emphasis> is <emphasis>Less Than</emphasis>,
2307      <emphasis>Less Than or Equal</emphasis>,
2308      <emphasis>Greater than</emphasis>, or <emphasis>Greater than or
2309       Equal</emphasis>, the term is assumed to be numerical, and a
2310      standard regular expression is constructed to match the given
2311      expression.
2312      If <emphasis>Relation</emphasis> is <emphasis>Relevance</emphasis>,
2313      the standard natural-language query processor is invoked.
2314     </para>
2315
2316     <para>
2317      For the <emphasis>Truncation</emphasis> attribute,
2318      <emphasis>No Truncation</emphasis> is the default.
2319      <emphasis>Left Truncation</emphasis> is not supported.
2320      <emphasis>Process # in search term</emphasis> is supported, as is
2321      <emphasis>Regxp-1</emphasis>.
2322      <emphasis>Regxp-2</emphasis> enables the fault-tolerant (fuzzy)
2323      search. As a default, a single error (deletion, insertion, 
2324      replacement) is accepted when terms are matched against the register
2325      contents.
2326     </para>
2327
2328      </section>
2329    </section>
2330
2331    <section  id="querymodel-regular">
2332     <title>&zebra; Regular Expressions in Truncation Attribute (type = 5)</title>
2333     
2334     <para>
2335      Each term in a query is interpreted as a regular expression if
2336      the truncation value is either <emphasis>Regxp-1 (@attr 5=102)</emphasis>
2337      or <emphasis>Regxp-2 (@attr 5=103)</emphasis>.
2338      Both query types follow the same syntax with the operands:
2339     </para>
2340
2341     <table id="querymodel-regular-operands-table" frame="top">
2342      <title>Regular Expression Operands</title>
2343      <tgroup cols="2">
2344       <tbody>
2345        <row>
2346         <entry><literal>x</literal></entry>
2347         <entry>Matches the character <literal>x</literal>.</entry>
2348        </row>
2349        <row>
2350         <entry><literal>.</literal></entry>
2351         <entry>Matches any character.</entry>
2352        </row>
2353        <row>
2354         <entry><literal>[ .. ]</literal></entry>
2355         <entry>Matches the set of characters specified;
2356          such as <literal>[abc]</literal> or <literal>[a-c]</literal>.</entry>
2357        </row>
2358       </tbody>
2359      </tgroup>
2360     </table>      
2361
2362     <para>
2363      The above operands can be combined with the following operators:
2364     </para>
2365     
2366     <table id="querymodel-regular-operators-table" frame="top">
2367      <title>Regular Expression Operators</title>
2368      <tgroup cols="2">
2369       <tbody>
2370        <row>
2371         <entry><literal>x*</literal></entry>
2372         <entry>Matches <literal>x</literal> zero or more times. 
2373          Priority: high.</entry>
2374        </row>
2375        <row>
2376         <entry><literal>x+</literal></entry>
2377         <entry>Matches <literal>x</literal> one or more times. 
2378          Priority: high.</entry>
2379        </row>
2380        <row>
2381         <entry><literal>x?</literal></entry>
2382         <entry> Matches <literal>x</literal> zero or once. 
2383          Priority: high.</entry>
2384        </row>
2385        <row>
2386         <entry><literal>xy</literal></entry>
2387         <entry> Matches <literal>x</literal>, then <literal>y</literal>.
2388          Priority: medium.</entry>
2389        </row>
2390        <row>
2391         <entry><literal>x|y</literal></entry>
2392         <entry> Matches either <literal>x</literal> or <literal>y</literal>.
2393          Priority: low.</entry>
2394        </row>
2395        <row>
2396         <entry><literal>( )</literal></entry>
2397         <entry>The order of evaluation may be changed by using parentheses.</entry>
2398        </row>
2399       </tbody>
2400       </tgroup>
2401     </table>      
2402     
2403     <para>
2404      If the first character of the <literal>Regxp-2</literal> query
2405      is a plus character (<literal>+</literal>) it marks the
2406      beginning of a section with non-standard specifiers.
2407      The next plus character marks the end of the section.
2408      Currently &zebra; only supports one specifier, the error tolerance,
2409      which consists one digit. 
2410      <!-- TODO Nice thing, but what does
2411      that error tolerance digit *mean*? Maybe an example would be nice? -->
2412     </para>
2413
2414     <para>
2415      Since the plus operator is normally a suffix operator the addition to
2416      the query syntax doesn't violate the syntax for standard regular
2417      expressions.
2418     </para>
2419
2420     <para>
2421      For example, a phrase search with regular expressions  in
2422      the title-register is performed like this:
2423      <screen>
2424       Z> find @attr 1=4 @attr 5=102 "informat.* retrieval"
2425      </screen>
2426     </para>
2427
2428     <para>
2429      Combinations with other attributes are possible. For example, a
2430      ranked search with a regular expression:
2431      <screen>
2432       Z> find @attr 1=4 @attr 5=102 @attr 2=102 "informat.* retrieval"
2433      </screen>
2434     </para>
2435    </section>
2436
2437   
2438    <!--
2439    <para>
2440     The RecordType parameter in the <literal>zebra.cfg</literal> file, or
2441     the <literal>-t</literal> option to the indexer tells &zebra; how to
2442     process input records.
2443     Two basic types of processing are available - raw text and structured
2444     data. Raw text is just that, and it is selected by providing the
2445     argument <literal>text</literal> to &zebra;. Structured records are
2446     all handled internally using the basic mechanisms described in the
2447     subsequent sections.
2448     &zebra; can read structured records in many different formats.
2449    </para>
2450    -->
2451   </section>
2452
2453
2454   <section id="querymodel-cql-to-pqf">
2455    <title>Server Side &acro.cql; to &acro.pqf; Query Translation</title>
2456    <para>
2457     Using the
2458     <literal>&lt;cql2rpn&gt;l2rpn.txt&lt;/cql2rpn&gt;</literal>
2459       &yaz; Frontend Virtual
2460     Hosts option, one can configure
2461     the &yaz; Frontend &acro.cql;-to-&acro.pqf;
2462     converter, specifying the interpretation of various 
2463     <ulink url="&url.cql;">&acro.cql;</ulink>
2464     indexes, relations, etc. in terms of Type-1 query attributes.
2465     <!-- The  yaz-client config file -->  
2466    </para>
2467    <para>
2468     For example, using server-side &acro.cql;-to-&acro.pqf; conversion, one might
2469     query a zebra server like this:
2470     <screen>
2471     <![CDATA[
2472      yaz-client localhost:9999
2473      Z> querytype cql
2474      Z> find text=(plant and soil)
2475      ]]>
2476     </screen>
2477      and - if properly configured - even static relevance ranking can
2478      be performed using &acro.cql; query syntax:
2479     <screen>
2480     <![CDATA[
2481      Z> find text = /relevant (plant and soil)
2482      ]]>
2483      </screen>
2484    </para>
2485
2486    <para>
2487     By the way, the same configuration can be used to 
2488     search using client-side &acro.cql;-to-&acro.pqf; conversion:
2489     (the only difference is <literal>querytype cql2rpn</literal> 
2490     instead of 
2491     <literal>querytype cql</literal>, and the call specifying a local
2492     conversion file)
2493     <screen>
2494     <![CDATA[
2495      yaz-client -q local/cql2pqf.txt localhost:9999
2496      Z> querytype cql2rpn
2497      Z> find text=(plant and soil)
2498      ]]>
2499      </screen>
2500    </para>
2501
2502    <para>
2503     Exhaustive information can be found in the
2504     Section <ulink url="&url.yaz.cql2pqf;">&acro.cql; to &acro.rpn; conversion"</ulink>
2505     in the &yaz; manual.
2506    </para> 
2507   <!-- 
2508   <para>
2509     See 
2510    <ulink url="http://www.loc.gov/z3950/agency/zing/cql/dc-indexes.html"/>
2511    for the Maintenance Agency's work-in-progress mapping of Dublin Core
2512     indexes to Attribute Architecture (util, XD and BIB-2)
2513    attributes.
2514   </para>
2515    -->
2516  </section>
2517
2518 </chapter>
2519
2520  <!-- Keep this comment at the end of the file
2521  Local variables:
2522  mode: sgml
2523  sgml-omittag:t
2524  sgml-shorttag:t
2525  sgml-minimize-attributes:nil
2526  sgml-always-quote-attributes:t
2527  sgml-indent-step:1
2528  sgml-indent-data:t
2529  sgml-parent-document: "zebra.xml"
2530  sgml-local-catalogs: nil
2531  sgml-namecase-general:t
2532  End:
2533  -->