General advice for working with the data model from hook scripts

Managed by | Updated .

When a query is submitted to Funnelback it runs through a query processing pipeline. This pipeline has several phases that initialise different elements within the data model.

The data model object may be modified at various points in the processing pipeline using a hook script.

Manipulating the search question

The question can be manipulated using the following hook scripts:

  • Pre process (hook_pre_process.groovy)
  • Pre data fetch (hook_pre_datafetch.groovy)
  • Extra searches (hook_extra_searches.groovy)

The following is defined at the start of the processing:

  • question.rawInputParameters
  • question.inputParameterMap
  • question.additionalParameters
  • question.environmentVariables
  • question.collection
  • question.profile
  • lang related elements
  • question.location

The pre process hook runs. This can be used to modify or inject extra elements.

The following data model elements are populated after the pre process hook runs. Most of these will be setup depending on the raw input parameters.

  • session
  • question.userKeys
  • faceted navigation related elements
  • question.metaParameters
  • question.systemMetaParameters
  • curator related elements
  • quicklinks related elements
  • explore related elements
  • extra search elements

The extra searches hook runs (this initialises all the extra search questions in the data model). Use this to modify the extra search questions.

The pre datafetch hook runs just before the query is passed to padre. This can be modify elements that were generated after the pre process hook ran.

Key question data model items to modify

These items can be modified in the hook scripts. The decision on which hook script to use will depend on what you need to affect in the the data model.

Modify in the pre process set if you want to affect how subsequent items are initialised (e.g. if you wish to change the meta parameters you can modify the meta_X values in the question.awInputParameters as a pre process step and this will mean that the question.metaParameters is generated correctly).

question.rawInputParameters

(and question.inputParameterMap)

Note: these two elements are different views of the same thing. question.inputParameterMap can be used if there is only a single value for the item (e.g. question.inputParameterMap["key"] = "value"). Otherwise you must use question.rawInputParameters. (e.g. question.rawInputParameters["key"] = ["value"] or question.rawInputParameters["key"] = ["value1","value2"])

Modify this for any parameters that will be used by the modern UI, or for any parameters that are used to setup the elements that are populated between the pre process hook and the extra searches/pre datafetch hooks

question.additionalParameters

Modify this for any parameters that need to be passed directly to padre as query processor options.

This includes the following:

  • origin
  • maxdist
  • sort
  • numeric query parameters (e.g. lt_x)
  • SM
  • SF
  • num_ranks

question.query

Modify this if you need to manipulate the passed in query.

Manipulating the search response

The question can be manipulated using the following hook scripts:

  • Post data fetch (hook_post_datafetch.groovy) - use this to modify the raw response values returned by padre. e.g. to update the live URL before the click link is generated, or to make modifications to faceted navigation such as renaming or sorting categories.
  • Post process (hook_post_process.groovy) - use this to makey any other modification to elements that will be displayed.

The initial response object is populated

The post data fetch hook runs.

The following is then initialised

  • search result links (click, cache, final live and display links)
  • curator related items
  • html encoded summaries
  • extra search responses
  • related document elements
  • faceted navigation elements
  • translations
  • search history

The post process hook runs.

Was this artcle helpful?

Tags
Type: