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. |
Tutorial: Configure an extra search
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. |
-
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. -
Switch to the Library search package management page.
-
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 tosilent-films
. This sets up the extra searches for the silent-films extra search to source the related results from thetraining~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
)
-
-
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 aquestion
andresponse
element which mirrors that of the main search. -
Make use of the extra search results within your template by adding an
<@ExtraResults>
block. The code nested within theExtraResults
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["image"]??> <div class="row"><img class="img-thumbnail pull-left" style="margin-right:0.5em;" src="${s.result.listMetadata["image"]?first!}" alt="${s.result.listMetadata["image"]?first!}" title="${s.result.listMetadata["image"]?first!}"/></div><div class="row" style="margin-right: 2em;"><strong>${s.result.listMetadata["t"]?first!}</strong></div> <#else> <strong>${s.result.listMetadata["t"]?first!}</strong> </#if> </a> </div> </#if> </@s.Results> </div> </div> </@fb.ExtraResults>
-
Rerun the search and this time view the HTML results, observing the related videos appearing below the related searches panel.
-
Run a search for twelfth night and confirm that the related videos are related to the search for dashboard.