Implementer training - extra searches

Funnelback has the ability to run a series of extra searches in parallel with the main search, with the extra results data added to the data model for use in the search results display.

An extra search could be used on an all-of-university search to pull in additional results for staff members and videos and display these alongside the results from the main search. The formatting of the extra results can be controlled per extra search, so for the university example staff results might be presented in a box to the right of the results with any matching video results returned in a JavaScript carousel.

The extra searches can be run against any search package or data source that exists on the Funnelback server, and it is possible via the to modify the extra search data model in a similar manner to the main search using plugins.

Extra searches vs search packages

The functionality provided by extra searches can sometimes be confused with that provided by search packages. While both will bring in results from different data sources, the main difference is that an extra search is a completely separated set of search results from the main result set.

  • A search package searches across multiple data sources and merges all the results into a single set of results.

  • An extra search on a results page runs a secondary search providing an additional set of search results and corresponding data model object. This data model object contains a separate question and response object, just as for the main search.

A similar outcome could be achieved by running a secondary search via Ajax from the search results page to populate a secondary set of result such as a video carousel. Note however that the use of extra search within Funnelback is more efficient than making an independent request via a method such as Ajax.

It is good practice to limit the number of extra searches run for any query otherwise performance of the search will be adversely affected. For good performance limit the number of extra searches to a maximum of 2 or 3.

In this exercise an extra search will be configured for the Library search package. The extra search will return any related results from the silent films - website data source and present these alongside the main results.

Extra searches currently have to be configured at the search package level.
  1. Log in to the administration dashboard where you are doing your training.

    See: Training - administration 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. Switch to the Library search package management page.

  3. Select the edit search package configuration from the settings panel, then add the following configuration options.

    • ui.modern.extra_searches: This defines the extra searches that should be run when executing a search on any results page that belongs to the search package. This is a comma-separated list of extra search IDs to run. Set this to silent-films, which is defined in the following two configuration options. Each ID defined in this list must have two corresponding entries defining the source and query processor options.

    • ui.modern.extra_searches.*.source: Defines the data source where the extra search will source the extra search results. Set this to training~ds-silent-films, and also make sure you set the extra search ID to silent-films. This sets up the extra searches for the silent-films extra search to source the related results from the training~ds-silent-films (silent films - website) data source.

    • ui.modern.extra_searches.*.query_processor_options: Sets display and ranking options that will be applied (merged with any that are defined in the results page configuration) when running the extra search -num_ranks=3 -SF=[image,t] (extra search ID = silent-films)

    exercise configure an extra search 01
  4. Run a search on the shakespeare search results page for taming of the shrew and observe the JSON or XML response now includes data beneath the extraSearches node. Within this is an element corresponding to each extra search that is run, and beneath that is a question and response element which mirrors that of the main search.

    exercise configure an extra search 02
  5. Make use of the extra search results within your template by adding an <@ExtraResults> block. The code nested within the ExtraResults block is identical to what you would use in your standard results, but the code is drawn from the extra search item within the data model. E.g. Print the title for each extra search result. Edit the default template (select edit results page templates from the template panel) and insert the following immediately after the </@s.ContextualNavigation> tag (approx. line 644) then save the template.

    <@fb.ExtraResults name="silent-films">
    <div class="well">
      <h3>Related videos</h3>
      <div class="row">
      <@s.Results>
        <#if s.result.class.simpleName != "TierBar">
        <div class="col-md-3">
          <a href="${s.result.liveUrl}">
            <#if s.result.listMetadata["displayImage"]??>
              <img class="img-thumbnail pull-left" style="margin-right:0.5em;" src="${s.result.listMetadata["displayImage"]?first!}" alt="${s.result.listMetadata["image"]?first!}" title="${s.result.listMetadata["image"]?first!}"/><br/><strong>${s.result.listMetadata["t"]?first!}</strong>
            <#else>
              <strong>${s.result.listMetadata["displayTitle"]?first!}</strong>
            </#if>
          </a>
        </div>
        </#if>
      </@s.Results>
      </div>
     </div>
    </@fb.ExtraResults>
  6. Rerun the search and this time view the HTML results, observing the related videos appearing below the related searches panel.

    exercise configure an extra search 03
  7. Run a search for twelfth night and confirm that the related videos are related to the search for dashboard.

    exercise configure an extra search 04