Implementer training - display options

Controlling display options

There are numerous display options that can be set, controlling various aspects of the display. Display options are a subset of the query processor options which control how a search runs when a query is submitted.

These options can be set as default behavior for your search, or passed in as parameters when a search is run.

The options below are some of the more commonly used display options:

  • Number of results per page: this is the number of search results to return for each page of search results. Parameter name is num_ranks. (Default is 10 results: num_ranks=10)

  • Summary mode: controls the type of result summaries returned with each result. Possible modes are:

    • Automatic: Summaries will be returned for each result. Summary source will be determined automatically by Funnelback. This is the default. (SM=auto) note: this is also equivalent to the old SM=both summary mode. (SM = Summary Mode)

    • Disabled: Summaries are disabled for all search results (set using SM=off). This also prevents metadata from being included in the data model response.

    • Snippet: A short snippet from the start of the document is returned as the result summary. (set using SM=snip)

    • Query biased: A series of short extracts are returned for each result. Each extract is biased to the keywords used for the search and shows the matched term(s) in context to the surrounding words. The number and order of extracts can be controlled using the EORDER and SQE options (set using SM=qb)

    • Metadata only: Return only metadata fields as defined by the SF (Summary Fields) parameter (set using SM=meta).

  • Metadata fields: Controls the metadata fields that are returned with the search results (as long as the summary mode is not set to off). Set using the SF parameter.

  • Summary length: Controls the size (in number of characters) of the buffer used to store the summaries. Increasing this will result in longer summaries being returned. Set using the SBL parameter.

  • Metadata length: Controls the size of the buffer used to store metadata summaries. This value may need to be increased if metadata values are being cut off. Set using the MBL parameter.

  • Sort mode: Controls the sort order for the search results. Sort can be by relevance/search score (default), title, metadata field, date or URL, in either ascending or descending direction. Set using the sort parameter.

A full list of display options is available in the documentation.

Tutorial: Dynamically alter the sort using URL parameters

Several sort modes are provided for results - relevance is set as the default, but we can easily experiment with others by adding URL parameters to any search results page.

  1. Perform a search against the silent films search results page for death.

    exercise dynamically alter the sort using url parameters 01
  2. Add &sort=title to the URL and observe the same number of results in the set, reordered by title (A-Z).

    exercise dynamically alter the sort using url parameters 02
  3. Edit the URL to sort by URL &sort=url and observe the same number of results in the set, this time reordered by URL (A-Z).

    exercise dynamically alter the sort using url parameters 03

A full list of sort modes is detailed in the Funnelback documentation.

Tutorial: Change the default sort mode

The default sort mode is to sort by relevance (or search score). The default can be changed by setting a display option inside the results page configuration.

  1. Log in to the search dashboard where you are doing your training.

    See: Training - search dashboard access information if you’re not sure how to access the training. Ignore this step if you’re treating this as a non-interactive tutorial.
  2. Locate the silent films search package.

  3. Open the silent films search results page and select edit results page configuration from the customize panel.

    manage results page panel customize
  4. Add a setting called query_processor_options by clicking on the add new button, then selecting query processor options from the drop-down list.

    exercise change the default sort mode 02
  5. The query processor is the Funnelback program that returns search results from the index based on search keywords. Query processor options are the ranking and display options that are passed to the query processor when it runs the search. Add -sort=title to the set of options then save the setting. This will set sort by title as the default sort mode. The value (title) can be substituted for any of the other sort modes that are available from the documentation page above.

    exercise change the default sort mode 03
  6. Run a search against the silent films search results page for death.

  7. Observe that the sorting is now alphabetic. Experiment by modifying the URL (as in the previous exercise) and observe that the sort mode can be overridden at the time the query runs, but will also be alphabetic when no sort parameter is supplied.

    exercise change the default sort mode 04
  8. Return to the configuration editor and revert the options, removing the -sort=title option to restore relevancy as the default search. An option can be reverted (set back to the default value) by clicking the button for the option you wish to revert. Alternatively you can edit the item and remove the -sort=title, which will have the same effect.

    exercise change the default sort mode 05

The previous two exercises have demonstrated the setting of sort both via configuration and dynamically at the time the query is run.

It’s important to understand that both methods are important for providing a useful search interface, with certain settings being set dynamically (e.g. via options you choose in your search form), and some values set as the defaults.

Tutorial: Create a sort-mode switcher in the template

In this example a switch control will be added to the search results listing to enable the user to re-sort the result set.

  1. Log in to the search dashboard where you are doing your training.

    See: Training - search dashboard access information if you’re not sure how to access the training. Ignore this step if you’re treating this as a non-interactive tutorial.
  2. Locate the silent films search package.

  3. Open the silent films search results page and select edit results page template from the templates panel.

    manage results page panel template
  4. Add the following code snippet above your result set output (e.g. just before the ol id="search-results" (approx line 501). Save and publish once complete:

    <#-- SEARCH AGAIN -->
        <form action="${question.currentProfileConfig.get("ui.modern.search_link")}" method="GET" id="sortform">
            <#-- PRE-FILL PARAMETERS -->
            <input type="hidden" name="collection" value="${question.collection.id}" />
            <input type="hidden" name="form" value="${question.form }" />
            <input type="hidden" name="profile" value="${question.profile}" />
            <input type="hidden" name="query" value="<@s.QueryClean/>" />
            <#-- SORT MODE -->
            <label for="sort">Sort</label>
            <@s.Select id="sort" name="sort" options=["=Relevance ", "date=Date (newest first)", "adate=Date (oldest first)","title=Title"] />
            <input type="submit" value="Go" />
        </form>
  5. Run a search for death.

  6. Observe that a sort dropdown is returned above the search results. Experiment with the sort mode drop-down observing the change in sort order while maintaining the same set of search keywords.

    exercise create a sort mode switcher in the template 01
Extended exercises: display options
  1. Create a switcher that allows a user to choose the number of results that they wish to see.

  2. Experiment with changing the summary mode setting by editing your URL and observe the effect on the search results.