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