Enable structural searching with sectionTypes
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.
Open the preFilters for all three of the XML content types (i.e., EAD, NLM, and TEI):
- Locate the templates near the top that are labeled “sectionType Indexing and Element Boosting”.
- 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)
- Shut down tomcat.
- Do a clean re-index.
- Start up tomcat.
- Make sure you are still getting results.
Now we have to enable searching on this new section type. Open:
Look for the part of the search form labeled “Section” and add a new xsl:when for $sectionType = ‘note’.
- Add a “note” radio button to each of the xsl:when elements, as well as the xsl:otherwise statement, so it is always present.
- 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:
(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.