Exercise 7: Strucutral searching

Enable structural searching with sectionTypes

Introduction:

A sectionType is a concept particular to XTF that allows you to implement more sophisticated structure-aware searching (1), for instance return documents with the keyword “kumquat”, but only if it occurs in a “note” element. This is useful in situations where the appearance of a term in one part of a document would be more significant or perhaps have a different meaning than if it appeared in another part of a document.

Demonstration:

Steps:

  1. Open the preFilters for all three of the XML content types (i.e., EAD, NLM, and TEI):

    %XTF_HOME%\style\textIndexer\ead\eadPreFilter.xsl
    %XTF_HOME%\style\textIndexer\nlm\nlmPreFilter.xsl
    %XTF_HOME%\style\textIndexer\tei\teiPreFilter.xsl

  2. Locate the templates near the top that are labeled “sectionType Indexing and Element Boosting”.
  3. All three of these content types have an element type that contains notes of various types (EAD: note; NLM: note|fn; TEI: note). To each of the preFilters, add a template that indexes these elements as sectionType. Use the existing templates as examples. (2)
  4. Shut down tomcat.
  5. Do a clean re-index.
  6. Start up tomcat.
  7. Make sure you are still getting results.
  8. Now we have to enable searching on this new section type. Open:

    %XTF_HOME%\style\crossQuery\resultFormatter\default\searchForms.xsl

    Look for the part of the search form labeled “Section” and add a new xsl:when for $sectionType = ‘note’.

  9. Add a “note” radio button to each of the xsl:when elements, as well as the xsl:otherwise statement, so it is always present.
  10. Go to the Advanced search form and check the functionality. (HINT: A search for “group*” should give you a good result set.)

Next tutorial step:

Exercise 8: Create a hierarchical facet

Footnotes:
(1) Unlike a full XML search engine or database, XTF requires that you define the elements you want to search within at index time. Ad hoc structural queries are not supported. The explanation is long, but basically this is in the interest of efficiency.
(2) You will notice a strange construct in the TEI preFilter, where rather than referring directly to the element name, we use local-name()=’note’. This is because TEI elements, depending on what version you are using, might use namespaces. local-name() as a convenient way of referring to an element whether it has a namespace or not.