Sorting Results Using Metadata

About this task

Certain types of metadata, such as the publication date stored in this tutorial's year metadata field, lend themselves to being used both as a searchable field and as a field that can be used to organize all of the results from a search collection. Mechanisms for sorting search results are typically identified by providing sortby:field as part of your query, where field identifies the mechanism that you want to sort by, known as a sort condition.

In Watson Explorer Engine, sort conditions are XPath expressions that you define on the form for the source associated with your search collection, which we edited in the Defining Fields for the Input Query.

Procedure

  1. Return to the Form tab of the binning-collection source
  2. Click edit beside the VSE Source Form entry to display the edit page
  3. Scroll down until you see the Sorting section.
  4. Select the Modified radio button above the sort textbox
  5. Use the textbox to define each way in which you want to sort your results.

    Use the form name:sort-type for each entry in the sort textbox. For example, year|ascending:$year defines a sort condition called year that sorts results in an ascending fashion based on the fast-indexed content year. Because the latter is an XPath expression, you must refer to the contents of the year content element using the variable $year. The value of the sort condition and fast-indexed content happen to match in this example, which is purely coincidental. The name of any sort condition is completely arbitrary.

  6. For the purposes of this tutorial, enter the following examples of some other valid sortby values:
      year|ascending:$year
      backwards-year|descending:$year
  7. Once you have completed defining these (and any other) sort conditions that you want to be able to use in your results, scroll back to the top of the editing page
  8. Click OK to save your changes and close the edit page.

Results

If the window that displays your Watson Explorer Engine application is still open, you can refresh the screen (typically by pressing the F5 key or holding down the Control key while clicking the Reload icon. If you are reloading an existing window, make sure that no search terms or fields are still shown in the Search textbox at the top of the screen.

If the search results window is no longer open, you can re-display it by clicking Search under the search box in the Watson Explorer Engine administration tool's left-hand navigation bar.

When your application redisplays, it should initially appear to be unsorted. If necessary, click Turn off debugging to disable debugging and make it easier to see your search results. Next, enter the string sortby:year, and press return to see the same results which are now sorted by the metadata field year that contains the year in which the book associated with each result was published.

To proceed to the next section of this tutorial, click Fine-Tuning the Search Collection.