Plugin: Modify extra search request

Purpose

Use this plugin to update or set fields in the extra search request.

This plugin is only used to make modifications to the extra search questions for any configured extra searches.

Any extra searches that are to be modified must be configured in your search package configuration. See: Extra searches documentation

If you wish to conditionally enable/disable extra searches for different results pages you need to use curator to do this.

Extra search defaults

Default values for most parameters used by your extra search should be set in the extra search query processor options and not using this plugin.

Freemarker template

The value supplied when configuring a plugin rule is a Freemarker template fragment. This output of this template is what your extra search parameter value will be set to.

The template has access to the extra search question (from the question variable).

The template can also make use of Freemarker language constructs (like <#assign>) and built-in functions (like ${var?replace("foo","bar")}).

The template does not have access to Funnelback macros used in the search result templates. (e.g. <@s.Results>)

Usage

Enable the plugin

  1. Select Plugins from the side navigation pane and click on the Modify extra search request tile.

  2. From the Location section, select the results page to which you would like to enable this plugin from the Select a results page select list.

The plugin will take effect as soon as you finish running through the plugin setup steps.

Configuration settings

The configuration settings section is where you do most of the configuration for your plugin. The settings enable you to control how the plugin behaves.

The configuration key names below are only used if you are configuring this plugin manually. The configuration keys are set in the results page configuration to configure the plugin. When setting the keys manually you need to type in (or copy and paste) the key name and value.

Template for setting the target field value.

Configuration key

plugin.modify-extra-search-request.config.*.template.*

Data type

string

Required

This setting is optional

The value should be set to a Freemarker template fragment that defines the value of the target field that will be output. This can include values from other parts of the search question. PARAMETER 1 specifies the extra search name that will be modified, PARAMETER 2 specifies the name of the input parameter to update/set. Note: the 'collection' parameter cannot be updated.

The target field value will be replaced with the generated output of this template. Updating the value of a parameter to an empty value has a similar effect to removing the parameter.

Examples

In this scenario you wish for an extra search (named alerts) to set an additional metadata constraint (type=official) to an extra search.

To achieve this add the following in your plugin configuration

Template for setting the target field value:

Parameter 1

alerts

Parameter 2

meta_type

Value

official

This has the same effect as you adding the parameter &meta_type=official to your extra search query string.

In this scenario you wish for an extra search (named globalrecommendations) to remove/unset a parameter meta_country.

To achieve this add the following in your plugin configuration, setting the value to an empty string.

Template for setting the target field value:

Parameter 1

globalrecommendations

Parameter 2

meta_country

Value

(empty value)

This has the same effect as you adding the parameter &meta_country= to your extra search query string.

In this scenario you wish for an extra search (named related) to lookup some items related to your query. The related items are discovered by running a search for the barcode metadata value supplied in your query in the relatedItems or childItems metadata fields.

To achieve this add the following in your plugin configuration, using a template to set the target field value:

Parameter 1

related

Parameter 2

query

Value

<#assign id=question.query?replace("barcode:","")> [relatedItems:${id} childItems:${id}]

This template reads the query from the extra search question and sets a variable id which is cleaned so that it only contains the value of the barcode metadata constraint in the query. The template then sets the desired metadata fields to the value of this variable, formatting a new Funnelback query language expression which is then set as the extra search query.

the value is interpreted as a Freemarker template fragment. You can make use of any elements of the extra search question from the data model inside your template, and you also have access to Freemarker built-in functions and language constructs.

If your original query is barcode:SKU1044 This has the same effect as you updating your query to [relatedItems:SKU1044 childItems:SKU1044].

when setting the query, the value must be specified as a valid Funnelback query language expression.

Change log