|
3 | 3 | schematypens="http://purl.oclc.org/dsdl/schematron"?><article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
|
4 | 4 | <info>
|
5 | 5 | <title>Full Text Index</title>
|
6 |
| - <date>4Q19</date> |
| 6 | + <date>1Q20</date> |
7 | 7 | <keywordset>
|
8 | 8 | <keyword>indexing</keyword>
|
9 | 9 | </keywordset>
|
|
394 | 394 | expression rooted in the parent node being indexed. In the example the parent will be a <tag>db:article</tag> element, so the context item
|
395 | 395 | for the expression is set to this element.</para>
|
396 | 396 | <para>The expression is evaluated and for each result item, a facet value is added
|
397 |
| - to the dimension using the string value of the item. If the expression returns |
398 |
| - the empty sequence for the current parent node, the corresponding facet will be |
399 |
| - empty as well.</para> |
| 397 | + to the dimension using the string value of the item. Therefore if the expression |
| 398 | + returns multiple items, a facet for that dimension will also hold multiple values. |
| 399 | + If the expression returns the empty sequence for the current parent node, the corresponding |
| 400 | + facet will be empty as well.</para> |
400 | 401 | <para>A facet can also be defined to be hierarchical. A typical example would be a date, which consists of a year, month and day component. By
|
401 | 402 | indexing the single components as separate parts of a hierarchical facet, we enable the user to drill down by year first, then by month and
|
402 | 403 | finally by day. Let's assume each of our docbook articles has a <tag>pubdate</tag> containing a date in <code>xs:date</code>
|
403 | 404 | format:</para>
|
404 | 405 | <programlisting language="xml" xlink:href="listings/listing-52.txt"></programlisting>
|
| 406 | + <para>Hierarchical facets may also hold multiple values, for example if we would like to associate |
| 407 | + our documents with a subject classification on various levels of granularity (say: <emphasis>science</emphasis> with |
| 408 | + <emphasis>math</emphasis> and <emphasis>physics</emphasis> as subcategories or <emphasis>humanities</emphasis> with |
| 409 | + <emphasis>art</emphasis>, <emphasis>sociology</emphasis> and <emphasis>history</emphasis>). |
| 410 | + This way we enable the user to drill down into broad <emphasis>humanities</emphasis> |
| 411 | + or <emphasis>science</emphasis> subject first and choose particular topics afterwards. |
| 412 | + If the result of the hierarchical facet <code>expression</code> |
| 413 | + evaluates to an array, each of array members will be treated as a hierarchical value for that facet. |
| 414 | + Such an array could look in XQuery similar to <code>[('science', 'math'), ('humanities', 'history')]</code> and be |
| 415 | + a result of evaluationg a function like <code>idx:subject-hierarchy</code> below stored in an imported module (see <link linkend="external-module">below</link>) |
| 416 | + </para> |
| 417 | + <programlisting language="xml" xlink:href="listings/listing-520.xml"/> |
| 418 | + <programlisting language="xquery" xlink:href="listings/listing-521.txt"/> |
| 419 | + <para>which assumes hierarchical subject structure stored in <emphasis>/db/subjects/subjects.xml</emphasis></para> |
| 420 | + <programlisting language="xml" xlink:href="listings/listing-522.xml"/> |
405 | 421 | <para>Next, we may want to define fields for the authors and title of the article. In docbook, <tag>author</tag> can be a complex element,
|
406 | 422 | consisting e.g. of a <tag>personname</tag> with nested
|
407 | 423 | <tag>surname</tag> and <tag>firstname</tag>. For display to the user and sorting we want to pre-compute a normalized string out of those
|
|
428 | 444 | attribute <code>store="no"</code>. The field will still be indexed and
|
429 | 445 | available for queries though.</para>
|
430 | 446 |
|
431 |
| - <para><emphasis role="bold">Importing external modules</emphasis>: as can be seen in the field definition for "author" above, expressions can easily become quite verbose, so writing them into an attribute |
| 447 | + <para xml:id="external-module"><emphasis role="bold">Importing external modules</emphasis>: as can be seen in the field definition for "author" above, expressions can easily become quite verbose, so writing them into an attribute |
432 | 448 | is not convenient. It is thus also possible to import one or more XQuery modules into the index configuration and use the functions declared
|
433 | 449 | in the module:</para>
|
434 | 450 | <programlisting language="xml" xlink:href="listings/listing-58.xml"></programlisting>
|
|
0 commit comments