Exercise 6: Modify results

Change the fields displayed in search results


The next exercise will move us from indexing to the display of search results. The default set of fields displayed and their order can be changed to suit the metadata available and the project design. The data itself can also be reformatted, if so desired.



  1. Using your XML editor, open:


    We will be editing the “default” stylesheet, because we want this change to affect all content.

  2. Search for “Document Hit Template,” as we will be editing the template that matches “docHit.” Scroll down to the main table element within that template. Here you can see how the various index fields (author, title, date, subject(s), full-text matches, etc.) are added to the results.
  3. Add a border attribute to the table element and give it a value of 1:

    <table border=’1′>

  4. Save the file.
  5. Refresh the page in your browser. You can now see how the table is laid out.
  6. By copying and pasting, switch the order of author and title. There are two <td> elements for each of these. The first displays the label for the field, e.g. “Author” or “Title.” The second displays the value for a specific search results. Note that the Author related elements are in the first row (or “<tr>” element), which also contains <td> elements for the result item number and the link to add a given result to the BookBag. These are the first and fourth <td> elements respectively (and are in “col1” and “col4”, as one might expect). Make sure to leave these <td> elements in place when doing your cutting and pasting.
  7. Save the file.
  8. Refresh the page in your browser. Verify that title now precedes author.
  9. Add the value of the publisher field to the line labeled “Published”, making the addition conditional on the presence of the meta/publisher index field:

    <xsl:if test=”meta/publisher”>
    <xsl:value-of select=”‘;’ ,meta/publisher”/>

  10. Remove the border attribute on the table to improve its appearance.
  11. Save the file.
  12. Refresh the page in your browser. Check to see whether the publisher field has been added. Verify the removal of the border.

Next tutorial step:

Exercise 7: Enable structural searching with sectionTypes