1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
|
<html><head><meta charset="ISO-8859-1"><title>2.RPN queries and semantics</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Zebra - User's Guide and Reference"><link rel="up" href="querymodel.html" title="Chapter5.Query Model"><link rel="prev" href="querymodel.html" title="Chapter5.Query Model"><link rel="next" href="querymodel-zebra.html" title="3.Extended Zebra RPN Features"></head><body><link rel="stylesheet" type="text/css" href="common/style1.css"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.<acronym class="acronym">RPN</acronym> queries and semantics</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="querymodel.html">Prev</a></td><th width="60%" align="center">Chapter5.Query Model</th><td width="20%" align="right"><a accesskey="n" href="querymodel-zebra.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="querymodel-rpn"></a>2.<acronym class="acronym">RPN</acronym> queries and semantics</h2></div></div></div><p>
The <a class="ulink" href="https://www.indexdata.com/yaz/doc/tools.html#PQF" target="_top"><acronym class="acronym">PQF</acronym> grammar</a>
is documented in the <span class="application">YAZ</span> manual, and shall not be
repeated here. This textual <acronym class="acronym">PQF</acronym> representation
is not transmitted to <span class="application">Zebra</span> during search, but it is in the
client mapped to the equivalent <acronym class="acronym">Z39.50</acronym> binary
query parse tree.
</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="querymodel-rpn-tree"></a>2.1.<acronym class="acronym">RPN</acronym> tree structure</h3></div></div></div><p>
The <acronym class="acronym">RPN</acronym> parse tree - or the equivalent textual representation in <acronym class="acronym">PQF</acronym> -
may start with one specification of the
<span class="emphasis"><em>attribute set</em></span> used. Following is a query
tree, which
consists of <span class="emphasis"><em>atomic query parts (<acronym class="acronym">APT</acronym>)</em></span> or
<span class="emphasis"><em>named result sets</em></span>, eventually
paired by <span class="emphasis"><em>boolean binary operators</em></span>, and
finally <span class="emphasis"><em>recursively combined </em></span> into
complex query trees.
</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-attribute-sets"></a>2.1.1.Attribute sets</h4></div></div></div><p>
Attribute sets define the exact meaning and semantics of queries
issued. <span class="application">Zebra</span> comes with some predefined attribute set
definitions, others can easily be defined and added to the
configuration.
</p><div class="table"><a name="querymodel-attribute-sets-table"></a><p class="title"><b>Table5.1.Attribute sets predefined in <span class="application">Zebra</span></b></p><div class="table-contents"><table class="table" summary="Attribute sets predefined in Zebra" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute set</th><th><acronym class="acronym">PQF</acronym> notation (Short hand)</th><th>Status</th><th>Notes</th></tr></thead><tbody><tr><td>Explain</td><td><code class="literal">exp-1</code></td><td>Special attribute set used on the special automagic
<code class="literal">IR-Explain-1</code> database to gain information on
server capabilities, database names, and database
and semantics.</td><td>predefined</td></tr><tr><td><acronym class="acronym">BIB-1</acronym></td><td><code class="literal">bib-1</code></td><td>Standard <acronym class="acronym">PQF</acronym> query language attribute set which defines the
semantics of <acronym class="acronym">Z39.50</acronym> searching. In addition, all of the
non-use attributes (types 2-14) define the hard-wired
<span class="application">Zebra</span> internal query
processing.</td><td>default</td></tr><tr><td>GILS</td><td><code class="literal">gils</code></td><td>Extension to the <acronym class="acronym">BIB-1</acronym> attribute set.</td><td>predefined</td></tr></tbody></table></div></div><br class="table-break"><p>
The use attributes (type 1) mappings the
predefined attribute sets are found in the
attribute set configuration files <code class="filename">tab/*.att</code>.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
The <span class="application">Zebra</span> internal query processing is modeled after
the <acronym class="acronym">BIB-1</acronym> attribute set, and the non-use
attributes type 2-6 are hard-wired in. It is therefore essential
to be familiar with <a class="xref" href="querymodel-rpn.html#querymodel-bib1-nonuse" title="2.4.Zebra general Bib1 Non-Use Attributes (type 2-6)">Section2.4, “<span class="application">Zebra</span> general Bib1 Non-Use Attributes (type 2-6)”</a>.
</p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-boolean-operators"></a>2.1.2.Boolean operators</h4></div></div></div><p>
A pair of sub query trees, or of atomic queries, is combined
using the standard boolean operators into new query trees.
Thus, boolean operators are always internal nodes in the query tree.
</p><div class="table"><a name="querymodel-boolean-operators-table"></a><p class="title"><b>Table5.2.Boolean operators</b></p><div class="table-contents"><table class="table" summary="Boolean operators" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Keyword</th><th>Operator</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">@and</code></td><td>binary AND operator</td><td>Set intersection of two atomic queries hit sets</td></tr><tr><td><code class="literal">@or</code></td><td>binary OR operator</td><td>Set union of two atomic queries hit sets</td></tr><tr><td><code class="literal">@not</code></td><td>binary AND NOT operator</td><td>Set complement of two atomic queries hit sets</td></tr><tr><td><code class="literal">@prox</code></td><td>binary PROXIMITY operator</td><td>Set intersection of two atomic queries hit sets. In
addition, the intersection set is purged for all
documents which do not satisfy the requested query
term proximity. Usually a proper subset of the AND
operation.</td></tr></tbody></table></div></div><br class="table-break"><p>
For example, we can combine the terms
<span class="emphasis"><em>information</em></span> and <span class="emphasis"><em>retrieval</em></span>
into different searches in the default index of the default
attribute set as follows.
Querying for the union of all documents containing the
terms <span class="emphasis"><em>information</em></span> OR
<span class="emphasis"><em>retrieval</em></span>:
</p><pre class="screen">
Z> find @or information retrieval
</pre><p>
</p><p>
Querying for the intersection of all documents containing the
terms <span class="emphasis"><em>information</em></span> AND
<span class="emphasis"><em>retrieval</em></span>:
The hit set is a subset of the corresponding
OR query.
</p><pre class="screen">
Z> find @and information retrieval
</pre><p>
</p><p>
Querying for the intersection of all documents containing the
terms <span class="emphasis"><em>information</em></span> AND
<span class="emphasis"><em>retrieval</em></span>, taking proximity into account:
The hit set is a subset of the corresponding
AND query
(see the <a class="ulink" href="https://www.indexdata.com/yaz/doc/tools.html#PQF" target="_top"><acronym class="acronym">PQF</acronym> grammar</a> for
details on the proximity operator):
</p><pre class="screen">
Z> find @prox 0 3 0 2 k 2 information retrieval
</pre><p>
</p><p>
Querying for the intersection of all documents containing the
terms <span class="emphasis"><em>information</em></span> AND
<span class="emphasis"><em>retrieval</em></span>, in the same order and near each
other as described in the term list.
The hit set is a subset of the corresponding
PROXIMITY query.
</p><pre class="screen">
Z> find "information retrieval"
</pre><p>
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-atomic-queries"></a>2.1.3.Atomic queries (<acronym class="acronym">APT</acronym>)</h4></div></div></div><p>
Atomic queries are the query parts which work on one access point
only. These consist of <span class="emphasis"><em>an attribute list</em></span>
followed by a <span class="emphasis"><em>single term</em></span> or a
<span class="emphasis"><em>quoted term list</em></span>, and are often called
<span class="emphasis"><em>Attributes-Plus-Terms (<acronym class="acronym">APT</acronym>)</em></span> queries.
</p><p>
Atomic (<acronym class="acronym">APT</acronym>) queries are always leaf nodes in the <acronym class="acronym">PQF</acronym> query tree.
UN-supplied non-use attributes types 2-12 are either inherited from
higher nodes in the query tree, or are set to <span class="application">Zebra</span>'s default values.
See <a class="xref" href="querymodel-rpn.html#querymodel-bib1" title="2.3.BIB-1 Attribute Set">Section2.3, “<acronym class="acronym">BIB-1</acronym> Attribute Set”</a> for details.
</p><div class="table"><a name="querymodel-atomic-queries-table"></a><p class="title"><b>Table5.3.Atomic queries (<acronym class="acronym">APT</acronym>)</b></p><div class="table-contents"><table class="table" summary="Atomic queries (APT)" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Notes</th></tr></thead><tbody><tr><td><span class="emphasis"><em>attribute list</em></span></td><td>List of <span class="emphasis"><em>orthogonal</em></span> attributes</td><td>Any of the orthogonal attribute types may be omitted,
these are inherited from higher query tree nodes, or if not
inherited, are set to the default <span class="application">Zebra</span> configuration values.
</td></tr><tr><td><span class="emphasis"><em>term</em></span></td><td>single <span class="emphasis"><em>term</em></span>
or <span class="emphasis"><em>quoted term list</em></span> </td><td>Here the search terms or list of search terms is added
to the query</td></tr></tbody></table></div></div><br class="table-break"><p>
Querying for the term <span class="emphasis"><em>information</em></span> in the
default index using the default attribute set, the server choice
of access point/index, and the default non-use attributes.
</p><pre class="screen">
Z> find information
</pre><p>
</p><p>
Equivalent query fully specified including all default values:
</p><pre class="screen">
Z> find @attrset bib-1 @attr 1=1017 @attr 2=3 @attr 3=3 @attr 4=1 @attr 5=100 @attr 6=1 information
</pre><p>
</p><p>
Finding all documents which have the term
<span class="emphasis"><em>debussy</em></span> in the title field.
</p><pre class="screen">
Z> find @attr 1=4 debussy
</pre><p>
</p><p>
The <span class="emphasis"><em>scan</em></span> operation is only supported with
atomic <acronym class="acronym">APT</acronym> queries, as it is bound to one access point at a
time. Boolean query trees are not allowed during
<span class="emphasis"><em>scan</em></span>.
</p><p>
For example, we might want to scan the title index, starting with
the term
<span class="emphasis"><em>debussy</em></span>, and displaying this and the
following terms in lexicographic order:
</p><pre class="screen">
Z> scan @attr 1=4 debussy
</pre><p>
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-resultset"></a>2.1.4.Named Result Sets</h4></div></div></div><p>
Named result sets are supported in <span class="application">Zebra</span>, and result sets can be
used as operands without limitations. It follows that named
result sets are leaf nodes in the <acronym class="acronym">PQF</acronym> query tree, exactly as
atomic <acronym class="acronym">APT</acronym> queries are.
</p><p>
After the execution of a search, the result set is available at
the server, such that the client can use it for subsequent
searches or retrieval requests. The Z30.50 standard actually
stresses the fact that result sets are volatile. It may cease
to exist at any time point after search, and the server will
send a diagnostic to the effect that the requested
result set does not exist any more.
</p><p>
Defining a named result set and re-using it in the next query,
using <span class="application">yaz-client</span>. Notice that the client, not
the server, assigns the string '1' to the
named result set.
</p><pre class="screen">
Z> f @attr 1=4 mozart
...
Number of hits: 43, setno 1
...
Z> f @and @set 1 @attr 1=4 amadeus
...
Number of hits: 14, setno 2
</pre><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
Named result sets are only supported by the <acronym class="acronym">Z39.50</acronym> protocol.
The <acronym class="acronym">SRU</acronym> web service is stateless, and therefore the notion of
named result sets does not exist when accessing a <span class="application">Zebra</span> server by
the <acronym class="acronym">SRU</acronym> protocol.
</p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-use-string"></a>2.1.5.<span class="application">Zebra</span>'s special access point of type 'string'</h4></div></div></div><p>
The numeric <span class="emphasis"><em>use (type 1)</em></span> attribute is usually
referred to from a given
attribute set. In addition, <span class="application">Zebra</span> let you use
<span class="emphasis"><em>any internal index
name defined in your configuration</em></span>
as use attribute value. This is a great feature for
debugging, and when you do
not need the complexity of defined use attribute values. It is
the preferred way of accessing <span class="application">Zebra</span> indexes directly.
</p><p>
Finding all documents which have the term list "information
retrieval" in an <span class="application">Zebra</span> index, using its internal full string
name. Scanning the same index.
</p><pre class="screen">
Z> find @attr 1=sometext "information retrieval"
Z> scan @attr 1=sometext aterm
</pre><p>
</p><p>
Searching or scanning
the bib-1 use attribute 54 using its string name:
</p><pre class="screen">
Z> find @attr 1=Code-language eng
Z> scan @attr 1=Code-language ""
</pre><p>
</p><p>
It is possible to search
in any silly string index - if it's defined in your
indexing rules and can be parsed by the <acronym class="acronym">PQF</acronym> parser.
This is definitely not the recommended use of
this facility, as it might confuse your users with some very
unexpected results.
</p><pre class="screen">
Z> find @attr 1=silly/xpath/alike[@index]/name "information retrieval"
</pre><p>
</p><p>
See also <a class="xref" href="querymodel-zebra.html#querymodel-pqf-apt-mapping" title="3.5.Mapping from PQF atomic APT queries to Zebra internal register indexes">Section3.5, “Mapping from <acronym class="acronym">PQF</acronym> atomic <acronym class="acronym">APT</acronym> queries to <span class="application">Zebra</span> internal
register indexes”</a> for details, and
<a class="xref" href="zebrasrv.html#zebrasrv-sru" title="The SRU Server">the section called “The <acronym class="acronym">SRU</acronym> Server”</a>
for the <acronym class="acronym">SRU</acronym> <acronym class="acronym">PQF</acronym> query extension using string names as a fast
debugging facility.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-use-xpath"></a>2.1.6.<span class="application">Zebra</span>'s special access point of type 'XPath'
for <acronym class="acronym">GRS-1</acronym> filters</h4></div></div></div><p>
As we have seen above, it is possible (albeit seldom a great
idea) to emulate
<a class="ulink" href="http://www.w3.org/TR/xpath" target="_top">XPath 1.0</a> based
search by defining <span class="emphasis"><em>use (type 1)</em></span>
<span class="emphasis"><em>string</em></span> attributes which in appearance
<span class="emphasis"><em>resemble XPath queries</em></span>. There are two
problems with this approach: first, the XPath-look-alike has to
be defined at indexing time, no new undefined
XPath queries can entered at search time, and second, it might
confuse users very much that an XPath-alike index name in fact
gets populated from a possible entirely different <acronym class="acronym">XML</acronym> element
than it pretends to access.
</p><p>
When using the <acronym class="acronym">GRS-1</acronym> Record Model
(see <a class="xref" href="grs.html" title="Chapter9.GRS-1 Record Model and Filter Modules">Chapter9, <i><acronym class="acronym">GRS-1</acronym> Record Model and Filter Modules</i></a>), we have the
possibility to embed <span class="emphasis"><em>life</em></span>
XPath expressions
in the <acronym class="acronym">PQF</acronym> queries, which are here called
<span class="emphasis"><em>use (type 1)</em></span> <span class="emphasis"><em>xpath</em></span>
attributes. You must enable the
<code class="literal">xpath enable</code> directive in your
<code class="literal">.abs</code> configuration files.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
Only a <span class="emphasis"><em>very</em></span> restricted subset of the
<a class="ulink" href="http://www.w3.org/TR/xpath" target="_top">XPath 1.0</a>
standard is supported as the <acronym class="acronym">GRS-1</acronym> record model is simpler than
a full <acronym class="acronym">XML</acronym> <acronym class="acronym">DOM</acronym> structure. See the following examples for
possibilities.
</p></div><p>
Finding all documents which have the term "content"
inside a text node found in a specific <acronym class="acronym">XML</acronym> <acronym class="acronym">DOM</acronym>
<span class="emphasis"><em>subtree</em></span>, whose starting element is
addressed by XPath.
</p><pre class="screen">
Z> find @attr 1=/root content
Z> find @attr 1=/root/first content
</pre><p>
<span class="emphasis"><em>Notice that the
XPath must be absolute, i.e., must start with '/', and that the
XPath <code class="literal">descendant-or-self</code> axis followed by a
text node selection <code class="literal">text()</code> is implicitly
appended to the stated XPath.
</em></span>
It follows that the above searches are interpreted as:
</p><pre class="screen">
Z> find @attr 1=/root//text() content
Z> find @attr 1=/root/first//text() content
</pre><p>
</p><p>
Searching inside attribute strings is possible:
</p><pre class="screen">
Z> find @attr 1=/link/@creator morten
</pre><p>
</p><p>
Filter the addressing XPath by a predicate working on exact
string values in
attributes (in the <acronym class="acronym">XML</acronym> sense) can be done: return all those docs which
have the term "english" contained in one of all text sub nodes of
the subtree defined by the XPath
<code class="literal">/record/title[@lang='en']</code>. And similar
predicate filtering.
</p><pre class="screen">
Z> find @attr 1=/record/title[@lang='en'] english
Z> find @attr 1=/link[@creator='sisse'] sibelius
Z> find @attr 1=/link[@creator='sisse']/description[@xml:lang='da'] sibelius
</pre><p>
</p><p>
Combining numeric indexes, boolean expressions,
and xpath based searches is possible:
</p><pre class="screen">
Z> find @attr 1=/record/title @and foo bar
Z> find @and @attr 1=/record/title foo @attr 1=4 bar
</pre><p>
</p><p>
Escaping <acronym class="acronym">PQF</acronym> keywords and other non-parseable XPath constructs
with <code class="literal">'{ }'</code> to prevent client-side <acronym class="acronym">PQF</acronym> parsing
syntax errors:
</p><pre class="screen">
Z> find @attr {1=/root/first[@attr='danish']} content
Z> find @attr {1=/record/@set} oai
</pre><p>
</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>
It is worth mentioning that these dynamic performed XPath
queries are a performance bottleneck, as no optimized
specialized indexes can be used. Therefore, avoid the use of
this facility when speed is essential, and the database content
size is medium to large.
</p></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="querymodel-exp1"></a>2.2.Explain Attribute Set</h3></div></div></div><p>
The <acronym class="acronym">Z39.50</acronym> standard defines the
<a class="ulink" href="https://www.loc.gov/z3950/agency/markup/07.html" target="_top">Explain</a> attribute set
Exp-1, which is used to discover information
about a server's search semantics and functional capabilities
<span class="application">Zebra</span> exposes a "classic"
Explain database by base name <code class="literal">IR-Explain-1</code>, which
is populated with system internal information.
</p><p>
The attribute-set <code class="literal">exp-1</code> consists of a single
use attribute (type 1).
</p><p>
In addition, the non-Use
<acronym class="acronym">BIB-1</acronym> attributes, that is, the types
<span class="emphasis"><em>Relation</em></span>, <span class="emphasis"><em>Position</em></span>,
<span class="emphasis"><em>Structure</em></span>, <span class="emphasis"><em>Truncation</em></span>,
and <span class="emphasis"><em>Completeness</em></span> are imported from
the <acronym class="acronym">BIB-1</acronym> attribute set, and may be used
within any explain query.
</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-exp1-use"></a>2.2.1.Use Attributes (type = 1)</h4></div></div></div><p>
The following Explain search attributes are supported:
<code class="literal">ExplainCategory</code> (@attr 1=1),
<code class="literal">DatabaseName</code> (@attr 1=3),
<code class="literal">DateAdded</code> (@attr 1=9),
<code class="literal">DateChanged</code>(@attr 1=10).
</p><p>
A search in the use attribute <code class="literal">ExplainCategory</code>
supports only these predefined values:
<code class="literal">CategoryList</code>, <code class="literal">TargetInfo</code>,
<code class="literal">DatabaseInfo</code>, <code class="literal">AttributeDetails</code>.
</p><p>
See <code class="filename">tab/explain.att</code> and the
<a class="ulink" href="https://www.loc.gov/z3950/agency/" target="_top"><acronym class="acronym">Z39.50</acronym></a> standard
for more information.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-examples"></a>2.2.2.Explain searches with yaz-client</h4></div></div></div><p>
Classic Explain only defines retrieval of Explain information
via ASN.1. Practically no <acronym class="acronym">Z39.50</acronym> clients supports this. Fortunately
they don't have to - <span class="application">Zebra</span> allows retrieval of this information
in other formats:
<acronym class="acronym">SUTRS</acronym>, <acronym class="acronym">XML</acronym>,
<acronym class="acronym">GRS-1</acronym> and <code class="literal">ASN.1</code> Explain.
</p><p>
List supported categories to find out which explain commands are
supported:
</p><pre class="screen">
Z> base IR-Explain-1
Z> find @attr exp1 1=1 categorylist
Z> form sutrs
Z> show 1+2
</pre><p>
</p><p>
Get target info, that is, investigate which databases exist at
this server endpoint:
</p><pre class="screen">
Z> base IR-Explain-1
Z> find @attr exp1 1=1 targetinfo
Z> form xml
Z> show 1+1
Z> form grs-1
Z> show 1+1
Z> form sutrs
Z> show 1+1
</pre><p>
</p><p>
List all supported databases, the number of hits
is the number of databases found, which most commonly are the
following two:
the <code class="literal">Default</code> and the
<code class="literal">IR-Explain-1</code> databases.
</p><pre class="screen">
Z> base IR-Explain-1
Z> find @attr exp1 1=1 databaseinfo
Z> form sutrs
Z> show 1+2
</pre><p>
</p><p>
Get database info record for database <code class="literal">Default</code>.
</p><pre class="screen">
Z> base IR-Explain-1
Z> find @and @attr exp1 1=1 databaseinfo @attr exp1 1=3 Default
</pre><p>
Identical query with explicitly specified attribute set:
</p><pre class="screen">
Z> base IR-Explain-1
Z> find @attrset exp1 @and @attr 1=1 databaseinfo @attr 1=3 Default
</pre><p>
</p><p>
Get attribute details record for database
<code class="literal">Default</code>.
This query is very useful to study the internal <span class="application">Zebra</span> indexes.
If records have been indexed using the <code class="literal">alvis</code>
<acronym class="acronym">XSLT</acronym> filter, the string representation names of the known indexes can be
found.
</p><pre class="screen">
Z> base IR-Explain-1
Z> find @and @attr exp1 1=1 attributedetails @attr exp1 1=3 Default
</pre><p>
Identical query with explicitly specified attribute set:
</p><pre class="screen">
Z> base IR-Explain-1
Z> find @attrset exp1 @and @attr 1=1 attributedetails @attr 1=3 Default
</pre><p>
</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="querymodel-bib1"></a>2.3.<acronym class="acronym">BIB-1</acronym> Attribute Set</h3></div></div></div><p>
Most of the information contained in this section is an excerpt of
the ATTRIBUTE SET <acronym class="acronym">BIB-1</acronym> (<acronym class="acronym">Z39.50</acronym>-1995) SEMANTICS
found at <a class="ulink" href="https://www.loc.gov/z3950/agency/bib1.html" target="_top">. The <acronym class="acronym">BIB-1</acronym>
Attribute Set Semantics</a> from 1995, also in an updated
<a class="ulink" href="https://www.loc.gov/z3950/agency/defns/bib1.html" target="_top"><acronym class="acronym">BIB-1</acronym>
Attribute Set</a>
version from 2003. Index Data is not the copyright holder of this
information, except for the configuration details, the listing of
<span class="application">Zebra</span>'s capabilities, and the example queries.
</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-bib1-use"></a>2.3.1.Use Attributes (type 1)</h4></div></div></div><p>
A use attribute specifies an access point for any atomic query.
These access points are highly dependent on the attribute set used
in the query, and are user configurable using the following
default configuration files:
<code class="filename">tab/bib1.att</code>,
<code class="filename">tab/dan1.att</code>,
<code class="filename">tab/explain.att</code>, and
<code class="filename">tab/gils.att</code>.
</p><p>
For example, some few <acronym class="acronym">BIB-1</acronym> use
attributes from the <code class="filename">tab/bib1.att</code> are:
</p><pre class="screen">
att 1 Personal-name
att 2 Corporate-name
att 3 Conference-name
att 4 Title
...
att 1009 Subject-name-personal
att 1010 Body-of-text
att 1011 Date/time-added-to-db
...
att 1016 Any
att 1017 Server-choice
att 1018 Publisher
...
att 1035 Anywhere
att 1036 Author-Title-Subject
</pre><p>
</p><p>
New attribute sets can be added by adding new
<code class="filename">tab/*.att</code> configuration files, which need to
be sourced in the main configuration <code class="filename">zebra.cfg</code>.
</p><p>
In addition, <span class="application">Zebra</span> allows the access of
<span class="emphasis"><em>internal index names</em></span> and <span class="emphasis"><em>dynamic
XPath</em></span> as use attributes; see
<a class="xref" href="querymodel-rpn.html#querymodel-use-string" title="2.1.5.Zebra's special access point of type 'string'">Section2.1.5, “<span class="application">Zebra</span>'s special access point of type 'string'”</a> and
<a class="xref" href="querymodel-rpn.html#querymodel-use-xpath" title="2.1.6.Zebra's special access point of type 'XPath' for GRS-1 filters">Section2.1.6, “<span class="application">Zebra</span>'s special access point of type 'XPath'
for <acronym class="acronym">GRS-1</acronym> filters”</a>.
</p><p>
Phrase search for <span class="emphasis"><em>information retrieval</em></span> in
the title-register, scanning the same register afterwards:
</p><pre class="screen">
Z> find @attr 1=4 "information retrieval"
Z> scan @attr 1=4 information
</pre><p>
</p></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="querymodel-bib1-nonuse"></a>2.4.<span class="application">Zebra</span> general Bib1 Non-Use Attributes (type 2-6)</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-bib1-relation"></a>2.4.1.Relation Attributes (type 2)</h4></div></div></div><p>
Relation attributes describe the relationship of the access
point (left side
of the relation) to the search term as qualified by the attributes (right
side of the relation), e.g., Date-publication <= 1975.
</p><div class="table"><a name="querymodel-bib1-relation-table"></a><p class="title"><b>Table5.4.Relation Attributes (type 2)</b></p><div class="table-contents"><table class="table" summary="Relation Attributes (type 2)" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Relation</th><th>Value</th><th>Notes</th></tr></thead><tbody><tr><td>Less than</td><td>1</td><td>supported</td></tr><tr><td>Less than or equal</td><td>2</td><td>supported</td></tr><tr><td>Equal</td><td>3</td><td>default</td></tr><tr><td>Greater or equal</td><td>4</td><td>supported</td></tr><tr><td>Greater than</td><td>5</td><td>supported</td></tr><tr><td>Not equal</td><td>6</td><td>unsupported</td></tr><tr><td>Phonetic</td><td>100</td><td>unsupported</td></tr><tr><td>Stem</td><td>101</td><td>unsupported</td></tr><tr><td>Relevance</td><td>102</td><td>supported</td></tr><tr><td>AlwaysMatches</td><td>103</td><td>supported *</td></tr></tbody></table></div></div><br class="table-break"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
AlwaysMatches searches are only supported if alwaysmatches indexing
has been enabled. See <a class="xref" href="fields-and-charsets.html#default-idx-file" title="1.The default.idx file">Section1, “The default.idx file”</a>
</p></div><p>
The relation attributes 1-5 are supported and work exactly as
expected.
All ordering operations are based on a lexicographical ordering,
<span class="emphasis"><em>except</em></span> when the
structure attribute numeric (109) is used. In
this case, ordering is numerical. See
<a class="xref" href="querymodel-rpn.html#querymodel-bib1-structure" title="2.4.3.Structure Attributes (type 4)">Section2.4.3, “Structure Attributes (type 4)”</a>.
</p><pre class="screen">
Z> find @attr 1=Title @attr 2=1 music
...
Number of hits: 11745, setno 1
...
Z> find @attr 1=Title @attr 2=2 music
...
Number of hits: 11771, setno 2
...
Z> find @attr 1=Title @attr 2=3 music
...
Number of hits: 532, setno 3
...
Z> find @attr 1=Title @attr 2=4 music
...
Number of hits: 11463, setno 4
...
Z> find @attr 1=Title @attr 2=5 music
...
Number of hits: 11419, setno 5
</pre><p>
</p><p>
The relation attribute
<span class="emphasis"><em>Relevance (102)</em></span> is supported, see
<a class="xref" href="administration-ranking.html" title="9.Relevance Ranking and Sorting of Result Sets">Section9, “Relevance Ranking and Sorting of Result Sets”</a> for full information.
</p><p>
Ranked search for <span class="emphasis"><em>information retrieval</em></span> in
the title-register:
</p><pre class="screen">
Z> find @attr 1=4 @attr 2=102 "information retrieval"
</pre><p>
</p><p>
The relation attribute
<span class="emphasis"><em>AlwaysMatches (103)</em></span> is in the default
configuration
supported in conjecture with structure attribute
<span class="emphasis"><em>Phrase (1)</em></span> (which may be omitted by
default).
It can be configured to work with other structure attributes,
see the configuration file
<code class="filename">tab/default.idx</code> and
<a class="xref" href="querymodel-zebra.html#querymodel-pqf-apt-mapping" title="3.5.Mapping from PQF atomic APT queries to Zebra internal register indexes">Section3.5, “Mapping from <acronym class="acronym">PQF</acronym> atomic <acronym class="acronym">APT</acronym> queries to <span class="application">Zebra</span> internal
register indexes”</a>.
</p><p>
<span class="emphasis"><em>AlwaysMatches (103)</em></span> is a
great way to discover how many documents have been indexed in a
given field. The search term is ignored, but needed for correct
<acronym class="acronym">PQF</acronym> syntax. An empty search term may be supplied.
</p><pre class="screen">
Z> find @attr 1=Title @attr 2=103 ""
Z> find @attr 1=Title @attr 2=103 @attr 4=1 ""
</pre><p>
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-bib1-position"></a>2.4.2.Position Attributes (type 3)</h4></div></div></div><p>
The position attribute specifies the location of the search term
within the field or subfield in which it appears.
</p><div class="table"><a name="querymodel-bib1-position-table"></a><p class="title"><b>Table5.5.Position Attributes (type 3)</b></p><div class="table-contents"><table class="table" summary="Position Attributes (type 3)" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Position</th><th>Value</th><th>Notes</th></tr></thead><tbody><tr><td>First in field </td><td>1</td><td>supported *</td></tr><tr><td>First in subfield</td><td>2</td><td>supported *</td></tr><tr><td>Any position in field</td><td>3</td><td>default</td></tr></tbody></table></div></div><br class="table-break"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
<span class="application">Zebra</span> only supports first-in-field seaches if the
<code class="literal">firstinfield</code> is enabled for the index
Refer to <a class="xref" href="fields-and-charsets.html#default-idx-file" title="1.The default.idx file">Section1, “The default.idx file”</a>.
<span class="application">Zebra</span> does not distinguish between first in field and
first in subfield. They result in the same hit count.
Searching for first position in (sub)field in only supported in <span class="application">Zebra</span>
2.0.2 and later.
</p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-bib1-structure"></a>2.4.3.Structure Attributes (type 4)</h4></div></div></div><p>
The structure attribute specifies the type of search
term. This causes the search to be mapped on
different <span class="application">Zebra</span> internal indexes, which must have been defined
at index time.
</p><p>
The possible values of the
<code class="literal">structure attribute (type 4)</code> can be defined
using the configuration file <code class="filename">tab/default.idx</code>.
The default configuration is summarized in this table.
</p><div class="table"><a name="querymodel-bib1-structure-table"></a><p class="title"><b>Table5.6.Structure Attributes (type 4)</b></p><div class="table-contents"><table class="table" summary="Structure Attributes (type 4)" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Structure</th><th>Value</th><th>Notes</th></tr></thead><tbody><tr><td>Phrase </td><td>1</td><td>default</td></tr><tr><td>Word</td><td>2</td><td>supported</td></tr><tr><td>Key</td><td>3</td><td>supported</td></tr><tr><td>Year</td><td>4</td><td>supported</td></tr><tr><td>Date (normalized)</td><td>5</td><td>supported</td></tr><tr><td>Word list</td><td>6</td><td>supported</td></tr><tr><td>Date (un-normalized)</td><td>100</td><td>unsupported</td></tr><tr><td>Name (normalized) </td><td>101</td><td>unsupported</td></tr><tr><td>Name (un-normalized) </td><td>102</td><td>unsupported</td></tr><tr><td>Structure</td><td>103</td><td>unsupported</td></tr><tr><td>Urx</td><td>104</td><td>supported</td></tr><tr><td>Free-form-text</td><td>105</td><td>supported</td></tr><tr><td>Document-text</td><td>106</td><td>supported</td></tr><tr><td>Local-number</td><td>107</td><td>supported</td></tr><tr><td>String</td><td>108</td><td>unsupported</td></tr><tr><td>Numeric string</td><td>109</td><td>supported</td></tr></tbody></table></div></div><br class="table-break"><p>
The structure attribute values
<code class="literal">Word list (6)</code>
is supported, and maps to the boolean <code class="literal">AND</code>
combination of words supplied. The word list is useful when
Google-like bag-of-word queries need to be translated from a GUI
query language to <acronym class="acronym">PQF</acronym>. For example, the following queries
are equivalent:
</p><pre class="screen">
Z> find @attr 1=Title @attr 4=6 "mozart amadeus"
Z> find @attr 1=Title @and mozart amadeus
</pre><p>
</p><p>
The structure attribute value
<code class="literal">Free-form-text (105)</code> and
<code class="literal">Document-text (106)</code>
are supported, and map both to the boolean <code class="literal">OR</code>
combination of words supplied. The following queries
are equivalent:
</p><pre class="screen">
Z> find @attr 1=Body-of-text @attr 4=105 "bach salieri teleman"
Z> find @attr 1=Body-of-text @attr 4=106 "bach salieri teleman"
Z> find @attr 1=Body-of-text @or bach @or salieri teleman
</pre><p>
This <code class="literal">OR</code> list of terms is very useful in
combination with relevance ranking:
</p><pre class="screen">
Z> find @attr 1=Body-of-text @attr 2=102 @attr 4=105 "bach salieri teleman"
</pre><p>
</p><p>
The structure attribute value
<code class="literal">Local number (107)</code>
is supported, and maps always to the <span class="application">Zebra</span> internal document ID,
irrespectively which use attribute is specified. The following queries
have exactly the same unique record in the hit set:
</p><pre class="screen">
Z> find @attr 4=107 10
Z> find @attr 1=4 @attr 4=107 10
Z> find @attr 1=1010 @attr 4=107 10
</pre><p>
</p><p>
In
the GILS schema (<code class="literal">gils.abs</code>), the
west-bounding-coordinate is indexed as type <code class="literal">n</code>,
and is therefore searched by specifying
<span class="emphasis"><em>structure</em></span>=<span class="emphasis"><em>Numeric String</em></span>.
To match all those records with west-bounding-coordinate greater
than -114 we use the following query:
</p><pre class="screen">
Z> find @attr 4=109 @attr 2=5 @attr gils 1=2038 -114
</pre><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
The exact mapping between <acronym class="acronym">PQF</acronym> queries and <span class="application">Zebra</span> internal indexes
and index types is explained in
<a class="xref" href="querymodel-zebra.html#querymodel-pqf-apt-mapping" title="3.5.Mapping from PQF atomic APT queries to Zebra internal register indexes">Section3.5, “Mapping from <acronym class="acronym">PQF</acronym> atomic <acronym class="acronym">APT</acronym> queries to <span class="application">Zebra</span> internal
register indexes”</a>.
</p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-bib1-truncation"></a>2.4.4.Truncation Attributes (type = 5)</h4></div></div></div><p>
The truncation attribute specifies whether variations of one or
more characters are allowed between search term and hit terms, or
not. Using non-default truncation attributes will broaden the
document hit set of a search query.
</p><div class="table"><a name="querymodel-bib1-truncation-table"></a><p class="title"><b>Table5.7.Truncation Attributes (type 5)</b></p><div class="table-contents"><table class="table" summary="Truncation Attributes (type 5)" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Truncation</th><th>Value</th><th>Notes</th></tr></thead><tbody><tr><td>Right truncation </td><td>1</td><td>supported</td></tr><tr><td>Left truncation</td><td>2</td><td>supported</td></tr><tr><td>Left and right truncation</td><td>3</td><td>supported</td></tr><tr><td>Do not truncate</td><td>100</td><td>default</td></tr><tr><td>Process # in search term</td><td>101</td><td>supported</td></tr><tr><td>RegExpr-1 </td><td>102</td><td>supported</td></tr><tr><td>RegExpr-2</td><td>103</td><td>supported</td></tr></tbody></table></div></div><br class="table-break"><p>
The truncation attribute values 1-3 perform the obvious way:
</p><pre class="screen">
Z> scan @attr 1=Body-of-text schnittke
...
* schnittke (81)
schnittkes (31)
schnittstelle (1)
...
Z> find @attr 1=Body-of-text @attr 5=1 schnittke
...
Number of hits: 95, setno 7
...
Z> find @attr 1=Body-of-text @attr 5=2 schnittke
...
Number of hits: 81, setno 6
...
Z> find @attr 1=Body-of-text @attr 5=3 schnittke
...
Number of hits: 95, setno 8
</pre><p>
</p><p>
The truncation attribute value
<code class="literal">Process # in search term (101)</code> is a
poor-man's regular expression search. It maps
each <code class="literal">#</code> to <code class="literal">.*</code>, and
performs then a <code class="literal">Regexp-1 (102)</code> regular
expression search. The following two queries are equivalent:
</p><pre class="screen">
Z> find @attr 1=Body-of-text @attr 5=101 schnit#ke
Z> find @attr 1=Body-of-text @attr 5=102 schnit.*ke
...
Number of hits: 89, setno 10
</pre><p>
</p><p>
The truncation attribute value
<code class="literal">Regexp-1 (102)</code> is a normal regular search,
see <a class="xref" href="querymodel-zebra.html#querymodel-regular" title="3.6.Zebra Regular Expressions in Truncation Attribute (type = 5)">Section3.6, “<span class="application">Zebra</span> Regular Expressions in Truncation Attribute (type = 5)”</a> for details.
</p><pre class="screen">
Z> find @attr 1=Body-of-text @attr 5=102 schnit+ke
Z> find @attr 1=Body-of-text @attr 5=102 schni[a-t]+ke
</pre><p>
</p><p>
The truncation attribute value
<code class="literal">Regexp-2 (103) </code> is a <span class="application">Zebra</span> specific extension
which allows <span class="emphasis"><em>fuzzy</em></span> matches. One single
error in spelling of search terms is allowed, i.e., a document
is hit if it includes a term which can be mapped to the used
search term by one character substitution, addition, deletion or
change of position.
</p><pre class="screen">
Z> find @attr 1=Body-of-text @attr 5=100 schnittke
...
Number of hits: 81, setno 14
...
Z> find @attr 1=Body-of-text @attr 5=103 schnittke
...
Number of hits: 103, setno 15
...
</pre><p>
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="querymodel-bib1-completeness"></a>2.4.5.Completeness Attributes (type = 6)</h4></div></div></div><p>
The <code class="literal">Completeness Attributes (type = 6)</code>
is used to specify that a given search term or term list is either
part of the terms of a given index/field
(<code class="literal">Incomplete subfield (1)</code>), or is
what literally is found in the entire field's index
(<code class="literal">Complete field (3)</code>).
</p><div class="table"><a name="querymodel-bib1-completeness-table"></a><p class="title"><b>Table5.8.Completeness Attributes (type = 6)</b></p><div class="table-contents"><table class="table" summary="Completeness Attributes (type = 6)" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Completeness</th><th>Value</th><th>Notes</th></tr></thead><tbody><tr><td>Incomplete subfield</td><td>1</td><td>default</td></tr><tr><td>Complete subfield</td><td>2</td><td>deprecated</td></tr><tr><td>Complete field</td><td>3</td><td>supported</td></tr></tbody></table></div></div><br class="table-break"><p>
The <code class="literal">Completeness Attributes (type = 6)</code>
is only partially and conditionally
supported in the sense that it is ignored if the hit index is
not of structure <code class="literal">type="w"</code> or
<code class="literal">type="p"</code>.
</p><p>
<code class="literal">Incomplete subfield (1)</code> is the default, and
makes <span class="application">Zebra</span> use
register <code class="literal">type="w"</code>, whereas
<code class="literal">Complete field (3)</code> triggers
search and scan in index <code class="literal">type="p"</code>.
</p><p>
The <code class="literal">Complete subfield (2)</code> is a reminiscent
from the happy <acronym class="acronym">MARC</acronym>
binary format days. <span class="application">Zebra</span> does not support it, but maps silently
to <code class="literal">Complete field (3)</code>.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
The exact mapping between <acronym class="acronym">PQF</acronym> queries and <span class="application">Zebra</span> internal indexes
and index types is explained in
<a class="xref" href="querymodel-zebra.html#querymodel-pqf-apt-mapping" title="3.5.Mapping from PQF atomic APT queries to Zebra internal register indexes">Section3.5, “Mapping from <acronym class="acronym">PQF</acronym> atomic <acronym class="acronym">APT</acronym> queries to <span class="application">Zebra</span> internal
register indexes”</a>.
</p></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="querymodel.html">Prev</a></td><td width="20%" align="center"><a accesskey="u" href="querymodel.html">Up</a></td><td width="40%" align="right"><a accesskey="n" href="querymodel-zebra.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter5.Query Model</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">3.Extended <span class="application">Zebra</span> <acronym class="acronym">RPN</acronym> Features</td></tr></table></div></body></html>
|